k8s部署nginx反向代理
如题
Dockerfile
FROM harbor.querycap.com/rk-infra/nginx:1.17.9
COPY nginx.conf /etc/nginx/conf.d/nginx.conf
RUN rm -f /etc/nginx/conf.d/default.conf
nginx.conf
server {
listen 80;
location / {
proxy_pass http://111.53.209.167:20080;
proxy_http_version 1.1;
}
}
k8s-yml
---
apiVersion: v1
kind: Service
metadata:
name: proxy
spec:
selector:
srv: proxy
type: ClusterIP
ports:
- name: http-80
port: 80
targetPort: 80
protocol: TCP
---
apiVersion: apps/v1
kind: Deployment
spec:
selector:
matchLabels:
srv: proxy
template:
metadata:
labels:
srv: proxy
spec:
containers:
- name: proxy
resources:
requests:
cpu: 10m
memory: 10Mi
limits:
cpu: 500m
memory: 1024Mi
readinessProbe:
httpGet:
port: 80
path: /
scheme: HTTP
initialDelaySeconds: 60
periodSeconds: 10
livenessProbe:
httpGet:
port: 80
path: /
scheme: HTTP
initialDelaySeconds: 60
periodSeconds: 10
image: 改镜像
ports:
- containerPort: 80
protocol: TCP
dnsPolicy: ClusterFirst
dnsConfig:
options:
- name: ndots
value: "2"
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: proxy
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- host: demo.rockontrol.com
http:
paths:
- backend:
service:
name: proxy
port:
number: 80
path: /
pathType: ImplementationSpecific