Здравствуйте. Пытаюсь в K8s развернуть nginx reverseproxy. У меня есть pod-ы dotnet их хочу в проксировать через реверс прокси nginx
Не понимаю как это сделать.
Вот конфиг.
configmap
nginx.conf
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx
data:
nginx.conf: |
worker_processes 4;
events { worker_connections 1024; }
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
default_type application/octet-stream;
gzip on;
upstream hosts {
server ip:port;
server ip:port;
}
server {
listen 80;
location / {
proxy_pass http://hosts;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}
deployment nginx
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
selector:
matchLabels:
app: nginx
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1
ports:
- name: http
containerPort: 80
volumeMounts:
- name: nginx-config
mountPath: /etc/nginx
volumes:
- name: nginx-config
configMap:
name: nginx
service nginx
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
type: LoadBalancer
selector:
app: nginx
ports:
- port: 80
name: http
externalIPs:
- ip
- ip