Install calicoctl
About installing calicoctl
calicoctl
allows you to create, read, update, and delete Calico objects
from the command line. Calico objects are stored in one of two datastores,
either etcd or Kubernetes. The choice of datastore is determined at the time Calico
is installed. Typically for Kubernetes installations the Kubernetes datastore is the
default.
You can run calicoctl
on any host with network access to the
Calico datastore as either a binary or a container.
For step-by-step instructions, refer to the section that
corresponds to your desired deployment.
Install calicoctl as a binary on a single host
-
Log into the host, open a terminal prompt, and navigate to the location where you want to install the binary.
Tip: Consider navigating to a location that’s in your
PATH
. For example,/usr/local/bin/
. -
Use the following command to download the
calicoctl
binary.curl -O -L https://github.com/projectcalico/calicoctl/releases/download/v3.17.1/calicoctl
-
Set the file to be executable.
chmod +x calicoctl
Note: If the location of
calicoctl
is not already in yourPATH
, move the file to one that is or add its location to yourPATH
. This will allow you to invoke it without having to prepend its location.
Next step:
Configure calicoctl
to connect to your datastore.
Install calicoctl as a container on a single host
To install calicoctl
as a container on a single host, log into the
target host and issue the following command.
docker pull calico/ctl:v3.17.1
Next step:
Configure calicoctl
to connect to your datastore.
Install calicoctl as a Kubernetes pod
Use the YAML that matches your datastore type to deploy the calicoctl
container to your nodes.
-
etcd
kubectl apply -f https://docs.projectcalico.org/manifests/calicoctl-etcd.yaml
Note: You can also view the YAML in a new tab.
-
Kubernetes API datastore
kubectl apply -f https://docs.projectcalico.org/manifests/calicoctl.yaml
Note: You can also view the YAML in a new tab.
You can then run commands using kubectl as shown below.
kubectl exec -ti -n kube-system calicoctl -- /calicoctl get profiles -o wide
An example response follows.
NAME TAGS
kns.default kns.default
kns.kube-system kns.kube-system
We recommend setting an alias as follows.
alias calicoctl="kubectl exec -i -n kube-system calicoctl -- /calicoctl"
Note: In order to use the
calicoctl
alias when reading manifests, redirect the file into stdin, for example:calicoctl create -f - < my_manifest.yaml
Install calicoctl as a kubectl plugin on a single host
-
Log in to the host, open a terminal prompt, and navigate to the location where you want to install the binary.
Note: In order to install
calicoctl
as a kubectl plugin, the binary must be located in yourPATH
. For example,/usr/local/bin/
. -
Use the following command to download the
calicoctl
binary.curl -o kubectl-calico -L https://github.com/projectcalico/calicoctl/releases/download/v3.17.1/calicoctl
-
Set the file to be executable.
chmod +x kubectl-calico
Note: If the location of
kubectl-calico
is not already in yourPATH
, move the file to one that is or add its location to yourPATH
. This is required in order for kubectl to detect the plugin and allow you to use it. -
Verify the plugin works.
kubectl calico -h
You can now run any calicoctl
subcommands through kubectl calico
.
Note: If you run these commands from your local machine (instead of a host node), some of the node related subcommands will not work (like node status).
Next step: