-
Notifications
You must be signed in to change notification settings - Fork 205
Description
Problem
Currently when using the kubernetes backend the configuration block expects a reference to a kubeconfig filename.
projects:
- name: main
backends:
- type: kubernetes
kubeconfig:
filename: ~/.kube/configHowever, that reference is not something that can be entered via the dstack server backend interface running in a docker container.
Solution
Noted in the code https://github.com/dstackai/dstack/blob/master/src/dstack/_internal/core/backends/kubernetes/models.py#L39-L50 there is a reference to be able to specify a data key instead of filename. It is unclear to me if this already supported, but if it is then an example on that would be great. I am assuming it would work like this, but not clear if that is right.
projects:
- name: main
backends:
- type: kubernetes
kubeconfig:
data:
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: <redacted>
server: https://cluster.k8s.io
name: kubernetes
contexts:
- context:
cluster: kubernetes
namespace: development
user: dstack-server
name: dstack-server-context
current-context: dstack-server-context
kind: Config
users:
- name: dstack-server
user:
token: <redacted>
proxy_jump:
hostname: 204.12.171.137
port: 32000It looks like this is somewhat described in https://dstack.ai/docs/reference/server/config.yml/#kubernetes-kubeconfig although that assumes you have compact raw JSON blob of the config, while generally you deal with yaml files.
cat my-service-account-file.json | jq -c | jq -RWorkaround
don't use the dstack server UI or if the data block is supported, use something similar to the following to convert the yaml.
kubectl config --kubeconfig ~/.kube/config view --raw=true -o json | jq -c | jq -RWould you like to help us implement this feature by sending a PR?
Yes