kunbernetls部署单节点mongodb

vim mongodb.yaml


apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongodb
  labels:
    app: mongodb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mongodb
  template:
    metadata:
      labels:
        app: mongodb
    spec:
      nodeName: lan    # 固定在 k8s-node1 节点
      containers:
      - name: mongodb
        image: mongo:4.2.9
        env:
          - name: MONGO_INITDB_ROOT_USERNAME  # 设置用户名
            value: root
          - name: MONGO_INITDB_ROOT_PASSWORD  # 设置密码
            value: ‘123123‘
        volumeMounts:
          - mountPath: /data/db          
            name: mongodb-volume 
      volumes:
        - name: mongodb-volume 
          hostPath:
            path: /data/mongo   # 映射的宿主机目录 
            type: DirectoryOrCreate
    
--- 
    
apiVersion: v1 
kind: Service
metadata:
  name: mongodb
spec:
  type: ClusterIP
  selector:
    app: mongodb
  ports:
  - port: 27017
    targetPort: 27017

kunbernetls部署单节点mongodb

上一篇:2020.12.30 数据库入门了


下一篇:mysql修改密码命令