yaml

作者: 无味wy | 来源:发表于2023-04-10 11:03 被阅读0次
apiVersion: v1 # api 版本
kind: Service # 对象类型
metadata: # 元数据
  name: svc #Service 服务名
  namespace: default  #命名空间
spec:
  type: NodePort #默认类型为ClusterIP
  ports: #端口信息
    - port: 80  # 容器端口80
      protocol: TCP #tcp类型
      targetPort: 80 # Service 将 nginx 容器的 80 端口暴露出来
  selector:     # 标签选择器
      app: nginx

apiVersion: networking.k8s.io/v1 
kind: Ingress 
metadata:   
  name: my-ingress   
  namespace: test 
  annotations:     
    nginx.ingress.kubernetes.io/rewrite-target: / 
spec:   
  rules:     
    - host: xx.xxx.cn       
      http:         
        paths:           
          - path: /test             
            pathType: Prefix             
            backend:               
              service:                 
                name: svc                 
                port:                   
                  name: http           
          - path: /             
            pathType: Prefix             
            backend:               
              service:                 
                name: vue-svc                 
                port:                   
                  name: http
apiVersion: v1 
kind: ConfigMap 
metadata: 
  name: nginx-vue-config 
  namespace: test 
data: 
  default.conf: | 
    server { 
      listen 80; 
      server_name *.ia.cn; 
      root /usr/share/nginx/; 
      location / { 
        index index.html; 
      } 
      error_page 500 502 503 504 /50x.html; 
      location = /50x.html { 
        root /usr/share/nginx/html; 
      } 
    } 
apiVersion: v1 
kind: ConfigMap 
metadata: 
  name: php-nginx-config 
  namespace: test 
data: 
  default.conf: | 
    server { 
      listen 80; 
      server_name localhost; 
      location / { 
        root /code/Zn_/htdocs; 
        index index.php index.html index.htm; 
      } 
      location ~ \.php$ { 
        root /code/Zn_/htdocs; 
        fastcgi_pass 127.0.0.1:9000; 
        fastcgi_index index.php; 
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
        include fastcgi_params; 
      } 
      error_page 500 502 503 504 /50x.html; 
      location = /50x.html { 
        root /usr/share/nginx/html; 
      } 
    } 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
        volumeMounts:
        - name: nginx-vue-config
          mountPath: /etc/nginx/conf.d/default.conf
          subPath: default.conf
      volumes:
      - name: nginx-vue-config
        configMap:
          name: nginx-vue-config
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-php-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx-php
  template:
    metadata:
      labels:
        app: nginx-php
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
        volumeMounts:
        - name: php-nginx-config
          mountPath: /etc/nginx/conf.d/default.conf
          subPath: default.conf
      - name: php
        image: php
        ports:
        - containerPort: 9000
        volumeMounts:
        - name: php-nginx-config
          mountPath: /etc/nginx/conf.d
      volumes:
      - name: php-nginx-config
        configMap:
          name: php-nginx-config

相关文章

网友评论

      本文标题:yaml

      本文链接:https://www.haomeiwen.com/subject/mqgbddtx.html