Let’s say I want to programmatically save the Kubeconfig of my Kubernetes cluster using doctl :
doctl -t "$DIGITALOCEAN_ACCESS_TOKEN" \
kubernetes cluster kubeconfig save "$CLUSTER_NAME"
I have at my disposal an Access token. However doing this creates a new API Key on my account, which I don’t understand the reason. Since I am providing a API token why should I create a new one? This may result in creating an excessive number of tokens.
Is this normal? Can we force doctl to use the provided API token throughout the full process?
Cheers
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Is this normal?
Yes! You are seeing this due to a recent change in how DOKS Kubernetes clusters handle authentication. Rather than using certificates, they now use API tokens. This gives team administrators much finer control over how their clusters can be accessed. Rather than a shared certificate that can not be revoked, a token tied to a specific kubeconfig file can be revoked without breaking other users.
You can read more about those changes here:
Can we force doctl to use the provided API token throughout the full process?
I’d love to know a more about your use case. Are you calling this as part of a CI process? If you are able to reuse ~/.config/doctl/cache/exec-credential across CI runs, only one token will be generated and reused until it expires. When a token expires, it will be automatically removed from your account.
To prevent the tokens from being generated all together, you could craft a kubeconfig file using a normal DO API token:
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: <CA data>
server: https://<cluster-id>.k8s.ondigitalocean.com
name: do-region-cluster-name
contexts:
- context:
cluster: do-region-cluster-name
user: do-region-cluster-name-admin
name: do-region-cluster-name
current-context: do-region-cluster-name
kind: Config
preferences: {}
users:
- name: do-region-cluster-name-admin
user:
token: <a DO api token>
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.