(01)Deploy to cluster
Linux
1kubectl apply -f .2kubectl get all3kubectl get pods -wPostgreSQL with PVC — persistent database in the cluster
postgres-pvc.yml
1apiVersion: v12kind: PersistentVolumeClaim3metadata:4 name: postgres-pvc5spec:6 accessModes:7 - ReadWriteOnce8 resources:9 requests:10 storage: 5Gipostgres-deployment.yml
1apiVersion: apps/v12kind: Deployment3metadata:4 name: postgres5spec:6 replicas: 17 selector:8 matchLabels:9 app: postgres10 template:11 metadata:12 labels:13 app: postgres14 spec:15 containers:16 - name: postgres17 image: postgres:16-alpine18 ports:19 - containerPort: 543220 env:21 - name: POSTGRES_USER22 value: app23 - name: POSTGRES_PASSWORD24 valueFrom:25 secretKeyRef:26 name: postgres-secret27 key: password28 - name: POSTGRES_DB29 value: appdb30 volumeMounts:31 - name: data32 mountPath: /var/lib/postgresql/data33 volumes:34 - name: data35 persistentVolumeClaim:36 claimName: postgres-pvcpostgres-secret.yml
1apiVersion: v12kind: Secret3metadata:4 name: postgres-secret5type: Opaque6stringData:7 password: change-me-in-productionStep 01
1kubectl apply -f .2kubectl get all3kubectl get pods -w1kubectl delete -f .