Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

helm and kubectl context mismatch

I'm having trouble understanding helm's use of helm --kube-context=microk8s install ... should install into the context microk8s thus into my local microk8s cluster rather than the remote GKE cluster which I once connected to.

This however fails due to Error: could not get Kubernetes config for context "microk8s": context "microk8s" does not exist if I run e.g. helm --kube-context=microk8s install --name mereet-kafka after successfully running helm init and adding necessary repositories.

The context microk8s is present and enabled according to kubectl config current-context. I can even reproduce this by running helm --kube-context=$(kubectl config current-context) install --name mereet-kafka in order to avoid any typos.

Why can't helm use obviously present contexts?

like image 677
Kalle Richter Avatar asked Jun 12 '19 21:06

Kalle Richter


People also ask

What is the difference between Helm and kubectl?

Rather than an IT admin simply listing the files to install via kubectl, a single command can install an entire application, and Helm will pull the required dependencies and apply the manifests.

How do I change the context in kubectl?

Utilize the command “kubectl config set-context my-context —cluster=my-app —namespace=production” to configure per-context parameters. This approach will build a new context named my-context with default Kubernetes cluster and namespace parameters.

Is kubectl required for Helm?

You must have Kubernetes installed. For the latest release of Helm, we recommend the latest stable release of Kubernetes, which in most cases is the second-latest minor release. You should also have a local configured copy of kubectl .

What is a kubectl context?

Context. A context element in a kubeconfig file is used to group access parameters under a convenient name. Each context has three parameters: cluster, namespace, and user. By default, the kubectl command-line tool uses parameters from the current context to communicate with the cluster.


1 Answers

This looks like a kubernetes configuration problem more than an issue with helm itself.

There are few things that might help:

  1. Check the config file in ~/.kube/config

    • kubectl config view

Is current-context set to: microk8s?

  1. Try to use:

    • kubectl config get-contexts

    • kubectl config set-context

    • kubectl config use-context

with proper arguments --server --user --cluster

  1. Check if you are refering to the config from ~/.kube/config and not your own private config from somewhere else.

  2. Check if you have a KUBECONFIG environment variable (echo $KUBECONFIG)

I hope it helps.

like image 126
Wytrzymały Wiktor Avatar answered Oct 25 '22 02:10

Wytrzymały Wiktor