Installing calicoctl

About installing calicoctl

calicoctl allows you to create, read, update, and delete Calico objects from the command line.

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.

Installing calicoctl as a binary on a single host

  1. 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/.

  2. Use the following command to download the calicoctl binary.

    curl -O -L https://github.com/projectcalico/calicoctl/releases/download/v3.2.1/calicoctl
    
  3. Set the file to be executable.

    chmod +x calicoctl
    

    Note: If the location of calicoctl is not already in your PATH, move the file to one that is or add its location to your PATH. This will allow you to invoke it without having to prepend its location.

Next step:

Configure calicoctl to connect to your datastore.

Installing 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 quay.io/calico/ctl:v3.2.1

Next step:

Configure calicoctl to connect to your datastore.

Installing 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://just-master--zealous-perlman-827aaa.netlify.com/v3.2/getting-started/kubernetes/installation/hosted/calicoctl.yaml
    

    Note: You can also view the YAML in a new tab.

  • Kubernetes API datastore

     kubectl apply -f \
     https://just-master--zealous-perlman-827aaa.netlify.com/v3.2/getting-started/kubernetes/installation/hosted/kubernetes-datastore/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

NAME                 TAGS
kns.default          kns.default
kns.kube-system      kns.kube-system

Next step:

Configure calicoctl to connect to your datastore.