Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
Fix kubernete-helm certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
shikanime committed May 6, 2019
1 parent 13f697c commit 3f22a89
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
25 changes: 20 additions & 5 deletions containers/kubernetes-helm/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,26 @@ RUN curl -s https://raw.githubusercontent.com/helm/helm/master/scripts/get | bas

# Copy localhost's ~/.kube/config file into the container and swap out localhost
# for host.docker.internal whenever a new shell starts to keep them in sync.
RUN echo 'if [ "$SYNC_LOCALHOST_KUBECONFIG" == "true" ]; then \
mkdir -p $HOME/.kube \
&& cp -r $HOME/.kube-localhost/* $HOME/.kube \
&& sed -i -e "s/localhost/host.docker.internal/g" $HOME/.kube/config; \
fi' >> $HOME/.bashrc
RUN echo '\n\
if [ "$SYNC_LOCALHOST_KUBECONFIG" == "true" ]; then\n\
mkdir -p $HOME/.kube\n\
cp -r $HOME/.kube-localhost/* $HOME/.kube\n\
sed -i -e "s/localhost/host.docker.internal/g" $HOME/.kube/config;\n\
fi' \
>> $HOME/.bashrc

# Copy localhost's minikube certificate file into the container and swap out localhost
RUN echo '\n\
if [ "$SYNC_LOCALHOST_MINIKUBE" == "true" ]; then\n\
mkdir -p $HOME/.minikube\n\
cp -r $HOME/.minikube-localhost/ca.crt $HOME/.minikube\n\
cp -r $HOME/.minikube-localhost/client.crt $HOME/.minikube\n\
cp -r $HOME/.minikube-localhost/client.key $HOME/.minikube\n\
sed -i -r "s|(\s*client-key:\s).*|\\1$HOME\/.minikube\/client.key|g" $HOME/.kube/config;\n\
sed -i -r "s|(\s*client-certificate:\s).*|\\1$HOME\/.minikube\/client.crt|g" $HOME/.kube/config\n\
sed -i -r "s|(\s*certificate-authority:\s).*|\\1$HOME\/.minikube\/ca.crt|g" $HOME/.kube/config;\n\
fi' \
>> $HOME/.bashrc

# Clean up
RUN apt-get autoremove -y \
Expand Down
10 changes: 7 additions & 3 deletions containers/kubernetes-helm/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"peterjausovec.vscode-docker",
"ms-kubernetes-tools.vscode-kubernetes-tools"
],
"runArgs": ["-e", "SYNC_LOCALHOST_KUBECONFIG=true",
"-v", "/var/run/docker.sock:/var/run/docker.sock",
"-v", "${env:HOME}${env:USERPROFILE}/.kube:/root/.kube-localhost"]
"runArgs": [
"-e", "SYNC_LOCALHOST_KUBECONFIG=true",
"-e", "SYNC_LOCALHOST_MINIKUBE=true",
"-v", "/var/run/docker.sock:/var/run/docker.sock",
"-v", "${env:HOME}${env:USERPROFILE}/.kube:/root/.kube-localhost",
"-v", "${env:HOME}${env:USERPROFILE}/.minikube:/root/.minikube-localhost"
]
}

0 comments on commit 3f22a89

Please sign in to comment.