Unable to connect to Kubernetes - Invalid Configuration

1/9/2021

I here for hours every day, reading and learning, but this is my first question, so bear with me.

I'm simply trying to get my Kubernetes cluster to start up.

Below is my skaffold.yaml file in the root of the project:

apiVersion: skaffold/v2alpha3
kind: Config
deploy:
  kubectl:
    manifests:
      - ./infra/k8s/*
build:
  local:
    push: false
  artifacts:
    - image: omesadev/auth
      context: auth
      docker:
        dockerfile: Dockerfile
      sync:
        manual:
          - src: 'src/**/*.ts'
            dest: .

Below is my auth-depl.yaml file in the infra/k8s/ directory:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: auth-depl
spec:
  replicas: 1
  selector:
    matchLabels:
      app: auth
  template:
    metadata:
      labels:
        app: auth
    spec:
      containers:
        - name: auth
          image: omesadev/auth
---
apiVersion: v1
kind: Service
metadata:
  name: auth-srv
spec:
  selector:
    app: auth
  ports:
    - name: auth
      protocol: TCP
      port: 3000
      targetPort: 3000

Below is the error message I'm receiving in the cli:

exiting dev mode because first deploy failed: unable to connect to Kubernetes: getting client config for Kubernetes client: error creating REST client config for kubeContext "": invalid configuration: [unable to read client-cert C:\Users\omesa\.minikube\profiles\minikube\client.crt for minikube due to open C:\Users\omesa\.minikube\profiles\minikube\client.crt: The system cannot find the path specified., unable to read client-key C:\Users\omesa\.minikube\profiles\minikube\client.key for minikube due to open C:\Users\omesa\.minikube\profiles\minikube\client.key: The system cannot find the path specified., unable to read certificate-authority C:\Users\omesa\.minikube\ca.crt for minikube due to open C:\Users\omesa\.minikube\ca.crt: The system cannot find the file specified.

I've tried to install kubernetes, minikube, and kubectl. I've added them to the path and removed them a few times in different ways because I thought my configuration or usage could have been incorrect.

Then, I read that if I'm using the Docker GUI that Kubernetes should be running in that, so I checked the settings in the Docker GUI to ensure Kubernetes was running through Docker and it is.

I have Hyper-V set up. I've used it in the past successfully with Docker and with Virtualbox, so I know my Hyper-V is not the issue.

I've also attached an image of my file directory, but I'm pretty sure everything is good to go here too.

src tree

Thanks in advance!

-- Jim
docker
kubernetes
microservices

2 Answers

1/18/2021

Posting @Jim solution from comments as community wiki for better visibility:

The problem was, I had two different contexts inside of my kubectl config and the project I was trying to launch was using the wrong cluster/context. I don't know how the minikube cluster and context were created, but I deleted them and set the new context to docker-desktop with "kubectl config use-context docker-desktop"

Helpful links:

Organizing Cluster Access Using kubeconfig Files

Configure Access to Multiple Clusters

-- kool
Source: StackOverflow

4/4/2021

Enable Kubernetes!

The reason why you are getting is that Kubernetes is not enabled.

Docker desktop

-- Nuriddin Kudratov
Source: StackOverflow