digitalocean / doctl

The official command line interface for the DigitalOcean API.
https://docs.digitalocean.com/reference/doctl/
Apache License 2.0
3.26k stars 395 forks source link

k8s: something not quite right with config #405

Closed TonyApuzzo closed 5 years ago

TonyApuzzo commented 5 years ago

If I use the kubernetes config downloaded by doctl, I can't subsequently use kompose but if I download the config file from the GUI it works fine.

Download k8s config

DIGITALOCEAN_ENABLE_BETA=1 doctl k8s cluster kubeconfig save  <my-cluster>
Notice: adding cluster credentials to kubeconfig file found in "/home/me/.kube/config"

Use it

kubectl config use-context <my-cluster>
kubectl cluster-info
Kubernetes master is running at https://my-cluster.k8s.ondigitalocean.com
CoreDNS is running at https://my-cluster.k8s.ondigitalocean.com/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

But kompose fails:

kompose -f docker-compose.yml up
Enter your Username:
^C

... remove ~/.kube/config and replace with one downloaded from the Web GUI ...

kompose up -f ~/code/config.yml
INFO We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application. If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.

INFO Deploying application in "default" namespace
INFO Successfully created Service: myserver
INFO Successfully created Service: mywebapp
INFO Successfully created Deployment: myserver
INFO Successfully created Deployment: mywebapp

Your application has been deployed to Kubernetes. You can run 'kubectl get deployment,svc,pods,pvc' for details.
eddiezane commented 5 years ago

Thanks for the report.

Does this work? Note: it will replace your config completely so back it up.

doctl k8s cluster config show cluster-id > ~/.kube/config
TonyApuzzo commented 5 years ago

Yes, using doctl k8s cluster config show cluster-id > ~/.kube/config worked fine.

Thank you!

eddiezane commented 5 years ago

Think this was fixed and saving behavior works as expected. Please reopen if not.

mike-engel commented 5 years ago

I'm still seeing this issue with version 1.20.0-release. I would be fine inputting my username and password but I have no idea what it is and several iterations I've tried don't work. doctl is installed through homebrew for me.

Here's the command I'm using:

doctl k8s cluster config save <cluster-name>

And here's the config that gets saved:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: <cert-data>
    server: <server-url>
  name: do-nyc1-<cluster-name>
contexts:
- context:
    cluster: do-nyc1-<cluster-name>
    user: do-nyc1-<cluster-name>-admin
  name: do-nyc1-<cluster-name>
current-context: do-nyc1-<cluster-name>
kind: Config
preferences: {}
users:
- name: do-nyc1-<cluster-name>-admin
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1beta1
      args:
      - kubernetes
      - cluster
      - kubeconfig
      - exec-credential
      - --version=v1beta1
      - <uuid?>
      command: doctl
      env: null

Output from doctl k8s cluster config show <cluster-name>:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: <cert-data>
    server: <server-url>
  name: do-nyc1-<cluster-name>
contexts:
- context:
    cluster: do-nyc1-<cluster-name>
    user: do-nyc1-<cluster-name>-admin
  name: do-nyc1-<cluster-name>
current-context: do-nyc1-<cluster-name>
kind: Config
preferences: {}
users:
- name: do-nyc1-<cluster-name>-admin
  user:
    client-certificate-data: <cert-data>
    client-key-data: <key-data>
> doctl version
doctl version 1.20.0-release