Unable to connect to a Kubernetes cluster in OCI using kubectl πŸ”Œ

The time finally came for me to get hands on with Kubernetes on OCI (or OKE as it’s affectionately know).

Spinning up a Kubernetes cluster was an absolute breeze, however when I started to work through the Quick Start….or not so Quick Start for me – I stumbled up an error when attempting to deploy the sample app to my cluster.

When I ran the command in Step 3 I received the following error:

error: error validating “https://k8s.io/examples/application/deployment.yaml”: error validating data: failed to download openapi: the server has asked for the client to provide credentials; if you choose to ignore these errors, turn validation off with –validate=false

Looked like some form of authentication issue, after much head scratching and experimentation I figured out what the problem was (it took me far too long ⏱️).

I have multiple profiles specified within my OCI CLI configuration file, example below (with the juicy bits removed!):

The OKE cluster I needed to connect to is within the tenancy I have named PubSec, if I take a look at the Kubernetes config file (located in “.kube” within my user profile), I could see that this uses the OCI CLI to connect to the cluster – however as it doesn’t specify a profile within the OCI CLI config this will use the DEFAULT profile, in my specific case I needed to override this to uses the PubSec profile.

I resolved this by adding the highlighted lines (below) to the Kubernetes config file within “.kube”. This tells the OCI CLI to connect to the cluster using the PubSec profile rather than DEFAULT.

Once I’d updated this, saved and re-sarted the terminal, I ran the command again and it worked like magic πŸͺ„

Comments

Leave a comment