I am working on running a project locally inside a Docker container with Linux-amd64 architecture. The start script runs the following command
kubectl create configmap -o yaml \
--dry-run=true \
--from-file ./configs/local/grafana \
grafana-dashboards-source-config |
kubectl apply -f -
which runs well on my MacOs but when run inside the Docker container, it fails with The connection to the server localhost:8080 was refused - did you specify the right host or port?
error. On browsing resources online, many posts suggested to use these commands to fix the issue
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
but inside my Docker container I cannot find the /kubernetes
directory and hence the admin.conf
file.
I am using COPY --from=lachlanevenson/k8s-kubectl:v1.10.3 /usr/local/bin/kubectl /usr/local/bin/kubectl
command in my Dockerfile to install kubectl and kubectl version --client
returns with
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:17:39Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
I wished to know what is the correct way to install kubectl while creating a Docker image so that I can find the kubernetes/admin.conf
file, or if there is a way to generate it after kubectl is installed?