K8s部署Nginx容器+端口映射

2023-10-25  本文已影响0人  sexy_cyber

这里涉及到了证书挂载和启动配置文件的挂载,需要配置正确


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
上一篇 下一篇

猜你喜欢

热点阅读