--- apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: mongodb-local provisioner: kubernetes.io/no-provisioner volumeBindingMode: WaitForFirstConsumer --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mongodb-pvc-local spec: storageClassName: mongodb-local accessModes: - ReadWriteOnce resources: requests: storage: 3Gi --- apiVersion: v1 kind: PersistentVolume metadata: name: mongodb-pv-local labels: type: local spec: storageClassName: mongodb-local claimRef: name: mongodb-pvc-local # ref: PersistentVolumeClaim namespace: basic capacity: storage: 20Gi accessModes: - ReadWriteOnce local: path: /data/mongodb nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - bfs-k8snode-10-2-1-8.hetzner.base.beaconfireinc.com --- apiVersion: v1 kind: Service metadata: name: mongodb spec: selector: app: mongodb ports: - name: mongodb protocol: TCP port: 27017 targetPort: 27017 nodePort: 30018 type: NodePort --- apiVersion: apps/v1 kind: Deployment metadata: name: mongodb spec: replicas: 1 selector: matchLabels: app: mongodb template: metadata: labels: app: mongodb spec: containers: - name: mongodbs image: mongo:4.4 imagePullPolicy: IfNotPresent env: - name: MONGO_INITDB_ROOT_USERNAME value: root - name: MONGO_INITDB_ROOT_PASSWORD value: 'root@123' ports: - containerPort: 27017 volumeMounts: - name: mongodb-data mountPath: /data/db volumes: - name: mongodb-data persistentVolumeClaim: claimName: mongodb-pvc-local