As much as anything, this is a reminder of where the KUBECONFIG ( Kubernetes configuration ) gets persisted, by default, when I retrieve the cluster config using the IBM Cloud CLI tool.
So, I have a cluster called davehay-cluster-24112022 in my account, which I spun up last week, targeting version 1.25.4_1522. This cluster has a unique ID of cdvpi5320u9g36cvpjrg.
I can retrieve this cluster configuration using a command such as: -
ibmcloud cs cluster config --cluster davehay-cluster-24112022
or, even: -
ibmcloud cs cluster config --cluster cdvpi5320u9g36cvpjrg --admin --network
( if I want to (a) admin the cluster and (b) get the Calico network configuration )
When I run this command, I get a helpful output reminding me where things get stored: -
The configuration for cdvpi5320u9g36cvpjrg was downloaded successfully.
Network Config:
/Users/hayd/.bluemix/plugins/container-service/clusters/davehay-cluster-24112022-cdvpi5320u9g36cvpjrg-admin/calicoctl.cfg
Added context for cdvpi5320u9g36cvpjrg to the current kubeconfig file.
You can now execute 'kubectl' commands against your cluster. For example, run 'kubectl get nodes'.
If you are accessing the cluster for the first time, 'kubectl' commands might fail for a few seconds while RBAC synchronizes.
Most notably, this is the important bit: -
/Users/hayd/.bluemix/plugins/container-service/clusters/davehay-cluster-24112022-cdvpi5320u9g36cvpjrg-admin
If I inspect that subdirectory: -
ls -al
I see a bunch of files: -
drwxr-x--- 10 hayd staff 320 28 Nov 14:41 .
drwxr-x--- 3 hayd staff 96 28 Nov 14:41 ..
-rw-r--r-- 1 hayd staff 1679 28 Nov 14:41 admin-key.pem
-rw-r--r-- 1 hayd staff 1350 28 Nov 14:41 admin.pem
-rw-r--r-- 1 hayd staff 1188 28 Nov 14:41 ca-aaa00-davehay-cluster-24112022.pem
-rw-r--r-- 1 hayd staff 1188 28 Nov 14:41 ca.pem
-rw-r--r-- 1 hayd staff 230 28 Nov 14:41 calicoctl.cfg
-rw-r--r-- 1 hayd staff 135 28 Nov 14:41 calicoctl.cfg.template
-rw-r--r-- 1 hayd staff 628 28 Nov 14:41 kube-config-aaa00-davehay-cluster-24112022.yml
-rw-r--r-- 1 hayd staff 628 28 Nov 14:41 kube-config.yaml
including kube-config.yaml.
I can then setup my kubectl environment: -
export KUBECONFIG=/Users/hayd/.bluemix/plugins/container-service/clusters/davehay-cluster-24112022-cdvpi5320u9g36cvpjrg-admin/kube-config.yaml
and then run kubectl commands such as: -
kubectl get nodes -A
10.240.0.5 Ready <none> 3d22h v1.25.4+IKS
As an alternate, I could do this: -
ibmcloud cs cluster config --cluster cdvpi5320u9g36cvpjrg --admin --output YAML > ~/k8s.yaml
export KUBECONFIG=~/k8s.yaml
which is a nice alternative.
No comments:
Post a Comment