k8s部署nginx反向代理

Dockerfile

1
2
3
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

1
2
3
4
5
6
7
8
9
server {
listen 80;
location / {
proxy_pass http://111.53.209.167:20080;
proxy_http_version 1.1;

}
}

k8s-yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
--- 
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