kubernetes-yaml/learn/learn-kubernetes-master/kiamol/ch05/lab/todo-list/proxy.yaml

78 lines
1.6 KiB
YAML

apiVersion: v1
kind: Service
metadata:
name: todo-proxy-lab
labels:
app: todo-proxy-lab
spec:
ports:
- port: 8082
targetPort: 80
selector:
app: todo-proxy-lab
type: LoadBalancer
---
apiVersion: v1
kind: ConfigMap
metadata:
name: todo-proxy-lab-configmap
data:
nginx.conf: |-
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=STATIC:10m inactive=24h max_size=1g;
server {
listen 80 default_server;
listen [::]:80 default_server;
location / {
proxy_pass http://todo-web-lab;
proxy_set_header Host $host;
proxy_cache STATIC;
proxy_cache_valid 200 1d;
add_header X-Cache $upstream_cache_status;
add_header X-Host $hostname;
}
}
}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: todo-proxy-lab
labels:
app: todo-proxy-lab
spec:
selector:
matchLabels:
app: todo-proxy-lab
template:
metadata:
labels:
app: todo-proxy-lab
spec:
containers:
- image: nginx:1.17-alpine
name: nginx
ports:
- containerPort: 80
name: http
volumeMounts:
- name: config
mountPath: "/etc/nginx/"
readOnly: true
volumes:
- name: config
configMap:
name: todo-proxy-lab-configmap