Kubernetes integration not working

Hi,
I’m new to Gitlab CI/CD. I’m seeing this issue in my deployments and I’m hoping someone here can point out what I’m doing wrong.

I’ve setup a self hosted gitlab, runner and kubernetes cluster (minikube).

This is the error I get in the production stage:

$ auto-deploy ensure_namespace
The connection to the server localhost:8080 was refused - did you specify the right host or port?

The project is the default Ruby on Rails template, with an empty Agent file added.
I’ve just enabled Auto DevOps, no gitlab-ci.yml file.

My minikube looks like this:

$ kubectl get all -A
NAMESPACE                 NAME                                            READY   STATUS      RESTARTS      AGE
gitlab-kubernetes-agent   pod/gitlab-agent-845d768d7-vjq2s                1/1     Running     0             116m
ingress-nginx             pod/ingress-nginx-admission-create-t75z9        0/1     Completed   0             34m
ingress-nginx             pod/ingress-nginx-admission-patch-zkvr6         0/1     Completed   1             34m
ingress-nginx             pod/ingress-nginx-controller-6d5f55986b-24xpx   1/1     Running     0             34m
kube-system               pod/coredns-64897985d-c9n24                     1/1     Running     0             24h
kube-system               pod/etcd-minikube                               1/1     Running     1             24h
kube-system               pod/kube-apiserver-minikube                     1/1     Running     1             24h
kube-system               pod/kube-controller-manager-minikube            1/1     Running     1             24h
kube-system               pod/kube-proxy-c2zdq                            1/1     Running     0             24h
kube-system               pod/kube-scheduler-minikube                     1/1     Running     1             24h
kube-system               pod/storage-provisioner                         1/1     Running     1 (24h ago)   24h
kubernetes-dashboard      pod/dashboard-metrics-scraper-58549894f-g4rp7   1/1     Running     0             24h
kubernetes-dashboard      pod/kubernetes-dashboard-ccd587f44-bslcq        1/1     Running     1 (24h ago)   24h

NAMESPACE              NAME                                         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
default                service/kubernetes                           ClusterIP   10.96.0.1       <none>        443/TCP                      24h
ingress-nginx          service/ingress-nginx-controller             NodePort    10.110.158.32   <none>        80:30674/TCP,443:31491/TCP   34m
ingress-nginx          service/ingress-nginx-controller-admission   ClusterIP   10.96.59.203    <none>        443/TCP                      34m
kube-system            service/kube-dns                             ClusterIP   10.96.0.10      <none>        53/UDP,53/TCP,9153/TCP       24h
kubernetes-dashboard   service/dashboard-metrics-scraper            ClusterIP   10.109.92.24    <none>        8000/TCP                     24h
kubernetes-dashboard   service/kubernetes-dashboard                 ClusterIP   10.99.206.120   <none>        80/TCP                       24h

NAMESPACE     NAME                        DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR            AGE
kube-system   daemonset.apps/kube-proxy   1         1         1       1            1           kubernetes.io/os=linux   24h

NAMESPACE                 NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
gitlab-kubernetes-agent   deployment.apps/gitlab-agent                1/1     1            1           24h
ingress-nginx             deployment.apps/ingress-nginx-controller    1/1     1            1           34m
kube-system               deployment.apps/coredns                     1/1     1            1           24h
kubernetes-dashboard      deployment.apps/dashboard-metrics-scraper   1/1     1            1           24h
kubernetes-dashboard      deployment.apps/kubernetes-dashboard        1/1     1            1           24h

NAMESPACE                 NAME                                                  DESIRED   CURRENT   READY   AGE
gitlab-kubernetes-agent   replicaset.apps/gitlab-agent-57cfffcb7                0         0         0       24h
gitlab-kubernetes-agent   replicaset.apps/gitlab-agent-845d768d7                1         1         1       116m
ingress-nginx             replicaset.apps/ingress-nginx-controller-6d5f55986b   1         1         1       34m
kube-system               replicaset.apps/coredns-64897985d                     1         1         1       24h
kubernetes-dashboard      replicaset.apps/dashboard-metrics-scraper-58549894f   1         1         1       24h
kubernetes-dashboard      replicaset.apps/kubernetes-dashboard-ccd587f44        1         1         1       24h

NAMESPACE       NAME                                       COMPLETIONS   DURATION   AGE
ingress-nginx   job.batch/ingress-nginx-admission-create   1/1           2s         34m
ingress-nginx   job.batch/ingress-nginx-admission-patch    1/1           3s         34m

Kinda solved this. Even though the solution isn’t optimal.

I changed from minikube => k3s (same result)
I changed from Agent => Certificate based cluster

Now it works.
I would however have liked to see it work with the Agent.

I’m seeing similar problems with the agent. It doesn’t create contexts, it doesn’t create a runner, it doesn’t seem to do anything at all. Apparently installing a runner via the agent is a ‘premium’ feature (per the docs at runner/install/kubernetes-agent), so I think the agent is actually non-usable for the CE edition, only the kubeconfig method which is conveniently deprecated… Happy for someone to prove me wrong and show me how to get it working :slight_smile:

I got this working with the Agent now as well.
You’re right it’s the missing contexts. If you set the KUBE_CONTEXT then it works as expected.