Override Harness Kubernetes Service Settings

Updated 1 month 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. Click 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. Click 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. Click 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 - Specify the Git repo branch and folder for the remote manifest files to use, as explained in Add Source Repo Providers.

Option 4: Helm Chart

  1. Click 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:

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

Next Steps


How did we do?