-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx-proxy.yaml
117 lines (115 loc) · 2.77 KB
/
nginx-proxy.yaml
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-proxy
labels:
app: nginx-proxy
spec:
replicas: 1
selector:
matchLabels:
app: nginx-proxy
template:
metadata:
labels:
app: nginx-proxy
spec:
nodeSelector:
kubernetes.io/hostname: "xxx" # changeme
initContainers:
- name: setsysctl
image: busybox
securityContext:
privileged: true
command:
- sh
- -c
- |
sysctl -w net.core.somaxconn=65535
sysctl -w net.ipv4.ip_local_port_range="1024 65535"
sysctl -w net.ipv4.tcp_tw_reuse=1
sysctl -w fs.file-max=1048576
containers:
- image: nginx:1.19.4
imagePullPolicy: Always
name: nginx-proxy
ports:
- containerPort: 80
protocol: TCP
volumeMounts:
- name: app-config-volume
mountPath: /etc/nginx/conf.d
- name: main-config-volume
mountPath: /etc/nginx
volumes:
- name: app-config-volume
configMap:
name: app-conf2
- name: main-config-volume
configMap:
name: main-conf2
---
apiVersion: v1
kind: ConfigMap
metadata:
name: app-conf2
data:
app.conf: |
upstream backend_server {
keepalive 30;
server 172.19.0.126:80; # changeme
}
server {
listen 80;
server_name nginx.qcloud.com; # changeme
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://backend_server;
}
}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: main-conf2
data:
nginx.conf: |+
user nginx;
worker_processes 8;
worker_rlimit_nofile 1024000;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 100000;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
tcp_nopush on;
tcp_nodelay on;
access_log off;
keepalive_timeout 315;
keepalive_requests 10000000;
include /etc/nginx/conf.d/*.conf;
}
---
apiVersion: v1
kind: Service
metadata:
name: nginx-proxy
spec:
type: ClusterIP
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx-proxy