Slight variation of the sample Hello App.
It creates an hello-app
deployment in the hello
namespace that consume a hello-secrets
secret value mounting it on the SECRET
environment variable.
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-app
namespace: hello
...
spec:
...
spec:
containers:
- name: hello-app
image: ghcr.io/nikever/kubernetes-hello-secret:latest
...
env:
- name: SECRET
valueFrom:
secretKeyRef:
name: hello-secret
key: secret
The ghcr.io/nikever/kubernetes-hello-secret:latest
contains a containerized Go web server application that responds to all HTTP requests with the value of the SECRET
environment variable.
Hello, secret!
Secret: <VALUE>
The source code is available at /docker/main.go
- kustomize
>= 3.6
- Deploy the secret:
kubectl create secret generic -n hello hello-secret --from-literal=secret=1234
- Build the application manifests and apply:
cd manifest
kustomize build manifests/ | kubectl apply -f -
- Verify that the ingress controller is directing traffic:
curl -H "Host: hello-secret.info" $(minikube ip)
Output:
Hello, secret!
Secret: 1234