s.jpg
pvc:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mongo-data
  namespace: crawlab
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: "1000Gi"
  volumeName: 
  storageClassName: nfs04

svc:

apiVersion: v1
kind: Service
metadata:
  name: mongo
  namespace: crawlab
spec:
  type: NodePort
  ports:
  - port: 27017
    name: mongo 
    targetPort: 27017
    nodePort: 30034
    protocol: TCP
  selector:
    app: mongo

Deployment:

apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: mongo
  namespace: crawlab
spec:
  selector:
    matchLabels:
      app: mongo
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: mongo
    spec:
      containers:
      - image: mongo:4.2.6
        name: mongo
        ports:
        - containerPort: 27017
          name: mongo
        volumeMounts:
        - name: mongo-persistent-storage
          mountPath: /data/db
      volumes:
      - name: mongo-persistent-storage
        persistentVolumeClaim:
          claimName: mongo-data

发表评论

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

Captcha Code