first commit
This commit is contained in:
166
k3s/stacks/mongodb.yml
Normal file
166
k3s/stacks/mongodb.yml
Normal file
@@ -0,0 +1,166 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: mongodb
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: mongodb-secret
|
||||
namespace: mongodb
|
||||
type: Opaque
|
||||
data:
|
||||
root.username: YWRtaW4=
|
||||
root.password: bGpUMTkx
|
||||
username: YXBwdXNlcg==
|
||||
password: VTNlNzRy
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: mongodb-config
|
||||
namespace: mongodb
|
||||
data:
|
||||
database.name: "appdb"
|
||||
database.replicaset: "primary"
|
||||
database.port: "27017"
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: mongodb-sa
|
||||
namespace: mongodb
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: mongodb-role
|
||||
namespace: mongodb
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["pods", "services", "persistentvolumeclaims", "configmaps", "secrets"]
|
||||
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: mongodb-rolebinding
|
||||
namespace: mongodb
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: mongodb-sa
|
||||
namespace: mongodb
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: mongodb-role
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: mongodb-pv
|
||||
spec:
|
||||
capacity:
|
||||
storage: 10Gi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: local-pvs
|
||||
local:
|
||||
path: /home/ansible/k3s/makhiwane/mongodb
|
||||
nodeAffinity:
|
||||
required:
|
||||
nodeSelectorTerms:
|
||||
- matchExpressions:
|
||||
- key: kubernetes.io/hostname
|
||||
operator: In
|
||||
values:
|
||||
- lead
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: mongodb-pvc
|
||||
namespace: mongodb
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: local-pvs
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: mongodb
|
||||
namespace: mongodb
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: mongodb
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: mongodb
|
||||
spec:
|
||||
serviceAccountName: mongodb-sa
|
||||
containers:
|
||||
- name: mongodb
|
||||
image: mongo:6
|
||||
env:
|
||||
- name: MONGO_INITDB_ROOT_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mongodb-secret
|
||||
key: root.username
|
||||
- name: MONGO_INITDB_ROOT_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mongodb-secret
|
||||
key: root.password
|
||||
- name: MONGO_INITDB_DATABASE
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: mongodb-config
|
||||
key: database.name
|
||||
ports:
|
||||
- containerPort: 27017
|
||||
volumeMounts:
|
||||
- mountPath: /data/db
|
||||
name: mongodb-data
|
||||
volumes:
|
||||
- name: mongodb-data
|
||||
persistentVolumeClaim:
|
||||
claimName: mongodb-pvc
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mongodb
|
||||
namespace: mongodb
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: mongodb
|
||||
ports:
|
||||
- port: 27017
|
||||
targetPort: 27017
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata:
|
||||
name: mongodb-ingress
|
||||
namespace: mongodb
|
||||
spec:
|
||||
entryPoints:
|
||||
- websecure
|
||||
routes:
|
||||
- match: Host(`mongodb.database.mngoma.lab`)
|
||||
kind: Rule
|
||||
services:
|
||||
- name: mongodb
|
||||
port: 27017
|
||||
tls: {}
|
||||
Reference in New Issue
Block a user