Super Heroes on OpenShift Workshop
  • Super Heroes on OpenShift Workshop
    • About Workshop
    • Application Architecture
    • Getting Started
  • Application Services Deployment
    • Databases Deployment
      • Deploy Database For Hero Microservice
      • Deploy Database For Villain Microservice
      • Deploy Database For Fight Microservice
    • AMQ Streams (Kafka) Deployment
    • Service Registry (Apicurio) Deployment
  • Application Deployment
    • Microservices Deployment
      • Hero Microservice
      • Villain Microservice
      • Fight Microservice
      • Super Hero UI Microservice
      • Statistics and UI Microservices
      • Beautify The Topology View
  • Continuous Deployment (CD)
    • GitOps
  • Application Monitoring
    • Application Metrics
      • Configure Service Monitoring
      • Query Application Metrics
    • Distributed Tracing
      • Configure OpenShift Distributed Tracing Platform
      • Configure OpenShift Distributed Tracing Data Collection
      • Trace Application Transaction
  • Appendix
    • What's Quarkus?
    • Useful Resources
Powered by GitBook
On this page
  • Create a ConfigMap object to store application configurations
  • Create a Secret object to store the secret configurations
  • Deploy application with existing container image
  • Add application configurations in ConfigMap and Secret objects to application container
  • What have you learnt?
  1. Application Deployment
  2. Microservices Deployment

Hero Microservice

PreviousMicroservices DeploymentNextVillain Microservice

Last updated 2 years ago

Create a ConfigMap object to store application configurations

  1. Click on icon located at top right corner of web console.

  2. Copy this YAML snippet to the editor and click Create button.

    YAML snippet:

    apiVersion: v1
    kind: ConfigMap
    metadata:
      labels:
        app: rest-heroes
        application: heroes-service
        system: quarkus-super-heroes
      name: rest-heroes-config
    data:
      quarkus.hibernate-orm.database.generation: validate
      quarkus.hibernate-orm.sql-load-script: no-file
      quarkus.datasource.reactive.url: postgresql://heroes-db:5432/heroes_database
      quarkus.opentelemetry.tracer.exporter.otlp.endpoint: http://otel-collector:4317
      quarkus.http.access-log.enabled: "false"
      quarkus.http.access-log.pattern: >
        %h %l %u %t "%r" %s %b "User-Agent: %{i,User-Agent}" "x-request-id:
        %{i,x-request-id}" "x-b3-traceid: %{i,x-b3-traceid}"  " Referer:
        %{i,Referer}"
  3. A rest-heroes-config ConfigMap object should be created.

Create a Secret object to store the secret configurations

  1. Copy this YAML snippet to the editor and click Create button.

    YAML snippet:

    apiVersion: v1
    kind: Secret
    metadata:
      labels:
        app: rest-heroes
        application: heroes-service
        system: quarkus-super-heroes
      name: rest-heroes-config-creds
    data:
      quarkus.datasource.username: c3VwZXJtYW4=
      quarkus.datasource.password: c3VwZXJtYW4=
    type: Opaque
  2. A rest-heroes-config-creds Secret object should be created.

Deploy application with existing container image

  1. Go to Topology menu, right click on view area then select Add to Project -> Container Image menu.

  2. Enter following inputs:

    • Image name from external registry: quay.io/asuksunt/rest-heroes:1.0

    • Runtime icon: quarkus

    • Application: heroes-service

    • Name: rest-heroes

  3. Scroll down to the bottom of the page, select 8080 option for Target port, uncheck the Create a route checkbox, and then click Health checks link.

  4. Click Add Readiness probe link.

    • Path: /q/health/ready

    • Port: 8080

    • Period: 30

    • Timeout: 10

  5. Click Add Liveness probe link.

    • Path: /q/health/live

    • Port: 8080

    • Period: 30

    • Timeout: 10

  6. Click Deployment link.

  7. Enter following environment variable. Then click Resource limits link.

    • Name: KUBERNETES_NAMESPACE

    • Value: userX-super-heroes where X is your user number.

  8. Enter following memory request and limit. Then click Labels link.

    • Request: 256

    • Limit: 768

  9. Enter system=quarkus-super-heroes then click Create button.

Add application configurations in ConfigMap and Secret objects to application container

  1. Click on rest-heroes entity in view area. A panel will show up, then click rest-heroes link.

  2. Go to Environment tab to add environment variables to application container. Then click Add all from ConfigMap or Secret link.

  3. Select rest-heroes-config ConfigMap and rest-heroes-config-creds Secret objects, then click Save button. And then go to Topology menu.

  4. Hover mouse pointer over the rest-heroes entity, a bubble should show up and say 1 Running which means there is 1 pod running.

What have you learnt?

  1. How to create ConfigMap object with YAML to keep all application configurations.

  2. How to create Secret object with YAML to keep all secret application configurations.

  3. How to deploy application using existing container image with following additional configurations:

    • Application health checks e.g. liveness and readiness probes

    • Require and limit resource i.e. memory for application.

    • Environment variable for application container

    • User-defined label

  4. Bind configurations from ConfigMap and Secret objects to application container via environment variables.

Click on icon located at top right corner of web console.

Enter following inputs then click icon.

Enter following inputs then click icon.

✔️
✔️
Create a ConfigMap object
Create a ConfigMap object
Create a Secret object
Create a Secret object
Create a Secret object
Deploy application container
Deploy application container
Deploy application container
Deploy application container
Deploy application container
Deploy application container
Deploy application container
Deploy application container
Deploy application container
Deploy application container
Deploy application container
Deploy application container
Deploy application container
Deploy application container
add
add