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

Commit a0370e4

Browse files
authored
Update README.md
1 parent 7a726c7 commit a0370e4

File tree

1 file changed

+45
-35
lines changed

1 file changed

+45
-35
lines changed

containers/kubernetes-helm/README.md

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,7 @@ The dev container also syncs your local Kubernetes config (`~/.kube/config` or `
2222

2323
You can adapt your own existing development container Dockerfile to support this scenario by following these steps:
2424

25-
1. First, install all of the needed CLIs in the container. From `.devcontainer/Dockerfile`:
26-
27-
```Dockerfile
28-
# Install Docker CE CLI
29-
RUN apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common lsb-release \
30-
&& curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | apt-key add - 2>/dev/null \
31-
&& add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" \
32-
&& apt-get update \
33-
&& apt-get install -y docker-ce-cli
34-
35-
# Install kubectl
36-
RUN curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - 2>/dev/null \
37-
&& echo "deb https://apt.kubernetes.io/ kubernetes-$(lsb_release -cs) main" | tee -a /etc/apt/sources.list.d/kubernetes.list \
38-
&& apt-get update \
39-
&& apt-get install -y kubectl
40-
41-
# Install Helm
42-
RUN curl -s https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash -
43-
```
44-
45-
2. Next, forward the local Docker socket and mount the local `.kube` folder in the container so the configuration can be reused. From `.devcontainer/devcontainer.json`:
25+
1. First, update your `devcontainer.json` to forward the local Docker socket and mount the local `.kube` folder in the container so its contents can be reused. From `.devcontainer/devcontainer.json`:
4626

4727
```json
4828
"runArgs": ["-e", "SYNC_LOCALHOST_KUBECONFIG=true",
@@ -58,10 +38,12 @@ You can adapt your own existing development container Dockerfile to support this
5838
"-v", "$HOME/.kube:/root/.kube-localhost",
5939
"-v", "$HOME/.minikube:/root/.minikube-localhost"]
6040
```
61-
62-
3. Update `.bashrc` to automatically swap out `localhost` for `host.docker.internal` in the container's copy of the Kubernetes config and (optionally) Minikube certificates. From `.devcontainer/Dockerfile`:
41+
42+
2. Second, update your Dockerfile so the default shell is `bash`, and update the `.bashrc` script to automatically swap out `localhost` for `host.docker.internal` in the container's copy of the Kubernetes config and (optionally) Minikube certificates. From `.devcontainer/Dockerfile`:
6343

6444
```Dockerfile
45+
ENV SHELL /bin/bash
46+
6547
RUN echo '\n\
6648
if [ "$SYNC_LOCALHOST_KUBECONFIG" == "true" ]; then\n\
6749
mkdir -p $HOME/.kube\n\
@@ -78,10 +60,30 @@ You can adapt your own existing development container Dockerfile to support this
7860
sed -i -r "s|(\s*client-key:\s).*|\\1$HOME\/.minikube\/client.key|g" $HOME/.kube/config\n\
7961
fi\n\
8062
fi' \
81-
>> $HOME/.bashrc
63+
>> $HOME/.bashrc
64+
```
65+
66+
3. Next, update your Dockerfile to install all of the needed CLIs in the container. From `.devcontainer/Dockerfile`:
67+
68+
```Dockerfile
69+
# Install Docker CE CLI
70+
RUN apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common lsb-release \
71+
&& curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | apt-key add - 2>/dev/null \
72+
&& add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" \
73+
&& apt-get update \
74+
&& apt-get install -y docker-ce-cli
75+
76+
# Install kubectl
77+
RUN curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - 2>/dev/null \
78+
&& echo "deb https://apt.kubernetes.io/ kubernetes-$(lsb_release -cs) main" | tee -a /etc/apt/sources.list.d/kubernetes.list \
79+
&& apt-get update \
80+
&& apt-get install -y kubectl
81+
82+
# Install Helm
83+
RUN curl -s https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash -
8284
```
8385

84-
5. Add a container specific user settings file that forces the Docker extension to be installed inside the container instead of locally. From `.devcontainer/Dockerfile`:
86+
4. Finally, have your Dockerfile add a container specific user settings file that forces the Docker extension to be installed inside the container instead of locally. From `.devcontainer/Dockerfile`:
8587

8688
```Dockerfile
8789
COPY settings.vscode.json /root/.vscode-remote/data/Machine/settings.json
@@ -97,23 +99,31 @@ You can adapt your own existing development container Dockerfile to support this
9799
}
98100
```
99101

100-
6. Press <kbd>F1</kbd> and run **Remote-Containers: Rebuild Container** so the changes take effect.
102+
5. Press <kbd>F1</kbd> and run **Remote-Containers: Rebuild Container** so the changes take effect.
101103

102104
That's it!
103105

104106
## Using this definition with an existing folder
105107

106-
There are no special setup steps are required, but note that the included `.devcontainer/Dockerfile` can be altered to work with other Debian/Ubuntu-based container images such as `node` or `python`. Just, update the `FROM` statement to reference the new base image. For example:
108+
A few notes on the definition:
109+
110+
* The included `.devcontainer/Dockerfile` can be altered to work with other Debian/Ubuntu-based container images such as `node` or `python`. Just, update the `FROM` statement to reference the new base image. For example:
107111

108-
```Dockerfile
109-
FROM node:lts
110-
```
112+
```Dockerfile
113+
FROM node:lts
114+
```
115+
116+
* If you also want to sync your Minikube certificates, open `.devcontainer/devcontainer.json` and uncomment this line in `runArgs`:
111117

112-
In addition, if you want to **disable sync'ing** local Kubernetes config into the container, remove `"-e", "SYNC_LOCALHOST_KUBECONFIG=true",` from `runArgs` in `.devcontainer/devcontainer.json`.
118+
```json
119+
"--mount", "type=bind,source=${env:HOME}${env:USERPROFILE}/.minikube,target=/root/.minikube-localhost",
120+
```
121+
122+
* If you want to **disable sync'ing** local Kubernetes config / Minikube certs into the container, remove `"-e", "SYNC_LOCALHOST_KUBECONFIG=true",` from `runArgs` in `.devcontainer/devcontainer.json`.
113123

114-
Follow the steps below for your operating system to use the definition.
124+
See the section below for your operating system for more detailed setup instructions.
115125

116-
### macOS / Windows
126+
### Windows / macOS
117127

118128
1. If this is your first time using a development container, please follow the [getting started steps](https://aka.ms/vscode-remote/containers/getting-started) to set up your machine.
119129

@@ -164,10 +174,10 @@ Follow the steps below for your operating system to use the definition.
164174

165175
6. After following step 2 or 3, the contents of the `.devcontainer` folder in your project can be adapted to meet your needs.
166176

167-
7. Open `.devcontainer/devcontainer.json` and uncomment/add this line to `runArgs` array:
177+
7. Open `.devcontainer/devcontainer.json` and uncomment this line in the `runArgs` array:
168178

169179
```json
170-
"--mount", "type=bind,source=${env:HOME}${env:USERPROFILE}/.minikube,target=/root/.minikube-localhost"
180+
"--mount", "type=bind,source=${env:HOME}${env:USERPROFILE}/.minikube,target=/root/.minikube-localhost",
171181
```
172182

173183
8. Finally, press <kbd>F1</kbd> and run **Remote-Containers: Reopen Folder in Container** to start using the definition.

0 commit comments

Comments
 (0)