k8s部署nginx
2021-10-15 本文已影响0人
rushui
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
namespase: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
version: v1
template:
metadata:
labels:
app: nginx
version: v1
spec:
containers:
- image: nginx
imagePullPolicy: IfNotPresent
name: nginx
ports:
- containerPort: 80
protocol: TCP
- containerPort: 443
protocol: TCP
volumeMounts:
- mountPath: /etc/nginx/conf.d
name: nginx-config
volumes:
- configMap:
defaultMode: 511
name: nginx-config
optional: false
name: nginx-config
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
namespase: nginx
data:
default.conf: "server {\n listen 80;\n listen [::]:80;\n server_name
\ localhost;\n \n #access_log /var/log/nginx/host.access.log main;\n root
\ /usr/share/nginx/html;\n index index.html index.htm;\n \n location /
{\n try_files $uri $uri/ @router;\n root /usr/share/nginx/html;\n
\ index index.html index.htm;\n }\n \n location @router {\n rewrite
^.*$ /index.html last;\n }\n \n #error_page 404 /404.html;\n
\n # redirect server error pages to the static page /50x.html\n #\n error_page
\ 500 502 503 504 /50x.html;\n location = /50x.html {\n root /usr/share/nginx/html;\n
\ }\n \n # proxy the PHP scripts to Apache listening on 127.0.0.1:80\n #\n
\ #location ~ \\.php$ {\n # proxy_pass http://127.0.0.1;\n #}\n \n
\ # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000\n #\n
\ #location ~ \\.php$ {\n # root html;\n # fastcgi_pass
\ 127.0.0.1:9000;\n # fastcgi_index index.php;\n # fastcgi_param
\ SCRIPT_FILENAME /scripts$fastcgi_script_name;\n # include fastcgi_params;\n
\ #}\n \n # deny access to .htaccess files, if Apache's document root\n #
concurs with nginx's one\n #\n #location ~ /\\.ht {\n # deny all;\n
\ #}\n}"