2

This is my skaffold.yaml file:

apiVersion: skaffold/v2alpha3
kind: Config
deploy:
  kubeContext: kind-kind
  kubectl: 
    manifests:
      - ./infra/k8s/*
build:
  local:
    push: false
  artifacts:
    - image: learnertester/auth
      context: auth
      docker:`
        dockerfile: Dockerfile
      sync:
        manual:
          - src: 'src/**/*.ts'
            dest: .
    - image: learnertester/ticketing-client
      context: client
      docker:
        dockerfile: Dockerfile
      sync:
        manual:
          - src: '**/*.js'
            dest: .
    - image: learnertester/tickets
      context: tickets
      docker:
        dockerfile: Dockerfile
      sync:
        manual:
          - src: 'src/**/*.ts'
            dest: .
    - image: learnertester/orders
      context: orders
      docker:
        dockerfile: Dockerfile
      sync:
        manual:
          - src: 'src/**/*.ts'
            dest: .
    - image: learnertester/expiration
      context: expiration
      docker:
        dockerfile: Dockerfile
      sync:
        manual:
          - src: 'src/**/*.ts'
            dest: .
    - image: learnertester/payments
      context: payments
      docker:
        dockerfile: Dockerfile
      sync:
        manual:
          - src: 'src/**/*.ts'
            dest: .

When I try kubectl config view I get this result:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://192.168.1.2:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: DATA+OMITTED
    client-key-data: DATA+OMITTED

I have also installed kind and created a cluster with that. this is the result of kubectl cluster-info --context kind-kind :

Kubernetes control plane is running at https://127.0.0.1:41887
CoreDNS is running at https://127.0.0.1:41887/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

However when I run skaffold dev I get this error at the end:

 - Error in configuration: context was not found for specified context: kind-kind
WARN[0480] deployer cleanup:kubectl delete: exit status 1  subtask=-1 task=DevLoop
unable to connect to Kubernetes: getting client config for Kubernetes client: error creating REST client config for kubeContext "kind-kind": context "kind-kind" does not exist

I tried to remove kubeContext: kind from the skaffold.yaml file and add the context inside the /.skaffold/config file instead of that, as following:

global:
  local-cluster: true
  survey:
    last-prompted: "2022-12-18T12:20:01-08:00"
  collect-metrics: true
  update:
    last-prompted: "2022-12-18T12:30:37-08:00"
kubeContexts: [kind-kind]

But still I get:

WARN[0000] Could not load global Skaffold defaults. Error encounter while unmarshalling the contents of file "/home/a/.skaffold/config"  subtask=-1 task=DevLoop
WARN[0000] error retrieving insecure registries from global config: push/pull issues may exist...  subtask=-1 task=DevLoop
getting run context: getting cluster: unmarshalling global skaffold config: yaml: unmarshal errors:
  line 8: cannot unmarshal !!str `kind-kind` into config.ContextConfig

2 Answers2

2

The skaffold uses "kubectl" binary to deploy to the cluster. Check your skaffold yaml. To access your Kubernetes cluster, kubectl uses a configuration file. The default configuration file is located at ~/.kube/config and is referred to as the kubeconfig file. Go to the master node and run kubectl config view --flatten and paste the output to the ~/.kube/config on your PC and then try running kubectl from the PC. You will need the correct kubeconfig file in your system with the correct context set. To check current context use this kubectl config current-context

Please refer to similar SO1 SO2 for more information.

1

For me I had to change the contexts:

kubectl config use-context <cluster_name>
chicks
  • 3,915
  • 10
  • 29
  • 37