K8s部署Nginx容器+端口映射
这里涉及到了证书挂载和启动配置文件的挂载,需要配置正确
-
挂载启动配置和证书
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-nginx
spec:
replicas: 1
selector:
matchLabels:
app: web-nginx
template:
metadata:
labels:
app: web-nginx
spec:
containers:
- name: web-nginx
image: nginx:latest
imagePullPolicy: IfNotPresent
volumeMounts:
- name: web-nginx-config
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
- name: nginx-cert-volume
mountPath: /etc/nginx/certs
volumes:
- name: web-nginx-config
configMap:
name: nginx-config
- name: nginx-cert-volume
secret:
secretName: nginx-cert
---
apiVersion: v1
kind: Service
metadata:
name: web-nginx
labels:
app: web-nginx
spec:
type: NodePort
selector:
app: web-nginx
ports:
- name: second-routing
nodePort: 30008
port: 90
targetPort: 443
本文标题:K8s部署Nginx容器+端口映射
本文链接:https://www.haomeiwen.com/subject/bcleidtx.html
网友评论