question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

config set-context is not working

See original GitHub issue

inspection-report-20190204_171917.tar.gz Please run microk8s.inspect and attach the generated tarball to this issue.

When I run following command

$ microk8s.kubectl config set-context qqq-staging --kubeconfig="/home/www/admin.conf"

Context "qqq-staging" modified.

and running following does not list created context:

$ microk8s.kubectl config get-contexts
CURRENT   NAME       CLUSTER            AUTHINFO   NAMESPACE
*         microk8s   microk8s-cluster   admin

Am I missing something here, or is it a known issue?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ktsakalozoscommented, Feb 7, 2019

Hi @reyou,

Here is what I tried. First I moved the kubeconfig file that you need to access MicroK8s in the default location that is also read/write:

microk8s.kubectl config view > ~/.kube/config

Then I made sure I have a kubectl (other than the kubectl you get with microk8s):

sudo snap install kubectl --classic

At this point you should be able to access the MicroK8s cluster with kubectl. For example:

> kubectl get no
NAME               STATUS   ROLES    AGE    VERSION
jackal-vgn-fz11m   Ready    <none>   8m2s   v1.13.2

Adding the context with kubectl now works:

> kubectl config set-context qqq-staging 
Context "qqq-staging" created.

> kubectl config get-contexts
CURRENT   NAME          CLUSTER            AUTHINFO   NAMESPACE
*         microk8s      microk8s-cluster   admin      
          qqq-staging                             

microk8s.kubectl uses always the kubeconfig of microk8s stored on a read only location this is why you need a non-microk8s kubectl.

1reaction
reyoucommented, Feb 11, 2019

OK, I had to follow below;

https://blog.ubuntu.com/2017/01/28/ubuntu-core-how-to-enable-aliases-for-your-snaps-commands

snap aliases

snap unalias kubectl
Read more comments on GitHub >

github_iconTop Results From Across the Web

config set-context is not working · Issue #304
When I run following command $ microk8s.kubectl config set-context qqq-staging --kubeconfig="/home/www/admin.conf" Conte...
Read more >
Kubernetes context is not set
Yes, Try the following steps to access the kubernetes cluster. This steps assumes that you have your k8s certificates in /etc/kubernetes.
Read more >
kubectl config set-context - Kubernetes
Synopsis. Sets a context entry in kubeconfig Specifying a name that already exists will merge new fields on top of existing values for...
Read more >
Kubectl Config Set-Context | Tutorial and Best Practices
Kubernetes comes with many tools to help you manage your clusters, including kubectl set-context. In this guide, you'll learn how to use this...
Read more >
kubectl config set-context not working
If you want to switch between contexts, you might be thinking of use-context? kubectl config use-context my-context.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found