Override Harness Kubernetes Service Settings

Updated 3 months ago by Michael Cretzman

Harness Kubernetes Service Config VariablesConfig Files, and values.yaml settings can be overwritten by Harness Environments Service Configuration Overrides.

This enables you to have a Service keep its settings but change them when the Service is deployed to the Environment.

For example, you might have a single Service but an Environment for QA and an Environment for Production, and you want to overwrite the namespace setting in the Service values.yaml depending on the Environment.

You can also overwrite Service variables at the Phase-level of a multiple Phase Workflow.

In this topic:

Before You Begin

Step 1: Select the Service to Override

  1. In the Harness Environment, in the Service Configuration Overrides section, click Add Configuration Overrides. The Service Configuration Override settings appear.

  1. In Service, select the Service you are using for your Kubernetes deployment.
  2. Select one of the Override Type options.

Option 1: Variable Override

  1. In Override Type, select Variable Override. The Variable Override options appear.
  2. In Configuration Variable, select a variable configured in the Service's Config Variables settings.
  3. In Type, select Text or Encrypted Text.
  4. In Override Value, enter the value to overwrite the variable value in the Service. If you selected Encrypted Text in Type, you can select an Encrypted Text values defined in Secrets Management.

Option 2: File Override

  1. In Override Type, select File Override.
  2. In File Name, select a file configured in the Service's Config Files settings.
  3. In File, select the file to overwrite the Service's Config Files file.

Option 3: Values YAML

  1. In Override Type, select Values YAML. Click Local or Remote.
  2. Local - Enter in the values.yaml variables and values just as your would in a Service Manifests values.yaml. Ensure the name of the variable you want to overwrite is identical.
  3. Remote - See Override Remote Values YAML Files.

Option 4: Helm Chart for Specific Service

Currently, this feature is behind a Feature Flag. Contact Harness Support to enable the feature.
  1. In Override Type, select Helm Chart.
  2. In Location of Helm Chart, you must pick the same location that you used in your Harness Kubernetes Service when you set up your link to the remote Helm chart: Either Helm Repository or Source Repository.

For example, here you can see the Helm Chart from Helm Repository option was selected in the Harness Service Remote Manifests settings, and so the corresponding Helm Repository location is selected in the Service Configuration Overrides:

  1. In Chart Name, enter the name of the chart to use when overriding the chart select in the Service(s).
  2. In Chart Version, enter the chart version to use. This is found in the chart.yaml version label. If you leave this field empty Harness gets the latest chart.

Notes

  • Override for all Services is not supported for Helm chart override. If you select All Services in Service, the Helm Chart option is not available in Override Type.
  • If you select a location type in Location of Helm Chart that is different from the location type you selected in the Service Remote Manifests, deployment will fail.
  • You can use some overrides together. For example, you can use both Helm Chart Overrides with Values YAML Overrides for the same Harness Service. Harness will merge the overrides:

Option 5: Helm Chart for All Services

You can use a specific Helm chart to override All Services deployed to this Environment.

  1. In Service, select All Services.
  2. In Override Type, select Helm Chart Repository.
  3. In Helm Repository, select the Helm Repository containing the Helm chart that you want to override all Service's Helm Charts, and then click Submit.

Example

Here is an example of overwriting a Service values.yaml with a Service Configuration Override.

In the Service values.yaml, we have a variable for replicas:

replicas: 1

This is used in the manifest file like this:

...
spec:
replicas: {{int.Values.replicas}}
...

Now, in Service Configuration Override, you can overwrite the Service values.yaml replicas value using the Local option:

At deployment runtime to this Environment, the overwritten replicas values is used:

kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3

Option 6: OpenShift Template for Specific Service

  1. In Service, select the specific service that you want to override.
  2. In Override Type, select OpenShift Param.
  3. Select Inline or Remote.
    1. If you select Inline, then enter the value inline. If you select Remote, perform the following steps.
  4. Select the Git Connector.
  5. Select either Use latest commit from branch or Use specific commit ID.
    - If you select Use latest commit from branch, enter the branch name where the file is located, such as masterdev, or myAppName. Do not provide the full URL to the branch.
    - If you select Use specific commit ID, enter the commit ID.
  6. In File path, enter the full path to the file in the repo.
  7. Click Submit.

Option 7: OpenShift Template for All Services

  1. In Service, select All Services.
  2. In Override Type, select OpenShift Param.
  3. Select Inline or Remote.
    1. If you select Inline, then enter the value inline. If you select Remote, perform the following steps.
  4. Select the Git Connector.
  5. Select either Use latest commit from branch or Use specific commit ID.
    - If you select Use latest commit from branch, enter the branch name where the file is located, such as masterdev, or myAppName. Do not provide the full URL to the branch.
    - If you select Use specific commit ID, enter the commit ID.
  6. In File path, enter the full path to the file in the repo.
  7. Click Submit.

Next Steps


How did we do?