Skip to main content

Connect to the cluster

You access your cluster with the Kubernetes client kubectl and a kubeconfig file. You create the file in ccloud. It contains a client certificate with administrator rights and is valid for seven days.

Prerequisites​

1. Check kubectl​

kubectl version --client

kubectl supports a difference of one minor version above and below the cluster version. For a cluster with version 1.36, client versions 1.35 to 1.37 are suitable.

2. Create the kubeconfig​

Open the cluster in ccloud and download the kubeconfig. Note the date: the file is valid for seven days from the download.

PropertyValue
AuthenticationClient certificate, signed by the certificate authority of your cluster
Usercustomer-admin
Rightscluster-admin – full access to the complete cluster
Validity7 days from creation

Each download creates a new file with a new certificate. Older files stay valid until they expire.

Warnung

An issued certificate stays valid until it expires. Treat the file like a password: do not commit it to version control, do not send it through unencrypted channels, and delete it after use.

chmod 600 /<path>/<cluster-name>-kubeconfig.yaml

For applications and CI pipelines that need permanent access with limited rights, create a separate ServiceAccount in the cluster, see Set up RoleBindings.

3. Point kubectl to the file​

kubectl --kubeconfig=/<path>/<cluster-name>-kubeconfig.yaml get nodes

To not give the path with each command, set the environment variable KUBECONFIG:

export KUBECONFIG=/<path>/<cluster-name>-kubeconfig.yaml

4. Check the connection​

CommandPurpose
kubectl config get-contextsLists the contexts in the file
kubectl cluster-infoShows the address of the control plane
kubectl versionShows the client and server version
kubectl get nodesLists all nodes of the cluster

With kubectl get nodes, all nodes must show the status Ready:

NAME                                  STATUS   ROLES           AGE   VERSION
ks12345-control-plane-abcde Ready control-plane 20m v1.36.5
ks12345-md-node-pool-1-xyz12-fghij Ready <none> 15m v1.36.5

Manage more than one cluster​

# List the available contexts
kubectl config get-contexts

# Change the context
kubectl config use-context <context-name>

# Set the default namespace for the current context
kubectl config set-context --current --namespace=<namespace>

Troubleshooting​

SymptomPossible cause
error: You must be logged in to the server (Unauthorized)The certificate has expired – create a new kubeconfig
The connection to the server ... was refusedThe cluster is not fully provisioned yet
Unable to connect to the server: dial tcp ... i/o timeoutYour network or firewall blocks access to the API endpoint
Nodes with the status NotReadySee Node Remediation
Warning about a version differenceYour kubectl version differs by more than one minor version

Next steps​