https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/
nfs for k8
https://www.youtube.com/watch?v=zmzH3xpJCGs
root@ip-172-31-44-144:~# echo -n 'username'|base64
dXNlcm5hbWU=
root@ip-172-31-44-144:~# echo -n 'password'|base64
cGFzc3dvcmQ=
file: mongo-secret.yml
======
apiVersion: v1
kind: Secret
metadata:
name: mongodb-seret
type: Opaque
data:
mongo-root-username: dXNlcm5hbWU=
mongo-root-password: cGFzc3dvcmQ=
note: here we added encrypted values
file: mongo.yml
======
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongodb-deployment
labels:
app: mongodb
spec:
replicas: 1
selector:
matchLabels:
app: mongodb
template:
metadata:
labels:
app: mongodb
spec:
containers:
- name: mongodb
image: mongo
ports:
- containerPort: 27017
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
=============
mongodb-service:
apiVersion: v1
kind: Service
metadata:
name: mongodb-service
spec:
selector:
app: mongodb
ports:
- protocol: TCP
port: 27017
targetPort: 27017
----------------
mongoexpress-deployment.yml
apiVersion: app/v1
kind: Deployment
metadata:
name: mongo-express
labels:
app: mongo-express
spec:
replicas: 1
selector:
matchLabels:
app: mongo-express
template:
metadata:
labels:
app: mongo-express
spec:
containers:
- name: mongo-express
image: mongo-express
ports:
- containerPort: 8081
env:
- name: ME_CONFIG_MONGODB_ADMINUSERNAME
valueFrom:
secretKeyRef:
name: mongodb-secret
key: mongo-root-username
- name: ME_CONFIG_MONGODB_ADMINPASSWORD
valueFrom:
secretKeyRef:
name: mongodb-secret
key: mongo-root-password
- name: ME_CONFIG_MONGODB_SERVER
valueFrom:
configMapKeyRef:
name: mongodb-configmap
key: database_url
==========
mongo-configmap.yml
apiVersion: v1
kind: ConfigMap
metatdat:
name: mongodb-configmap
data:
database_url: mongodb-service
======
mongo-express-service.yml
apiVersion: v1
kind: Service
metatadata:
name: mongo-express-service
spec:
selector:
app: mongo-express
type: LoadBalancer
ports:
- protocol: TCP
port: 80881
targetPort: 8081
nodePort: 30000
No comments:
Post a Comment