Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Using $KUBECONFIG with several files, logging into the cluster dumps all contexts into the default config file #966

Description

@adietish

Steps:

  1. ASSERT: have several config files, all of them listed on the KUBECONFIG env var
  • $KUBECONFIG
export KUBECONFIG=${HOME}/.kube/config:${HOME}/.kube/minikube.yaml:${HOME}/.kube/sandbox.yaml
  • config
apiVersion: v1
current-context: rh-sandbox
kind: Config
preferences: {}
  • minikube.yaml
apiVersion: v1
clusters:
- cluster:
    certificate-authority: /Users/adietish/.minikube/ca.crt
    extensions:
    - extension:
        provider: minikube.sigs.k8s.io
        version: v1.34.0
      name: cluster_info
    server: https://127.0.0.1:41825
  name: minikube
contexts:
- context:
    cluster: minikube
    extensions:
    - extension:
        last-update: Wed, 08 Jan 2025 15:05:54 CET
        provider: minikube.sigs.k8s.io
        version: v1.34.0
      name: context_info
    namespace: kube-node-lease
    user: minikube
  name: minikube
kind: Config
preferences: {}
users:
- name: minikube
  user:
    client-certificate: /Users/adietish/.minikube/profiles/minikube/client.crt
    client-key: /Users/adietish/.minikube/profiles/minikube/client.key
  • sandbox.yaml
apiVersion: v1
clusters:
- cluster:
    server: https://api.XXXX.openshiftapps.com:6443
  name: rh-sandbox
contexts:
- context:
    cluster: rh-sandbox
    namespace: adietish-dev
    user: adietish/rh-sandbox
  name: rh-sandbox
current-context: ""
kind: Config
preferences: {}
users:
- name: adietish/rh-sandbox
  user:
    token: sha256~XXXXXXXXXXXXXXXXXXXEMhxfNi614txI
  1. EXEC: pick ctx menu action "Log in to Cluster"
  2. ASSERT: Login dialog is show
  3. EXEC: get the token and paste into the Login dialog into the field "Token:"
  4. EXEC: hit "OK"
  5. ASSERT: The plugin is logged into the RH sandbox
  6. EXEC: cat ~/.kube/config

Result:
~/.kube/config was altered. All the above contexts were dumped into it. Interestingly, Only the context were dumped. Neiter the users, nor clusters were. Additionally a new context was created for the cluster using the url that was listed in the dialog.

apiVersion: v1
clusters:
- cluster:
    insecure-skip-tls-verify: true
    server: https://api.rm1.0a51.p1.openshiftapps.com:6443
  name: api-rm1-0a51-p1-openshiftapps-com:6443
contexts:
- context:
    cluster: apiXXXXopenshiftapps-com:6443
    namespace: adietish-dev
    user: adietish/apiXXXXXopenshiftapps-com:6443
  name: adietish-dev/apiXXXXXopenshiftapps-com:6443/adietish
- context:
    cluster: minikube
    extensions:
    - extension:
        provider: minikube.sigs.k8s.io
        version: v1.34.0
      name: context_info
    namespace: kube-node-lease
    user: minikube
  name: minikube
- context:
    cluster: rh-sandbox
    namespace: adietish-dev
    user: adietish/rh-sandbox
  name: rh-sandbox
current-context: adietish-dev/api-rm1-0a51-p1-openshiftapps-com:6443/adietish
kind: Config
preferences: {}
users:
- name: adietish/apiXXXXXopenshiftapps-com:6443
  user:
    token: sha256XXXXXXXXXEMhxfNi614txI

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions