首页 > 数据库技术 > 详细

kunbernetls部署单节点mongodb

时间:2021-01-04 23:27:47      阅读:29      评论:0      收藏:0      [点我收藏+]

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

原文:https://www.cnblogs.com/sonyy/p/14231459.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!