Last active
March 26, 2022 12:16
-
-
Save sosan/b5dc8573f3d84f24ddf1aa880f94a982 to your computer and use it in GitHub Desktop.
deploy mongo statefulset con volumenclain y volumenmounts, service, secrets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: StatefulSet | |
metadata: | |
name: mongodb-single | |
labels: | |
app: mongodb | |
spec: | |
serviceName: mongodb-single | |
replicas: 1 | |
updateStrategy: | |
type: RollingUpdate | |
selector: | |
matchLabels: | |
app: mongodb | |
template: | |
metadata: | |
labels: | |
app: mongodb | |
spec: | |
securityContext: | |
fsGroup: 1001 | |
sysctls: [] | |
containers: | |
- name: mongodb | |
image: mongo | |
imagePullPolicy: "IfNotPresent" | |
securityContext: | |
runAsNonRoot: true | |
runAsUser: 1001 | |
# utilizando secretos de kubernetes | |
env: | |
- name: MONGO_INITDB_ROOT_USERNAME | |
valueFrom: | |
secretKeyRef: | |
name: mongodb-secret | |
key: mongo-root-username | |
- name: MONGO_INITDB_ROOT_PASSWORD | |
valueFrom: | |
secretKeyRef: | |
name: mongodb-secret | |
key: mongo-root-password | |
ports: | |
- name: mongodb | |
containerPort: 27017 | |
resources: | |
requests: | |
memory: 300Mi | |
cpu: 250m | |
limits: | |
memory: 500Mi | |
cpu: 500m | |
volumeMounts: | |
- name: data-mongodb | |
mountPath: /data/db | |
volumes: | |
- name: data-mongodb | |
persistentVolumeClaim: | |
claimName: data-mongodb-pvc | |
--- | |
apiVersion: v1 | |
kind: PersistentVolumeClaim | |
metadata: | |
name: data-mongodb-pvc | |
spec: | |
accessModes: | |
- ReadWriteOnce | |
resources: | |
requests: | |
storage: 500Mi | |
storageClassName: do-block-storage | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: mongodb-single | |
labels: | |
app: mongodb | |
spec: | |
clusterIP: None | |
ports: | |
- name: mongodb | |
port: 27017 | |
targetPort: mongodb | |
selector: | |
app: mongodb | |
--- | |
apiVersion: v1 | |
kind: Secret | |
metadata: | |
name: mongodb-secret | |
type: Opaque | |
data: | |
# admin en base64 | |
mongo-root-username: YWRtaW4= | |
mongo-root-password: YWRtaW4= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment