kubernetes-yaml/learn/learn-kubernetes-master/kiamol/ch13/numbers/proxy.yaml

81 lines
1.8 KiB
YAML
Raw Normal View History

apiVersion: v1
kind: Service
metadata:
name: numbers-api-proxy
namespace: kiamol-ch13-test
spec:
ports:
- port: 8080
targetPort: http
selector:
app: numbers-api-proxy
type: LoadBalancer
---
apiVersion: v1
kind: ConfigMap
metadata:
name: numbers-api-proxy-config
namespace: kiamol-ch13-test
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:1m inactive=24h max_size=1g;
server {
listen 80 default_server;
listen [::]:80 default_server;
location / {
proxy_pass http://numbers-api;
proxy_set_header Host $host;
proxy_cache STATIC;
proxy_cache_valid 20s;
add_header X-Cache $upstream_cache_status;
add_header X-Host $hostname;
}
}
}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: numbers-api-proxy
namespace: kiamol-ch13-test
spec:
selector:
matchLabels:
app: numbers-api-proxy
template:
metadata:
labels:
app: numbers-api-proxy
spec:
containers:
- image: nginx:1.17-alpine
name: nginx
ports:
- containerPort: 80
name: http
volumeMounts:
- name: config
mountPath: "/etc/nginx/"
readOnly: true
- name: cache-volume
mountPath: /data/nginx/cache
volumes:
- name: config
configMap:
name: numbers-api-proxy-config
- name: cache-volume
emptyDir: {}