You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
org.opencontainers.image.description="Provides a demo image to deploy to a Kubernetes cluster. It displays a message, the name of the pod and details of the node it's deployed to." \
9
+
org.opencontainers.image.description="Provides a demo image to deploy to a Kubernetes cluster. It displays a message, the name of the pod and details of the node it is deployed to." \
Copy file name to clipboardExpand all lines: README.md
+24-34Lines changed: 24 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,28 @@
1
1
# Hello Kubernetes!
2
2
3
-
This image can be deployed on a Kubernetes cluster. It displays:
3
+
This container image can be deployed on a Kubernetes cluster. When accessed via a web browser on port `8080`, it will display:
4
4
- a default **Hello world!** message
5
5
- the pod name
6
6
- node os information
7
7
8
-
The default "Hello world!" message displayed can be overridden using the `MESSAGE` environment variable.
8
+

9
9
10
-
The default port of 8080 can be overriden using the `PORT` environment variable.
10
+
The default "Hello world!" message displayed can be overridden using the `MESSAGE` environment variable. The default port of 8080 can be overriden using the `PORT` environment variable.
This will display a **Hello world!** message when you hit the service endpoint in a browser. You can get the service endpoint ip address by executing the following command and grabbing the returned external ip address value:
72
64
73
65
```bash
74
66
$ kubectl get service hello-kubernetes
75
67
```
76
68
77
-
## Custom Message
78
-
79
-
You can customise the message displayed by the `hello-kubernetes` container as follows:
69
+
### Customise Message
80
70
81
-
Deploy using the hello-kubernetes.custom-message.yaml, which contains definitions for the service and deployment objects:
71
+
You can customise the message displayed by the `hello-kubernetes` container. Deploy using the hello-kubernetes.custom-message.yaml, which contains definitions for the service and deployment objects.
82
72
83
73
In the definition for the deployment, add an `env` variable with the name of `MESSAGE`. The value you provide will be displayed as the custom message.
Or, deploy by executing the following `run` and `expose` commands on `kubectl`, with the environment variable `MESSAGE` provided as part of the `run` command.
129
-
130
-
```bash
131
-
$ kubectl run hello-kubernetes --replicas=3 --image=paulbouwer/hello-kubernetes:1.5 --port=8080 --env="MESSAGE=I just deployed this on Kubernetes!"
By default, the `hello-kubernetes` app listens on port `8080`. If you have a requirement for the app to listen on another port, you can specify the port via an env variable with the name of PORT. Remember to also update the `containers.ports.containerPort` value to match.
138
120
@@ -155,7 +137,7 @@ spec:
155
137
spec:
156
138
containers:
157
139
- name: hello-kubernetes
158
-
image: paulbouwer/hello-kubernetes:1.5
140
+
image: paulbouwer/hello-kubernetes:1.6
159
141
ports:
160
142
- containerPort: 80
161
143
env:
@@ -164,16 +146,24 @@ spec:
164
146
```
165
147
166
148
167
-
## Build
149
+
## Build Container Image
168
150
169
151
If you'd like to build the image yourself, then you can do so as follows. The `build-arg` parameters provides metadata as defined in [OCI image spec annotations](https://github.com/opencontainers/image-spec/blob/master/annotations.md).
If you have [VS Code](https://code.visualstudio.com/) and the [Visual Studio Code Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension installed, the `.devcontainer` folder will be used to build a container based node.js 13 development environment.
166
+
167
+
Port `8080` has been configured to be forwarded to your host. If you run `npm start` in the VS Code Remote Containers terminal, you will be able to access the website on `http://localhost:8080`. You can change the port in the `.devcontainer\devcontainer.json` file under the `appPort` key.
168
+
169
+
See [here](https://code.visualstudio.com/docs/remote/containers) for more details on working with this setup.
0 commit comments