-a7f7d2e7faf74d.jpg

ConfigMap nginx-config

kind: ConfigMap 
apiVersion: v1 
metadata: 
  name: nginx-config 
  namespace: sre
data: 
  default.conf: | 
        server {
            listen       80;
            listen  [::]:80;
            server_name _;

            location / {
                try_files uriuri/ /index.php?args;
            }
            # Add trailing slash to */wp-admin requests.

            root /app;
            index index.html index.php;

            location ~ \.php {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_param  SCRIPT_FILENAME  document_rootfastcgi_script_name;
                include        fastcgi_params;
            }
        }

pvc nginx-www

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nginx-www
  namespace: sre
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: "1000Gi"
  volumeName: 
  storageClassName: nfs

Deployment

kind: Deployment  
apiVersion: apps/v1  
metadata:  
  name: php-fpm-nginx  
  namespace: sre
spec:  
  selector:  
    matchLabels:  
      app: php-fpm-nginx
  replicas: 1  
  template:  
    metadata:  
      labels:  
        app: php-fpm-nginx
    spec:  
      containers:  
        - name: php-fpm 
          image: bitnami/php-fpm:7.4.16
          ports:
            - containerPort: 9000  
          volumeMounts:  
            - mountPath: /app
              name: nginx-www
        - name: nginx 
          image: nginx:1.19.8
          ports:
            - containerPort: 443
              name: https
            - containerPort: 80
              name: http
          volumeMounts:  
            - mountPath: /app
              name: nginx-www
            - mountPath: /etc/nginx/conf.d
              name: nginx-config
      volumes:
       - name: nginx-www
         persistentVolumeClaim:
           claimName: nginx-www
       - name: nginx-config 
         configMap: 
           name: nginx-config

svc

kind: Service  
apiVersion: v1  
metadata:  
  name: php-fpm-nginx
  namespace: sre
spec:
  type: NodePort
  selector:
    app: php-fpm-nginx
  ports:
    - port: 443 
      targetPort: 443  
      nodePort: 30004
      name: https
    - port: 80 
      targetPort: 80  
      name: http

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code