当前位置:Gxlcms > 数据库问题 > kunbernetls部署单节点mongodb

kunbernetls部署单节点mongodb

时间:2021-07-01 10:21:17 帮助过:28人阅读

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

标签:directory   label   user   creat   temp   create   metadata   用户名   用户   

人气教程排行