# front: nginx (unprivileged) serving a static page and proxying /api/ to the api Service. apiVersion: v1 kind: ConfigMap metadata: name: front-nginx namespace: demo data: default.conf: | server { listen 8080; server_name _; location = /healthz { add_header Content-Type text/plain; return 200 'ok'; } location /api/ { proxy_pass http://api:8080/api/; proxy_connect_timeout 2s; proxy_read_timeout 5s; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location / { root /usr/share/nginx/html; index index.html; } } index.html: |
container layer (AWS k8s) -> VPN -> VM layer (GCP legacy-api, PostgreSQL)
--- apiVersion: apps/v1 kind: Deployment metadata: name: front namespace: demo labels: { app: front } spec: replicas: 2 selector: matchLabels: { app: front } template: metadata: labels: { app: front } spec: containers: - name: nginx image: nginxinc/nginx-unprivileged:1.31.6-alpine ports: [{ name: http, containerPort: 8080 }] volumeMounts: - { name: conf, mountPath: /etc/nginx/conf.d/default.conf, subPath: default.conf, readOnly: true } - { name: conf, mountPath: /usr/share/nginx/html/index.html, subPath: index.html, readOnly: true } livenessProbe: { httpGet: { path: /healthz, port: http }, periodSeconds: 10, failureThreshold: 3 } readinessProbe: { httpGet: { path: /healthz, port: http }, periodSeconds: 5, failureThreshold: 2 } resources: requests: { cpu: 50m, memory: 32Mi } limits: { memory: 64Mi } volumes: - name: conf configMap: { name: front-nginx } --- apiVersion: v1 kind: Service metadata: name: front namespace: demo spec: selector: { app: front } ports: [{ name: http, port: 8080, targetPort: http }]