0
0
Kubernetesdevops~10 mins

Database operators example in Kubernetes - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a PostgreSQL cluster using the operator.

Kubernetes
apiVersion: postgresql.k8s.enterprisedb.io/v1
kind: Cluster
metadata:
  name: my-postgres
spec:
  instances: [1]
Drag options to blanks, or click blank then click option'
A0
B3
C5
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Setting instances to 0 will not create any database pods.
Using a high number like 5 without resources can cause failures.
2fill in blank
medium

Complete the code to expose the PostgreSQL service on port 5432.

Kubernetes
apiVersion: v1
kind: Service
metadata:
  name: postgres-service
spec:
  ports:
  - port: [1]
    targetPort: 5432
Drag options to blanks, or click blank then click option'
A3306
B5432
C80
D8080
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 80 or 8080 will not connect to PostgreSQL correctly.
Port 3306 is for MySQL, not PostgreSQL.
3fill in blank
hard

Fix the error in the container spec to use the correct image for the PostgreSQL operator.

Kubernetes
spec:
  template:
    spec:
      containers:
      - name: postgres-operator
        image: [1]
Drag options to blanks, or click blank then click option'
Ak8s.gcr.io/postgres-operator:latest
Boperator/postgres:1.0
Cpostgres-operator:latest
Dpostgres:latest
Attempts:
3 left
💡 Hint
Common Mistakes
Using the plain postgres image runs the database, not the operator.
Custom or incorrect image names cause deployment failures.
4fill in blank
hard

Fill both blanks to define a PersistentVolumeClaim for the PostgreSQL data storage.

Kubernetes
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: postgres-pvc
spec:
  accessModes:
  - [1]
  resources:
    requests:
      storage: [2]
Drag options to blanks, or click blank then click option'
AReadWriteOnce
BReadOnlyMany
C10Gi
D1Gi
Attempts:
3 left
💡 Hint
Common Mistakes
Using ReadOnlyMany will prevent writing data.
Setting storage too small may cause out-of-space errors.
5fill in blank
hard

Fill all three blanks to create a ConfigMap with database credentials and mount it as environment variables.

Kubernetes
apiVersion: v1
kind: ConfigMap
metadata:
  name: [1]
data:
  POSTGRES_USER: [2]
  POSTGRES_PASSWORD: [3]
Drag options to blanks, or click blank then click option'
Adb-config
Badmin
Csecret123
Dpostgres-data
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect ConfigMap names breaks environment variable references.
Leaving password empty causes authentication failures.