Skip to main content
Version: 3.18 (latest)

Configure calicoctl to connect to the datastore

Default configuration

By default, calicoctl will attempt to read from the Kubernetes API using the default kubeconfig located at $(HOME)/.kube/config.

If the default kubeconfig does not exist, or you would like to specify alternative API access information, you can do so using the following configuration options.

Complete list of Kubernetes API connection configuration

Configuration file optionEnvironment variableDescriptionSchema
datastoreTypeDATASTORE_TYPEIndicates the datastore to use. [Default: kubernetes]kubernetes, etcdv3
kubeconfigKUBECONFIGWhen using the Kubernetes datastore, the location of a kubeconfig file to use, e.g. /path/to/kube/config.string
k8sAPIEndpointK8S_API_ENDPOINTLocation of the Kubernetes API. Not required if using kubeconfig. [Default: https://kubernetes-api:443]string
k8sCertFileK8S_CERT_FILELocation of a client certificate for accessing the Kubernetes API, e.g., /path/to/cert.string
k8sKeyFileK8S_KEY_FILELocation of a client key for accessing the Kubernetes API, e.g., /path/to/key.string
k8sCAFileK8S_CA_FILELocation of a CA for accessing the Kubernetes API, e.g., /path/to/ca.string
k8sTokenK8S_TOKENToken to be used for accessing the Kubernetes API.string

The kubeconfig file specifies the user whose privileges are used. We recommend giving only trusted administrators the permission to modify Calico Enterprise Custom Resource Definitions. All environment variables may also be prefixed with "CALICO_", for example "CALICO_DATASTORE_TYPE" and "CALICO_KUBECONFIG" etc. may be used. This is useful if the non-prefixed names clash with existing environment variables defined on your system.


Kubernetes command line

DATASTORE_TYPE=kubernetes KUBECONFIG=~/.kube/config calicoctl get nodes

Example configuration file

kind: CalicoAPIConfig
datastoreType: 'kubernetes'
kubeconfig: '/path/to/.kube/config'

Example using environment variables

export DATASTORE_TYPE=kubernetes
export KUBECONFIG=~/.kube/config
calicoctl get workloadendpoints

And using CALICO_ prefixed names:

export CALICO_DATASTORE_TYPE=kubernetes
export CALICO_KUBECONFIG=~/.kube/config
calicoctl get workloadendpoints

With multiple kubeconfig files:

export DATASTORE_TYPE=kubernetes
export KUBECONFIG=~/.kube/main:~/.kube/auxy
calicoctl get --context main workloadendpoints
calicoctl get --context auxy workloadendpoints

Checking the configuration

Here is a simple command to check that the installation and configuration is correct.

calicoctl get nodes

A correct setup will yield a list of the nodes that have registered. If an empty list is returned you are either pointed at the wrong datastore or no nodes have registered. If an error is returned then attempt to correct the issue then try again.

Next steps

Now you are ready to read and configure most aspects of Calico Enterprise. You can find the full list of commands in the Command Reference.

The full list of resources that can be managed, including a description of each, can be found in the Resource Definitions.