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
- A fully provisioned cluster
- An installed
kubectl, see the official installation guide
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.
| Property | Value |
|---|---|
| Authentication | Client certificate, signed by the certificate authority of your cluster |
| User | customer-admin |
| Rights | cluster-admin – full access to the complete cluster |
| Validity | 7 days from creation |
Each download creates a new file with a new certificate. Older files stay valid until they expire.
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
| Command | Purpose |
|---|---|
kubectl config get-contexts | Lists the contexts in the file |
kubectl cluster-info | Shows the address of the control plane |
kubectl version | Shows the client and server version |
kubectl get nodes | Lists 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
| Symptom | Possible 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 refused | The cluster is not fully provisioned yet |
Unable to connect to the server: dial tcp ... i/o timeout | Your network or firewall blocks access to the API endpoint |
Nodes with the status NotReady | See Node Remediation |
| Warning about a version difference | Your kubectl version differs by more than one minor version |