Setting up basic authentication credentials by using environment variables

An administrator can use the username and password container environment variables for basic authentication credentials.

After your WebSphereLibertyApplication image is deployed on your Kubernetes cluster, you can use the username and password environment variables for basic authentication with your username and password of choice.

Procedure

  1. Create a secret with your wanted username and password values in your Kubernetes cluster.
  2. Modify your WebSphereLibertyApplication custom resource (CR) to add a .spec.envFrom parameter definition that references your secret.
    For example, add the following .spec.envFrom.secretRef parameter to your CR and replace basic-auth with your secret.
    spec:
      envFrom:
       - secretRef:
          name: basic-auth
  3. Ensure that your application container can access the secret.

Results

The .spec.envFrom configuration sets two environment variables for your application container, username and password, and uses the username and password values in your secret.