Uploaded image for project: 'Product Technical Learning'
  1. Product Technical Learning
  2. PTL-2209

DO378-48: Ch4 S3: Useless section on K8S service lookup using env variables

XMLWordPrintable

    • ILT, ROLE, VT
    • en-US (English)

      URL:
      Reporter RHNID:
      Section: -
      Language: en-US (English)||
      Workaround:

      Description: The (otherwise short) section "Service Discovery by Environment Variable Injection" is in need of a couple of fixes.

      The formatting, and convention, makes it completely unclear what the SVC_NAME refers to:

      ...the following environment variables are automatically defined and injected into the containers for all of the pods running inside the project.
      SVC_NAME_SERVICE_HOST is the service IP address.
      SVC_NAME_SERVICE_PORT is the service TCP port.

      The above is "SVC_NAME" (single underscores on each side), which is supposedly to be the actual name of the service, placed into a variable name which uses underscores, and it is completely unclear which is which and how to actually compose the name.

      Additionally, the paragraph on configuring REST clients using environment variables is... I can find no other word but "useless", as a consequence of the above, and an additional error introduced in it:

      In Quarkus, you can use these environment variables directly in the application.properties file.
      FQN/mp-rest/url=http://_SVC_NAME__SERVICE_HOST:`SVC_NAME_SERVICE_PORT`

      The above means nothing in application.properties. Environment variables are referenced using dollar-curly-brace notation: ${FOO_SERVICE_HOST}.

      In both cases an example service name and example class should be used to illustrate the use, rather than going for conventions that end up having zero value.

      Such as:

      ...the following environment variables are automatically defined and injected into the containers for all of the pods running inside the project. For an example service with the name of "calculator", the environment variables:
      CALCULATOR_SERVICE_HOST would contain the service's IP address.
      CALCULATOR_SERVICE_PORT would point to the service's TCP port.

      and

      In Quarkus, you can use these environment variables directly in the application.properties file. From a client class named com.example.RestClient accessing the "calculator" service, that would be:
      com.example.RestClient/mp-rest/url=http://${CALCULATOR_SERVICE_HOST}:${CALCULATOR_SERVICE_PORT} 

              rht-zgutterman Zachary Gutterman
              gregab@p0f.net Grega Bremec
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: