Compute Services

Configure Calicoctl for IBM Cloud Kubernetes Service

Share this post:

Configure Calicoctl for IBM Cloud Kubernetes Service

Do you want to have access to your Calico policies in a quick and simple way? We’ve got you covered.

In the IBM Cloud Kubernetes Service, the Calico configuration file can now be generated automatically with just a single command. For clusters 1.10 and above, you can use the new flag --network to download your cluster config.

$ ibmcloud ks cluster-config <CLUSTER_NAME> --network

Downloading the Calico config example

Make sure to update the IBM Cloud Kubernetes Service CLI plugin in the following way:

$ ibmcloud plugin update container-service

With the latest CLI, you can download the Calico Config. The location of the calicoctl.cfg file will be displayed, which can be then used to configure calicoctl to access your cluster.

$ ibmcloud ks cluster-config <CLUSTER_NAME> --network

Installing the Calico binary on MacOS

Here are the steps on how to install the exact version of the calicoctl binary that matches what is running in your Kubernetes cluster. If you already have the right version of calicoctl installed, please proceed to the next section.

Assuming you have kubectl set up for your cluster, follow the steps below.

  1. Find the Calico version you have currently running in your Kubernetes cluster:
    $ calicoVersion=$(kubectl get po -n kube-system -l k8s-app=calico-kube-controllers -o yaml | grep -e "image:.*kube-controllers" | head -1 | cut -d':' -f3)
  2. Download the calicoctl binary:
    $ curl -O -L$calicoVersion/calicoctl-darwin-amd64
  3. Move the binary to your bin directory:
    $ chmod 755 calicoctl-darwin-amd64; sudo mv calicoctl-darwin-amd64 /usr/local/bin/calicoctl

Using the Calico config

Option #1) The CLIs --config flag

Calico has the option to specify the config on every cmd:

$ calicoctl get no --config <YOUR_CALICO_CONFIG>


Note: You can also pass it in as a variable if you set it beforehand $CALICOCNF.

Option #2) Using the config in the default config location

Calico has a default config location (/etc/calico/calicoctl.cfg), and if you move the config to this location, you won’t need to pass the config on every calicoctlcmd, which comes pretty handy.

$ sudo mv <YOUR_CALICO_CONFIG> /etc/calico/calicoctl.cfg

Enjoy the easy operation:

$ calicoctl get nodes

For more information about setting up Calico, you can check out the IBM Cloud Kubernetes Service docs.

Contact us

If you have questions, engage our team via Slack by registering here and join the discussion in the #general channel on our public IBM Cloud Kubernetes Service Slack.

Chief Architect, Networking – IBM Cloud Kubernetes Service

Thomas Cocozzello

Networking – IBM Cloud Kubernetes Service

More Compute Services stories
December 11, 2018

Unifying Containers, Apps, and Functions

Innovative solutions like Knative and Istio are leading us to a unified container application platform that lets developers leverage the best of containers, apps, and functions in a single integrated way.

Continue reading

December 11, 2018

Using Availability Zones to Enhance Event Streams Resilience

With the Enterprise plan of IBM Event Streams, you can deploy Kafka across availability zones to maximize both its resilience to failures and the durability of your message data. Applications can use Kafka to achieve the right balance of availability and durability to meet your business needs.

Continue reading

December 10, 2018

The Run Up to KubeCon: Easing the Burden of Security and Infrastructure Management

In the run up to KubeCon, IBM Cloud announced new capabilities to ease Kubernetes operations and improve security across multiple cloud architectures.

Continue reading