Monday, 21 August 2017

Gosh and Darn it - Kubernetes, kubectl, macOS and IBM Bluemix

So I'm continuing my Voyage O' Discovery with IBM Containers, Bluemix, Kubernetes etc. on my Mac, following tutorials such as this: -


and have got to the part where one sets up kubectl using an environment variable $KUBECONFIG.

Whilst I can "see" my Kubernetes cluster: -

bx cs clusters

OK
Name                ID                                 State    Created                    Workers   Datacenter   
DaveHayK8SCluster   fff102198c534d0096bacd575488c9dd   normal   2017-08-21T09:59:53+0000   1         par01   


the Kubernetes kubectl tool was barfing: -

kubectl version  —short

Client Version: v1.6.4
The connection to the server localhost:8080 was refused - did you specify the right host or port?


I checked the environment variable: -

echo $KUBECONFIG

/Users/davidhay/.bluemix/plugins/container-service/clusters/DaveHayK8SCluster/kube-config-prod-dal10-DaveHayK8SCluster.yml

and then checked the file-system to which it was relating: -

ls /Users/davidhay/.bluemix/plugins/container-service/clusters/

DaveHay

ls /Users/davidhay/.bluemix/plugins/container-service/clusters/DaveHay

ca-prod-dal10-DaveHay.pem kube-config-prod-dal10-DaveHay.yml

so that kinda explains why things weren't a-workin' 

Obviously I had mis-read the instructions which have you do this: -

bx cs cluster-config DaveHayK8SCluster

OK
The configuration for DaveHayK8SCluster was downloaded successfully. Export environment variables to start using Kubernetes.

export KUBECONFIG=/Users/davidhay/.bluemix/plugins/container-service/clusters/DaveHayK8SCluster/kube-config-par01-DaveHayK8SCluster.yml

Following that advice, I did this: -

export KUBECONFIG=/Users/davidhay/.bluemix/plugins/container-service/clusters/DaveHayK8SCluster/kube-config-par01-DaveHayK8SCluster.yml

and, quelle surprise, things started working: -

kubectl version  —short

Client Version: v1.6.4
Server Version: v1.5.6-4+abe34653415733

kubectl cluster-info

Kubernetes master is running at https://158.175.65.170:25305
Heapster is running at https://158.175.65.170:25305/api/v1/proxy/namespaces/kube-system/services/heapster
KubeDNS is running at https://158.175.65.170:25305/api/v1/proxy/namespaces/kube-system/services/kube-dns
kubernetes-dashboard is running at https://158.175.65.170:25305/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.


Can you say "Doofus" ? I betcha can !

2 comments:

Unknown said...

Did the same dang thing myself. Used the wrong path for $KUBECONFIG.

Dave Hay said...

:-) And that's what scripting and CLI is *such* good fun !

Note to self - use kubectl to query images in a pod or deployment

In both cases, we use JSON ... For a deployment, we can do this: - kubectl get deployment foobar --namespace snafu --output jsonpath="{...