<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Azure &#8211; abdulrahmanuk.com</title>
	<atom:link href="https://www.abdulrahmanuk.com/category/azure-cloud/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.abdulrahmanuk.com</link>
	<description>All about Cloud and DevOps</description>
	<lastBuildDate>Mon, 23 Jun 2025 07:37:26 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.abdulrahmanuk.com/wp-content/uploads/2023/02/icons8-devops-60.png</url>
	<title>Azure &#8211; abdulrahmanuk.com</title>
	<link>https://www.abdulrahmanuk.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Secure Secret Management in AKS with Azure Key Vault CSI Driver and Auto-Rotation Enabled</title>
		<link>https://www.abdulrahmanuk.com/secure-secret-management-in-aks-with-azure-key-vault-csi-driver-and-auto-rotation-enabled/</link>
					<comments>https://www.abdulrahmanuk.com/secure-secret-management-in-aks-with-azure-key-vault-csi-driver-and-auto-rotation-enabled/#respond</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Mon, 23 Jun 2025 03:06:56 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[Exclusive]]></category>
		<category><![CDATA[Kubernetes]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=562</guid>

					<description><![CDATA[<p>In today&#8217;s cloud-native environments, securely managing secrets such as database credentials, API tokens, and certificates is vital. For Kubernetes workloads running on Azure Kubernetes Service (AKS), Azure Key Vault provides a highly secure and centralized way to manage secrets. When integrated with the Kubernetes Secrets Store CSI (Container Storage Interface) driver and Azure Workload Identity, [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/secure-secret-management-in-aks-with-azure-key-vault-csi-driver-and-auto-rotation-enabled/">Secure Secret Management in AKS with Azure Key Vault CSI Driver and Auto-Rotation Enabled</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In today&#8217;s cloud-native environments, securely managing secrets such as database credentials, API tokens, and certificates is vital. For Kubernetes workloads running on Azure Kubernetes Service (AKS), Azure Key Vault provides a highly secure and centralized way to manage secrets. When integrated with the Kubernetes Secrets Store CSI (Container Storage Interface) driver and Azure Workload Identity, secrets can be dynamically and securely injected into pods with automatic rotation support. This blog demonstrates how to set up this integration in a production-grade environment.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f30d.png" alt="🌍" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Use Case Scenario</h2>



<p><strong>Problem:</strong> In most Kubernetes applications, secrets are hardcoded or statically injected, requiring pod restarts when secrets like database passwords are rotated. This creates downtime and maintenance overhead.</p>



<p><strong>Solution:</strong> Integrate AKS with Azure Key Vault using the CSI driver and enable automatic secret rotation. Secrets will be mounted into pods and updated dynamically without restarting the pod, ensuring zero-downtime secret updates.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2699.png" alt="⚙" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Architecture Overview</h2>



<p>The architecture includes:</p>



<ul class="wp-block-list">
<li><strong>AKS Cluster</strong></li>



<li><strong>Azure Key Vault</strong></li>



<li><strong>Workload Identity (OIDC)</strong> for secure identity management</li>



<li><strong>CSI Secrets Store Driver</strong> for mounting secrets</li>



<li><strong>Auto-Rotation</strong> of secrets via polling</li>
</ul>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="2560" height="1440" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/Secure-Secrets-Management-in-AKS-with-Azure-Key-Vault-CSI-Driver-and-Auto-Rotation.png" alt="Secure Secrets Management in AKS with Azure Key Vault CSI Driver and Auto Rotation" class="wp-image-565" title="Secure Secret Management in AKS with Azure Key Vault CSI Driver and Auto-Rotation Enabled 1" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/Secure-Secrets-Management-in-AKS-with-Azure-Key-Vault-CSI-Driver-and-Auto-Rotation.png 2560w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/Secure-Secrets-Management-in-AKS-with-Azure-Key-Vault-CSI-Driver-and-Auto-Rotation-768x432.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/Secure-Secrets-Management-in-AKS-with-Azure-Key-Vault-CSI-Driver-and-Auto-Rotation-1536x864.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/Secure-Secrets-Management-in-AKS-with-Azure-Key-Vault-CSI-Driver-and-Auto-Rotation-2048x1152.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/Secure-Secrets-Management-in-AKS-with-Azure-Key-Vault-CSI-Driver-and-Auto-Rotation-150x84.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/Secure-Secrets-Management-in-AKS-with-Azure-Key-Vault-CSI-Driver-and-Auto-Rotation-300x169.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/Secure-Secrets-Management-in-AKS-with-Azure-Key-Vault-CSI-Driver-and-Auto-Rotation-696x392.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/Secure-Secrets-Management-in-AKS-with-Azure-Key-Vault-CSI-Driver-and-Auto-Rotation-1068x601.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/Secure-Secrets-Management-in-AKS-with-Azure-Key-Vault-CSI-Driver-and-Auto-Rotation-1920x1080.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/Secure-Secrets-Management-in-AKS-with-Azure-Key-Vault-CSI-Driver-and-Auto-Rotation-600x338.png 600w" sizes="(max-width: 2560px) 100vw, 2560px" /></figure>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4ca.png" alt="📊" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step-by-Step Implementation</h2>



<p>To create a AKS cluster using CLI please follow this blog: <a href="https://www.abdulrahmanuk.com/aks-cluster-setup-using-azure-cli-with-oidc-azure-key-vault-integration/" data-type="post" data-id="574">AKS Cluster Setup Using Azure CLI with OIDC &amp; Azure Key Vault Integration</a></p>



<h3 class="wp-block-heading">1. Enable OIDC and Workload Identity on exiting AKS cluster</h3>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>az aks update \
  --name &lt;cluster-name> \
  --resource-group &lt;rg> \
  --enable-oidc-issuer \
  --enable-workload-identity
</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">az aks update \</span></span>
<span class="line"><span style="color: #A6ACCD">  --name &lt;cluster-name&gt; \</span></span>
<span class="line"><span style="color: #A6ACCD">  --resource-group &lt;rg&gt; \</span></span>
<span class="line"><span style="color: #A6ACCD">  --enable-oidc-issuer \</span></span>
<span class="line"><span style="color: #A6ACCD">  --enable-workload-identity</span></span>
<span class="line"></span></code></pre></div>



<div style="height:15px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="2314" height="1246" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-6.png" alt="image 6" class="wp-image-579" title="Secure Secret Management in AKS with Azure Key Vault CSI Driver and Auto-Rotation Enabled 2" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-6.png 2314w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-6-768x414.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-6-1536x827.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-6-2048x1103.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-6-150x81.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-6-300x162.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-6-696x375.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-6-1068x575.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-6-1920x1034.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-6-600x323.png 600w" sizes="(max-width: 2314px) 100vw, 2314px" /></figure>



<p>To enable <strong>Azure Key Vault CSI driver</strong> after the cluster is created:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>az aks enable-addons \
  --addons azure-keyvault-secrets-provider \
  --name &lt;cluster-name> \
  --resource-group &lt;rg>
  </textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">az aks enable-addons \</span></span>
<span class="line"><span style="color: #A6ACCD">  --addons azure-keyvault-secrets-provider \</span></span>
<span class="line"><span style="color: #A6ACCD">  --name &lt;cluster-name&gt; \</span></span>
<span class="line"><span style="color: #A6ACCD">  --resource-group &lt;rg&gt;</span></span>
<span class="line"><span style="color: #A6ACCD">  </span></span></code></pre></div>



<p>You can verify through azure portal under your kuberenets cluster dashboard &#8220;Security Configuration&#8221; tab</p>



<figure class="wp-block-image size-full"><img decoding="async" width="2206" height="1168" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-7.png" alt="image 7" class="wp-image-580" title="Secure Secret Management in AKS with Azure Key Vault CSI Driver and Auto-Rotation Enabled 3" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-7.png 2206w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-7-768x407.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-7-1536x813.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-7-2048x1084.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-7-150x79.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-7-300x159.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-7-696x369.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-7-1068x565.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-7-1920x1017.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-7-600x318.png 600w" sizes="(max-width: 2206px) 100vw, 2206px" /></figure>



<p>Verify that each node in your cluster&#8217;s node pool has a Secrets Store CSI Driver pod and a Secrets Store Provider Azure pod running</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>kubectl get pods -n kube-system -l 'app in (secrets-store-csi-driver,secrets-store-provider-azure)' -o wide</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">kubectl get pods -n kube-system -l &#39;app in (secrets-store-csi-driver,secrets-store-provider-azure)&#39; -o wide</span></span></code></pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2560" height="381" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-8-scaled.png" alt="image 8 scaled" class="wp-image-581" title="Secure Secret Management in AKS with Azure Key Vault CSI Driver and Auto-Rotation Enabled 4" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-8-scaled.png 2560w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-8-768x114.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-8-1536x228.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-8-2048x305.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-8-150x22.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-8-300x45.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-8-696x104.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-8-1068x159.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-8-1920x286.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-8-600x89.png 600w" sizes="auto, (max-width: 2560px) 100vw, 2560px" /></figure>



<h3 class="wp-block-heading">1.2 Keyvault creation and configuration</h3>



<p>Create a key vault with Azure role-based access control (Azure RBAC).</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>az keyvault create -n my-demo-k8s-key-vault -g keyvault-demo -l eastus --enable-rbac-authorization</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">az keyvault create -n my-demo-k</span><span style="color: #5DE4C7">8</span><span style="color: #A6ACCD">s-key-vault -g keyvault-demo -l eastus --enable-rbac-authorization</span></span></code></pre></div>



<h3 class="wp-block-heading">2. Create a Managed Identity </h3>



<p>Please export following values on your terminal, make sure you have added your subscription id..etc</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>export SUBSCRIPTION_ID=fe4a1fdb-6a1c-4a6d-a6b0-dbb12f6a00f8
export RESOURCE_GROUP=keyvault-demo
export UAMI=azurekeyvaultsecretsprovider-keyvault-demo-cluster
export KEYVAULT_NAME=my-demo-k8s-key-vault
export CLUSTER_NAME=keyvault-demo-cluster

az account set --subscription $SUBSCRIPTION_ID</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">export SUBSCRIPTION_ID=fe</span><span style="color: #5DE4C7">4</span><span style="color: #A6ACCD">a</span><span style="color: #5DE4C7">1</span><span style="color: #A6ACCD">fdb</span><span style="color: #5DE4C7">-6</span><span style="color: #A6ACCD">a</span><span style="color: #5DE4C7">1</span><span style="color: #A6ACCD">c</span><span style="color: #5DE4C7">-4</span><span style="color: #A6ACCD">a</span><span style="color: #5DE4C7">6</span><span style="color: #A6ACCD">d-a</span><span style="color: #5DE4C7">6</span><span style="color: #A6ACCD">b</span><span style="color: #5DE4C7">0</span><span style="color: #A6ACCD">-dbb</span><span style="color: #5DE4C7">12</span><span style="color: #A6ACCD">f</span><span style="color: #5DE4C7">6</span><span style="color: #A6ACCD">a</span><span style="color: #5DE4C7">00</span><span style="color: #A6ACCD">f</span><span style="color: #5DE4C7">8</span></span>
<span class="line"><span style="color: #A6ACCD">export RESOURCE_GROUP=keyvault-demo</span></span>
<span class="line"><span style="color: #A6ACCD">export UAMI=azurekeyvaultsecretsprovider-keyvault-demo-cluster</span></span>
<span class="line"><span style="color: #A6ACCD">export KEYVAULT_NAME=my-demo-k</span><span style="color: #5DE4C7">8</span><span style="color: #A6ACCD">s-key-vault</span></span>
<span class="line"><span style="color: #A6ACCD">export CLUSTER_NAME=keyvault-demo-cluster</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">az account set --subscription $SUBSCRIPTION_ID</span></span></code></pre></div>



<p>To Create a managed identity, following azure cli command</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>az identity create --name $UAMI --resource-group $RESOURCE_GROUP

export USER_ASSIGNED_CLIENT_ID="$(az identity show -g $RESOURCE_GROUP --name $UAMI --query 'clientId' -o tsv)"

export IDENTITY_TENANT=$(az aks show --name $CLUSTER_NAME --resource-group $RESOURCE_GROUP --query identity.tenantId -o tsv)</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">az identity create --name $UAMI --resource-group $RESOURCE_GROUP</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">export USER_ASSIGNED_CLIENT_ID=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">$(az identity show -g $RESOURCE_GROUP --name $UAMI --query &#39;clientId&#39; -o tsv)</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">export IDENTITY_TENANT=$(az aks show --name $CLUSTER_NAME --resource-group $RESOURCE_GROUP --query identity.tenantId -o tsv)</span></span></code></pre></div>



<p>Create a role assignment that grants the workload ID access the key vault</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>export KEYVAULT_SCOPE=$(az keyvault show --name $KEYVAULT_NAME --query id -o tsv)

az role assignment create --role "Key Vault Administrator" --assignee $USER_ASSIGNED_CLIENT_ID --scope $KEYVAULT_SCOPE</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">export KEYVAULT_SCOPE=$(az keyvault show --name $KEYVAULT_NAME --query id -o tsv)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">az role assignment create --role </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Key Vault Administrator</span><span style="color: #A6ACCD">&quot;</span><span style="color: #A6ACCD"> --assignee $USER_ASSIGNED_CLIENT_ID --scope $KEYVAULT_SCOPE</span></span></code></pre></div>



<p>Get the AKS cluster OIDC Issuer URL</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>export AKS_OIDC_ISSUER="$(az aks show --resource-group $RESOURCE_GROUP --name $CLUSTER_NAME --query "oidcIssuerProfile.issuerUrl" -o tsv)"

echo $AKS_OIDC_ISSUER</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">export AKS_OIDC_ISSUER=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">$(az aks show --resource-group $RESOURCE_GROUP --name $CLUSTER_NAME --query </span><span style="color: #A6ACCD">&quot;</span><span style="color: #A6ACCD">oidcIssuerProfile.issuerUrl</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7"> -o tsv)</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">echo $AKS_OIDC_ISSUER</span></span></code></pre></div>



<h3 class="wp-block-heading">3. Annotate Kubernetes ServiceAccount</h3>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>export SERVICE_ACCOUNT_NAME="workload-identity-sa"
export SERVICE_ACCOUNT_NAMESPACE="default" </textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">export SERVICE_ACCOUNT_NAME=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">workload-identity-sa</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">export SERVICE_ACCOUNT_NAMESPACE=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">default</span><span style="color: #A6ACCD">&quot;</span><span style="color: #A6ACCD"> </span></span></code></pre></div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>cat &lt;&lt;EOF | kubectl apply -f -
apiVersion: v1
kind: ServiceAccount
metadata:
  name: ${SERVICE_ACCOUNT_NAME}
  namespace: ${SERVICE_ACCOUNT_NAMESPACE}
  annotations:
    azure.workload.identity/client-id: "${USER_ASSIGNED_CLIENT_ID}"
EOF
</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">cat &lt;&lt;EOF | kubectl apply -f -</span></span>
<span class="line"><span style="color: #A6ACCD">apiVersion: v</span><span style="color: #5DE4C7">1</span></span>
<span class="line"><span style="color: #A6ACCD">kind: ServiceAccount</span></span>
<span class="line"><span style="color: #A6ACCD">metadata:</span></span>
<span class="line"><span style="color: #A6ACCD">  name: ${</span><span style="color: #D0679D">SERVICE_ACCOUNT_NAME</span><span style="color: #A6ACCD">}</span></span>
<span class="line"><span style="color: #A6ACCD">  namespace: ${</span><span style="color: #D0679D">SERVICE_ACCOUNT_NAMESPACE</span><span style="color: #A6ACCD">}</span></span>
<span class="line"><span style="color: #A6ACCD">  annotations:</span></span>
<span class="line"><span style="color: #A6ACCD">    azure.workload.identity/client-id: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">${USER_ASSIGNED_CLIENT_ID}</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">EOF</span></span>
<span class="line"></span></code></pre></div>



<p>Or If above syntax confusing, SA direct yaml syntax given below fill details accordingly </p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>apiVersion: v1
kind: ServiceAccount
metadata:
  name: workload-identity-sa
  annotations:
    azure.workload.identity/client-id: &lt;your-client-id>
    namespace: default</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">apiVersion: v</span><span style="color: #5DE4C7">1</span></span>
<span class="line"><span style="color: #A6ACCD">kind: ServiceAccount</span></span>
<span class="line"><span style="color: #A6ACCD">metadata:</span></span>
<span class="line"><span style="color: #A6ACCD">  name: workload-identity-sa</span></span>
<span class="line"><span style="color: #A6ACCD">  annotations:</span></span>
<span class="line"><span style="color: #A6ACCD">    azure.workload.identity/client-id: &lt;your-client-id&gt;</span></span>
<span class="line"><span style="color: #A6ACCD">    namespace: default</span></span></code></pre></div>



<p>Setup Federation</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>export FEDERATED_IDENTITY_NAME="aksfederatedidentity" 

az identity federated-credential create --name $FEDERATED_IDENTITY_NAME --identity-name $UAMI --resource-group $RESOURCE_GROUP --issuer ${AKS_OIDC_ISSUER} --subject system:serviceaccount:${SERVICE_ACCOUNT_NAMESPACE}:${SERVICE_ACCOUNT_NAME}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">export FEDERATED_IDENTITY_NAME=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">aksfederatedidentity</span><span style="color: #A6ACCD">&quot;</span><span style="color: #A6ACCD"> </span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">az identity federated-credential create --name $FEDERATED_IDENTITY_NAME --identity-name $UAMI --resource-group $RESOURCE_GROUP --issuer ${</span><span style="color: #D0679D">AKS_OIDC_ISSUER</span><span style="color: #A6ACCD">} --subject system:serviceaccount:${</span><span style="color: #D0679D">SERVICE_ACCOUNT_NAMESPACE</span><span style="color: #A6ACCD">}:${</span><span style="color: #D0679D">SERVICE_ACCOUNT_NAME</span><span style="color: #A6ACCD">}</span></span></code></pre></div>



<h3 class="wp-block-heading">4. Create SecretProviderClass</h3>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>cat &lt;&lt;EOF | kubectl apply -f -
# This is a SecretProviderClass example using workload identity to access your key vault
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
  name: azure-kvname-wi # needs to be unique per namespace
spec:
  provider: azure
  parameters:
    usePodIdentity: "false"
    clientID: "${USER_ASSIGNED_CLIENT_ID}" # Setting this to use workload identity
    keyvaultName: ${KEYVAULT_NAME}       # Set to the name of your key vault
    cloudName: ""                         # [OPTIONAL for Azure] if not provided, the Azure environment defaults to AzurePublicCloud
    objects:  |
      array:
        - |
          objectName: DB-Password         # Set to the name of your secret
          objectType: secret              # object types: secret, key, or cert
          objectVersion: ""              
    tenantId: "${IDENTITY_TENANT}"        # The tenant ID of the key vault
EOF</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">cat &lt;&lt;EOF | kubectl apply -f -</span></span>
<span class="line"><span style="color: #A6ACCD"># This is a SecretProviderClass example using workload identity to access your key vault</span></span>
<span class="line"><span style="color: #A6ACCD">apiVersion: secrets-store.csi.x-k</span><span style="color: #5DE4C7">8</span><span style="color: #A6ACCD">s.io/v</span><span style="color: #5DE4C7">1</span></span>
<span class="line"><span style="color: #A6ACCD">kind: SecretProviderClass</span></span>
<span class="line"><span style="color: #A6ACCD">metadata:</span></span>
<span class="line"><span style="color: #A6ACCD">  name: azure-kvname-wi # needs to be unique per namespace</span></span>
<span class="line"><span style="color: #A6ACCD">spec:</span></span>
<span class="line"><span style="color: #A6ACCD">  provider: azure</span></span>
<span class="line"><span style="color: #A6ACCD">  parameters:</span></span>
<span class="line"><span style="color: #A6ACCD">    usePodIdentity: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">false</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    clientID: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">${USER_ASSIGNED_CLIENT_ID}</span><span style="color: #A6ACCD">&quot;</span><span style="color: #A6ACCD"> # Setting this to use workload identity</span></span>
<span class="line"><span style="color: #A6ACCD">    keyvaultName: ${</span><span style="color: #D0679D">KEYVAULT_NAME</span><span style="color: #A6ACCD">}       # Set to the name of your key vault</span></span>
<span class="line"><span style="color: #A6ACCD">    cloudName: </span><span style="color: #A6ACCD">&quot;&quot;</span><span style="color: #A6ACCD">                         # [</span><span style="color: #D0679D">OPTIONAL</span><span style="color: #A6ACCD"> </span><span style="color: #D0679D">for</span><span style="color: #A6ACCD"> </span><span style="color: #D0679D">Azure</span><span style="color: #A6ACCD">] if not provided, the Azure environment defaults to AzurePublicCloud</span></span>
<span class="line"><span style="color: #A6ACCD">    objects:  |</span></span>
<span class="line"><span style="color: #A6ACCD">      array:</span></span>
<span class="line"><span style="color: #A6ACCD">        - |</span></span>
<span class="line"><span style="color: #A6ACCD">          objectName: DB-Password         # Set to the name of your secret</span></span>
<span class="line"><span style="color: #A6ACCD">          objectType: secret              # object types: secret, key, or cert</span></span>
<span class="line"><span style="color: #A6ACCD">          objectVersion: </span><span style="color: #A6ACCD">&quot;&quot;</span><span style="color: #A6ACCD">              </span></span>
<span class="line"><span style="color: #A6ACCD">    tenantId: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">${IDENTITY_TENANT}</span><span style="color: #A6ACCD">&quot;</span><span style="color: #A6ACCD">        # The tenant ID of the key vault</span></span>
<span class="line"><span style="color: #A6ACCD">EOF</span></span></code></pre></div>



<p>Or use below direct yaml secretproviderclass and fill details accordingly</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
  name: azure-kvname-wi
spec:
  provider: azure
  parameters:
    keyvaultName: &lt;your-kv-name>
    tenantId: &lt;your-tenant-id>
    clientID: &lt;your-client-id>
    objects: |
      array:
        - objectName: DB-Password
          objectType: secret
          objectVersion: ""
</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">apiVersion: secrets-store.csi.x-k</span><span style="color: #5DE4C7">8</span><span style="color: #A6ACCD">s.io/v</span><span style="color: #5DE4C7">1</span></span>
<span class="line"><span style="color: #A6ACCD">kind: SecretProviderClass</span></span>
<span class="line"><span style="color: #A6ACCD">metadata:</span></span>
<span class="line"><span style="color: #A6ACCD">  name: azure-kvname-wi</span></span>
<span class="line"><span style="color: #A6ACCD">spec:</span></span>
<span class="line"><span style="color: #A6ACCD">  provider: azure</span></span>
<span class="line"><span style="color: #A6ACCD">  parameters:</span></span>
<span class="line"><span style="color: #A6ACCD">    keyvaultName: &lt;your-kv-name&gt;</span></span>
<span class="line"><span style="color: #A6ACCD">    tenantId: &lt;your-tenant-id&gt;</span></span>
<span class="line"><span style="color: #A6ACCD">    clientID: &lt;your-client-id&gt;</span></span>
<span class="line"><span style="color: #A6ACCD">    objects: |</span></span>
<span class="line"><span style="color: #A6ACCD">      array:</span></span>
<span class="line"><span style="color: #A6ACCD">        - objectName: DB-Password</span></span>
<span class="line"><span style="color: #A6ACCD">          objectType: secret</span></span>
<span class="line"><span style="color: #A6ACCD">          objectVersion: </span><span style="color: #A6ACCD">&quot;&quot;</span></span>
<span class="line"></span></code></pre></div>



<h3 class="wp-block-heading">5. Deploy a Workload (e.g., BusyBox Test Pod)</h3>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>apiVersion: apps/v1
kind: Deployment
metadata:
  name: busybox-secrets
spec:
  replicas: 1
  selector:
    matchLabels:
      app: busybox-secrets
  template:
    metadata:
      labels:
        app: busybox-secrets
        azure.workload.identity/use: "true"
    spec:
      serviceAccountName: workload-identity-sa
      containers:
        - name: busybox
          image: registry.k8s.io/e2e-test-images/busybox:1.29-4
          command: ["/bin/sleep", "10000"]
          volumeMounts:
            - name: secrets-store-vol
              mountPath: "/mnt/secrets-store"
              readOnly: true
      volumes:
        - name: secrets-store-vol
          csi:
            driver: secrets-store.csi.k8s.io
            readOnly: true
            volumeAttributes:
              secretProviderClass: azure-kvname-wi
              rotationPollInterval: "30s"
</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">apiVersion: apps/v</span><span style="color: #5DE4C7">1</span></span>
<span class="line"><span style="color: #A6ACCD">kind: Deployment</span></span>
<span class="line"><span style="color: #A6ACCD">metadata:</span></span>
<span class="line"><span style="color: #A6ACCD">  name: busybox-secrets</span></span>
<span class="line"><span style="color: #A6ACCD">spec:</span></span>
<span class="line"><span style="color: #A6ACCD">  replicas: </span><span style="color: #5DE4C7">1</span></span>
<span class="line"><span style="color: #A6ACCD">  selector:</span></span>
<span class="line"><span style="color: #A6ACCD">    matchLabels:</span></span>
<span class="line"><span style="color: #A6ACCD">      app: busybox-secrets</span></span>
<span class="line"><span style="color: #A6ACCD">  template:</span></span>
<span class="line"><span style="color: #A6ACCD">    metadata:</span></span>
<span class="line"><span style="color: #A6ACCD">      labels:</span></span>
<span class="line"><span style="color: #A6ACCD">        app: busybox-secrets</span></span>
<span class="line"><span style="color: #A6ACCD">        azure.workload.identity/use: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">true</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    spec:</span></span>
<span class="line"><span style="color: #A6ACCD">      serviceAccountName: workload-identity-sa</span></span>
<span class="line"><span style="color: #A6ACCD">      containers:</span></span>
<span class="line"><span style="color: #A6ACCD">        - name: busybox</span></span>
<span class="line"><span style="color: #A6ACCD">          image: registry.k</span><span style="color: #5DE4C7">8</span><span style="color: #A6ACCD">s.io/e</span><span style="color: #5DE4C7">2</span><span style="color: #A6ACCD">e-test-images/busybox:</span><span style="color: #5DE4C7">1.29-4</span></span>
<span class="line"><span style="color: #A6ACCD">          command: [</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">/bin/sleep</span><span style="color: #A6ACCD">&quot;</span><span style="color: #A6ACCD">, </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">10000</span><span style="color: #A6ACCD">&quot;</span><span style="color: #A6ACCD">]</span></span>
<span class="line"><span style="color: #A6ACCD">          volumeMounts:</span></span>
<span class="line"><span style="color: #A6ACCD">            - name: secrets-store-vol</span></span>
<span class="line"><span style="color: #A6ACCD">              mountPath: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">/mnt/secrets-store</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">              readOnly: </span><span style="color: #5DE4C7">true</span></span>
<span class="line"><span style="color: #A6ACCD">      volumes:</span></span>
<span class="line"><span style="color: #A6ACCD">        - name: secrets-store-vol</span></span>
<span class="line"><span style="color: #A6ACCD">          csi:</span></span>
<span class="line"><span style="color: #A6ACCD">            driver: secrets-store.csi.k</span><span style="color: #5DE4C7">8</span><span style="color: #A6ACCD">s.io</span></span>
<span class="line"><span style="color: #A6ACCD">            readOnly: </span><span style="color: #5DE4C7">true</span></span>
<span class="line"><span style="color: #A6ACCD">            volumeAttributes:</span></span>
<span class="line"><span style="color: #A6ACCD">              secretProviderClass: azure-kvname-wi</span></span>
<span class="line"><span style="color: #A6ACCD">              rotationPollInterval: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">30s</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"></span></code></pre></div>



<p>Now you can exec into the pod and verify the secret are mounted into the container. You can run following command to verify the same</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2374" height="296" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-9.png" alt="image 9" class="wp-image-582" title="Secure Secret Management in AKS with Azure Key Vault CSI Driver and Auto-Rotation Enabled 5" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-9.png 2374w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-9-768x96.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-9-1536x192.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-9-2048x255.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-9-150x19.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-9-300x37.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-9-696x87.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-9-1068x133.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-9-1920x239.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-9-600x75.png 600w" sizes="auto, (max-width: 2374px) 100vw, 2374px" /></figure>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>kubectl exec &lt;pod> -- ls /mnt/secrets-store/
kubectl exec &lt;pod> -- cat /mnt/secrets-store/DB-Password</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">kubectl exec &lt;pod&gt; -- ls /mnt/secrets-store/</span></span>
<span class="line"><span style="color: #A6ACCD">kubectl exec &lt;pod&gt; -- cat /mnt/secrets-store/DB-Password</span></span></code></pre></div>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">⟳ Enable Auto-Rotation of Secrets</h2>



<p>Run the following command to enable the rotation feature:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>az aks addon update \
  --resource-group &lt;rg> \
  --name &lt;cluster-name> \
  --addon azure-keyvault-secrets-provider \
  --enable-secret-rotation \
  --rotation-poll-interval 30s
</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">az aks addon update \</span></span>
<span class="line"><span style="color: #A6ACCD">  --resource-group &lt;rg&gt; \</span></span>
<span class="line"><span style="color: #A6ACCD">  --name &lt;cluster-name&gt; \</span></span>
<span class="line"><span style="color: #A6ACCD">  --addon azure-keyvault-secrets-provider \</span></span>
<span class="line"><span style="color: #A6ACCD">  --enable-secret-rotation \</span></span>
<span class="line"><span style="color: #A6ACCD">  --rotation-poll-interval </span><span style="color: #5DE4C7">30</span><span style="color: #A6ACCD">s</span></span>
<span class="line"></span></code></pre></div>



<p>Verify it with:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>kubectl -n kube-system describe ds aks-secrets-store-csi-driver
</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">kubectl -n kube-system describe ds aks-secrets-store-csi-driver</span></span>
<span class="line"></span></code></pre></div>



<p>Ensure the arguments include:</p>



<ul class="wp-block-list">
<li><code>--enable-secret-rotation=true</code></li>



<li><code>--rotation-poll-interval=30s</code></li>
</ul>



<p>To work Azure Key Vault auto rotation in deployment, Make sure following settings are there in first</p>



<p>1) Under SecretProviderClass Leave <code>objectVersion</code> blank</p>



<p>2) Add to volume attributes on deployment file: rotationPollInterval</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>volumeAttributes:
  secretProviderClass: azure-kvname-wi
  rotationPollInterval: "30s"</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">volumeAttributes:</span></span>
<span class="line"><span style="color: #A6ACCD">  secretProviderClass: azure-kvname-wi</span></span>
<span class="line"><span style="color: #A6ACCD">  rotationPollInterval: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">30s</span><span style="color: #A6ACCD">&quot;</span></span></code></pre></div>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f50d.png" alt="🔍" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Testing the Rotation</h2>



<ol class="wp-block-list">
<li>Manually update the secret version in Azure Key Vault.</li>



<li>Wait for <code>rotationPollInterval</code>.</li>



<li>Check the mounted file inside the pod:</li>
</ol>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>kubectl exec &lt;pod> -- ls /mnt/secrets-store/
kubectl exec &lt;pod> -- cat /mnt/secrets-store/DB-Password</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">kubectl exec &lt;pod&gt; -- ls /mnt/secrets-store/</span></span>
<span class="line"><span style="color: #A6ACCD">kubectl exec &lt;pod&gt; -- cat /mnt/secrets-store/DB-Password</span></span></code></pre></div>



<div style="height:15px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2560" height="113" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-4-scaled.png" alt="image 4 scaled" class="wp-image-577" title="Secure Secret Management in AKS with Azure Key Vault CSI Driver and Auto-Rotation Enabled 6" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-4-scaled.png 2560w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-4-768x34.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-4-1536x68.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-4-2048x90.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-4-150x7.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-4-300x13.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-4-696x31.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-4-1068x47.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-4-1920x85.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-4-600x26.png 600w" sizes="auto, (max-width: 2560px) 100vw, 2560px" /></figure>



<ol start="4" class="wp-block-list">
<li>Observe that the new value is reflected <strong>without restarting</strong> the pod.</li>
</ol>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2560" height="237" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-5-scaled.png" alt="image 5 scaled" class="wp-image-578" title="Secure Secret Management in AKS with Azure Key Vault CSI Driver and Auto-Rotation Enabled 7" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-5-scaled.png 2560w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-5-768x71.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-5-1536x142.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-5-2048x190.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-5-150x14.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-5-300x28.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-5-696x64.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-5-1068x99.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-5-1920x178.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-5-600x56.png 600w" sizes="auto, (max-width: 2560px) 100vw, 2560px" /></figure>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4d7.png" alt="📗" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Best Practices</h2>



<ul class="wp-block-list">
<li>Avoid <code>subPath</code> in volume mounts (breaks rotation).</li>



<li>Ensure your application <strong>reads secrets from file</strong>, not env vars.</li>



<li>Consider implementing <strong>file watchers</strong> for dynamic config reloads.</li>



<li>Monitor CSI driver logs: <code>kubectl logs ds/aks-secrets-store-csi-driver -n kube-system</code></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f31f.png" alt="🌟" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Conclusion</h2>



<p>With Azure Key Vault, CSI driver, and workload identity, you can achieve secure, automated, and zero-downtime secret management for your AKS workloads. Auto-rotation ensures credentials like DB passwords can be updated without disrupting live applications.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>Feel free to follow me on <a href="https://www.linkedin.com/in/abdul-rahman-uk/" rel="nofollow noopener" target="_blank">LinkedIn</a> and share your thoughts. For a complete YAML reference or demo repo, connect with me or leave a comment!</p>
</blockquote>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/secure-secret-management-in-aks-with-azure-key-vault-csi-driver-and-auto-rotation-enabled/">Secure Secret Management in AKS with Azure Key Vault CSI Driver and Auto-Rotation Enabled</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/secure-secret-management-in-aks-with-azure-key-vault-csi-driver-and-auto-rotation-enabled/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Create an AKS Cluster Using PowerShell in Azure Portal</title>
		<link>https://www.abdulrahmanuk.com/how-to-create-an-aks-cluster-using-powershell-in-azure-portal/</link>
					<comments>https://www.abdulrahmanuk.com/how-to-create-an-aks-cluster-using-powershell-in-azure-portal/#respond</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Mon, 23 Jun 2025 01:20:54 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[Kubernetes]]></category>
		<category><![CDATA[Powershell]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=566</guid>

					<description><![CDATA[<p>In today’s DevOps-driven world, Kubernetes has become the cornerstone of modern cloud-native applications. Microsoft Azure provides a fully managed Kubernetes service called Azure Kubernetes Service (AKS), which helps you focus on deploying and managing containerized applications without worrying about the underlying infrastructure. In this guide, we’ll walk you through how to create an AKS cluster [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/how-to-create-an-aks-cluster-using-powershell-in-azure-portal/">How to Create an AKS Cluster Using PowerShell in Azure Portal</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In today’s DevOps-driven world, Kubernetes has become the cornerstone of modern cloud-native applications. Microsoft Azure provides a fully managed Kubernetes service called <strong>Azure Kubernetes Service (AKS)</strong>, which helps you focus on deploying and managing containerized applications without worrying about the underlying infrastructure.</p>



<p>In this guide, we’ll walk you through <strong>how to create an AKS cluster using PowerShell directly from the Azure Cloud Shell or your local PowerShell session</strong>. Whether you’re getting started or automating cluster provisioning, this tutorial will provide a clear, step-by-step approach.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1858" height="994" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2.png" alt="image 2" class="wp-image-568" title="How to Create an AKS Cluster Using PowerShell in Azure Portal 8" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2.png 1858w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2-768x411.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2-1536x822.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2-150x80.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2-300x160.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2-696x372.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2-1068x571.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2-600x321.png 600w" sizes="auto, (max-width: 1858px) 100vw, 1858px" /></figure>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Prerequisites</h3>



<p>Before we begin, make sure you have the following:</p>



<ul class="wp-block-list">
<li>An active <a class="" href="https://portal.azure.com/" rel="nofollow noopener" target="_blank">Azure subscription</a></li>



<li>Azure PowerShell installed locally <strong>or</strong> use <a class="" href="https://shell.azure.com/" rel="nofollow noopener" target="_blank">Azure Cloud Shell</a></li>



<li>Azure CLI is optional but recommended for verification</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f527.png" alt="🔧" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 1: Log in to the Azure Account</h2>



<p>Open PowerShell and log in to your Azure account.</p>



<pre class="wp-block-code"><code><code>Connect-AzAccount
</code></code></pre>



<p>This command opens a sign-in window or browser-based prompt to authenticate your account.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4c1.png" alt="📁" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 2: Set Your Subscription (If You Have Multiple)</h2>



<pre class="wp-block-code"><code><code>Get-AzSubscription
Set-AzContext -SubscriptionId "your-subscription-id"
</code></code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f3d7.png" alt="🏗" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 3: Create a Resource Group</h2>



<p>A resource group is a container that holds related resources for an Azure solution.</p>



<pre class="wp-block-code"><code><code>$resourceGroup = "AKS-ResourceGroup"
$location = "EastUS"

New-AzResourceGroup -Name $resourceGroup -Location $location
</code></code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f6e1.png" alt="🛡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 4: Create an Azure AD Service Principal (Optional but recommended)</h2>



<p>This account will be used by AKS to interact with Azure resources.</p>



<pre class="wp-block-code"><code><code>$sp = New-AzADServicePrincipal -DisplayName "AKSServicePrincipal"
$spPassword = (New-AzADSpCredential -ServicePrincipalObjectId $sp.Id).SecretText
</code></code></pre>



<p>Store the AppId and Password for later use.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f680.png" alt="🚀" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 5: Create the AKS Cluster</h2>



<pre class="wp-block-code"><code><code>$aksName = "MyAKSCluster"

New-AzAksCluster `
  -ResourceGroupName $resourceGroup `
  -Name $aksName `
  -KubernetesVersion "1.29.2" `
  -NodeCount 3 `
  -NodeVmSize "Standard_DS2_v2" `
  -GenerateSshKey `
  -Location $location `
  -EnableRBAC
</code></code></pre>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> You can specify additional parameters such as <code>-ServicePrincipalId</code>, <code>-ClientSecret</code>, or <code>-NetworkPlugin azure</code> For more custom setups.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f50d.png" alt="🔍" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 6: Verify the Cluster</h2>



<p>After creation, verify the AKS cluster status:</p>



<pre class="wp-block-code"><code><code>Get-AzAksCluster -ResourceGroupName $resourceGroup -Name $aksName
</code></code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4e6.png" alt="📦" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 7: Connect to the AKS Cluster Using <code>kubectl</code></h2>



<p>First, install <code>kubectl</code> if you haven&#8217;t already:</p>



<pre class="wp-block-code"><code><code>az aks install-cli
</code></code></pre>



<p>Then, get credentials:</p>



<pre class="wp-block-code"><code><code>az aks get-credentials --resource-group $resourceGroup --name $aksName
</code></code></pre>



<p>Verify connection:</p>



<pre class="wp-block-code"><code><code>kubectl get nodes
</code></code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Wrapping Up</h2>



<p>You’ve successfully created an <strong>AKS Cluster using PowerShell</strong> on Microsoft Azure! This process is ideal for automating infrastructure deployment.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f3af.png" alt="🎯" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Bonus Tips</h2>



<ul class="wp-block-list">
<li>Use Azure Bicep or Terraform for infrastructure-as-code.</li>



<li>Integrate Azure Key Vault and Managed Identity for secure secrets management.</li>



<li>Enable monitoring with Azure Monitor and Log Analytics for production workloads.</li>
</ul>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/how-to-create-an-aks-cluster-using-powershell-in-azure-portal/">How to Create an AKS Cluster Using PowerShell in Azure Portal</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/how-to-create-an-aks-cluster-using-powershell-in-azure-portal/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AKS Cluster Setup Using Azure CLI with OIDC &#038; Azure Key Vault Integration</title>
		<link>https://www.abdulrahmanuk.com/aks-cluster-setup-using-azure-cli-with-oidc-azure-key-vault-integration/</link>
					<comments>https://www.abdulrahmanuk.com/aks-cluster-setup-using-azure-cli-with-oidc-azure-key-vault-integration/#respond</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Mon, 23 Jun 2025 01:36:03 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[Kubernetes]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[devops]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=574</guid>

					<description><![CDATA[<p>If you&#8217;re more comfortable using the Azure CLI, here&#8217;s how to set up an AKS cluster with Azure Key Vault integration using the Secrets Store CSI Driver, along with OIDC (OpenID Connect) support and Workload Identity. This is especially useful for secure, production-grade Kubernetes deployments. ✅ Step 1: Create an Azure Resource Group This creates [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/aks-cluster-setup-using-azure-cli-with-oidc-azure-key-vault-integration/">AKS Cluster Setup Using Azure CLI with OIDC &amp; Azure Key Vault Integration</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>If you&#8217;re more comfortable using the <strong>Azure CLI</strong>, here&#8217;s how to set up an <strong>AKS cluster with Azure Key Vault integration</strong> using the <strong>Secrets Store CSI Driver</strong>, along with <strong>OIDC (OpenID Connect) support</strong> and <strong>Workload Identity</strong>. This is especially useful for secure, production-grade Kubernetes deployments.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 1: Create an Azure Resource Group</h3>



<pre class="wp-block-code"><code><code>az group create --name keyvault-demo --location eastus
</code></code></pre>



<p>This creates a logical container for your AKS resources.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f680.png" alt="🚀" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 2: Create the AKS Cluster with Workload Identity and Azure Key Vault Integration</h3>



<pre class="wp-block-code"><code><code>az aks create \
  --name keyvault-demo-cluster \
  --resource-group keyvault-demo \
  --node-count 1 \
  --enable-addons azure-keyvault-secrets-provider \
  --enable-oidc-issuer \
  --enable-workload-identity
</code></code></pre>



<h4 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2699.png" alt="⚙" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Explanation of Flags:</h4>



<ul class="wp-block-list">
<li><code>--enable-addons azure-keyvault-secrets-provider</code>: Installs the CSI driver and Azure Key Vault provider addon.</li>



<li><code>--enable-oidc-issuer</code>: Enables the OIDC issuer URL for secure authentication with federated identity.</li>



<li><code>--enable-workload-identity</code>: Activates Azure Workload Identity (replacement for AAD Pod Identity).</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f510.png" alt="🔐" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 3: Get AKS Credentials for kubectl</h3>



<pre class="wp-block-code"><code><code>az aks get-credentials \
  --resource-group keyvault-demo \
  --name keyvault-demo-cluster
</code></code></pre>



<p>This updates your local kubeconfig so you can interact with the new cluster.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f50d.png" alt="🔍" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 4: Verify CSI Driver and Azure Provider Pods</h3>



<p>Make sure everything is running correctly:</p>



<pre class="wp-block-code"><code><code>kubectl get pods -n kube-system -l 'app in (secrets-store-csi-driver,secrets-store-provider-azure)' -o wide
</code></code></pre>



<p>You should see pods like:</p>



<ul class="wp-block-list">
<li><code>secrets-store-csi-driver-*</code></li>



<li><code>secrets-store-provider-azure-*</code></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f510.png" alt="🔐" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Bonus: Why Use Azure Key Vault with AKS?</h2>



<ul class="wp-block-list">
<li><strong>Centralized Secrets Management</strong></li>



<li><strong>Automatic Secret Rotation</strong></li>



<li><strong>No Secret Mounting in Code</strong></li>



<li><strong>Secure Identity Binding with Workload Identity</strong></li>
</ul>



<p>This setup is cloud-native, secure, and production-ready.</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/aks-cluster-setup-using-azure-cli-with-oidc-azure-key-vault-integration/">AKS Cluster Setup Using Azure CLI with OIDC &amp; Azure Key Vault Integration</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/aks-cluster-setup-using-azure-cli-with-oidc-azure-key-vault-integration/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
