Team Moonpie has a nginx server Deployment called web-moon in Namespace moon. Someone started configuring it but it was never completed. To complete please create a ConfigMap called configmap-web-moon-html containing the content of file /opt/course/15/web-moon.html under the data key-name index.html.
The Deployment web-moon is already configured to work with this ConfigMap and serve its content. Test the nginx configuration for example using curl from a temporary nginx:alpine Pod.
➜ k -n moon get pod
NAME READY STATUS RESTARTS AGE
secret-handler 1/1 Running 0 55m
web-moon-847496c686-2rzj4 0/1 ContainerCreating 0 33s
web-moon-847496c686-9nwwj 0/1 ContainerCreating 0 33s
web-moon-847496c686-cxdbx 0/1 ContainerCreating 0 33s
web-moon-847496c686-hvqlw 0/1 ContainerCreating 0 33s
web-moon-847496c686-tj7ct 0/1 ContainerCreating 0 33s
➜ k -n moon describe pod web-moon-847496c686-2rzj4
...
Warning FailedMount 31s (x7 over 63s) kubelet, gke-test-default-pool-ce83a51a-p6s4 MountVolume.SetUp failed for volume "html-volume" : configmaps "configmap-web-moon-html" not found
k -n moon create configmap -h # help
k -n moon create configmap configmap-web-moon-html --from-file=index.html=/opt/course/15/web-moon.html # important to set the index.html key
This should create a ConfigMap with yaml like:
apiVersion: v1
data:
index.html: | # notice the key index.html, this will be the filename when mounted
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Web Moon Webpage</title>
</head>
<body>
This is some great content.
</body>
</html>
kind: ConfigMap
metadata:
creationTimestamp: null
name: configmap-web-moon-html
namespace: moon
After waiting a bit or deleting/recreating (k -n moon rollout restart deploy web-moon) the Pods we should see:
➜ k -n moon get pod
NAME READY STATUS RESTARTS AGE
secret-handler 1/1 Running 0 59m
web-moon-847496c686-2rzj4 1/1 Running 0 4m28s
web-moon-847496c686-9nwwj 1/1 Running 0 4m28s
web-moon-847496c686-cxdbx 1/1 Running 0 4m28s
web-moon-847496c686-hvqlw 1/1 Running 0 4m28s
web-moon-847496c686-tj7ct 1/1 Running 0 4m28s
k -n moon get pod -o wide # get pod cluster IPs
➜ k run tmp --restart=Never --rm -i --image=nginx:alpine -- curl 10.44.0.78
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 161 100 161 0 0 80500 0 --:--:-- --:--:-- --:--:-- 157k
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Web Moon Webpage</title>
</head>
<body>
This is some great content.
</body>
For debugging or further checks we could find out more about the Pods volume mounts:
➜ k -n moon describe pod web-moon-c77655cc-dc8v4 | grep -A2 Mounts:
Mounts:
/usr/share/nginx/html from html-volume (rw)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-rvzcf (ro)
➜ k -n moon exec web-moon-c77655cc-dc8v4 find /usr/share/nginx/html
/usr/share/nginx/html
/usr/share/nginx/html/..2019_09_11_10_05_56.336284411
/usr/share/nginx/html/..2019_09_11_10_05_56.336284411/index.html
/usr/share/nginx/html/..data
/usr/share/nginx/html/index.html
Here it was important that the file will have the name index.html and not the original one web-moon.html which is controlled through the ConfigMap data key.