The code is in the 01 folder
- We'll use an official docker image with the persistent tag (1.19.6) as our source image
- Because it is a new solution and we want our image footprint to be as small as we can. we'll use the latest
alpine
based image
- Because it is a new solution and we want our image footprint to be as small as we can. we'll use the latest
- Create
index.html
with DATE/TIME settings - Running nginx as a non-root user
- Create an
nginx.conf
file and copy it to the Target image - Change Listener port from 80 => 8080 in
default.conf
file (this because we want to run as a not-root user (in our casenginx
)) - For the healthcheck (will be used in Liveness/Readiness probes) we'll expose
/healthz
path indefault.conf
file - Change docker image context from
root
tonginx
user (so user which attach to container will be attached as user with limited permissions)
- Create an
Docker build instructions:
docker login
docker build -t adamkpn/nginx-datetime:1.0.1 .
docker push adamkpn/nginx-datetime:1.0.1
The code is in the 03 folder
- The solution contains two environments,
qa
andproduction
qa
example:
# Bootstrap k3d cluster (this will also expose Ingress on ports 80/443)
k3d cluster create \
--agents 2 \
--port "80:80@loadbalancer" \
--port "443:443@loadbalancer"
# Create qa namespace
kubectl create ns qa
# Switch to qa namespace
kubectl config set-context $(kubectl config current-context) --namespace qa
# Navigate into the 03/_manifests file
cd 03/_manifests
# Deploy the manifest by running:
kustomize build qa/base | kaf -
# This will deploy the following resources:
- Deployment
- Service
- Ingress
- Add
127.0.0.1 datetime-qa.example.com
record if you want to test the service with the ingress edpoint.- To test, open the browser and navigate to http://datetime-qa.example.com/ or https://datetime-qa.example.com/
- If you want to test the service Internally from the Kubernetes cluster, run the following command:
kubectl run curl -it --rm --restart=Never --image curlimages/curl -- datetime
- You can repeat the process in an additional namespace production
- In this case the Ingress Hosts will have name
datetime-production.example.com
The code is in the 04 folder
- this part is not completed yet, will be updated...