-->

whaust

2023年2月20日 星期一

[K8s YAML] nginx yaml 產生範例

K8s Yaml 檔, 目的在於產生 nginx 服務 , 固定運行在 worker1 , worker2 , worker3 三個 node , 三個 node , pvc 的空間要 50G , storage class 為 basic1

 
 #!/bin/bash

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
    - name: http
      port: 80
      targetPort: 80
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx-container
          image: nginx
          volumeMounts:
            - name: nginx-pvc
              mountPath: /usr/share/nginx/html
      volumes:
        - name: nginx-pvc
          persistentVolumeClaim:
            claimName: nginx-pvc
      nodeSelector:
        kubernetes.io/hostname: worker1,worker2,worker3
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nginx-pvc
spec:
  storageClassName: basic1
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 50Gi



沒有留言:

張貼留言

Popular