Lab 11.2 - Create and Configure Deployment using PostgreSQL Database

1. Click Workloads → Deployments and then click Create Deployment to display the YAML editor. Update the YAML as follow:

kind: Deployment
apiVersion: apps/v1
metadata:
  name: books
  namespace: console-apps
spec:
  replicas: 1
  selector:
    matchLabels:
      app: books
  template:
    metadata:
      labels:
        app: books
    spec:
      containers:
        - name: books
          image: 'quay.io/redhattraining/books:v1.4'
          ports:
            - containerPort: 8080
              protocol: TCP
          readinessProbe:
            httpGet:
              path: /healthz
              port: 8080
          env:
             - name: DB_HOST
               value: database.console-apps.svc.cluster.local
             - name: DB_PORT
               value: '5432'
             - name: DB_USER
               value: postgres
             - name: DB_PASSWORD
               value: postgres
             - name: DB_NAME
               value: postgres

And then click create

2. Click the books deployments and wait until the donut indicates that one pod is running.

3. Click Networking → Services and then click Create Service to display the web console YAML editor. Update the YAML as follows:

kind: Service
apiVersion: v1
metadata:
  name: books
  namespace: console-apps
spec:
  selector:
    app: books
  ports:
    - protocol: TCP
      port: 8080
      targetPort: 8080

And then click create.

3. Click Networking → Routes and then click Create Route. Complete the page as follows:

  • Name: books
  • Service: books
  • Target Port: 8080 → 8080 (TCP)

Leaving the other fields unchanged, and then click Create.

4. Click the link in the Location column. Browser will open a new tab rendering a list of books that were fetched from the database.

Daftar Materi