Running Ubuntu Server 22.04.2 - No Docker installed on any nodes.
Hi all, I’m trying to fulfill a rather easy sounding task:
Create a nginx pod with a customized index.html page. Basically it’s a (very simple) HTML document that just say “Hello to machine 1”
This files should be placed in /var/www/htdocs and the nginx config needs to point to this location.
While you can manipulate the nginx config via “args” inside your yaml file, I’ve no idea how to “create” (if not present) the /var/www/htdocs folder + put the indexd.html file into it.
As this is a total static website, there’s no need for any ext. volumes.
So how can I write a YAML that deploys a nginx pod with my custom HTML page inside ?
Now create your deploy.yaml and link it to the config-map:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-t-m1
namespace: test
labels:
name: nginx-t-m1
spec:
selector:
matchLabels:
name: nginx-t-m1
strategy:
type: RollingUpdate
template:
metadata:
labels:
name: nginx-t-m1
spec:
containers:
- name: nginx-t-m1
image: nginx
ports:
volumeMounts:
- name: config-volume1
mountPath: /usr/share/nginx/html
volumes:
- name: config-volume1
configMap:
# Provide the name of the ConfigMap containing the files you want
# to add to the container
name: nginx-m1
Pay extra attention on the Metadata “name: nginx-m1”. That need to fit the name tag in your deploy.yaml
This is of course just an example of a very small HTML page. Mind that the max size of a config-map may not exceed 1MB. So if you plan to deploy “larger” pages you’ll need volumes with your pages configured/mounted.