For CICD purposes, I need to run a docker container and then create a kubernetes cluster inside of it using kind. Here is my Dockerfile:
FROM ubuntu:18.04
RUN apt-get update
RUN apt-get install curl -y
RUN apt-get install -y gnupg2
RUN curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add -
RUN apt-get install -y lsb-release
RUN apt-get install -y software-properties-common
RUN apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
RUN apt-get update && apt-get install terraform -y
RUN apt-get install -y wget
RUN wget https://golang.org/dl/go1.15.6.linux-amd64.tar.gz
RUN tar -C /usr/local -xzf go1.15.6.linux-amd64.tar.gz
RUN GO111MODULE="on" /usr/local/go/bin/go get sigs.k8s.io/[email protected]
RUN curl -fsSL https://get.docker.com -o get-docker.sh
RUN sh get-docker.sh
It's basically an ubuntu image with kind installed.
I run this image using docker run commad:
docker run -v /var/run/docker.sock:/var/run/docker.sock -it ef33f1a0ac5e bash
And then I create a kind cluster inside of it:
kind create cluster --name kind
Then I install kubectl on it.
When I try to connect to my kind cluster using kubectl (kubectl get all
, for example), I get the following error:
The connection to the server 127.0.0.1:37583 was refused - did you specify the right host or port?
Here is my kubeconfig (kind get kubeconfig
):
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: CERTIFICATE-AUTHORITY-DATA
server: https://127.0.0.1:37583
name: kind-kind
contexts:
- context:
cluster: kind-kind
user: kind-kind
name: kind-kind
current-context: kind-kind
kind: Config
preferences: {}
users:
- name: kind-kind
user:
client-certificate-data: CLIENT-CERTIFICATE-DATA
client-key-data: CLIENT-KEY-DATA