Getting "Error: Failed to load current kubeconfig. Please confirm that your kubeconfig is valid." when using VS Code Bridge to kubernetes

2/1/2021

When trying to use the Bridge Kubernetes extension of VS Code, having configured the tasks.json as follows:

	"version": "2.0.0",
	"tasks": [
		{
			"label": "bridge-to-kubernetes.service",
			"type": "bridge-to-kubernetes.service",
			"service": "frontend",
			"ports": [
				8080
			],
			"targetCluster": "minikube",
			"targetNamespace": "ecomm-ns"
		}
	]
}

And my launch.json as

            "name": "Launch Package with Kubernetes",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceFolder}",
            "env": {
                "GOOGLE_APPLICATION_CREDENTIALS": "somepath/ecomm-key.json",
            },
            "preLaunchTask": "bridge-to-kubernetes.service"
        }

I get following output:

Target cluster: minikube
Current cluster: minikube
Target namespace: ecomm-ns
Current namespace: ecomm-ns
Target service name: frontend
Target service ports: 8080


Error: Failed to load current kubeconfig. Please confirm that your kubeconfig is valid.

The terminal process terminated with exit code: 1.

Kkubectl config view gives me correct output

Looking at the logs of the bridge plugin, I hav the following:

2021-02-02T07:40:18.1876210Z | Library | WARNG | Failed to load kubeconfig at '/Users/scaucheteux/.kube/config': (Line: 10, Col: 5, Idx: 1804) - (Line: 10, Col: 6, Idx: 1805): Expected 'MappingStart', got 'SequenceStart' (at Line: 10, Col: 5, Idx: 1804).

My kubeconfig looks fine and is correctly parsed by various yaml plugins and by kubectl:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tLS1CRUdJTiBDRVJ
    server: https://35.205.91.182
  name: gke_sca-ecommerce-291313_europe-west1-b_ecomm-demo
- cluster:
    certificate-authority: /Users/someuser/.minikube/ca.crt
    extensions:
    - extension :
        last-update: Mon, 01 Feb 2021 15:27:30 CET
        provider: minikube.sigs.k8s.io
        version: v1.17.1
      name: cluster_info
    server: https://127.0.0.1:55000
  name: minikube
contexts:
- context:
    cluster: gke_sca-ecommerce-291313_europe-west1-b_ecomm-demo
    namespace: ecomm-ns
    user: gke_sca-ecommerce-291313_europe-west1-b_ecomm-demo
  name: gke_sca-ecommerce-291313_europe-west1-b_ecomm-demo
- context:
    cluster: minikube
    extensions:
    - extension:
        last-update: Mon, 01 Feb 2021 15:27:30 CET
        provider: minikube.sigs.k8s.io
        version: v1.17.1
      name: context_info
    namespace: ecomm-ns
    user: minikube
  name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: gke_sca-ecommerce-291313_europe-west1-b_ecomm-demo
  user:
    auth-provider:
      config:
        access-token: ya29.A0A
        cmd-args: config config-helper --format=json
        cmd-path: /Users/someuser/Devs/gcloud/google-cloud-sdk/bin/gcloud
        expiry: "2021-02-01T18:23:02Z"
        expiry-key: '{.credential.token_expiry}'
        token-key: '{.credential.access_token}'
      name: gcp
- name: minikube
  user:
    client-certificate: /Users/someuser/.minikube/profiles/minikube/client.crt
    client-key: /Users/someuser/.minikube/profiles/minikube/client.key
-- Sebastian
google-kubernetes-engine
kubernetes
visual-studio-code

1 Answer

8/9/2021

Read somewhere else removing the extensions fixes it for minikube https://github.com/microsoft/mindaro/issues/111

-- dave
Source: StackOverflow