pvc mongo-test

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mongo-test
  namespace: test
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: "1500Gi"
  volumeName: 
  storageClassName: nfs

Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongo-test
  namespace: test
spec:
  replicas: 1
  selector:
    matchLabels:
      name: mongo-test
  template:
    metadata:
      labels:
        name: mongo-test
    spec:
      containers:
      - name: mongo-test
        image: mongo:4.2.6
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 27017
        env:
        - name: MONGO_INITDB_ROOT_USERNAME
          value: root
        - name: MONGO_INITDB_ROOT_PASSWORD
          value: bShYIZ276Nh_TjD3
        volumeMounts:
        - name: mongo-pvc
          mountPath: /data/db
      volumes:
       - name: mongo-pvc
         persistentVolumeClaim:
           claimName: mongo-test

svc

kind: Service
apiVersion: v1
metadata:
  name: mongo-test
  namespace: test
spec:
  ports:
  - name: mongo
    port: 27017
    targetPort: 27017
    protocol: TCP
  selector:
    name: mongo-test


vist

mongo-test.test.svc.cluster.local:27017
root
bShYIZ276Nh_TjD3

发表评论

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

Captcha Code