title | weight | description |
---|---|---|
Installation |
10 |
How to install Inspektor Gadget
|
- Installing kubectl gadget
- Installing in the cluster
- Uninstalling from the cluster
- Version skew policy
- Installing
ig
Inspektor Gadget is composed of a kubectl
plugin executed in the user's
system and a DaemonSet deployed in the cluster.
Choose one way to install the Inspektor Gadget kubectl
plugin.
krew is the recommended way to install
kubectl gadget
. You can follow the
krew's quickstart
to install it and then install kubectl gadget
by executing the following
commands.
$ kubectl krew install gadget
$ kubectl gadget --help
Download the asset for a given release and platform from the
releases page,
uncompress and move the kubectl-gadget
executable to your PATH
.
$ curl -sL https://github.com/inspektor-gadget/inspektor-gadget/releases/latest/download/kubectl-gadget-linux-amd64.tar.gz | sudo tar -C /usr/local/bin -xzf - kubectl-gadget
$ kubectl gadget version
To build Inspektor Gadget from source, you'll need to have a Golang version 1.19 or higher installed.
$ git clone https://github.com/inspektor-gadget/inspektor-gadget.git
$ cd inspektor-gadget
$ make kubectl-gadget-linux-amd64
$ sudo cp kubectl-gadget-linux-amd64 /usr/local/bin/kubectl-gadget
$ kubectl gadget version
$ kubectl gadget deploy
This will deploy the gadget DaemonSet along with its RBAC rules.
If you wish to install an alternative gadget image, you could use the following commands:
$ kubectl gadget deploy --image=ghcr.io/myfork/inspektor-gadget:tag
The --node-selector
flag accepts a label
selector
that defines the nodes where Inspektor Gadget will be deloyed to:
# Deploy only to the minikube-m02 node
$ kubectl gadget deploy --node-selector kubernetes.io/hostname=minikube-m02
# Deploy to all nodes but minikube
$ kubectl gadget deploy --node-selector kubernetes.io/hostname!=minikube
# Deploy to minikube and minikube-m03 nodes only
$ kubectl gadget deploy --node-selector 'kubernetes.io/hostname in (minikube, minikube-m03)'
Inspektor Gadget needs to detect when containers are started and stopped.
The different supported modes can be set by using the hook-mode
option:
auto
(default): Inspektor Gadget will try to find the best option based on the system it is running on.crio
: Use the CRIO hooks support. Inspektor Gadget installs the required hooks in/etc/containers/oci/hooks.d
, be sure that path is part of thehooks_dir
option on crio.conf. Ifhooks_dir
is not declared at all, that path is considered by default.podinformer
: Use a Kubernetes controller to get information about new pods. This option is racy and the first events produced by a container could be lost. This mode is selected whenauto
is used and the above modes are not available.nri
: Use the Node Resource Interface. It requires containerd v1.5 and it's not considered whenauto
is used.fanotify
: Uses the Linux fanotify API. It only works with runc.
This section explains the additional steps that are required to run Inspektor Gadget in some platforms.
You can deploy Inspektor Gadget in minikube
.
We recommend to use the docker
driver:
$ minikube start --driver=docker
# Deploy Inspektor Gadget in the cluster as described above
But can also use the kvm
one:
$ minikube start --driver=kvm
# Deploy Inspektor Gadget in the cluster as described above
The following command will remove all the resources created by Inspektor Gadget from the cluster:
$ kubectl gadget undeploy
Inspektor Gadget requires the kubectl-gadget plugin and the DaemonSet deployed on the cluster to be the exact same version. Even if this is possible that different versions work well together, we don't provide any guarantee in those cases. We'll visit this policy again once we approach to the v1.0 release.
The ig
tool can be built and installed
independently. The result is a single binary (statically linked) that can be
copied to a Kubernetes node or any host to trace its containers.
It is possible to download the asset for a given release and platform from the releases page.
For instance, to download the latest release for linux-amd64:
$ curl -sL https://github.com/inspektor-gadget/inspektor-gadget/releases/latest/download/ig-linux-amd64.tar.gz | sudo tar -C /usr/local/bin -xzf - ig
$ ig version
ig
is built using a Docker container, so you don't have to worry
about installing dependencies:
$ make ig
$ sudo cp ig /usr/local/bin/