| @ -0,0 +1,6 @@ | |||||
| kubectl create -f pv-local-pg.yaml | |||||
| kubectl create -f pvc-pg.yaml | |||||
| kubectl create -f postgres-configmap.yaml | |||||
| kubectl create -f postgres-deployment.yaml | |||||
| kubectl create -f postgres-service.yaml | |||||
| watch kubectl get all -n postgres | |||||
| @ -0,0 +1 @@ | |||||
| kubectl exec -ti deployment.apps/postgres -n postgres -- /bin/bash | |||||
| @ -0,0 +1,10 @@ | |||||
| kubectl delete -f postgres-service.yaml | |||||
| kubectl delete -f postgres-deployment.yaml | |||||
| kubectl delete -f postgres-configmap.yaml | |||||
| kubectl delete -f pvc-pg.yaml | |||||
| kubectl delete -f pv-local-pg.yaml | |||||
| kubectl delete -f pgadmin-configmap.yaml | |||||
| kubectl delete -f pgadmin-secret.yaml | |||||
| kubectl delete -f pgadmin-service.yaml | |||||
| kubectl delete -f pgadmin-statefulset.yaml | |||||
| kubectl delete -f pv-local-pgadmin.yaml | |||||
| @ -0,0 +1,20 @@ | |||||
| apiVersion: v1 | |||||
| kind: ConfigMap | |||||
| metadata: | |||||
| name: pgadmin-config | |||||
| namespace: postgres | |||||
| data: | |||||
| servers.json: | | |||||
| { | |||||
| "Servers": { | |||||
| "1": { | |||||
| "Name": "PostgreSQL DB", | |||||
| "Group": "Servers", | |||||
| "Port": 5432, | |||||
| "Username": "postgres", | |||||
| "Host": "postgres", | |||||
| "SSLMode": "prefer", | |||||
| "MaintenanceDB": "postgres" | |||||
| } | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,8 @@ | |||||
| apiVersion: v1 | |||||
| kind: Secret | |||||
| type: Opaque | |||||
| metadata: | |||||
| name: pgadmin | |||||
| namespace: postgres | |||||
| data: | |||||
| pgadmin-password: UmV5LTExNzYK | |||||
| @ -0,0 +1,13 @@ | |||||
| apiVersion: v1 | |||||
| kind: Service | |||||
| metadata: | |||||
| name: pgadmin-service | |||||
| namespace: postgres | |||||
| spec: | |||||
| ports: | |||||
| - protocol: TCP | |||||
| port: 80 | |||||
| targetPort: http | |||||
| selector: | |||||
| app: pgadmin | |||||
| type: NodePort | |||||
| @ -0,0 +1,55 @@ | |||||
| apiVersion: apps/v1 | |||||
| kind: StatefulSet | |||||
| metadata: | |||||
| name: pgadmin | |||||
| namespace: postgres | |||||
| spec: | |||||
| serviceName: pgadmin-service | |||||
| podManagementPolicy: Parallel | |||||
| replicas: 1 | |||||
| updateStrategy: | |||||
| type: RollingUpdate | |||||
| selector: | |||||
| matchLabels: | |||||
| app: pgadmin | |||||
| template: | |||||
| metadata: | |||||
| labels: | |||||
| app: pgadmin | |||||
| spec: | |||||
| terminationGracePeriodSeconds: 10 | |||||
| containers: | |||||
| - name: pgadmin | |||||
| image: dpage/pgadmin4:5.4 | |||||
| imagePullPolicy: Always | |||||
| env: | |||||
| - name: PGADMIN_DEFAULT_EMAIL | |||||
| value: celestino.rey@gmail.com | |||||
| - name: PGADMIN_DEFAULT_PASSWORD | |||||
| valueFrom: | |||||
| secretKeyRef: | |||||
| name: pgadmin | |||||
| key: pgadmin-password | |||||
| ports: | |||||
| - name: http | |||||
| containerPort: 80 | |||||
| protocol: TCP | |||||
| volumeMounts: | |||||
| - name: pgadmin-config | |||||
| mountPath: /pgadmin4/servers.json | |||||
| subPath: servers.json | |||||
| readOnly: true | |||||
| - name: pgadmin-data | |||||
| mountPath: /var/lib/pgadmin | |||||
| volumes: | |||||
| - name: pgadmin-config | |||||
| configMap: | |||||
| name: pgadmin-config | |||||
| volumeClaimTemplates: | |||||
| - metadata: | |||||
| name: pgadmin-data | |||||
| spec: | |||||
| accessModes: [ "ReadWriteOnce" ] | |||||
| resources: | |||||
| requests: | |||||
| storage: 3Gi | |||||
| @ -0,0 +1,13 @@ | |||||
| # Create ConfigMap postgres-secret for the postgres app | |||||
| # Define default database name, user, and password | |||||
| apiVersion: v1 | |||||
| kind: ConfigMap | |||||
| metadata: | |||||
| name: postgres-secret | |||||
| namespace: postgres | |||||
| labels: | |||||
| app: postgres | |||||
| data: | |||||
| POSTGRES_DB: productos | |||||
| POSTGRES_USER: creylopez | |||||
| POSTGRES_PASSWORD: Rey-1176 | |||||
| @ -0,0 +1,31 @@ | |||||
| apiVersion: apps/v1 | |||||
| kind: Deployment # Create a deployment | |||||
| metadata: | |||||
| name: postgres # Set the name of the deployment | |||||
| namespace: postgres | |||||
| spec: | |||||
| replicas: 1 # Set 3 deployment replicas | |||||
| selector: | |||||
| matchLabels: | |||||
| app: postgres | |||||
| template: | |||||
| metadata: | |||||
| labels: | |||||
| app: postgres | |||||
| spec: | |||||
| containers: | |||||
| - name: postgres | |||||
| image: postgres:12.10 # Docker image | |||||
| imagePullPolicy: "IfNotPresent" | |||||
| ports: | |||||
| - containerPort: 5432 # Exposing the container port 5432 for PostgreSQL client connections. | |||||
| envFrom: | |||||
| - configMapRef: | |||||
| name: postgres-secret # Using the ConfigMap postgres-secret | |||||
| volumeMounts: | |||||
| - mountPath: /var/lib/postgresql/data | |||||
| name: postgresdata | |||||
| volumes: | |||||
| - name: postgresdata | |||||
| persistentVolumeClaim: | |||||
| claimName: pg-pv-claim | |||||
| @ -0,0 +1,13 @@ | |||||
| apiVersion: v1 | |||||
| kind: Service # Create service | |||||
| metadata: | |||||
| name: postgres # Sets the service name | |||||
| namespace: postgres | |||||
| labels: | |||||
| app: postgres # Defines app to create service for | |||||
| spec: | |||||
| type: NodePort # Sets the service type | |||||
| ports: | |||||
| - port: 5432 # Sets the port to run the postgres application | |||||
| selector: | |||||
| app: postgres | |||||
| @ -0,0 +1,11 @@ | |||||
| apiVersion: v1 | |||||
| kind: PersistentVolume | |||||
| metadata: | |||||
| name: pg-data | |||||
| spec: | |||||
| capacity: | |||||
| storage: 20Gi | |||||
| accessModes: | |||||
| - ReadWriteOnce | |||||
| hostPath: | |||||
| path: "/mnt/cluster/postgres/postgres-db" | |||||
| @ -0,0 +1,11 @@ | |||||
| apiVersion: v1 | |||||
| kind: PersistentVolume | |||||
| metadata: | |||||
| name: pgadmin-data | |||||
| spec: | |||||
| capacity: | |||||
| storage: 3Gi | |||||
| accessModes: | |||||
| - ReadWriteOnce | |||||
| hostPath: | |||||
| path: "/mnt/cluster/postgres/pgadmin" | |||||
| @ -0,0 +1,14 @@ | |||||
| apiVersion: v1 | |||||
| kind: PersistentVolumeClaim | |||||
| metadata: | |||||
| name: pg-pv-claim | |||||
| namespace: postgres | |||||
| labels: | |||||
| app: postgres | |||||
| spec: | |||||
| accessModes: | |||||
| - ReadWriteOnce | |||||
| storageClassName: "" | |||||
| resources: | |||||
| requests: | |||||
| storage: 10Gi | |||||