Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

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!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Accepted Answer
I cannot yet understand why doctl is necessary. Can it be done without doctl?
doctl is not necessary to connect to a DigitalOcean managed Kubernetes cluster. It is just a tool used to download a kubeconfig file. If you already have a working one (e.g. downloaded from the control panel), you don’t need doctl.
each time I download the config or when I create a new service account using the CLI a new DO API token is automatically generated.
If you are worried about the number of tokens being generated, the doctl kubernetes cluster kubeconfig save takes an --expiry-seconds flag. This can be useful for creating short lived tokens for CI/CD.
Like @nabsul said, I think you were almost there. In addition to decoding the base64 encoded token and putting the decoded version in the token entry, it looks like you also need to adjust the username for the context:
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: <CADATA>
server: <SERVER>
name: <CLUSTERNAME>
contexts:
- context:
cluster: <CLUSTERNAME>
user: <CLUSTERNAME>-admin
name: <CLUSTERNAME>
current-context: <CLUSTERNAME>
kind: Config
preferences: {}
users:
- name: <SERVICEACCOUNT-USERNAME>
user:
token: <BASE64 decoded SERVICE ACCOUNT Token>
Rather than the admin user, you want the service account user. The highlighted fields should match.
I’ve done this before for the purpose of using github actions deploy to my DO cluster. When you create a service account, there’s automatically a secret with the name format [accountname]-token-[somerandomstring].
You can use that secret to connect to the cluster. In the case of github actions I just needed to copy the whole yaml output. It might be a little different for you depending on what you’re using.
In GitHub actions you just give the “Kubernetes set context” task the whole secret yaml and it handles the rest automatically.
However, I did a little experimenting, and I think I know the solution.
I think you were almost there. You just need to decode the base64 and put the decoded version in the token entry.