aboutsummaryrefslogtreecommitdiffstats
path: root/kubernetes/mongodb/mongodb-deployment.yaml
blob: 20021467078adafd302940360d11ce34a9fb0934 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongodb
  labels:
    app: mongodb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mongodb
  template:
    metadata:
      labels:
        app: mongodb
    spec:
      containers:
      - name: mongodb
        image: mongo:4.4.10
        livenessProbe:
          exec:
            command:
              - mongo
              - --disableImplicitSessions
              - --eval
              - "db.adminCommand('ping')"
          initialDelaySeconds: 30
          periodSeconds: 10
          timeoutSeconds: 5
          successThreshold: 1
          failureThreshold: 6
        readinessProbe:
          exec:
            command:
              - mongo
              - --disableImplicitSessions
              - --eval
              - "db.adminCommand('ping')"
          initialDelaySeconds: 30
          periodSeconds: 10
          timeoutSeconds: 5
          successThreshold: 1
          failureThreshold: 6
        command:
          - mongod
          - --config
          - /etc/mongod.conf/mongod.conf
          - --noauth
          - --dbpath
          - /data/db
          - --bind_ip_all
        ports:
          - containerPort: 27017
          - containerPort: 27018
          - containerPort: 27019
        env:
          - name: MONGO_INITDB_ROOT_USERNAME
            valueFrom:
              secretKeyRef:
                name: mongodb-secrets
                key: mongodb-root-username
          - name: MONGO_INITDB_ROOT_PASSWORD
            valueFrom:
              secretKeyRef:
                name: mongodb-secrets
                key: mongodb-root-password
        volumeMounts:
          - name: mongo-data
            mountPath: /data/db
          - name: mongo-conf
            mountPath: /etc/mongod.conf
            readOnly: true
      volumes:
        - name: mongo-data
          persistentVolumeClaim:
            claimName: mongo-data
        - name: mongo-conf
          configMap:
            name: mongodb-config-file
---
apiVersion: v1
kind: Service
metadata:
  name: mongodb-service
spec:
  selector:
    app: mongodb
  type: LoadBalancer
  ports:
    - protocol: TCP
      name: "6617"
      port: 27117
      targetPort: 27017
      nodePort: 30017
    - protocol: TCP
      name: "6618"
      port: 27118
      targetPort: 27018
      nodePort: 30018
    - protocol: TCP
      name: "6619"
      port: 27119
      targetPort: 27019
      nodePort: 30019