2
votes

I was performing a practical where i was deploying a containerised sample application using kubernetes.

i was trying to run container on google cloud platform using kubernetes engine.But while deploying container using "kubectl run" command using google cloud shell.

its showing an error "error: failed to discover supported resources: Get https://35.240.145.231/apis/extensions/v1beta1: x509: certificate signed by unknown authority".

From Error, i can recollect that its because of "SSL Certificate" not authorised.

I even exported the config file resides at "$HOME/.kube/config". but still getting the same error.

please anyone help me understand the real issue behind this.

Best,

Swapnil Pawar

1
can you run "gcloud container clusters get-credentials [cluster_name] --zone [cluster_zone]" to make sure that you have the correct credentials to interact with the GKE API?Patrick W

1 Answers

6
votes

You may try following steps,

  1. List all the available clusters,

    $ gcloud container clusters list
    
  2. Depending upon how you have configured the cluster, if the cluster location is configured for a specific zone then,

    $ gcloud container clusters get-credentials <cluster_name> --ZONE <location>
    

    or if the location is configured for a region then,

    $ gcloud container clusters get-credentials <cluster_name> --REGION <location>
    

The above command will update your kubectl config file $HOME/.kube/config

  1. Now, the tricky part. If you have more than one cluster that you have configured, then your $HOME/.kube/config will have two or more entries. You can verify it by doing a cat command on the config file.

To select a particular context/cluster, you need to run the following commands

$ kubectl config get-contexts -o=name // will give you a list of available contexts

$ kubectl config use-context <CONTEXT_NAME>

$ kubectl config set-context <CONTEXT_NAME>

Now, you may run the kubectl run.