Create a GitOps cluster with Azure Workload Identity Federation (WIF)
Connect Harness GitOps (Argo CD) to Azure Kubernetes Service (AKS) using Workload Identity Federation for secure, keyless authentication.
In this guide, you will set up Harness GitOps (powered by Argo CD) to connect securely to an Azure Kubernetes Service (AKS) cluster without storing kubeconfigs or static credentials.
What you will learn from this topic
What Azure Workload Identity Federation is and how it enables keyless authentication for AKS clusters.
The setup process for connecting an AKS cluster to Harness GitOps.
How to configure AKS security, enable OIDC and workload identity, and create federated credentials for the GitOps agent.
How to troubleshoot a cluster that does not appear healthy after setup.
Before you begin
Before setting up Azure WIF with GitOps, ensure you have:
Azure subscription with appropriate permissions to:
Create and manage Azure AD applications
Create and manage Managed Identities
Assign RBAC roles
Manage AKS clusters
AKS cluster with specific authentication and authorization configuration
Harness GitOps module enabled in your account
What is Azure WIF
Azure Workload Identity Federation (WIF) allows Kubernetes ServiceAccounts to securely access Azure resources without storing credentials or secrets in the cluster. Instead, AKS issues short-lived tokens through its OpenID Connect (OIDC) issuer, which Azure validates before granting access to the linked Azure AD application.
With WIF:
No kubeconfigs or static service principal secrets are stored
Authentication is short-lived and automatically rotated
Access is scoped to a specific Kubernetes ServiceAccount
Go to the Azure Workload Identity Federation documentation to learn more about how WIF works in AKS.
Overview of the setup process
The Azure WIF setup involves these key steps:
Configure AKS security: Set up proper authentication and authorization.
Enable OIDC and workload identity: Enable your AKS cluster to issue trusted tokens.
Create managed identity: Create an Azure managed identity for your GitOps agent.
Download and modify GitOps agent YAML: Download the agent YAML and add workload identity annotations.
Configure federated credentials: Link your Kubernetes ServiceAccount to the managed identity.
Deploy GitOps agent: Install the modified agent.
Create cluster secret: Configure the cluster connection with workload identity authentication.
Verify setup: Ensure the cluster appears healthy in the Harness UI.
Configure AKS security settings
Ensure your AKS cluster is configured with the correct authentication and authorization method. Your cluster must use one of these configurations.
Option 1: Microsoft Entra ID authentication with Azure RBAC
Option 2: Microsoft Entra ID authentication with Kubernetes RBAC
Using the Azure portal
Go to the Azure portal to sign in to your Azure account.
Go to Kubernetes services and select your AKS cluster.
In the left menu, click Authentication and authorization.
Under Authentication method, select Microsoft Entra ID.
Under Authorization, choose either:
Azure RBAC (recommended for most scenarios)
Kubernetes RBAC (if you prefer Kubernetes-native RBAC)
Click Save to apply the changes.
Enable OIDC provider and workload identity
Enable the OIDC issuer and workload identity on your AKS cluster.
Using the Azure CLI
Using the Azure portal
In your AKS cluster page, go to Settings -> Security.
Under Workload Identity, toggle Enable workload identity to Enabled.
Under OIDC Issuer, toggle Enable OIDC issuer to Enabled.
Click Save to apply the changes.
After saving, note down the OIDC Issuer URL displayed. You need this for federated credentials.
Retrieve the OIDC issuer URL
Get the OIDC issuer URL, which you need for configuring federated credentials.
Using the Azure CLI:
Using the Azure portal:
In your AKS cluster page, go to Settings -> Security.
Under OIDC Issuer, copy the Issuer URL value.
Save this URL. You need it when configuring federated credentials.
Create managed identity
Create an Azure managed identity that will be used by your GitOps agent.
Using the Azure portal
In the Azure portal, search for Managed Identities and select it.
Click + Create to create a new managed identity.
Fill in the details:
Subscription: Select your subscription
Resource group: Select your resource group
Region: Select the same region as your AKS cluster
Name: Enter
gitops-managed-identity(or your preferred name)
Click Review + create, then Create.
Once created, click Go to resource.
Get the client ID and tenant ID
Retrieve the client ID and tenant ID that you need for the service account annotations.
Go to Get client ID from managed identity to learn how Azure derives the client ID, and go to Get tenant ID to learn how to find your tenant ID.
Getting the client ID and tenant ID through the portal
To get the client ID:
In your managed identity page, go to Overview.
Copy the Client ID value.
Save this value. You need it for service account annotations.
To get the tenant ID:
In the Azure portal, click your profile icon (top right).
Click Switch directory or go to Microsoft Entra ID.
In the Overview page, copy the Tenant ID value.
Alternatively, you can find it in your subscription details.
Download and modify the GitOps agent YAML
Before you can configure workload identity authentication, download the GitOps agent YAML from Harness and make specific modifications to it.
Download the GitOps agent YAML from Harness
First, download the agent YAML file from your Harness account.
Log in to your Harness account and navigate to the GitOps module.
Go to GitOps -> Settings -> GitOps Agents.
Click + New GitOps Agent.
Fill in the agent details:
Name: Enter a descriptive name for your agent (for example,
azure-wif-agent)Agent Type: Select Argo CD
Namespace: Enter
argocd(this must match the namespace in your federated credentials)
Click Continue or Next.
Download the agent YAML file. This is a file named something like
gitops-agent.yaml.Save the file locally. You need to edit it before applying it to your cluster.
Modify the application controller service account
Now that you have the agent YAML file, modify it to include workload identity annotations.
Open the downloaded YAML file in your preferred text editor. Find the application controller service account section. Look for this section in the file:
Example:
Add the required annotations to the metadata.annotations section:
azure.workload.identity/client-id: Replaceyour-client-idwith the Client ID from the managed identity stepazure.workload.identity/tenant-id: Replaceyour-tenant-idwith the Tenant ID from the managed identity step
Add the workload identity label to the repo server
Find the repo server deployment section. Look for this section in the same YAML file:
Example:
Add the workload identity label to the spec.template.metadata.labels section:
Add
azure.workload.identity/use: "true"
This setting allows the repo server to use the workload identity.
Verify your modifications
Before proceeding, double-check that you made these changes:
Added the
azure.workload.identity/client-idannotation with your actual Client IDAdded the
azure.workload.identity/tenant-idannotation with your actual Tenant IDAdded the
azure.workload.identity/use: "true"label to the repo server deploymentSaved the modified YAML file
Configure federated credentials
Create federated credentials to allow the service account to use the managed identity.
Navigate to the managed identity
In the Azure portal, go to Managed Identities.
Select the identity you created earlier (
gitops-managed-identity).Go to Settings -> Federated credentials.
Click Add credential.
Configure the federated credential
Fill in the following details:
Federated credential scenario: Select "Kubernetes accessing Azure resources"
Cluster issuer URL: Use the OIDC issuer URL from the previous step
Namespace:
argocd(the namespace where you are deploying your GitOps application)Service account:
argocd-application-controller(must match the service account name in your agent YAML)Name:
harness-gitops-federated-credential(or any descriptive name)
Alternatively, use the Azure CLI:
Deploy the GitOps agent
Apply the modified GitOps agent YAML to your cluster.
Verify agent health
Wait for the agent to become healthy.
Check that all pods are running and the agent shows as Healthy in the Harness UI.
Create cluster secret
Create a Kubernetes secret that defines how to connect to your cluster using workload identity authentication.
Prepare cluster information
Get your cluster's API server endpoint and CA certificate.
Create the secret YAML
Create a secret YAML file with the following content.
Example:
Replace the following values:
your-cluster-endpoint: Your cluster's API server endpointyour-client-id: The client ID from your managed identityyour-base64-encoded-ca-cert: The base64-encoded CA certificate
Apply the secret
Verify the secret
Check that the secret was created correctly.
Verify setup in the Harness UI
Check cluster status
Navigate to GitOps -> Settings -> Clusters in your Harness account.
You should see your cluster listed with a Healthy status.
The cluster should show as Connected.
Troubleshooting
If the cluster does not appear healthy:
Verify agent status: Ensure all GitOps agent pods are running.
Check service account annotations: Verify the client ID and tenant ID are correct.
Validate federated credentials: Ensure the issuer URL and subject match your configuration.
Review secret configuration: Check that the cluster secret has the correct endpoint and authentication details.
Next steps
You have connected an AKS cluster to Harness GitOps using Azure Workload Identity Federation, with no stored kubeconfigs or static credentials.
Create a GitOps cluster with GKE Workload Identity: Set up keyless authentication for a GKE cluster.
Create a GitOps cluster with IAM: Connect a cluster using IAM-based authentication.
Use secrets for cluster credentials: Connect a cluster with stored credentials instead of workload identity.
Last updated
Was this helpful?