Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save justindav1s/d6e4e03b8af8716f86f462401c12af5d to your computer and use it in GitHub Desktop.
Save justindav1s/d6e4e03b8af8716f86f462401c12af5d to your computer and use it in GitHub Desktop.
---
kind: Template
apiVersion: v1
metadata:
labels:
app: mongodb
name: mongodb
annotations:
openshift.io/display-name: Deploy Mongodb
description: Deploy Mongodb
tags: mongodb
objects:
- apiVersion: v1
kind: Service
metadata:
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
labels:
name: mongodb
name: mongodb-internal
spec:
ports:
- name: 27017-tcp
port: 27017
clusterIP: None
selector:
name: "mongodb"
- apiVersion: v1
kind: Service
metadata:
annotations:
labels:
name: mongodb
name: mongodb
spec:
ports:
- name: 27017-tcp
port: 27017
protocol: TCP
targetPort: 27017
selector:
name: mongodb
- apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
labels:
app: mongodb
name: mongodb
spec:
replicas: ${REPLICAS}
serviceName: mongodb-internal
selector:
matchLabels:
name: mongodb
template:
metadata:
labels:
name: mongodb
spec:
containers:
- image: registry.access.redhat.com/rhscl/mongodb-32-rhel7:3.2
ports:
- containerPort: 27017
name: mongodb
volumeMounts:
- name: mongo
mountPath: /var/lib/mongodb/data
name: mongodb
args: ["run-mongod-replication" ]
env:
- name: MONGODB_USER
valueFrom:
secretKeyRef:
key: database-user
name: mongodb
- name: MONGODB_PASSWORD
valueFrom:
secretKeyRef:
key: database-password
name: mongodb
- name: MONGODB_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
key: database-admin-password
name: mongodb
- name: MONGODB_DATABASE
valueFrom:
secretKeyRef:
key: database-name
name: mongodb
- name: MONGODB_REPLICA_NAME
value: "rs0"
- name: MONGODB_KEYFILE_VALUE
value: "12345678901234567890"
- name: MONGODB_SERVICE_NAME
value: "mongodb-internal"
volumeClaimTemplates:
- metadata:
name: mongo
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
- apiVersion: v1
kind: Secret
data:
database-admin-password: bW9uZ29kYg==
database-name: cGFya3M=
database-password: bW9uZ29kYg==
database-user: bW9uZ29kYg==
metadata:
labels:
app: mongodb
name: mongodb
type: Opaque
parameters:
- description: the number of mongodbs required in the statefulset.
name: REPLICAS
required: true
value: "1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment