Reputation: 4964
I am wondering how do I create a kube config file for my Kubernetes cluster programatically so I can use it with kubectl
in IBM Cloud.
Upvotes: 0
Views: 558
Reputation: 4964
To generate a Kube config file to use with kubectl
you can do the following via curl to generate the file.
First you will need to get your bearer and refresh token. There are a couple ways to do this. If you have an API key you [can generate your tokens here.
Once you have your tokens you can call the following API.
POST https://containers.cloud.ibm.com/global/v1/clusters/clusterid/config
.
That will give you a zipped file with the kube config and relevant certificates.
curl --location --request GET 'https://containers.cloud.ibm.com/global/v1/clusters/xxx/config' \
--header 'Authorization: mybearertoken' \
--header 'X-Auth-Refresh-Token: myrefreshtoken' >> kubeconfig.zip
Replace mybearertoken
and myrefreshtoken
with the correct values from here.
Upvotes: 1