<?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>abdulrahmanuk.com</title>
	<atom:link href="https://www.abdulrahmanuk.com/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 08:07:31 +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>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>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>
		<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>Kubernetes Resource Limits Simplified – From Beginner to Production Ready</title>
		<link>https://www.abdulrahmanuk.com/kubernetes-resource-limits-simplified-from-beginner-to-production-ready/</link>
					<comments>https://www.abdulrahmanuk.com/kubernetes-resource-limits-simplified-from-beginner-to-production-ready/#respond</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Sun, 15 Jun 2025 13:08:20 +0000</pubDate>
				<category><![CDATA[Kubernetes]]></category>
		<category><![CDATA[devops]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=545</guid>

					<description><![CDATA[<p>In the world of Kubernetes, managing resources wisely is key to keeping your cluster healthy and your workloads running smoothly. Without proper controls, one application can easily consume more than its fair share of CPU, memory, or pods, leading to resource contention and system instability. Thankfully, Kubernetes provides powerful tools to enforce resource limits at [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/kubernetes-resource-limits-simplified-from-beginner-to-production-ready/">Kubernetes Resource Limits Simplified – From Beginner to Production Ready</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In the world of <strong>Kubernetes</strong>, managing resources wisely is key to keeping your cluster healthy and your workloads running smoothly. Without proper controls, one application can easily consume more than its fair share of CPU, memory, or pods, leading to resource contention and system instability.</p>



<p>Thankfully, Kubernetes provides powerful tools to enforce <strong>resource limits at the namespace level</strong>, allowing teams to share the cluster fairly. In this blog post, we’ll explore two important tools for namespace-level resource management:</p>



<ul class="wp-block-list">
<li><strong>Resource Quotas</strong></li>



<li><strong>Limit Ranges</strong></li>
</ul>



<p>Let’s dive in and see how they work, with practical examples to help you get started.</p>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f539.png" alt="🔹" class="wp-smiley" style="height: 1em; max-height: 1em;" /> What Are Resource Quotas in Kubernetes?</h2>



<p><strong>Resource Quotas</strong> let administrators cap the total amount of resources that a specific namespace can use. Think of it as setting a budget for pods, CPU, memory, and other compute resources.</p>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4cc.png" alt="📌" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Why Use Resource Quotas?</h3>



<ul class="wp-block-list">
<li>Define clear usage boundaries per namespace.</li>



<li>Monitor and track resource usage in real-time.</li>



<li>Automatically block workloads that try to exceed their limits.</li>
</ul>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f6e0.png" alt="🛠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> How to Set a Resource Quota</h3>



<p>To apply a Resource Quota, create a YAML file and apply it to the relevant namespace.</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"><textarea class="code-block-pro-copy-button-textarea" aria-hidden="true" readonly>apiVersion: v1
kind: ResourceQuota
metadata:
  name: resource-quota-example
  namespace: example-namespace
spec:
  hard:
    pods: &#8220;1&#8221;
    requests.cpu: &#8220;2&#8221;
    requests.memory: &#8220;5Gi&#8221;
    limits.cpu: &#8220;4&#8221;
    limits.memory: &#8220;10Gi&#8221;</textarea><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: ResourceQuota</span></span>
<span class="line"><span style="color: #A6ACCD">metadata:</span></span>
<span class="line"><span style="color: #A6ACCD">  name: resource-quota-example</span></span>
<span class="line"><span style="color: #A6ACCD">  namespace: example-namespace</span></span>
<span class="line"><span style="color: #A6ACCD">spec:</span></span>
<span class="line"><span style="color: #A6ACCD">  hard:</span></span>
<span class="line"><span style="color: #A6ACCD">    pods: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">1</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    requests.cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">2</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    requests.memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">5Gi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    limits.cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">4</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    limits.memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">10Gi</span><span style="color: #A6ACCD">&quot;</span></span></code></pre></div>



<p>Then apply it using:</p>



<pre class="wp-block-code"><code>kubectl apply -f resource-quota.yaml</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;" /> This will limit the <code>example-namespace</code> to <strong>1 pod</strong>, <strong>2 CPU requests</strong>, <strong>5Gi of memory requests</strong>, and caps CPU and memory usage at <strong>4 CPUs</strong> and <strong>10Gi</strong>, respectively.</p>



<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;" /> Verifying the Resource Quota</h3>



<p>Check if the quota has been successfully applied:</p>



<pre class="wp-block-code"><code>kubectl get resourcequota resource-quota-example -n example-namespace</code></pre>



<p>Or to get detailed info:</p>



<pre class="wp-block-code"><code>kubectl describe ns example-namespace</code></pre>



<p>Sample output:</p>



<pre class="wp-block-preformatted">Resource         Used  Hard<br>limits.cpu       0     4<br>limits.memory    0     10Gi<br>pods             0     1<br>requests.cpu     0     2<br>requests.memory  0     5Gi</pre>



<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;" /> Testing Quota Enforcement</h3>



<p>Let’s try deploying more pods than allowed to see the quota in action.</p>



<p><strong>Deployment with 2 replicas (but the quota allows only 1):</strong></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"><textarea class="code-block-pro-copy-button-textarea" aria-hidden="true" readonly>apiVersion: apps/v1
kind: Deployment
metadata:
  name: quota-test
  namespace: example-namespace
  labels:
    app: deployment-label
spec:
  replicas: 2
  selector:
    matchLabels:
      app: deployment-label
  template:
    metadata:
      labels:
        app: deployment-label
    spec:
      containers:
      &#8211; name: nginx-deploy
        image: nginx:latest
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
          limits:
            cpu: 100m
            memory: 100Mi</textarea><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: quota-test</span></span>
<span class="line"><span style="color: #A6ACCD">  namespace: example-namespace</span></span>
<span class="line"><span style="color: #A6ACCD">  labels:</span></span>
<span class="line"><span style="color: #A6ACCD">    app: deployment-label</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">2</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: deployment-label</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: deployment-label</span></span>
<span class="line"><span style="color: #A6ACCD">    spec:</span></span>
<span class="line"><span style="color: #A6ACCD">      containers:</span></span>
<span class="line"><span style="color: #A6ACCD">      - name: nginx-deploy</span></span>
<span class="line"><span style="color: #A6ACCD">        image: nginx:latest</span></span>
<span class="line"><span style="color: #A6ACCD">        resources:</span></span>
<span class="line"><span style="color: #A6ACCD">          requests:</span></span>
<span class="line"><span style="color: #A6ACCD">            cpu: </span><span style="color: #5DE4C7">100</span><span style="color: #A6ACCD">m</span></span>
<span class="line"><span style="color: #A6ACCD">            memory: </span><span style="color: #5DE4C7">100</span><span style="color: #A6ACCD">Mi</span></span>
<span class="line"><span style="color: #A6ACCD">          limits:</span></span>
<span class="line"><span style="color: #A6ACCD">            cpu: </span><span style="color: #5DE4C7">100</span><span style="color: #A6ACCD">m</span></span>
<span class="line"><span style="color: #A6ACCD">            memory: </span><span style="color: #5DE4C7">100</span><span style="color: #A6ACCD">Mi</span></span></code></pre></div>



<p>Apply the deployment:</p>



<pre class="wp-block-preformatted">kubectl apply -f deploy.yaml<br></pre>



<p>Check the pod status:</p>



<pre class="wp-block-preformatted">kubectl get all -n example-namespace<br></pre>



<p>ou’ll see something like:</p>



<pre class="wp-block-preformatted">Warning  FailedCreate  pods "quota-test-xxxx" is forbidden: exceeded quota: resource-quota-example...</pre>



<p>The second pod fails to start—<strong>exactly what we want</strong>. The quota is working as intended!</p>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f539.png" alt="🔹" class="wp-smiley" style="height: 1em; max-height: 1em;" /> What Are Limit Ranges in Kubernetes?</h2>



<p>While Resource Quotas set overall namespace limits, <strong>Limit Ranges</strong> control the <strong>default and maximum/minimum resource limits for each pod, container, or PVC</strong>. This ensures no single pod or container hogs cluster resources.</p>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4cc.png" alt="📌" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Why Use Limit Ranges?</h3>



<ul class="wp-block-list">
<li>Enforce consistent resource consumption across deployments.</li>



<li>Prevent resource abuse by setting sensible defaults.</li>



<li>Ensure all pods have a minimum allocation for healthy operation.</li>
</ul>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f6e0.png" alt="🛠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> How to Set a Limit Range</h3>



<p>Create a <code>limit-range.yaml</code> file:</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"><textarea class="code-block-pro-copy-button-textarea" aria-hidden="true" readonly>apiVersion: v1
kind: LimitRange
metadata:
  name: limit-range-example
  namespace: example-namespace
spec:
  limits:
  &#8211; type: Pod
    max:
      cpu: &#8220;2&#8221;
      memory: &#8220;4Gi&#8221;
    min:
      cpu: &#8220;200m&#8221;
      memory: &#8220;256Mi&#8221;
    maxLimitRequestRatio:
      cpu: &#8220;4&#8221;
      memory: &#8220;8&#8221;
  &#8211; type: Container
    default:
      cpu: &#8220;500m&#8221;
      memory: &#8220;512Mi&#8221;
    defaultRequest:
      cpu: &#8220;250m&#8221;
      memory: &#8220;256Mi&#8221;
    max:
      cpu: &#8220;1&#8221;
      memory: &#8220;1Gi&#8221;
    min:
      cpu: &#8220;100m&#8221;
      memory: &#8220;128Mi&#8221;
    maxLimitRequestRatio:
      cpu: &#8220;2&#8221;
      memory: &#8220;4&#8221;
  &#8211; type: PersistentVolumeClaim
    max:
      storage: &#8220;10Gi&#8221;
    min:
      storage: &#8220;1Gi&#8221;
    default:
      storage: &#8220;5Gi&#8221;
    defaultRequest:
      storage: &#8220;2Gi&#8221;
    maxLimitRequestRatio:
      storage: &#8220;2&#8221;</textarea><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: LimitRange</span></span>
<span class="line"><span style="color: #A6ACCD">metadata:</span></span>
<span class="line"><span style="color: #A6ACCD">  name: limit-range-example</span></span>
<span class="line"><span style="color: #A6ACCD">  namespace: example-namespace</span></span>
<span class="line"><span style="color: #A6ACCD">spec:</span></span>
<span class="line"><span style="color: #A6ACCD">  limits:</span></span>
<span class="line"><span style="color: #A6ACCD">  - type: Pod</span></span>
<span class="line"><span style="color: #A6ACCD">    max:</span></span>
<span class="line"><span style="color: #A6ACCD">      cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">2</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">      memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">4Gi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    min:</span></span>
<span class="line"><span style="color: #A6ACCD">      cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">200m</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">      memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">256Mi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    maxLimitRequestRatio:</span></span>
<span class="line"><span style="color: #A6ACCD">      cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">4</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">      memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">8</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">  - type: Container</span></span>
<span class="line"><span style="color: #A6ACCD">    default:</span></span>
<span class="line"><span style="color: #A6ACCD">      cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">500m</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">      memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">512Mi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    defaultRequest:</span></span>
<span class="line"><span style="color: #A6ACCD">      cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">250m</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">      memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">256Mi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    max:</span></span>
<span class="line"><span style="color: #A6ACCD">      cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">1</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">      memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">1Gi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    min:</span></span>
<span class="line"><span style="color: #A6ACCD">      cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">100m</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">      memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">128Mi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    maxLimitRequestRatio:</span></span>
<span class="line"><span style="color: #A6ACCD">      cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">2</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">      memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">4</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">  - type: PersistentVolumeClaim</span></span>
<span class="line"><span style="color: #A6ACCD">    max:</span></span>
<span class="line"><span style="color: #A6ACCD">      storage: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">10Gi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    min:</span></span>
<span class="line"><span style="color: #A6ACCD">      storage: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">1Gi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    default:</span></span>
<span class="line"><span style="color: #A6ACCD">      storage: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">5Gi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    defaultRequest:</span></span>
<span class="line"><span style="color: #A6ACCD">      storage: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">2Gi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    maxLimitRequestRatio:</span></span>
<span class="line"><span style="color: #A6ACCD">      storage: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">2</span><span style="color: #A6ACCD">&quot;</span></span></code></pre></div>



<p>Apply it:</p>



<pre class="wp-block-preformatted"><code>kubectl apply -f limit-range.yaml<br></code></pre>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9e0.png" alt="🧠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Limit Ranges apply defaults <em>automatically</em> to pods if you forget to specify them!</p>
</blockquote>



<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;" /> Verifying the Limit Range</h3>



<p>Use the following commands:</p>



<pre class="wp-block-preformatted">kubectl describe limitrange limit-range-example -n example-namespace<br>kubectl describe ns example-namespace</pre>



<p>You’ll see something like:</p>



<pre class="wp-block-preformatted">Type                   Resource  Min    Max   Default Request  Default Limit  Max Limit/Request Ratio<br>Pod                    cpu       200m   2     -                -              4<br>Pod                    memory    256Mi  4Gi   -                -              8<br>Container              cpu       100m   1     250m             500m           2<br>Container              memory    128Mi  1Gi   256Mi            512Mi          4<br>PersistentVolumeClaim  storage   1Gi    10Gi  2Gi              5Gi            2</pre>



<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;" /> Testing the Limit Range in Action</h3>



<p>Create a deployment <strong>without resource specs</strong> and watch the defaults kick in:</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"><textarea class="code-block-pro-copy-button-textarea" aria-hidden="true" readonly>apiVersion: apps/v1
kind: Deployment
metadata:
  name: limit-test
  namespace: example-namespace
  labels:
    app: deployment-label
spec:
  replicas: 1
  selector:
    matchLabels:
      app: deployment-label
  template:
    metadata:
      labels:
        app: deployment-label
    spec:
      containers:
      &#8211; name: nginx-deploy
        image: nginx:latest</textarea><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: limit-test</span></span>
<span class="line"><span style="color: #A6ACCD">  namespace: example-namespace</span></span>
<span class="line"><span style="color: #A6ACCD">  labels:</span></span>
<span class="line"><span style="color: #A6ACCD">    app: deployment-label</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: deployment-label</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: deployment-label</span></span>
<span class="line"><span style="color: #A6ACCD">    spec:</span></span>
<span class="line"><span style="color: #A6ACCD">      containers:</span></span>
<span class="line"><span style="color: #A6ACCD">      - name: nginx-deploy</span></span>
<span class="line"><span style="color: #A6ACCD">        image: nginx:latest</span></span></code></pre></div>



<p>Apply it:</p>



<pre class="wp-block-preformatted"><code>kubectl apply -f deploy.yaml<br></code></pre>



<p>Now describe the pod and you&#8217;ll notice the resource requests and limits are automatically applied based on the LimitRange!</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/1f9e9.png" alt="🧩" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Final Thoughts</h2>



<p><strong>Namespace-level resource control</strong> in Kubernetes is not just a best practice—it’s a necessity for scalable and stable clusters.</p>



<p><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;" /> Use <strong>Resource Quotas</strong> to enforce overall limits per namespace.<br><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;" /> Use <strong>Limit Ranges</strong> to set smart defaults and enforce per-container or per-pod limits.</p>



<p>By combining both, you ensure fair resource distribution, avoid noisy neighbor problems, and maintain consistent workload performance across your Kubernetes environment.</p>



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



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4ac.png" alt="💬" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Got questions about resource management in Kubernetes?<br><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4e9.png" alt="📩" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Drop a comment below or connect with me for more DevOps tips and Kubernetes best practices.</p>



<p>Happy Clustering! <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;" /></p>



<p></p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/kubernetes-resource-limits-simplified-from-beginner-to-production-ready/">Kubernetes Resource Limits Simplified – From Beginner to Production Ready</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/kubernetes-resource-limits-simplified-from-beginner-to-production-ready/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>35 Must-Know Linux Commands Every DevOps Engineer Should Master (with Real DevOps Use Cases)</title>
		<link>https://www.abdulrahmanuk.com/35-must-know-linux-commands-every-devops-engineer-should-master-with-real-devops-use-cases/</link>
					<comments>https://www.abdulrahmanuk.com/35-must-know-linux-commands-every-devops-engineer-should-master-with-real-devops-use-cases/#respond</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Fri, 23 May 2025 06:13:05 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=534</guid>

					<description><![CDATA[<p>Introduction As a DevOps engineer, mastering Linux is non-negotiable. Whether you&#8217;re deploying microservices, debugging performance issues, managing cloud infrastructure, or building CI/CD pipelines, Linux commands are at the core of your workflow. This guide walks you through 35 essential Linux commands, each with real-world use cases tailored for DevOps. 🔧 File &#38; Directory Operations 📁 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/35-must-know-linux-commands-every-devops-engineer-should-master-with-real-devops-use-cases/">35 Must-Know Linux Commands Every DevOps Engineer Should Master (with Real DevOps Use Cases)</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p><strong>Introduction</strong></p>



<p>As a DevOps engineer, mastering Linux is non-negotiable. Whether you&#8217;re deploying microservices, debugging performance issues, managing cloud infrastructure, or building CI/CD pipelines, Linux commands are at the core of your workflow. This guide walks you through 35 essential Linux commands, each with real-world use cases tailored for DevOps.</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/1f527.png" alt="🔧" class="wp-smiley" style="height: 1em; max-height: 1em;" /> File &amp; Directory Operations</h3>



<ol class="wp-block-list">
<li><strong><code>ls</code></strong> – List files and directories.
<ul class="wp-block-list">
<li><code>ls -lah</code> shows file sizes and permissions.</li>
</ul>
</li>



<li><strong><code>cd</code></strong> – Change directories.
<ul class="wp-block-list">
<li>Navigate efficiently in scripts: <code>cd /var/www/html</code>.</li>
</ul>
</li>



<li><strong><code>pwd</code></strong> – Print working directory.
<ul class="wp-block-list">
<li>Useful for debugging scripts.</li>
</ul>
</li>



<li><strong><code>mkdir</code></strong> – Create directories.
<ul class="wp-block-list">
<li>Example: <code>mkdir -p /opt/myapp/logs</code> creates nested folders.</li>
</ul>
</li>



<li><strong><code>touch</code></strong> – Create empty files.
<ul class="wp-block-list">
<li>Used to create <code>.env</code> or placeholder files in pipelines.</li>
</ul>
</li>



<li><strong><code>rm</code></strong> – Remove files and directories.
<ul class="wp-block-list">
<li>Caution: <code>rm -rf /some/path</code> can be destructive. Automate cleanup jobs.</li>
</ul>
</li>



<li><strong><code>cp</code></strong> – Copy files and directories.
<ul class="wp-block-list">
<li>Example: <code>cp config.yaml config.yaml.bak</code> before updates.</li>
</ul>
</li>



<li><strong><code>mv</code></strong> – Move or rename files.
<ul class="wp-block-list">
<li>Use in deployment steps: <code>mv new.html index.html</code></li>
</ul>
</li>



<li><strong><code>find</code></strong> – Search for files.
<ul class="wp-block-list">
<li><code>find /var/log -name "*.log"</code> to identify large log files.</li>
</ul>
</li>



<li><strong><code>du</code></strong> – Estimate file space usage.
<ul class="wp-block-list">
<li><code>du -sh *</code> shows space used by directories.</li>
</ul>
</li>
</ol>



<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/1f4c1.png" alt="📁" class="wp-smiley" style="height: 1em; max-height: 1em;" /> File Viewing &amp; Manipulation</h3>



<ol start="11" class="wp-block-list">
<li><strong><code>cat</code></strong> – View file contents.
<ul class="wp-block-list">
<li>Combine with <code>grep</code> for quick searches.</li>
</ul>
</li>



<li><strong><code>less</code> / <code>more</code></strong> – Page through text.
<ul class="wp-block-list">
<li><code>less /var/log/syslog</code> to view logs comfortably.</li>
</ul>
</li>



<li><strong><code>head</code> / <code>tail</code></strong> – View the start or end of files.
<ul class="wp-block-list">
<li><code>tail -f /var/log/nginx/access.log</code> for live logs.</li>
</ul>
</li>



<li><strong><code>grep</code></strong> – Search text with patterns.
<ul class="wp-block-list">
<li>Example: <code>grep "ERROR" /var/log/app.log</code></li>
</ul>
</li>



<li><strong><code>awk</code></strong> – Pattern scanning and data extraction.
<ul class="wp-block-list">
<li>Real use: <code>awk -F":" '{ print $1 }' /etc/passwd</code> to list usernames.</li>
</ul>
</li>



<li><strong><code>sed</code></strong> – Stream editor for modifying files.
<ul class="wp-block-list">
<li>Replace text in files: <code>sed -i 's/foo/bar/g' config.txt</code></li>
</ul>
</li>



<li><strong><code>cut</code></strong> – Extract fields from text.
<ul class="wp-block-list">
<li><code>cut -d':' -f1 /etc/passwd</code></li>
</ul>
</li>



<li><strong><code>sort</code></strong> – Sort lines in text files.
<ul class="wp-block-list">
<li>Useful in processing pipeline logs or output.</li>
</ul>
</li>



<li><strong><code>uniq</code></strong> – Filter out repeated lines.
<ul class="wp-block-list">
<li><code>sort data.txt | uniq -c</code> shows duplicates.</li>
</ul>
</li>
</ol>



<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;" /> Permissions &amp; Ownership</h3>



<ol start="20" class="wp-block-list">
<li><strong><code>chmod</code></strong> – Change file permissions.
<ul class="wp-block-list">
<li><code>chmod 755 script.sh</code> makes it executable.</li>
</ul>
</li>



<li><strong><code>chown</code></strong> – Change file owner and group.
<ul class="wp-block-list">
<li><code>chown www-data:www-data /var/www/html -R</code></li>
</ul>
</li>



<li><strong><code>umask</code></strong> – Set default permissions.
<ul class="wp-block-list">
<li>Often set in init scripts.</li>
</ul>
</li>



<li><strong><code>stat</code></strong> – Display detailed file info.
<ul class="wp-block-list">
<li>Helps in debugging file access issues.</li>
</ul>
</li>
</ol>



<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/1f4ca.png" alt="📊" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Process &amp; Resource Management</h3>



<ol start="24" class="wp-block-list">
<li><strong><code>ps</code></strong> – Display current processes.
<ul class="wp-block-list">
<li><code>ps aux | grep nginx</code> to locate specific services.</li>
</ul>
</li>



<li><strong><code>top</code> / <code>htop</code></strong> – Monitor system resource usage.
<ul class="wp-block-list">
<li><code>htop</code> is interactive and user-friendly.</li>
</ul>
</li>



<li><strong><code>kill</code> / <code>killall</code></strong> – Terminate processes.
<ul class="wp-block-list">
<li><code>kill -9 &lt;PID></code> to forcefully stop rogue processes.</li>
</ul>
</li>



<li><strong><code>nice</code> / <code>renice</code></strong> – Set process priority.
<ul class="wp-block-list">
<li>Adjust priority for resource-hungry tasks.</li>
</ul>
</li>



<li><strong><code>lsof</code></strong> – List open files.
<ul class="wp-block-list">
<li>Debug file locks: <code>lsof | grep deleted</code></li>
</ul>
</li>



<li><strong><code>strace</code></strong> – Trace system calls.
<ul class="wp-block-list">
<li>Debug startup issues: <code>strace ./myapp</code></li>
</ul>
</li>
</ol>



<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;" /> Networking &amp; Troubleshooting</h3>



<ol start="30" class="wp-block-list">
<li><strong><code>curl</code></strong> – Transfer data to/from a server.
<ul class="wp-block-list">
<li>Test APIs: <code>curl -X POST -d '{}' https://api.example.com</code></li>
</ul>
</li>



<li><strong><code>wget</code></strong> – Non-interactive file download.
<ul class="wp-block-list">
<li><code>wget https://downloads.example.com/tool.sh</code></li>
</ul>
</li>



<li><strong><code>netstat</code> / <code>ss</code></strong> – Network statistics.
<ul class="wp-block-list">
<li><code>ss -tulnp</code> shows listening ports.</li>
</ul>
</li>



<li><strong><code>tcpdump</code></strong> – Capture network traffic.
<ul class="wp-block-list">
<li>Debug latency: <code>tcpdump -i eth0 port 80</code></li>
</ul>
</li>



<li><strong><code>ping</code> / <code>traceroute</code></strong> – Network connectivity.
<ul class="wp-block-list">
<li>Identify broken routes or DNS issues.</li>
</ul>
</li>
</ol>



<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/1f504.png" alt="🔄" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Automation &amp; Scripting</h3>



<ol start="35" class="wp-block-list">
<li><strong><code>xargs</code></strong> – Build and execute commands from input.
<ul class="wp-block-list">
<li>Bulk operations: <code>cat urls.txt | xargs wget</code></li>
</ul>
</li>
</ol>



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



<p><strong><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f539.png" alt="🔹" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Real DevOps Use Case Highlights:</strong></p>



<ul class="wp-block-list">
<li><strong>Using <code>awk</code> in CI/CD</strong>: Extract version info from files and pass it to Docker.</li>



<li><strong><code>lsof</code> to troubleshoot</strong>: Find services holding deleted files and causing disk bloat.</li>



<li><strong><code>sed</code> in automation</strong>: Replace environment variables during deployment.</li>



<li><strong><code>tail -f</code> in monitoring</strong>: View live logs in Kubernetes pods.</li>



<li><strong><code>xargs</code> for batch tasks</strong>: Automate bulk log rotation or file downloads.</li>
</ul>



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



<p><strong>Conclusion</strong></p>



<p>Mastering these 35 Linux commands will not only boost your productivity but also help you troubleshoot and automate your infrastructure with confidence. Bookmark this list and start integrating these commands into your daily workflow. Want more DevOps content? Follow me on LinkedIn and stay tuned for upcoming posts on Ansible, Docker, Kubernetes, and Terraform!</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/35-must-know-linux-commands-every-devops-engineer-should-master-with-real-devops-use-cases/">35 Must-Know Linux Commands Every DevOps Engineer Should Master (with Real DevOps Use Cases)</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/35-must-know-linux-commands-every-devops-engineer-should-master-with-real-devops-use-cases/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Creating a Highly Available MySQL InnoDB Cluster</title>
		<link>https://www.abdulrahmanuk.com/creating-a-highly-available-mysql-innodb-cluster/</link>
					<comments>https://www.abdulrahmanuk.com/creating-a-highly-available-mysql-innodb-cluster/#comments</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Thu, 17 Apr 2025 22:31:28 +0000</pubDate>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[devops]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=517</guid>

					<description><![CDATA[<p>Setting up a highly available MySQL InnoDB Cluster with MySQL Router, group replication, automatic failover, and point-in-time recovery can be complex, but I’ll break everything down into step-by-step instructions with explanations, suitable for beginners. This guide summarizes my real-world setup journey for a production-ready MySQL cluster with a dedicated MySQL Router VM, backups, and failover [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/creating-a-highly-available-mysql-innodb-cluster/">Creating a Highly Available MySQL InnoDB Cluster</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Setting up a <strong>highly available MySQL InnoDB Cluster</strong> with <strong>MySQL Router</strong>, <strong>group replication</strong>, <strong>automatic failover</strong>, and <strong>point-in-time recovery</strong> can be complex, but I’ll break everything down into <strong>step-by-step instructions with explanations</strong>, suitable for beginners. This guide summarizes my real-world setup journey for a production-ready MySQL cluster with a dedicated MySQL Router VM, backups, and failover handling.</p>



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



<ol class="wp-block-list">
<li><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9e0.png" alt="🧠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>3 MySQL Nodes</strong>: 1 primary (writer) + 2 secondaries (readers)</li>



<li><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f501.png" alt="🔁" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Group Replication</strong> for HA</li>



<li><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f6aa.png" alt="🚪" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>MySQL Router</strong> (deployed on a separate VM for better failover control)</li>



<li><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;" /> <strong>Backups</strong> (dump + binary logs) for PITR</li>
</ol>



<p><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;" /> <strong>Pre-requisites</strong><br>Ubuntu VMs (each with at least 2 vCPUs and 4GB RAM recommended)<br>All VMs must be reachable via an internal network.<br>MySQL port (3306) and Group Replication ports (33061, 33062) must be open.</p>



<p>I had created 3 VMs on Azure Cloud to create the MySQL Cluster architecture</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2560" height="1213" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-scaled.png" alt="image 9 scaled" class="wp-image-527" title="Creating a Highly Available MySQL InnoDB Cluster 9" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-scaled.png 2560w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-768x364.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-1536x728.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-2048x971.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-150x71.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-300x142.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-696x330.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-1068x506.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-1920x910.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-600x284.png 600w" sizes="auto, (max-width: 2560px) 100vw, 2560px" /></figure>



<h5 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: Install MySQL on All Nodes</h5>



<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" data-code="sudo apt update &amp;&amp; sudo apt install mysql-server net-tools -y
wget https://repo.mysql.com//mysql-apt-config_0.8.34-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.34-1_all.deb
sudo apt update &amp;&amp; sudo apt install mysql-shell -y
" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">sudo apt update &amp;&amp; sudo apt install mysql-server net-tools -y</span></span>
<span class="line"><span style="color: #A6ACCD">wget https:</span><span style="color: #767C9DB0; font-style: italic">//repo.mysql.com//mysql-apt-config_0.8.34-1_all.deb</span></span>
<span class="line"><span style="color: #A6ACCD">sudo dpkg -i mysql-apt-config_</span><span style="color: #5DE4C7">0.8</span><span style="color: #A6ACCD">.</span><span style="color: #5DE4C7">34-1</span><span style="color: #A6ACCD">_all.deb</span></span>
<span class="line"><span style="color: #A6ACCD">sudo apt update &amp;&amp; sudo apt install mysql-shell -y</span></span>
<span class="line"></span></code></pre></div>



<p>Check that MySQL is running and listening on 3306 on each node (especially node01):</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" data-code="sudo netstat -tulnp | grep 3306" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">sudo netstat -tulnp | grep </span><span style="color: #5DE4C7">3306</span></span></code></pre></div>



<pre class="wp-block-code"><code>#You should see something like:
**tcp &nbsp; 0&nbsp; 0 0.0.0.0:3306 &nbsp; 0.0.0.0:* &nbsp; LISTEN &nbsp; 1234/mysqld**</code></pre>



<pre class="wp-block-code"><code>If it only shows 127.0.0.1:3306, then MySQL is **not listening on external IPs**.
&#x1f449; **To fix that:**
Edit your mysqld.cnf (location: /etc/mysql/mysql.conf.d/mysqld.cnf):

**bind-address = 0.0.0.0**</code></pre>



<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" data-code="sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
# Set bind-address to:
bind-address = 0.0.0.0
" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf</span></span>
<span class="line"><span style="color: #A6ACCD"># Set bind-address to:</span></span>
<span class="line"><span style="color: #A6ACCD">bind-address = </span><span style="color: #5DE4C7">0.0</span><span style="color: #A6ACCD">.</span><span style="color: #5DE4C7">0.0</span></span>
<span class="line"></span></code></pre></div>



<p>Then restart:</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" data-code="sudo systemctl restart mysql" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">sudo systemctl restart mysql</span></span></code></pre></div>



<h5 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;" /> Step 2: Configure Each MySQL Node</h5>



<p>Create a config file <code>/etc/mysql/mysql.conf.d/group_replication.cnf</code> on each node.<br><strong>Example (for node01):</strong></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" data-code="[mysqld]
# Server identity (must be unique for each node)
server-id=1  # node01 = 1, node02 = 2, node03 = 3 (change accordingly)

# Enable binary logging
log_bin = mysql-bin
binlog_format = ROW
binlog_checksum = NONE
transaction_write_set_extraction = XXHASH64

# Enable GTID
gtid_mode = ON
enforce_gtid_consistency = ON

# Group Replication settings
loose-group_replication_group_name=&quot;aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&quot;
loose-group_replication_start_on_boot=off
loose-group_replication_bootstrap_group=off
loose-group_replication_local_address=&quot;node01:33061&quot;  # Change per node
loose-group_replication_group_seeds=&quot;node01:33061,node02:33061,node03:33061&quot;
loose-group_replication_single_primary_mode=ON
loose-group_replication_enforce_update_everywhere_checks=OFF

# Networking
report_host=node01  # change for each node
bind-address=0.0.0.0
mysqlx-bind-address=0.0.0.0

# InnoDB settings
innodb_flush_log_at_trx_commit = 1
sync_binlog = 1
" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">[</span><span style="color: #D0679D">mysqld</span><span style="color: #A6ACCD">]</span></span>
<span class="line"><span style="color: #A6ACCD"># Server identity (must be unique for each node)</span></span>
<span class="line"><span style="color: #A6ACCD">server-id=</span><span style="color: #5DE4C7">1</span><span style="color: #A6ACCD">  # node</span><span style="color: #5DE4C7">01</span><span style="color: #A6ACCD"> = </span><span style="color: #5DE4C7">1</span><span style="color: #A6ACCD">, node</span><span style="color: #5DE4C7">02</span><span style="color: #A6ACCD"> = </span><span style="color: #5DE4C7">2</span><span style="color: #A6ACCD">, node</span><span style="color: #5DE4C7">03</span><span style="color: #A6ACCD"> = </span><span style="color: #5DE4C7">3</span><span style="color: #A6ACCD"> (change accordingly)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD"># Enable binary logging</span></span>
<span class="line"><span style="color: #A6ACCD">log_bin = mysql-bin</span></span>
<span class="line"><span style="color: #A6ACCD">binlog_format = ROW</span></span>
<span class="line"><span style="color: #A6ACCD">binlog_checksum = NONE</span></span>
<span class="line"><span style="color: #A6ACCD">transaction_write_set_extraction = XXHASH</span><span style="color: #5DE4C7">64</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD"># Enable GTID</span></span>
<span class="line"><span style="color: #A6ACCD">gtid_mode = ON</span></span>
<span class="line"><span style="color: #A6ACCD">enforce_gtid_consistency = ON</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD"># Group Replication settings</span></span>
<span class="line"><span style="color: #A6ACCD">loose-group_replication_group_name=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">loose-group_replication_start_on_boot=off</span></span>
<span class="line"><span style="color: #A6ACCD">loose-group_replication_bootstrap_group=off</span></span>
<span class="line"><span style="color: #A6ACCD">loose-group_replication_local_address=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">node01:33061</span><span style="color: #A6ACCD">&quot;</span><span style="color: #A6ACCD">  # Change per node</span></span>
<span class="line"><span style="color: #A6ACCD">loose-group_replication_group_seeds=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">node01:33061,node02:33061,node03:33061</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">loose-group_replication_single_primary_mode=ON</span></span>
<span class="line"><span style="color: #A6ACCD">loose-group_replication_enforce_update_everywhere_checks=OFF</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD"># Networking</span></span>
<span class="line"><span style="color: #A6ACCD">report_host=node</span><span style="color: #5DE4C7">01</span><span style="color: #A6ACCD">  # change for each node</span></span>
<span class="line"><span style="color: #A6ACCD">bind-address=</span><span style="color: #5DE4C7">0.0</span><span style="color: #A6ACCD">.</span><span style="color: #5DE4C7">0.0</span></span>
<span class="line"><span style="color: #A6ACCD">mysqlx-bind-address=</span><span style="color: #5DE4C7">0.0</span><span style="color: #A6ACCD">.</span><span style="color: #5DE4C7">0.0</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD"># InnoDB settings</span></span>
<span class="line"><span style="color: #A6ACCD">innodb_flush_log_at_trx_commit = </span><span style="color: #5DE4C7">1</span></span>
<span class="line"><span style="color: #A6ACCD">sync_binlog = </span><span style="color: #5DE4C7">1</span></span>
<span class="line"></span></code></pre></div>



<p>Make sure each node has a <strong>unique <code>server-id</code></strong> and correct <code>report_host</code>.</p>



<h5 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f464.png" alt="👤" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 3: Create a Cluster Admin User</h5>



<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" data-code="CREATE USER 'clusteradmin'@'%' IDENTIFIED BY 'StrongPass!123';
GRANT ALL PRIVILEGES ON *.* TO 'clusteradmin'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">CREATE USER &#39;clusteradmin&#39;@&#39;%&#39; IDENTIFIED BY &#39;StrongPass!</span><span style="color: #5DE4C7">123</span><span style="color: #A6ACCD">&#39;;</span></span>
<span class="line"><span style="color: #A6ACCD">GRANT ALL PRIVILEGES ON *.* TO &#39;clusteradmin&#39;@&#39;%&#39; WITH GRANT OPTION;</span></span>
<span class="line"><span style="color: #A6ACCD">FLUSH PRIVILEGES;</span></span></code></pre></div>



<h5 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f310.png" alt="🌐" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 4: Configure InnoDB Cluster</h5>



<p>On <strong>node01</strong>, use MySQL Shell:</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" data-code="mysqlsh --uri clusteradmin@localhost" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">mysqlsh --uri clusteradmin@localhost</span></span></code></pre></div>



<p>Please enter clusteradmin password &#8220;StrongPass!123&#8221; once it pops up on your terminal</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2068" height="588" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image.png" alt="image" class="wp-image-518" title="Creating a Highly Available MySQL InnoDB Cluster 10" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image.png 2068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-768x218.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1536x437.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2048x582.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-150x43.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-300x85.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-696x198.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1068x304.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1920x546.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-600x171.png 600w" sizes="auto, (max-width: 2068px) 100vw, 2068px" /></figure>



<p>Then: Run the following command one by one on node01 </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" data-code="dba.configureInstance('clusteradmin@node01')
dba.configureInstance('clusteradmin@node02')
dba.configureInstance('clusteradmin@node03')" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">dba.configureInstance(&#39;clusteradmin@node</span><span style="color: #5DE4C7">01</span><span style="color: #A6ACCD">&#39;)</span></span>
<span class="line"><span style="color: #A6ACCD">dba.configureInstance(&#39;clusteradmin@node</span><span style="color: #5DE4C7">02</span><span style="color: #A6ACCD">&#39;)</span></span>
<span class="line"><span style="color: #A6ACCD">dba.configureInstance(&#39;clusteradmin@node</span><span style="color: #5DE4C7">03</span><span style="color: #A6ACCD">&#39;)</span></span></code></pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2276" height="720" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1.png" alt="image 1" class="wp-image-519" title="Creating a Highly Available MySQL InnoDB Cluster 11" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1.png 2276w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-768x243.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-1536x486.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-2048x648.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-150x47.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-300x95.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-696x220.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-1068x338.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-1920x607.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-600x190.png 600w" sizes="auto, (max-width: 2276px) 100vw, 2276px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2196" height="1698" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2.png" alt="image 2" class="wp-image-520" title="Creating a Highly Available MySQL InnoDB Cluster 12" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2.png 2196w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-768x594.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-1536x1188.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-2048x1584.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-150x116.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-300x232.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-696x538.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-1068x826.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-1920x1485.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-600x464.png 600w" sizes="auto, (max-width: 2196px) 100vw, 2196px" /></figure>



<p>After once you have completed above command, then run following command on node01</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" data-code="var cluster = dba.createCluster('wordpressCluster')
cluster.addInstance('clusteradmin@node02')
cluster.addInstance('clusteradmin@node03')" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">var cluster = dba.createCluster(&#39;wordpressCluster&#39;)</span></span>
<span class="line"><span style="color: #A6ACCD">cluster.addInstance(&#39;clusteradmin@node</span><span style="color: #5DE4C7">02</span><span style="color: #A6ACCD">&#39;)</span></span>
<span class="line"><span style="color: #A6ACCD">cluster.addInstance(&#39;clusteradmin@node</span><span style="color: #5DE4C7">03</span><span style="color: #A6ACCD">&#39;)</span></span></code></pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2260" height="634" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3.png" alt="image 3" class="wp-image-521" title="Creating a Highly Available MySQL InnoDB Cluster 13" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3.png 2260w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-768x215.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-1536x431.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-2048x575.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-150x42.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-300x84.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-696x195.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-1068x300.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-1920x539.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-600x168.png 600w" sizes="auto, (max-width: 2260px) 100vw, 2260px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2560" height="1519" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-scaled.png" alt="image 5 scaled" class="wp-image-523" title="Creating a Highly Available MySQL InnoDB Cluster 14" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-scaled.png 2560w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-768x456.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-1536x911.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-2048x1215.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-150x89.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-300x178.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-696x413.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-1068x634.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-1920x1139.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-600x356.png 600w" sizes="auto, (max-width: 2560px) 100vw, 2560px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2560" height="1491" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-scaled.png" alt="image 6 scaled" class="wp-image-524" title="Creating a Highly Available MySQL InnoDB Cluster 15" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-scaled.png 2560w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-768x447.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-1536x895.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-2048x1193.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-150x87.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-300x175.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-696x405.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-1068x622.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-1920x1118.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-600x350.png 600w" sizes="auto, (max-width: 2560px) 100vw, 2560px" /></figure>



<p>Finally, you can check the cluster status.  </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" data-code="cluster.status()" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">cluster.status()</span></span></code></pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1732" height="1596" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7.png" alt="image 7" class="wp-image-525" title="Creating a Highly Available MySQL InnoDB Cluster 16" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7.png 1732w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7-768x708.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7-1536x1415.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7-150x138.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7-300x276.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7-696x641.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7-1068x984.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7-600x553.png 600w" sizes="auto, (max-width: 1732px) 100vw, 1732px" /></figure>



<p><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;" /> At this point, the cluster is formed, and MySQL group replication is working.<br><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;" /> <strong>Success!</strong> You now have a functional InnoDB Cluster <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f389.png" alt="🎉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<h5 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;" /> <strong>Step 5: Setup <code>mysqldump</code> Cron Job for Daily Backups</strong></h5>



<p>Create a script <code>/usr/local/bin/mysql_backup.sh</code>:<br>You can mount a volume to this directory <strong>/mnt/mysql_backup.</strong> This way, you can make sure your backup will be safe if the server has any issues.</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" data-code="#!/bin/bash
DATE=$(date +%F_%H-%M)
mysqldump -u root --all-databases &gt; /mnt/mysql_backup/db_backup_$DATE.sql" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">#!/bin/bash</span></span>
<span class="line"><span style="color: #A6ACCD">DATE=$(date +%F_%H-%M)</span></span>
<span class="line"><span style="color: #A6ACCD">mysqldump -u root --all-databases &gt; /mnt/mysql_backup/db_backup_$DATE.sql</span></span></code></pre></div>



<p>Make it executable:</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" data-code="chmod +x /usr/local/bin/mysql_backup.sh" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">chmod +x /usr/local/bin/mysql_backup.sh</span></span></code></pre></div>



<p>Add a cron job:</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" data-code="crontab -e

0 2 * * * /usr/local/bin/mysql_backup.sh" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">crontab -e</span></span>
<span class="line"></span>
<span class="line"><span style="color: #5DE4C7">0</span><span style="color: #A6ACCD"> </span><span style="color: #5DE4C7">2</span><span style="color: #A6ACCD"> * * * /usr/local/bin/mysql_backup.sh</span></span></code></pre></div>



<p>This runs daily at 2 AM.</p>



<h5 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;" /> <strong>Step 6: Backup Binary Logs Every Minute</strong></h5>



<p>Use <code>mysqlbinlog</code> to extract binlog content every minute:<br>Create <code>/usr/local/bin/binlog_backup.sh</code>:</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" data-code="#!/bin/bash
DATE=$(date +%F_%H-%M)
BINLOG_PATH=&quot;/mnt/mysql_binlog&quot;
DEST_PATH=&quot;/mnt/mysql_backup/binlogs&quot;
mkdir -p &quot;$DEST_PATH&quot;
cp $BINLOG_PATH/mysql-bin.* &quot;$DEST_PATH/binlog_$DATE&quot;" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">#!/bin/bash</span></span>
<span class="line"><span style="color: #A6ACCD">DATE=$(date +%F_%H-%M)</span></span>
<span class="line"><span style="color: #A6ACCD">BINLOG_PATH=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">/mnt/mysql_binlog</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">DEST_PATH=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">/mnt/mysql_backup/binlogs</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">mkdir -p </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">$DEST_PATH</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">cp $BINLOG_PATH/mysql-bin.* </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">$DEST_PATH/binlog_$DATE</span><span style="color: #A6ACCD">&quot;</span></span></code></pre></div>



<p>Add to crontab:</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" data-code="* * * * * /usr/local/bin/binlog_backup.sh" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">* * * * * /usr/local/bin/binlog_backup.sh</span></span></code></pre></div>



<p>This ensures you can do <strong>point-in-time recovery</strong> using full dump + binlogs.</p>



<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;" /> <strong>Important Concepts to Know </strong></h3>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Concept</th><th>Description</th></tr></thead><tbody><tr><td><strong>InnoDB Cluster</strong></td><td>A high-availability solution using Group Replication and MySQL Shell</td></tr><tr><td><strong>Group Replication</strong></td><td>Ensures all nodes are in sync using GTID-based replication</td></tr><tr><td><strong>MySQL Router</strong></td><td>Middle layer that routes read/write traffic to correct nodes</td></tr><tr><td><strong>Single Primary Mode</strong></td><td>Only one node accepts writes; automatic failover is supported</td></tr><tr><td><strong>Backup Strategy</strong></td><td><code>mysqldump</code> for full backups, <code>mysqlbinlog</code> for PITR</td></tr><tr><td><strong>GTID</strong></td><td>Global Transaction IDs used to track transactions in replication</td></tr><tr><td><strong>Failover</strong></td><td>If primary fails, a new primary is elected from secondaries</td></tr></tbody></table></figure>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f501.png" alt="🔁" class="wp-smiley" style="height: 1em; max-height: 1em;" /> MySQL Router – On a Dedicated VM<br>For better <strong>failover and load balancing</strong>, deploy MySQL Router separately:</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" data-code="sudo apt install mysql-router -y
mysqlrouter --bootstrap clusteradmin@node01:3306 --directory /etc/mysqlrouter
sudo systemctl start mysqlrouter" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">sudo apt install mysql-router -y</span></span>
<span class="line"><span style="color: #A6ACCD">mysqlrouter --bootstrap clusteradmin@node</span><span style="color: #5DE4C7">01</span><span style="color: #A6ACCD">:</span><span style="color: #5DE4C7">3306</span><span style="color: #A6ACCD"> --directory /etc/mysqlrouter</span></span>
<span class="line"><span style="color: #A6ACCD">sudo systemctl start mysqlrouter</span></span></code></pre></div>



<p>It ensures connections always route to the right node. <strong>no manual switching needed</strong> <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f504.png" alt="🔄" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



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



<p>Try stopping MySQL on node01:</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" data-code="sudo systemctl stop mysql" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">sudo systemctl stop mysql</span></span></code></pre></div>



<p>Once you stop MySQL services, to see the failover, you have to connect to the MySQL shell. For that, follow the commands below </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" data-code="mysqlsh --uri clusteradmin@localhost

var cluster = dba.getCluster('wordpressCluster')

cluster.status()" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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">mysqlsh --uri clusteradmin@localhost</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">var cluster = dba.getCluster(&#39;wordpressCluster&#39;)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">cluster.status()</span></span></code></pre></div>



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



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1906" height="1532" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8.png" alt="image 8" class="wp-image-526" title="Creating a Highly Available MySQL InnoDB Cluster 17" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8.png 1906w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8-768x617.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8-1536x1235.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8-150x121.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8-300x241.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8-696x559.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8-1068x858.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8-600x482.png 600w" sizes="auto, (max-width: 1906px) 100vw, 1906px" /></figure>



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



<p>Setting up a MySQL InnoDB Cluster <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f6e0.png" alt="🛠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> isn&#8217;t just about replication. It&#8217;s about building a resilient, production-ready database architecture with automatic failover, dedicated routing, and reliable backups. With 3 MySQL nodes, a separate MySQL Router VM, binary logs, and regular dumps, you&#8217;re all set for high availability and peace of mind. <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;" /><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4be.png" alt="💾" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/creating-a-highly-available-mysql-innodb-cluster/">Creating a Highly Available MySQL InnoDB Cluster</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/creating-a-highly-available-mysql-innodb-cluster/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Day 8 Task &#8211; Basics Of Git &#038; GitHub</title>
		<link>https://www.abdulrahmanuk.com/day-8-task-basics-of-git-github/</link>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Sat, 03 Jun 2023 04:52:41 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=394</guid>

					<description><![CDATA[<p>#90DaysOfDevopsChallenge If you are working in Software Industry must hear about the two-term &#8220;Git and GitHub&#8221; but before jumping into git first, you have to understand what version control is and what issue the software industry was facing before git. What is Version Control System? A version control system is software that tracks changes to a [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-8-task-basics-of-git-github/">Day 8 Task &#8211; Basics Of Git &#038; GitHub</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><strong>#90DaysOfDevopsChallenge</strong></p>



<p>If you are working in Software Industry must hear about the two-term &#8220;<strong>Git and</strong> <strong>GitHub</strong>&#8221; but before jumping into git first, you have to understand what version control is and what issue the software industry was facing before git.</p>



<h3 class="wp-block-heading" id="heading-what-is-version-control-system"><strong><mark>What is Version Control System?</mark></strong></h3>



<p>A version control system is software that tracks changes to a file or set of files over time so that you can recall specific versions later. It also allows you to work together with other programmers.</p>



<p>The version control system is a collection of software tools that help a team to manage changes in a source code. It uses a special kind of database to keep track of every modification to the code.</p>



<p>Developers can compare earlier versions of the code with an older version to fix the mistakes.</p>



<h3 class="wp-block-heading" id="heading-benefits"><strong><mark>Benefits</mark></strong></h3>



<ul class="wp-block-list">
<li>Enhances the project development speed by providing efficient collaboration.</li>



<li>Reduce possibilities of errors and conflicts meanwhile project development through traceability to every small change.</li>



<li>Employees or contributors of the project can contribute from anywhere irrespective of the different geographical locations through this&nbsp;<strong>VCS</strong></li>



<li>For each different contributor to the project, a different working copy is maintained and not merged to the main file unless the working copy is validated.</li>



<li>Informs us about Who, What, When, and Why changes have been made.</li>



<li>Helps in recovery in case of any disaster situation</li>
</ul>



<h3 class="wp-block-heading" id="heading-types-of-vcs"><strong><mark>Types of VCS</mark></strong></h3>



<p>1. Centralized Version Control Systems</p>



<p>2. Distributed Version Control Systems</p>



<h3 class="wp-block-heading" id="heading-benefits"><strong><mark>Centralized Version Control Systems :</mark></strong></h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1508" height="968" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-6.png" alt="image 6" class="wp-image-395" title="Day 8 Task - Basics Of Git &amp; GitHub 18" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-6.png 1508w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-6-768x493.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-6-150x96.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-6-300x193.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-6-696x447.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-6-1068x686.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-6-600x385.png 600w" sizes="auto, (max-width: 1508px) 100vw, 1508px" /></figure>



<h4 class="wp-block-heading" id="heading-benefits">Centralized version control systems contain just one repository globally and every user needs to commit for reflecting one’s changes in the repository. Others can see your changes by updating.<a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-benefits" rel="nofollow noopener" target="_blank"></a></h4>



<h3 class="wp-block-heading" id="heading-cvcs-has-some-drawbacks-and-the-problem-was"><strong><mark>CVCS has some drawbacks and the problem was,</mark></strong></h3>



<p>a) It is not locally available, meaning you always need to be connected to a network to perform any actions.</p>



<p>b) Since everything is centralized, if Central Server gets failed, you will lose the entire data.</p>



<p>Central Repository or Central Server means,it is a kind of storage or folder in a remote server, where you or anyone can keep your code and can see that code or can access it.</p>



<h3 class="wp-block-heading" id="heading-distributed-version-control-systems"><strong><mark>Distributed Version Control Systems</mark></strong><br><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-distributed-version-control-systems" rel="nofollow noopener" target="_blank"></a></h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1504" height="1066" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-7.png" alt="image 7" class="wp-image-396" title="Day 8 Task - Basics Of Git &amp; GitHub 19" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-7.png 1504w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-7-768x544.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-7-150x106.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-7-300x213.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-7-696x493.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-7-1068x757.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-7-600x425.png 600w" sizes="auto, (max-width: 1504px) 100vw, 1504px" /></figure>



<ol class="wp-block-list">
<li>In a DVCS, every developer has a full copy of the repository, including the entire history of all changes. This makes it easier for developers to work together, as they don&#8217;t have to constantly communicate with a central server to commit their changes or to see the changes made by others.</li>



<li>Because developers have a local copy of the repository, they can commit their changes and perform other version control actions faster, as they don&#8217;t have to communicate with a central server.</li>



<li>With a DVCS, developers can work offline and commit their changes later when they do have an internet connection. They can also choose to share their changes with only a subset of the team, rather than pushing all of their changes to a central server.</li>



<li>In a DVCS, the repository history is stored on multiple servers and computers, which makes it more resistant to data loss.</li>
</ol>



<p><strong><mark>Git is an example of DVCS.</mark></strong></p>



<h3 class="wp-block-heading" id="heading-difference-between-cvcs-and-dvcs"><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-difference-between-cvcs-and-dvcs" rel="nofollow noopener" target="_blank"></a><strong><mark>Difference between CVCS and DVCS</mark></strong></h3>



<p>1. In CVCS, a client need to get a local copy of the source from the server, do the changes and commit those changes to the central source on the server, while in DVCS each client can have a local branch or repository as well and have a complete history on it. The client needs to push the changes to the branch which will then be pushed to the server repository.</p>



<p>2. CVCS systems are easy to learn and set up, and DVCS systems are difficult for beginners. Multiple commands need to be remembered.</p>



<p>3. Working on branches is difficult in CVCS, Developer often faces Merge Conflict. Working on branches is easier in DVCS, developers face less conflict.</p>



<p>4. CVCS systems do not provide offline access. DVCS systems are working fine in offline mode as a client copies the entire repository on their local machine.</p>



<p>5. CVCS is slower as every command needs to communicate with the server. while DVCS is faster as most user deals with a local copy without hitting the server every time.</p>



<p>6. If the CVCS server goes down, the developer is not able to do the work. But if the DVCS server is down, developers can work using their local copies.</p>



<h3 class="wp-block-heading" id="heading-github"><strong><mark>GitHub</mark></strong></h3>



<p>Git and GitHub are not the same things, Git mainly works on local systems. Github is used to store code that is remotely centralized and most Developers use this to store their code. GitHub is the largest host of source code in the world and has been owned by Microsoft since 2018.</p>



<h3 class="wp-block-heading" id="heading-git"><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-git" rel="nofollow noopener" target="_blank"></a><strong><mark>Git</mark></strong></h3>



<p>Git is a Distributed Version Control System and was launched by&nbsp;<strong>Linus Torvald</strong>&nbsp;&amp; this person also introduced Linux. Git is a software tool.</p>



<p>It is used for:</p>



<ul class="wp-block-list">
<li>Tracking code changes</li>



<li>Tracking who made changes</li>



<li>Coding collaboration</li>
</ul>



<h3 class="wp-block-heading" id="heading-what-does-git-do"><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-what-does-git-do" rel="nofollow noopener" target="_blank"></a>What does Git do?</h3>



<ul class="wp-block-list">
<li>Manage projects with&nbsp;<strong>Repositories</strong></li>



<li><strong>Clone</strong>&nbsp;a project to work on a local copy</li>



<li>Control and track changes with&nbsp;<strong>Staging</strong>&nbsp;and&nbsp;<strong>Committing</strong></li>



<li><strong>Branch</strong>&nbsp;and&nbsp;<strong>Merge</strong>&nbsp;to allow for work on different parts and versions of a project</li>



<li><strong>Pull</strong>&nbsp;the latest version of the project to a local copy</li>



<li><strong>Push</strong>&nbsp;local updates to the main project</li>
</ul>



<p><strong><mark>Actual Workflow of Git</mark></strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1752" height="1240" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8.png" alt="image 8" class="wp-image-397" title="Day 8 Task - Basics Of Git &amp; GitHub 20" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8.png 1752w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8-768x544.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8-1536x1087.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8-150x106.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8-300x212.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8-696x493.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8-1068x756.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8-600x425.png 600w" sizes="auto, (max-width: 1752px) 100vw, 1752px" /></figure>



<ol class="wp-block-list">
<li>Initialize Git on a folder, making it a local <strong>Repository</strong> by the <strong><mark>git init </mark>command.</strong> A hidden folder will create named <strong><mark>.git</mark></strong></li>



<li><strong>Clone</strong>&nbsp;a project to work on a local copy</li>



<li><strong><mark>Working directory and Staging area</mark></strong><mark>:</mark>&nbsp;this is where you see files physically and do modifications. At a time you can work on a particular branch. When we send our code to the staging area to finalize our code from the working space, this procedure is known as&nbsp;<strong><mark>Add</mark></strong>In other CVCS, developers generally make modifications and commit their changes directly to the Repository (central). But Git uses a different strategy. Git does not track every modified file. Whenever you do commit an operation, Git looks for the files present in the staging area. Only those files present in the staging area are considered for commit and not all the modified files.</li>



<li><strong><mark>Commit</mark></strong><mark>:</mark>&nbsp;From the staging area when we send our codes to the local Repository this process will be known as Commit (save/snapshot). After saving the code, a commit id will be created &amp; this is unique.<strong><mark>Commit Id</mark>:</strong>&nbsp;So if anyone needs to check any code later time, then they can check it through that commit id. Commit-ID is 40 alpha-numeric characters. It mainly uses the&nbsp;<strong>SHA-1</strong>&nbsp;checksum concept. Even if you change one dot, the commit-id will get changed. It helps you to track the changes. Commit is also known as SHA-Hash.</li>



<li><strong><mark>Snapshot</mark></strong><mark>:</mark>&nbsp;It is that when you keep the codes into a file &amp; when you change some code, eg:you change into 4-5 lines then when you take a snapshot of that file, the snapshot will copy only that 4-5 lines of code in another file, not the entire code. So this helps to save less storage of a file.Snapshot is incremental i.e. it will copy or save only the changed data.</li>



<li><strong><mark>Push</mark></strong><mark>:</mark>&nbsp;Push operation copies changes from a local Repository instance to a Remote or Central Repo(<strong>GitHub</strong>). This is used to store the changes permanently in the Git Repo.</li>



<li><strong><mark>Pull:&nbsp;</mark></strong>Pull Operation copies the changes from a Remote Repo to a local machine. The pull operation is used for synchronization between two repo.</li>



<li><strong><mark>Branch:</mark></strong> There is an important concept of the branch&#8230;</li>
</ol>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1624" height="850" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9.png" alt="image 9" class="wp-image-398" title="Day 8 Task - Basics Of Git &amp; GitHub 21" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9.png 1624w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9-768x402.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9-1536x804.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9-150x79.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9-300x157.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9-696x364.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9-1068x559.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9-600x314.png 600w" sizes="auto, (max-width: 1624px) 100vw, 1624px" /></figure>



<p>The diagram above visualizes a repository with two isolated lines of development. By developing them as branches, it&#8217;s not only possible to work on both of them in parallel, but it also keeps the main&nbsp;<strong><mark>Master (default branch)&nbsp;</mark></strong>free from error.</p>



<ul class="wp-block-list">
<li>Each task has one separate branch.</li>



<li>After done with the code,&nbsp;<strong><mark>Merge other Branches with the Master.</mark></strong></li>



<li>This concept is useful for parallel development means at times many persons can work on their branch and that won&#8217;t reflect on the main branch.</li>



<li>you can create any number of branches.</li>



<li>Changes are personal to that particular branch.</li>



<li><mark>The default branch is Master.</mark></li>



<li><mark>Files created in Workspace will be visible in any of the branch workspaces until you commit. Once you commit, then that file belongs to that particular branch.</mark></li>



<li><mark>When creating a new branch, data from the existing Branch is copied to the new branch (only one time when the branch is created).</mark></li>
</ul>



<h3 class="wp-block-heading" id="heading-tasks"><strong><mark>Tasks</mark></strong></h3>



<h3 class="wp-block-heading" id="heading-1-install-git-on-your-system"><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-1-install-git-on-your-system" rel="nofollow noopener" target="_blank"></a><strong>1. Install git on your system</strong></h3>



<p>As am using Linux OS(Ubuntu ) so by default git is already installed in it ( Aws instance). My git version is&nbsp;<strong>2.34.1</strong></p>



<h3 class="wp-block-heading" id="heading-2-create-a-free-account-in-github"><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-2-create-a-free-account-in-github" rel="nofollow noopener" target="_blank"></a><strong>2. Create a free account in GitHub.</strong></h3>



<p>You can create a free account in GitHub by Signing up&nbsp;<a target="_blank" href="https://github.com/" rel="noreferrer noopener nofollow"><strong></strong></a><strong><a href="https://github.com/" target="_blank" rel="noreferrer noopener nofollow">github.com</a></strong>&nbsp;(use this link).</p>



<h3 class="wp-block-heading" id="heading-3-make-a-directory-and-make-it-a-local-repository-by-git-init-command"><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-3-make-a-directory-and-make-it-a-local-repository-by-git-init-command" rel="nofollow noopener" target="_blank"></a><strong>3. Make a directory and make it a local repository by the git init command</strong></h3>



<p>Created one directory as <strong>test-repository</strong> then changed the directory to it. Then made it a git repository with <strong><mark>git init</mark> command.</strong>A .git folder will be created that is hidden</p>



<h3 class="wp-block-heading" id="heading-4-create-a-new-repository-on-github-and-clone-it-to-your-local-machine"><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-4-create-a-new-repository-on-github-and-clone-it-to-your-local-machine" rel="nofollow noopener" target="_blank"></a><strong>4. Create a new repository on GitHub and clone it to your local machine</strong></h3>



<p>Created one repository in GitHub named&nbsp;<strong>Task-Repo and</strong>&nbsp;cloned it to my machine.</p>



<h3 class="wp-block-heading" id="heading-5-make-some-changes-to-a-file-in-the-repository-and-commit-them-to-the-repository-using-git"><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-5-make-some-changes-to-a-file-in-the-repository-and-commit-them-to-the-repository-using-git" rel="nofollow noopener" target="_blank"></a><strong>5. Make some changes to a file in the repository and commit them to the repository using Git</strong></h3>



<p>Cloned the repository that I created in GitHub by the url in my machine.</p>



<p>configured git with git config &#8211;global user.name and user.email (this will help to check who is committed by name and mail id) command.</p>



<p>Now chnaged to the repository that I cloned. Then created a file called devops.txt.</p>



<p>add the file by <strong><mark>git add &lt;filename> </mark></strong>command and check the git status. This file is now <strong>staged</strong>. Now commit the file by the <strong><mark>git commit command.</mark></strong></p>



<h3 class="wp-block-heading" id="heading-6-push-the-changes-back-to-the-repository-on-github">6.&nbsp;<strong>Push the changes back to the repository on GitHub</strong></h3>



<p>Now add the repository by the command <strong><mark>git remote add origin</mark> &lt;url of GitHub repo</strong>></p>



<p>Then I pushed the committed file into GitHub by the command&nbsp;<strong><mark>git push origin main (as my default branch is main here, it can be master sometimes too).</mark></strong></p>



<p><strong><mark>While pushing the file into github have to enter the GitHub username and Personal access token ( go to Developers settings in GitHub -&gt; personal access token-&gt;generate token)</mark></strong></p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-8-task-basics-of-git-github/">Day 8 Task &#8211; Basics Of Git &#038; GitHub</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Day 7 Task &#8211; Understanding package manager and systemctl</title>
		<link>https://www.abdulrahmanuk.com/day-7-task-understanding-package-manager-and-systemctl/</link>
					<comments>https://www.abdulrahmanuk.com/day-7-task-understanding-package-manager-and-systemctl/#respond</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Fri, 02 Jun 2023 19:16:53 +0000</pubDate>
				<category><![CDATA[90DaysOfDevOps]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[devops]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=385</guid>

					<description><![CDATA[<p>#90DaysOfDevopsChallenge 1. Pacakage Manager A package manager is a tool that allows users to install, remove, upgrade, configure and manage software packages on an operating system. The package manager can be a graphical application like a software center or a command lines tool like&#160;apt-get&#160;or&#160;Pacman. What is a Package? A package is usually referred to an [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-7-task-understanding-package-manager-and-systemctl/">Day 7 Task &#8211; Understanding package manager and systemctl</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><span style="background-color:#cdfe00" class="td_text_highlight_marker">#90DaysOfDevopsChallenge</span></p>



<p><mark><strong>1. Pacakage Manager</strong></mark></p>



<p>A package manager is a tool that allows users to install, remove, upgrade, configure and manage software packages on an operating system. The package manager can be a graphical application like a software center or a command lines tool like&nbsp;apt-get&nbsp;or&nbsp;Pacman.</p>



<h2 class="wp-block-heading" id="heading-what-is-a-package"><strong><mark>What is a Package?</mark></strong></h2>



<p>A package is usually referred to an application but it could be a GUI application, command line tool or a software library (required by other software programs). A package is essentially an archive file containing the binary executable, configuration file and sometimes information about the dependencies.</p>



<h2 class="wp-block-heading" id="heading-how-does-the-package-manager-work"><mark>How does the package manager work?</mark></h2>



<p>The package manager is a generic concept and it’s not exclusive to Linux. You’ll often find package managers for different software or programming languages. There is a PIP package manager just for Python packages.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1522" height="480" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image.png" alt="image" class="wp-image-386" title="Day 7 Task - Understanding package manager and systemctl 22" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image.png 1522w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-768x242.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-150x47.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-300x95.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-696x220.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1068x337.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-600x189.png 600w" sizes="auto, (max-width: 1522px) 100vw, 1522px" /></figure>



<p>Almost all Linux distributions have software repositories which is a collections of software packages. Yes, there could be more than one repository. The repositories contain software packages of a different kinds.</p>



<p>Repositories also have metadata files that contain information about the packages such as the name of the package, version number, description of the package and the repository name etc. This is what you see if you use the&nbsp;<strong>apt show command</strong>&nbsp;in Ubuntu/Debian.</p>



<p>Your system’s package manager first interacts with the metadata. The package manager creates a local cache of metadata on your system. When you run the update option of the package manager (for example apt update), it updates this local cache of metadata by referring to metadata from the repository.</p>



<p>When you run the installation command of your package manager (for example apt install package_name), the package manager refers to this cache. If it finds the package information in the cache, it uses the internet connection to connect to the appropriate repository and downloads the package first before installing on your system.</p>



<p>A package may have dependencies. Meaning that it may require other packages to be installed. The package manager often takes care of the dependencies and installs it automatically along with the package you are installing.</p>



<p><strong><mark>Types of Package Managers:</mark></strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1268" height="794" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1.png" alt="image 1" class="wp-image-387" title="Day 7 Task - Understanding package manager and systemctl 23" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1.png 1268w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1-768x481.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1-150x94.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1-300x188.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1-696x436.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1-1068x669.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1-600x376.png 600w" sizes="auto, (max-width: 1268px) 100vw, 1268px" /></figure>



<ul class="wp-block-list">
<li><strong>1. DPKG – Debian Package Management System</strong></li>



<li><a href="https://tanaya.hashnode.dev/understanding-package-manager-and-systemctlday-7-task#heading-apt-advanced-packaging-tool" rel="nofollow noopener" target="_blank"></a><strong>APT (Advanced Packaging Tool) :</strong><a href="https://tanaya.hashnode.dev/understanding-package-manager-and-systemctlday-7-task#heading-it-is-a-very-popular-free-powerful-and-more-so-useful-command-line-package-management-system-that-is-a-front-end-for-the-dpkg-package-management-system" rel="nofollow noopener" target="_blank"></a>It is a very popular, free, powerful, and more so, useful command line package management system that is a front end for the dpkg package management system.Users of Debian or its derivatives such as Ubuntu and Linux Mint should be familiar with this package management tool.</li>



<li><a href="https://tanaya.hashnode.dev/understanding-package-manager-and-systemctlday-7-task#heading-aptitude-package-manager" rel="nofollow noopener" target="_blank"></a><strong>Aptitude Package Manager</strong>This is also a popular command line front-end package management tool for the&nbsp;<strong>Debian</strong>&nbsp;Linux family, it works similarly to&nbsp;<strong>APT</strong>&nbsp;. It was initially built for Debian and its derivatives but now its functionality stretches to the&nbsp;<strong>RHEL</strong>&nbsp;family.</li>



<li><strong>2. RPM (Red Hat Package Manager)</strong></li>



<li><a href="https://tanaya.hashnode.dev/understanding-package-manager-and-systemctlday-7-task#heading-yum-yellowdog-updater-modified" rel="nofollow noopener" target="_blank"></a><strong>YUM (Yellowdog Updater, Modified)</strong>It is an open-source and popular command line package manager that works as an interface for users to RPM. You can compare it to&nbsp;<strong>APT</strong>&nbsp;under Debian Linux systems, it incorporates the common functionalities that APT has.</li>



<li><strong>3.</strong>&nbsp;<strong>Pacman Package Manager – Arch Linux</strong></li>



<li><strong>4.</strong>&nbsp;<strong>Zypper Package Manager – openSUSE</strong></li>



<li><strong>5. Portage Package Manager – Gentoo</strong></li>
</ul>



<p><strong>2. You have to install docker and Jenkins in your system from your terminal using package managers</strong></p>



<p><strong><mark>Jenkins:</mark></strong></p>



<p>To install Jenkins you first have to install&nbsp;<strong><mark>java</mark></strong>. So this is some steps to install java:</p>



<p>Initially update all packages used in the below command. <span style="background-color:#0ea3e6" class="td_text_highlight_marker">NOTE: I&#8217;m showing here for Ubuntu operating system.</span></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>sudo apt update</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">sudo apt update</span></span></code></pre></div>



<p>Depending on which Java version you want to install, Java 8 or 11, run one of the following commands:</p>



<p>To install OpenJDK 8, run:</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>sudo apt install openjdk-8-jdk -y</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">sudo apt install openjdk</span><span style="color: #5DE4C7">-8</span><span style="color: #A6ACCD">-jdk -y</span></span></code></pre></div>



<p>To install OpenJDK 11, run:</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>sudo apt install openjdk-11-jdk -y</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">sudo apt install openjdk</span><span style="color: #5DE4C7">-11</span><span style="color: #A6ACCD">-jdk -y</span></span></code></pre></div>



<p><strong>Add Jenkins Repository</strong></p>



<p>The version of Jenkins included with the default Ubuntu packages is often behind the latest available version from the project itself. To ensure you have the latest fixes and features, use the project-maintained packages to install Jenkins.</p>



<p>First, add the repository key to your system:</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>wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key |sudo gpg --dearmor -o /usr/share/keyrings/jenkins.gpg</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">wget -q -O - https:</span><span style="color: #767C9DB0; font-style: italic">//pkg.jenkins.io/debian-stable/jenkins.io.key |sudo gpg --dearmor -o /usr/share/keyrings/jenkins.gpg</span></span></code></pre></div>



<p>The&nbsp;<code>gpg --dearmor</code>&nbsp;command is used to convert the key into a format that&nbsp;<code>apt</code>&nbsp;recognizes.</p>



<p>Next, let’s append the Debian package repository address to the server’s&nbsp;<code>sources.list</code>:</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>sudo sh -c 'echo deb [signed-by=/usr/share/keyrings/jenkins.gpg] http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'</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">sudo sh -c &#39;echo deb [</span><span style="color: #D0679D">signed-by=/usr/share/keyrings/jenkins.gpg</span><span style="color: #A6ACCD">] http:</span><span style="color: #767C9DB0; font-style: italic">//pkg.jenkins.io/debian-stable binary/ &gt; /etc/apt/sources.list.d/jenkins.list&#39;</span></span></code></pre></div>



<p>The&nbsp;<code>[signed-by=/usr/share/keyrings/jenkins.gpg]</code>&nbsp;portion of the line ensures that&nbsp;<code>apt</code>&nbsp;will verify files in the repository using the GPG key that you just downloaded.</p>



<p>After both commands have been entered, run&nbsp;<code>apt update</code>&nbsp;so that&nbsp;<code>apt</code>&nbsp;will use the new repository.</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>sudo apt update</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">sudo apt update</span></span></code></pre></div>



<p>Finally, install Jenkins and its dependencies:</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>sudo apt install jenkins</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">sudo apt install jenkins</span></span></code></pre></div>



<p>Now that Jenkins and its dependencies are in place, we’ll start the Jenkins server.</p>



<p><strong>Starting Jenkins</strong></p>



<p>now that Jenkins is installed, start it by using&nbsp;<code>systemctl</code>:</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>sudo systemctl start jenkins.service</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">sudo systemctl start jenkins.service</span></span></code></pre></div>



<p>Since&nbsp;<code>systemctl</code>&nbsp;doesn’t display status output, we’ll use the&nbsp;<code>status</code>&nbsp;command to verify that Jenkins started successfully:</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>sudo systemctl status jenkins</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">sudo systemctl status jenkins</span></span></code></pre></div>



<p>If everything went well, the beginning of the status output shows that the service is active and configured to start at boot:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1504" height="802" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-2.png" alt="image 2" class="wp-image-388" title="Day 7 Task - Understanding package manager and systemctl 24" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-2.png 1504w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-2-768x410.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-2-150x80.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-2-300x160.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-2-696x371.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-2-1068x570.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-2-600x320.png 600w" sizes="auto, (max-width: 1504px) 100vw, 1504px" /></figure>



<p>you have completed the installation stage and can continue with configuring Jenkins.</p>



<p><strong><mark>Docker installation:</mark></strong></p>



<p><strong><mark>step 1: sudo apt update -y</mark></strong></p>



<p><strong><mark>step 2: sudo apt install&nbsp;docker.io&nbsp;-y</mark></strong></p>



<p><strong><mark>step 3: docker &#8211;version</mark></strong></p>



<p><strong><mark>step 4: systemctl status docker [ to check if docker is in the active state]</mark></strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1612" height="854" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3.png" alt="image 3" class="wp-image-389" title="Day 7 Task - Understanding package manager and systemctl 25" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3.png 1612w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3-768x407.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3-1536x814.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3-150x79.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3-300x159.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3-696x369.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3-1068x566.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3-600x318.png 600w" sizes="auto, (max-width: 1612px) 100vw, 1612px" /></figure>



<h3 class="wp-block-heading" id="heading-3-systemctl-and-systemd"><strong><mark>systemctl and systemd</mark></strong></h3>



<p><strong><mark>systemctl</mark></strong>&nbsp;is used to examine and control the state of the “<strong><mark>systemd”</mark></strong>&nbsp;system and service manager.</p>



<p><strong><mark>systemd&nbsp;</mark></strong>is a system and service manager for Unix-like operating systems(most of the distributions, not all).</p>



<h3 class="wp-block-heading" id="heading-4-stop-the-service-jenkins-and-post-before-and-after-screenshots"><a href="https://tanaya.hashnode.dev/understanding-package-manager-and-systemctlday-7-task#heading-4-stop-the-service-jenkins-and-post-before-and-after-screenshots" rel="nofollow noopener" target="_blank"></a><strong>4. stop the service Jenkins and post before and after screenshots</strong></h3>



<p><strong><mark>Jenkins active status Screenshot:</mark></strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1408" height="762" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-4.png" alt="image 4" class="wp-image-390" title="Day 7 Task - Understanding package manager and systemctl 26" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-4.png 1408w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-4-768x416.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-4-150x81.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-4-300x162.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-4-696x377.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-4-1068x578.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-4-600x325.png 600w" sizes="auto, (max-width: 1408px) 100vw, 1408px" /></figure>



<p><strong><mark>Jenkins stop Screenshot :</mark></strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1372" height="612" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-5.png" alt="image 5" class="wp-image-391" title="Day 7 Task - Understanding package manager and systemctl 27" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-5.png 1372w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-5-768x343.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-5-150x67.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-5-300x134.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-5-696x310.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-5-1068x476.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-5-600x268.png 600w" sizes="auto, (max-width: 1372px) 100vw, 1372px" /></figure>



<h3 class="wp-block-heading" id="heading-5-read-about-the-commands-systemctl-vs-service"><strong>Read about the commands systemctl vs service</strong></h3>



<p>The&nbsp;<strong><mark>Service command</mark></strong>&nbsp;looks up the script to run at the path /etc/init.d/SCRIPT. It then runs the script, passing the COMMAND unchanged as the arguments. The&nbsp;<em>service</em>&nbsp;command guarantees a predictable running environment by removing most of the variables and setting the root path as the current working directory.</p>



<p><strong><mark>eg: sudo service jenkins start</mark></strong></p>



<p>The&nbsp;<strong><em><mark>systemctl</mark></em>&nbsp;<mark>command</mark></strong>&nbsp;interacts with the SystemD service manager to manage the services. Contrary to the&nbsp;<em>service</em>&nbsp;command, it manages the services by interacting with the SystemD process instead of running the init script.</p>



<p>To start, stop, and restart a process, we can run the commands with&nbsp;<em>systemctl</em>&nbsp;.</p>



<p><strong><mark>eg: sudo systemctl start docker</mark></strong></p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-7-task-understanding-package-manager-and-systemctl/">Day 7 Task &#8211; Understanding package manager and systemctl</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/day-7-task-understanding-package-manager-and-systemctl/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Day 6 &#8211; Linux File Permissions and Access Control Lists</title>
		<link>https://www.abdulrahmanuk.com/day-6-linux-file-permissions-and-access-control-lists/</link>
					<comments>https://www.abdulrahmanuk.com/day-6-linux-file-permissions-and-access-control-lists/#comments</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Wed, 31 May 2023 13:54:07 +0000</pubDate>
				<category><![CDATA[90DaysOfDevOps]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[linux]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=378</guid>

					<description><![CDATA[<p>1. About File Permissions: File permissions are core to the security model used by Linux systems. They determine who can access files and directories on a system and how. To check a file permission as : ls -l &#60;file-name> Permission Descriptions: Owner (u):&#160;Permissions used for the Owner of the file. Group(g):&#160;Permissions used by members of [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-6-linux-file-permissions-and-access-control-lists/">Day 6 &#8211; Linux File Permissions and Access Control Lists</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="heading-1-about-file-permissions"><strong><mark>1. About File Permissions:</mark></strong></h2>



<p>File permissions are core to the security model used by Linux systems. They determine who can access files and directories on a system and how.</p>



<p>To check a file permission as :</p>



<p><strong><mark>ls -l &lt;file-name></mark></strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1542" height="288" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16.png" alt="image 16" class="wp-image-379" title="Day 6 - Linux File Permissions and Access Control Lists 28" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16.png 1542w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16-768x143.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16-1536x287.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16-150x28.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16-300x56.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16-696x130.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16-1068x199.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16-600x112.png 600w" sizes="auto, (max-width: 1542px) 100vw, 1542px" /></figure>



<p><strong><mark>Permission Descriptions:</mark></strong></p>



<ol class="wp-block-list">
<li><strong>Read (r):</strong>&nbsp;The read permission allows you to open and read the content of a file. But you can&#8217;t do any editing or modification in the file.</li>



<li><strong>Write (w):</strong>&nbsp;The write permission allows you to edit, remove or rename a file. For instance, if a file is present in a directory, and write permission is set on the file but not on the directory, then you can edit the content of the file but can&#8217;t remove, or rename it.</li>



<li><strong>Execute (x):</strong>&nbsp;In Unix type system, you can&#8217;t run or execute a program unless execute permission is set. But in Windows, there is no such permission available.</li>
</ol>



<p><strong><mark>Owner (u):</mark></strong>&nbsp;Permissions used for the Owner of the file.</p>



<p><strong><mark>Group(g):</mark></strong>&nbsp;Permissions used by members of the group.</p>



<p><strong><mark>Other(o):</mark></strong>&nbsp;Permissions used by all other users.</p>



<p><strong><mark>Permission Set:</mark></strong></p>



<figure class="wp-block-table"><table><thead><tr><td>permission</td><td>on a file</td><td>on a directory</td></tr></thead><tbody><tr><td>r (read)</td><td>read file content (cat)</td><td>read directory content (ls)</td></tr><tr><td>w (write)</td><td>change file content (vi)</td><td>create a file in the directory (touch)</td></tr><tr><td>x (execute)</td><td>execute the file</td><td>enter the directory (cd)</td></tr></tbody></table></figure>



<p><strong><mark>Permissions in detail:</mark></strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1484" height="926" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-17.png" alt="image 17" class="wp-image-380" title="Day 6 - Linux File Permissions and Access Control Lists 29" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-17.png 1484w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-17-768x479.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-17-150x94.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-17-300x187.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-17-696x434.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-17-1068x666.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-17-600x374.png 600w" sizes="auto, (max-width: 1484px) 100vw, 1484px" /></figure>



<p><strong><mark>Change File Permissions:</mark></strong></p>



<p>a)&nbsp;<strong><mark>chmod</mark></strong>: Change file access permissions.</p>



<p><strong>Description:</strong>&nbsp;This command is used to change the file permissions. These permissions read, write and execute permission for the owner, group, and others.</p>



<p><strong>Syntax (symbolic mode)</strong>:&nbsp;<em><mark>chmod [ugoa][[+-=][mode]] file</mark></em></p>



<p>The first optional parameter indicates who – this can be (u)ser, (g)roup, (o)there, or (a)ll.</p>



<p>The second optional parameter indicates opcode – this can be for adding (+), removing (-), or assigning (=) permission.</p>



<p>The third optional parameter indicates the mode – this can be (r)ead, (w)rite, or e(x) acute.</p>



<p><strong>Example</strong>: Add writes permission for user, group, and others for file1.</p>



<p><strong><em><mark>$ chmod ugo+w file1</mark></em></strong></p>



<p>There is another way to change file permissions by numeric symbol:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1114" height="458" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-18.png" alt="image 18" class="wp-image-381" title="Day 6 - Linux File Permissions and Access Control Lists 30" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-18.png 1114w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-18-768x316.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-18-150x62.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-18-300x123.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-18-696x286.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-18-1068x439.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-18-600x247.png 600w" sizes="auto, (max-width: 1114px) 100vw, 1114px" /></figure>



<p><strong>Example</strong>: Give read/write/execute permission to the user, read/execute permission to the group, and execute permission to others.</p>



<p><strong><em><mark>$ chmod 751 file1</mark></em></strong></p>



<p>b)&nbsp;<strong><mark>chown</mark></strong>: Change ownership of the file.</p>



<p><strong>Description</strong>: Only the owner of the file has the right to change the file ownership.</p>



<p><strong>Syntax</strong>: chown [owner] [file]</p>



<p><strong>Example</strong>: Change the owner of file1 to user2 assuming it is currently owned by the current user</p>



<p><strong><em><mark>$ chown user2 file1</mark></em></strong></p>



<p>c)&nbsp;<strong><mark>chgrp</mark></strong>: Change the group ownership of the file</p>



<p><strong>Description</strong>: Only the owner of the file has the right to change the file ownership</p>



<p><strong>Syntax</strong>: chgrp [group] [file]</p>



<p><strong>Example</strong>: Change group of file1 to group2 assuming it is currently owned by the current user</p>



<p><strong><em><mark>$ chgrp group2 file1</mark></em></strong></p>



<p><strong>2. Create a simple file and check the details of the file:</strong></p>



<p>Here I created one file by using <strong><mark>the touch command</mark></strong> and then check the details of the file by using the <strong><mark>ls -l command </mark></strong>and then change the file permissions to <strong>766</strong> [all owner permissions, read and write permissions to group and others].<br></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1184" height="348" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-19.png" alt="image 19" class="wp-image-382" title="Day 6 - Linux File Permissions and Access Control Lists 31" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-19.png 1184w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-19-768x226.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-19-150x44.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-19-300x88.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-19-696x205.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-19-1068x314.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-19-600x176.png 600w" sizes="auto, (max-width: 1184px) 100vw, 1184px" /></figure>



<p><strong>3 . Read about ACL and try out the commands getfacl and setfacl</strong></p>



<p>Access control list (ACL) provides an additional, more flexible permission mechanism for file systems. It is designed to assist with UNIX file permissions. ACL allows you to give permissions for any user or group to any disc resource.</p>



<p><strong>Use Of ACL:</strong>&nbsp;Think of a scenario in which a particular user is not a member of a group created by you but still you want to give some read or write access, how can you do it without making the user a member of the group, here comes in picture Access Control Lists, ACL helps us to do this trick.</p>



<p>ACLs are used to make a flexible permission mechanism in Linux.</p>



<p>From Linux man pages, ACLs are used to define more fine-grained discretionary access rights for files and directories.</p>



<p><strong><mark>setfacl and getfacl command:</mark></strong></p>



<p>The command&nbsp;<mark>&#8220;setfacl&#8221;</mark>&nbsp;refers to Set File Access Control Lists and&nbsp;<mark>&#8220;getfacl&#8221;</mark>&nbsp;refers to Get File Access Control List.</p>



<p>Example:</p>



<p><strong>getfacl &lt;file or directory name&gt;</strong></p>



<p>1. To add permission for user</p>



<p><strong>setfacl -m &#8220;u:user: permissions&#8221; /path/to/file</strong></p>



<p>setfacl -m u:tanaya:rwx test/declarations.h</p>



<p>2. To add permissions for a group</p>



<p><strong>setfacl -m &#8220;g:group: permissions&#8221; /path/to/file</strong></p>



<p>3. To remove ACL permission of user:</p>



<p><strong>setfacl -x &#8220;u:user: permissions&#8221; /path/to/file</strong></p>



<p>4. To remove ACL permission of group:</p>



<p><strong>setfacl -x &#8220;g:group: permissions&#8221; /path/to/file</strong></p>



<p></p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-6-linux-file-permissions-and-access-control-lists/">Day 6 &#8211; Linux File Permissions and Access Control Lists</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/day-6-linux-file-permissions-and-access-control-lists/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Day-5 Task &#8211; Advanced Linux Shell Scripting for DevOps Engineers with User Management</title>
		<link>https://www.abdulrahmanuk.com/day-5-task-advanced-linux-shell-scripting-for-devops-engineers-with-user-management/</link>
					<comments>https://www.abdulrahmanuk.com/day-5-task-advanced-linux-shell-scripting-for-devops-engineers-with-user-management/#respond</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Wed, 31 May 2023 13:38:21 +0000</pubDate>
				<category><![CDATA[90DaysOfDevOps]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[devops]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=370</guid>

					<description><![CDATA[<p>Challenge: If you noticed that there are total 90 sub directories in the directory &#8216;2023&#8217; of this repository. What did you think, how did I create 90 directories. Manually one by one or using a script, or a command ? All 90 directories within seconds using a simple command. mkdir day{1..90} Tasks So Write a [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-5-task-advanced-linux-shell-scripting-for-devops-engineers-with-user-management/">Day-5 Task &#8211; Advanced Linux Shell Scripting for DevOps Engineers with User Management</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Challenge:</p>



<p>If you noticed that there are total 90 sub directories in the directory &#8216;2023&#8217; of this repository. What did you think, how did I create 90 directories. Manually one by one or using a script, or a command ?</p>



<p>All 90 directories within seconds using a simple command.</p>



<p><code>mkdir day{1..90}</code></p>



<h3 class="wp-block-heading"><a href="https://github.com/abdulrahman911/90DaysOfDevOps/blob/master/2023/day05/tasks.md#tasks" rel="nofollow noopener" target="_blank"></a>Tasks</h3>



<ol class="wp-block-list">
<li>You have to do the same using Shell Script i.e using either Loops or command with start day and end day variables using arguments &#8211;</li>
</ol>



<p>So Write a bash script createDirectories.sh that when the script is executed with three given arguments (one is directory name and second is start number of directories and third is the end number of directories ) it creates specified number of directories with a dynamic directory name.</p>



<p>Example 1: When the script is executed as</p>



<p><code>./createDirectories.sh day 1 90</code></p>



<p>then it creates 90 directories as&nbsp;<code>day1 day2 day3 .... day90</code></p>



<p>Example 2: When the script is executed as</p>



<p><code>./createDirectories.sh Movie 20 50</code> then it creates 50 directories as <code>Movie20 Movie21 Movie23 ...Movie50</code></p>



<p>As we know that if we want to pass any argument at the time of bash script execution we used to denote it as like&nbsp;<mark>$1(first arg),$2(2nd arg)</mark>&nbsp;etc&#8230;So here we will do the same thing in a bash script like :</p>



<p>name of the file as&nbsp;<strong><mark><a href="http://createdirectories.sh/" target="_blank" rel="noreferrer noopener nofollow">createDirectories.sh</a></mark></strong></p>



<p><strong><mark>start_day as $2 and end_day as $3 and day as $1</mark></strong></p>



<p><strong><mark>Execute as ./<a href="http://createdirectories.sh/" target="_blank" rel="noreferrer noopener nofollow">createDirectories.sh</a> day 1 90</mark></strong></p>



<p></p>



<p><strong><mark>Output</mark></strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2642" height="554" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11.png" alt="image 11" class="wp-image-371" title="Day-5 Task - Advanced Linux Shell Scripting for DevOps Engineers with User Management 32" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11.png 2642w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-768x161.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-1536x322.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-2048x429.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-150x31.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-300x63.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-696x146.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-1068x224.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-1920x403.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-600x126.png 600w" sizes="auto, (max-width: 2642px) 100vw, 2642px" /></figure>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" style="font-size:.875rem;--cbp-line-number-color:#a6accd;--cbp-line-number-width:17.8046875px;line-height:1.25rem"><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" data-code="#!/bin/bash

if [ $# != 3 ]
then
	echo &quot;Can't proceed \n Please give three arguments to continue&quot;
	exit 1

fi

echo &quot;Creating directory as per your requirement&quot;
start_day=$2
end_day=$3

for (( i=start_day; i&lt;=end_day; i++ ))
do
	mkdir $1$i
done	

echo &quot;Here are your directories:&quot;
ls
" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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"><code><span class="line"><span style="color: #A6ACCD">#!/bin/bash</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">if [ </span><span style="color: #D0679D">$#</span><span style="color: #A6ACCD"> </span><span style="color: #D0679D">!=</span><span style="color: #A6ACCD"> </span><span style="color: #5DE4C7">3</span><span style="color: #A6ACCD"> ]</span></span>
<span class="line"><span style="color: #A6ACCD">then</span></span>
<span class="line"><span style="color: #A6ACCD">	echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Can&#39;t proceed </span><span style="color: #5FB3A1">\n</span><span style="color: #5DE4C7"> Please give three arguments to continue</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">	exit </span><span style="color: #5DE4C7">1</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">fi</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Creating directory as per your requirement</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">start_day=$</span><span style="color: #5DE4C7">2</span></span>
<span class="line"><span style="color: #A6ACCD">end_day=$</span><span style="color: #5DE4C7">3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">for (( i=start_day; i&lt;=end_day; i++ ))</span></span>
<span class="line"><span style="color: #A6ACCD">do</span></span>
<span class="line"><span style="color: #A6ACCD">	mkdir $</span><span style="color: #5DE4C7">1</span><span style="color: #A6ACCD">$i</span></span>
<span class="line"><span style="color: #A6ACCD">done	</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Here are your directories:</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">ls</span></span>
<span class="line"></span></code></pre></div>



<p><strong>2. Create a Script to back up all your work done till now.</strong></p>



<p>Backups are an important part of DevOps Engineers&#8217; day to Day activities. Usually, when we create any backup of a file we used to create a zip file by using the tar command:&nbsp;<strong>tar -czvf file.tar.gz directory_name</strong></p>



<p>Here is a simple shell script to take a backup of recent work:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" style="font-size:.875rem;--cbp-line-number-color:#a6accd;--cbp-line-number-width:17.8046875px;line-height:1.25rem"><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" data-code="#!/bin/bash

src_directory=/var/www/my-blog

BACKUP_FILENAME=&quot;backup_$(date +%Y-%m-%d).tar.gz&quot;
TARGET_DIRECTORY=&quot;/home/ubuntu/backup/&quot;

#Create backup archive
tar -czvf $TARGET_DIRECTORY/$BACKUP_FILENAME $src_directory

if [ $? -eq 0 ]; then
	echo &quot;Backup successful!&quot;
else
	echo &quot;Backup failed.&quot;
fi

" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><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"><code><span class="line"><span style="color: #A6ACCD">#!/bin/bash</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">src_directory=/var/www/my-blog</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">BACKUP_FILENAME=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">backup_$(date +%Y-%m-%d).tar.gz</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">TARGET_DIRECTORY=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">/home/ubuntu/backup/</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">#Create backup archive</span></span>
<span class="line"><span style="color: #A6ACCD">tar -czvf $TARGET_DIRECTORY/$BACKUP_FILENAME $src_directory</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">if [ </span><span style="color: #D0679D">$?</span><span style="color: #A6ACCD"> </span><span style="color: #D0679D">-eq</span><span style="color: #A6ACCD"> </span><span style="color: #5DE4C7">0</span><span style="color: #A6ACCD"> ]; then</span></span>
<span class="line"><span style="color: #A6ACCD">	echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Backup successful!</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">else</span></span>
<span class="line"><span style="color: #A6ACCD">	echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Backup failed.</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">fi</span></span>
<span class="line"></span>
<span class="line"></span></code></pre></div>



<p><strong>3. Read About Cron and Crontab, to automate the backup Script</strong></p>



<p>Cron is a system process that will automatically perform tasks as per the specific schedule. It is a set of commands that are used for running regular scheduling tasks. Crontab stands for “<mark>cron table</mark>”. It allows using a job scheduler, which is known as cron to execute tasks.</p>



<p>Crontab is also the name of the program, which is used to edit that schedule. It is driven by a crontab file, a config file that indicates shell commands to run periodically for the specific schedule.</p>



<p><strong><mark>Reasons for using Cron jobs:</mark></strong></p>



<ul class="wp-block-list">
<li>Helps OS to take a scheduled backup of log files or database.</li>



<li>Delete old log files</li>



<li>Archive and purge database tables</li>



<li>Send out any notification email such as Newsletters, Password expiration email</li>



<li>Regular clean-up of cached data</li>



<li>Crontab is an ideal option to automate Unix jobs.</li>



<li>It is used to automate system maintenance</li>
</ul>



<p><strong>Crontab syntax:</strong></p>



<p><strong><mark>MIN HOUR DOM MON DOW CMD</mark></strong></p>



<p><strong>Ranges :</strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1262" height="516" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-13.png" alt="image 13" class="wp-image-373" title="Day-5 Task - Advanced Linux Shell Scripting for DevOps Engineers with User Management 33" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-13.png 1262w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-13-768x314.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-13-150x61.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-13-300x123.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-13-696x285.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-13-1068x437.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-13-600x245.png 600w" sizes="auto, (max-width: 1262px) 100vw, 1262px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="996" height="466" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-14.png" alt="image 14" class="wp-image-374" title="Day-5 Task - Advanced Linux Shell Scripting for DevOps Engineers with User Management 34" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-14.png 996w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-14-768x359.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-14-150x70.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-14-300x140.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-14-696x326.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-14-600x281.png 600w" sizes="auto, (max-width: 996px) 100vw, 996px" /></figure>



<p><strong>4. Read about User Management</strong></p>



<p>User management includes everything from creating a user to deleting a user on your system.</p>



<h3 class="wp-block-heading" id="heading-root"><a href="https://tanaya.hashnode.dev/advanced-linux-shell-scripting-for-devops-engineers-with-user-management-day-5-task#heading-root" rel="nofollow noopener" target="_blank"></a><strong>root</strong></h3>



<p>The root user is the superuser and has all the powers for creating a user, deleting a user and can even login in with the other user&#8217;s account. The root user always has userid 0.</p>



<h3 class="wp-block-heading" id="heading-useradd"><a href="https://tanaya.hashnode.dev/advanced-linux-shell-scripting-for-devops-engineers-with-user-management-day-5-task#heading-useradd" rel="nofollow noopener" target="_blank"></a><strong>useradd</strong></h3>



<p>1. With useradd command, you can add a user.</p>



<p>Syntax:&nbsp;<strong><mark>sudo adduser username [you should have the super user power to add a user]</mark></strong></p>



<p><strong>Then</strong>&nbsp;<mark>Enter the password for the new account and confirm</mark></p>



<p>You can check the newly added user from the file&nbsp;<strong><mark>/etc/passwd</mark></strong></p>



<p>Command:&nbsp;<strong>cat /etc/passwd</strong></p>



<p>2.&nbsp;<strong>For disabling an account using Terminal, remove the password set on the account.</strong></p>



<p><strong><mark>sudo passwd -l &#8216;username&#8217;</mark></strong></p>



<p>3. To delete an account, use the command –</p>



<p><strong><mark>sudo userdel -r &#8216;username</mark></strong></p>



<h2 class="wp-block-heading" id="heading-5-create-2-users-and-just-display-their-usernames"><strong>5. Create 2 users and just display their Usernames</strong></h2>



<p>Added two users by using the useradd command :</p>



<p>$ sudo useradd Sam</p>



<p>$ sudo useradd Vinod</p>



<p>To display their name use <strong>cat /etc/passwd</strong> and redirected the output to the <strong>tail</strong> command to see only the last two lines from the file :</p>



<p>To display their name use <strong>cat /etc/passwd</strong> and redirected the output to the <strong>tail</strong> command to see only the last two lines from the file :</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1606" height="356" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15.png" alt="image 15" class="wp-image-375" title="Day-5 Task - Advanced Linux Shell Scripting for DevOps Engineers with User Management 35" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15.png 1606w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15-768x170.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15-1536x340.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15-150x33.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15-300x67.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15-696x154.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15-1068x237.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15-600x133.png 600w" sizes="auto, (max-width: 1606px) 100vw, 1606px" /></figure>



<h2 class="wp-block-heading" id="heading-5-create-2-users-and-just-display-their-usernames"><a href="https://tanaya.hashnode.dev/advanced-linux-shell-scripting-for-devops-engineers-with-user-management-day-5-task#heading-5-create-2-users-and-just-display-their-usernames" rel="nofollow noopener" target="_blank"></a></h2>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-5-task-advanced-linux-shell-scripting-for-devops-engineers-with-user-management/">Day-5 Task &#8211; Advanced Linux Shell Scripting for DevOps Engineers with User Management</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/day-5-task-advanced-linux-shell-scripting-for-devops-engineers-with-user-management/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
