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 https://github.com/projectcalico/calicoctl/releases/download/$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>

Example:

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
February 21, 2019

IBM Cloud Kubernetes Service Available in Mexico City

IBM Cloud Kubernetes Service is a managed Kubernetes offering that delivers powerful management tools, an intuitive user experience, and built-in security and isolation. Today, we are excited to announce the availability of the IBM Cloud Kubernetes Service in Mexico City, Mexico.

Continue reading

February 18, 2019

Build a Container Image Inside a Kubernetes Cluster and Push it to IBM Cloud Container Registry

We're going to show you how to build a source into a container image from a Dockerfile inside a Kubernetes cluster and push the image to IBM Cloud Container Registry with Google's Kaniko tool.

Continue reading

February 12, 2019

A “Kubernetes Everywhere” Approach: Build and Deploy Enterprise-Scale Modern Applications for Hybrid Cloud

We are excited to introduce two optional cloud-managed services and capabilities designed to enable clients to quickly build and deploy enterprise-scale container-based applications across hybrid environments: Managed Istio and Managed Knative for IBM Cloud Kubernetes Service.

Continue reading