<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Paolo Carta on Medium]]></title>
        <description><![CDATA[Stories by Paolo Carta on Medium]]></description>
        <link>https://medium.com/@paolocarta_it?source=rss-9d447107642b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZrmT_hFvLAhMcnGRRIXOhg.png</url>
            <title>Stories by Paolo Carta on Medium</title>
            <link>https://medium.com/@paolocarta_it?source=rss-9d447107642b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 17:51:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@paolocarta_it/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Integrating SOPS in ArgoCD to handle Kubernetes Secrets]]></title>
            <link>https://itnext.io/integrating-sops-in-argocd-to-handle-kubernetes-secrets-e797b167d791?source=rss-9d447107642b------2</link>
            <guid isPermaLink="false">https://medium.com/p/e797b167d791</guid>
            <category><![CDATA[mozilla-sops]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[argo-cd]]></category>
            <category><![CDATA[kustomize]]></category>
            <dc:creator><![CDATA[Paolo Carta]]></dc:creator>
            <pubDate>Mon, 28 Jul 2025 15:53:40 GMT</pubDate>
            <atom:updated>2025-07-28T17:31:03.311Z</atom:updated>
            <content:encoded><![CDATA[<p>This ariticle focuses on using <strong>SOPS </strong>encrypted secrets with <strong>Argo CD</strong> when your Kubernetes manifests are managed by <strong>kustomize</strong>. One of the most common patterns is to use the <strong>kustomize-sops plugin</strong>. This plugin lets kustomize decrypt your SOPS-encrypted YAML files at build time, so Argo CD can apply the resulting manifests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mdQ5OBBp0ggAgtVcDM7pjg.png" /></figure><h3>1. Overview of the Flow</h3><ol><li>You keep your Kubernetes manifests in Git, including your <strong>SOPS encrypted secrets</strong>.</li><li>You configure <strong>kustomize</strong> to use the <strong>ksops</strong> plugin to decrypt those secrets on the fly.</li><li><strong>Argo CD</strong> pulls from your Git repo, runs kustomize with the ksops plugin, and gets decrypted YAML.</li><li>Argo CD applies the final plaintext resources to the cluster.</li></ol><p>This avoids storing plain-text secrets in Git or in Argo CD’s history. Decryption happens <em>just in time</em> during the kustomize build phase.</p><h3>2. Setup ksops in your Git Repository</h3><p>In the same directory as your kustomization.yaml, you typically create a small plugin config referencing your sops encoded (.enc.yaml) files. For example:</p><pre>my-kustomize-dir/<br>├─ kustomization.yaml<br>├─ secret.enc.yaml     # The SOPS-encrypted secret<br>├─ ksops-config.yaml   # The ksops plugin generator<br>├─ other-manifest.yaml</pre><h4>A) kustomization.yaml Example</h4><pre>apiVersion: kustomize.config.k8s.io/v1beta1<br>kind: Kustomization<br><br>resources:<br>  # Some normal resources that are not encrypted<br>  - deployment.yaml<br>  - service.yaml<br><br>generators:<br>  # Reference the ksops plugin configuration<br>  - ksops-config.yaml</pre><h4>B) ksops-config.yaml Example</h4><pre>apiVersion: viaduct.ai/v1<br>kind: ksops<br>metadata:<br>  name: ksops-config<br>files:<br># List all SOPS-encrypted YAMLs that you want ksops to handle<br>- secret.enc.yaml</pre><p>Here’s what happens:</p><ul><li><strong>apiVersion: viaduct.ai/v1</strong> and <strong>kind: ksops</strong> indicates to kustomize that it should use the <strong>ksops plugin</strong>.</li><li><strong>files</strong> points to your SOPS-encrypted file(s). Ksops will decrypt these on the fly.</li></ul><p>When kustomize runs with — enable-alpha-plugins, it sees ksops-config.yaml, loads the plugin, and decrypts secret.enc.yaml into a valid Kubernetes Secret manifest.</p><h4>C) Prepare your .sops.yaml (Optional but Recommended)</h4><p>If you’re using AWS KMS, GCP KMS, Azure, GPG, or Vault, you can define it in a .sops.yaml so you don’t have to specify the encryption key on every command. Example .sops.yaml:</p><pre>creation_rules:<br>- kms: &quot;arn:aws:kms:us-east-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab&quot;<br>encrypted_regex: &#39;^(data|stringData)$&#39;<br>path_regex: &#39;.*-secret\.yaml$&#39;</pre><p><strong>Please Note</strong>: If you want to see how to handle secrets with the SOPS CLI, have a look at <a href="https://medium.com/itnext/securing-secrets-in-a-gitops-environment-with-sops-dccd8e8952d9">my previous article</a>.</p><h3>3. Setup ksops in ArgoCD</h3><ul><li>Argo CD must be configured to <strong>allow custom kustomize plugins</strong>.</li><li><strong>Mount</strong> the ksops plugin into your Argo CD repo-server.</li></ul><h4>Argo CD custom plugin configuration</h4><p>In your argocd-cm ConfigMap, you might add something like:</p><pre>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: argocd-cm<br>  namespace: argocd<br>data:<br>  ...<br>  # Enable custom plugins in Kustomize<br>  kustomize.buildOptions: &quot; --enable-alpha-plugins&quot;<br>  ...</pre><h4>Argo CD Repo Server Configuration</h4><p>Below a snippet from the argocd-repo-server Deployment with just the relevent part for ksops integration:</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: argocd-repo-server<br>  namespace: argocd<br>spec:<br>  template:<br>    spec:<br>      initContainers:<br>        - name: install-ksops<br>          image: viaductoss/ksops:v4.3.1<br>          command: [&quot;/bin/sh&quot;, &quot;-c&quot;]<br>          args:<br>            - echo &quot;Installing KSOPS...&quot;;<br>              mv ksops /custom-tools/;<br>              mv kustomize /custom-tools/;<br>              echo &quot;Done.&quot;;<br>          volumeMounts:<br>            - mountPath: /custom-tools<br>              name: custom-tools<br>        - name: import-gpg-key<br>          image: quay.io/argoproj/argocd:v2.14.15<br>          command: [&quot;gpg&quot;, &quot;--import&quot;,&quot;/sops-gpg/ci.asc&quot;]<br>          env:<br>            - name: GNUPGHOME<br>              value: /gnupg-home/.gnupg<br>          volumeMounts:<br>            - mountPath: /sops-gpg<br>              name: sops-gpg<br>            - mountPath: /gnupg-home<br>              name: gnupg-home<br>      containers:<br>      - name: argocd-repo-server<br>        env:<br>          - name: XDG_CONFIG_HOME<br>            value: /.config<br>          - name: GNUPGHOME<br>            value: /home/argocd/.gnupg<br>        volumeMounts:<br>        - mountPath: /home/argocd/.gnupg<br>          name: gnupg-home<br>          subPath: .gnupg<br>        - mountPath: /usr/local/bin/kustomize<br>          name: custom-tools<br>          subPath: kustomize<br>        - mountPath: /usr/local/bin/ksops<br>          name: custom-tools<br>          subPath: ksops<br>      volumes:<br>      - name: custom-tools<br>        emptyDir: {}<br>      - name: gnupg-home<br>        emptyDir: {}<br>      - name: sops-gpg<br>        secret:<br>          secretName: sops-gpg-key<br></pre><p>In the snippet you can notice an init container copying ksops and kustomize into the /custom-tools folder. This folder is then mounted into the main container, so that the repo server can access those binaries.</p><h3>4. Provide SOPS Credentials/Keys to Argo CD</h3><p>The Repo Server Pod must have access to the SOPS decryption keys (GPG keys, KMS credentials, or Vault token). Common approaches:</p><ol><li><strong>AWS KMS</strong>:</li></ol><ul><li>The Argo CD repo-server’s service account can be annotated with a IAM role with KMS Decrypt permissions.</li><li>Alternatively, set environment variables (e.g., AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) in the Argo CD repo-server deployment if you do not use IRSA/roles.</li></ul><p><strong>2. GPG</strong>:</p><ul><li>Mount your GPG Key from a Secret.</li><li>Ensure SOPS can find that key in $GNUPGHOME.</li></ul><p><strong>3. Vault</strong>:</p><ul><li>Provide VAULT_ADDR and VAULT_TOKEN (or some dynamic auth method like Kubernetes auth) to the repo-server.</li><li>SOPS calls the Vault Transit engine.</li></ul><p>Without the correct credentials, the decryption step in Argo CD will fail.</p><h3>Summary of Key Steps</h3><ol><li><strong>Encrypt your secret</strong> with SOPS.</li><li><strong>Use ksops</strong> in kustomization.yaml (via a ksops plugin config) so kustomize can decrypt at build time.</li><li><strong>Enable alpha plugins in ArgoCD</strong> via the ConfigMap.</li><li><strong>Install the ksops plugin in the ArgoCD Repo Server</strong>.</li><li><strong>Provide the necessary SOPS keys/credentials</strong> to Argo CD’s repo-server (IAM role, GPG key, Vault token, etc.).</li><li><strong>Argo CD</strong> checks out your repo, runs kustomize (with ksops), decrypts secrets, and applies them to the cluster.</li></ol><p>With this setup, you have a secure, GitOps-friendly pipeline where your secrets remain encrypted in Git, yet Argo CD can dynamically decrypt them and deploy your apps.</p><h3>Contact Information</h3><p>Got questions, want to chat, or are just keen to stay connected? Write something here in the comments, or let’s connect on <a href="https://www.linkedin.com/in/paolo-carta/">LinkedIn</a> or visit my <a href="https://www.paolocarta.com/">website</a>. Don’t forget to subscribe to the <a href="https://medium.com/@paolocarta_it/subscribe">Medium Newsletter</a> so that you will not miss any updates!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e797b167d791" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/integrating-sops-in-argocd-to-handle-kubernetes-secrets-e797b167d791">Integrating SOPS in ArgoCD to handle Kubernetes Secrets</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securing Secrets in a GitOps Environment with SOPS]]></title>
            <link>https://itnext.io/securing-secrets-in-a-gitops-environment-with-sops-dccd8e8952d9?source=rss-9d447107642b------2</link>
            <guid isPermaLink="false">https://medium.com/p/dccd8e8952d9</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[yaml]]></category>
            <category><![CDATA[gitops]]></category>
            <category><![CDATA[encryption]]></category>
            <dc:creator><![CDATA[Paolo Carta]]></dc:creator>
            <pubDate>Sun, 13 Jul 2025 14:26:40 GMT</pubDate>
            <atom:updated>2025-07-13T16:30:54.973Z</atom:updated>
            <content:encoded><![CDATA[<p>Managing secrets, for instance API keys, database credentials, certificates, safely and efficiently is one of the hardest parts of operating a cloud native infrastructure. GitOps brings reproducibility and auditability by storing all configuration in a Git repository. But how do you keep sensitive values in Git, without risking exposure? In this post, I explore how<a href="https://github.com/mozilla/sops"> Mozilla SOPS</a> fits GitOps to encrypt, version and decrypt secrets alongside your Kubernetes manifests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z3Z-min-L7IhCy1nFgN08A.png" /></figure><h3>The Challenge of Secrets in GitOps</h3><ul><li>Storing secrets as plain text violates security best practices.</li><li>Secret management tools (Vault, AWS Secrets Manager) can complicate the GitOps flow and break the declarative Git-centric model.</li></ul><p>We need a way to keep secrets in Git <em>and</em> encrypted end-to-end.</p><h3>Mozilla SOPS</h3><p><strong>What is SOPS?</strong> A tool for encrypting/decrypting YAML, JSON and other files, using keys handled by KMS systems, Vault, PGP and more.</p><p><strong>Core features</strong>:</p><ul><li>Encrypts only the values, leaves the rest of the document intact.</li><li>Supports multiple key sources for flexible key management.</li><li>JSON/YAML aware.</li></ul><h3>Setting Up SOPS for Your Repository</h3><ol><li><strong>Install SOPS</strong></li></ol><pre>brew install sops           # macOS<br>apt-get install sops        # Debian/Ubuntu</pre><p><strong>2. Choose a Key Management Backend</strong></p><ul><li>AWS KMS: sops --kms arn:aws:kms:...</li><li>GCP KMS: sops --gcp-kms projects/...</li><li>PGP: sops --pgp 0123456789ABCDEF...</li></ul><p>3. <strong>Initialize the Configuration</strong></p><p>Create a .sops.yaml at the root of your repo:</p><pre>creation_rules:<br>  - path_regex: &quot;.*\.ya?ml$&quot;<br>    kms: [&quot;arn:aws:kms:region:acct-id:key/key-id&quot;]<br>    encrypted_regex: &quot;.*&quot;</pre><p>This allows to avoid specifying keys each time you use the sops CLI.</p><h3>Encrypting and Committing Secrets</h3><p><strong>Create a secret file</strong> (db-credentials.yaml)</p><pre>db:<br>  username: myuser<br>  password: mypassword</pre><p><strong>Encrypt with SOPS</strong></p><pre>sops --encrypt db-credentials.yaml &gt; db-credentials.sops.yaml</pre><p><strong>Commit to Git</strong></p><pre>git add db-credentials.sops.yaml  # needed only the first time<br>git commit -m &quot;Add encrypted DB credentials&quot;<br>git push origin main</pre><p>Before commiting to Git, it would be helpful to have a .gitignore file in order to avoid committing secret files without the .sops.yaml extension.</p><pre># Ignore files containing “secret.yaml” or “secrets.yaml” in their name<br>*secret.yaml*<br>*secrets.yaml*</pre><h3>Best Practices</h3><ul><li><strong>Rotate keys regularly</strong>: Use SOPS key rotation commands and re-encrypt files.</li><li><strong>Use multiple key backends</strong>: Allows failover if one KMS is unavailable.</li><li><strong>Automate encryption in CI</strong>: Prevent accidentally committing plaintext fine tuning the .sops file and also by adding a CI check.</li></ul><h3>Troubleshooting</h3><ul><li><strong>Decryption errors</strong>: Verify KMS permissions and local key availability.</li><li><strong>Merge conflicts</strong>: SOPS’s structured diffs reduce noise, but complex merges may still require manual resolution.</li></ul><h3>Conclusion</h3><p>By combining SOPS with a GitOps workflow, you keep the benefits of declarative, Git-based deployments while ensuring that secrets remain encrypted at rest and in transit. This approach maintains auditability, traceability, and security, simplifying operations for teams.</p><h3>Contact Information</h3><p>Got questions, want to chat, or are just keen to stay connected? Write something here in the comments, or let’s connect on <a href="https://www.linkedin.com/in/paolo-carta/">LinkedIn</a> or visit my <a href="https://www.paolocarta.com/">website</a>. Don’t forget to subscribe to the <a href="https://medium.com/@paolocarta_it/subscribe">Medium Newsletter</a> so that you will not miss any updates!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dccd8e8952d9" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/securing-secrets-in-a-gitops-environment-with-sops-dccd8e8952d9">Securing Secrets in a GitOps Environment with SOPS</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using ArgoCD ApplicationSet to deploy to multiple clusters]]></title>
            <link>https://itnext.io/using-applicationset-to-deploy-to-multiple-clusters-28f6879be217?source=rss-9d447107642b------2</link>
            <guid isPermaLink="false">https://medium.com/p/28f6879be217</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[argo-cd]]></category>
            <dc:creator><![CDATA[Paolo Carta]]></dc:creator>
            <pubDate>Sat, 05 Jul 2025 10:06:00 GMT</pubDate>
            <atom:updated>2025-07-06T08:32:11.578Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/">ApplicationSets</a> can be really useful to generate several applications, for instance when using multiple environments. This can be achieved by using generators, for instance the list, git or cluster ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bmElW53g36_VDBiMWCvyuw.png" /></figure><p>Let’s suppose now that ArgoCD is running in a management cluster and we need to deploy to serveral clusters, one per environment. So we can assume to have 3 clusters:</p><ul><li>management</li><li>test</li><li>prod</li></ul><p>If we want to use a simple list generator, the manifest could look like this:</p><pre>apiVersion: argoproj.io/v1alpha1<br>kind: ApplicationSet<br>metadata:<br>  name: applications<br>  namespace: argocd<br>spec:<br>  generators:<br>    - list:<br>        elements:<br>          - env: test<br>            cluster: https://test-cluster-url<br>          - env: prod<br>            cluster: https://prod-cluster-url<br>  template:<br>    metadata:<br>      name: &#39;my-app-{{env}}&#39;<br>    spec:<br>      project: backend-domain<br>      destination:<br>        server: &#39;{{cluster}}&#39;<br>        namespace: apps<br>      source:<br>        repoURL: https://github.com/my-org/gitops-repo.git<br>        targetRevision: main<br>        path: &#39;applications/overlays/{{env}}&#39;</pre><p>In this case, two applications will be generated, one for the test environment and one for prod. Each cluster has its own name and cluster URL. These parameters can be used in the ArgoCD Application template.</p><p>Alternatively we could have used a Cluster generator, taking care to filter the local management cluster by using a label selector:</p><pre>apiVersion: argoproj.io/v1alpha1<br>kind: ApplicationSet<br>metadata:<br>  name: applications<br>  namespace: argocd<br>spec:<br>  generators:<br>    - clusters:<br>        selector:<br>          matchLabels:<br>            argocd.argoproj.io/secret-type: cluster<br>  template:<br>    metadata:<br>      name: &#39;my-app-{{name}}&#39;<br>    spec:<br>      project: backend-domain<br>      destination:<br>        server: &#39;{{server}}&#39;<br>        namespace: apps<br>      source:<br>        repoURL: https://github.com/my-org/gitops-repo.git<br>        targetRevision: main<br>        path: &#39;applications/overlays/{{name}}&#39;</pre><p>The manifest above is using out of the box parameters provided by the cluster generator. This approach is more dynamic, so adding new clusters would result into new ArgoCD applications for our app.</p><h3>Contact Information</h3><p>Got questions, want to chat, or are just keen to stay connected? Write something here in the comments, or let’s connect on <a href="https://www.linkedin.com/in/paolo-carta/">LinkedIn</a> or visit my <a href="https://www.paolocarta.com/">website</a>. Don’t forget to subscribe to the <a href="https://medium.com/@paolocarta_it/subscribe">Medium Newsletter</a> so that you will not miss any updates!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28f6879be217" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/using-applicationset-to-deploy-to-multiple-clusters-28f6879be217">Using ArgoCD ApplicationSet to deploy to multiple clusters</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handle immutable fields in Kubernetes with ArgoCD]]></title>
            <link>https://medium.com/@paolocarta_it/handle-immutable-fields-in-kubernetes-with-argocd-0910253d566e?source=rss-9d447107642b------2</link>
            <guid isPermaLink="false">https://medium.com/p/0910253d566e</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[argo-cd]]></category>
            <dc:creator><![CDATA[Paolo Carta]]></dc:creator>
            <pubDate>Fri, 04 Jul 2025 15:37:11 GMT</pubDate>
            <atom:updated>2025-07-23T07:52:42.713Z</atom:updated>
            <content:encoded><![CDATA[<p>In Kubernetes several fields are immutable by default. This is because Kubernetes tries to follow the Immutable Infrastructure Pattern, where once you deploy something, the core structure cannot be changed.</p><p>One of those fields is the label selector for instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PV7_rwcx8slUqwxHwIduFw.png" /></figure><p>Let’s suppose we apply this Deployment:</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: my-app<br>spec:<br>  replicas: 2<br>  selector:<br>    matchLabels:<br>      app: my-app<br>  template:<br>    metadata:<br>      labels:<br>        app: my-app<br>        domain: example<br>    spec:<br>      containers:<br>        - name: my-app-container<br>          image: nginx:latest<br>          ports:<br>            - containerPort: 80</pre><p>The Engineering team then wants to add the “domain” label to the selector like this:</p><pre>spec:<br>  selector:<br>    matchLabels:<br>      app: my-app<br>      domain: example</pre><p>Applying the manifest an error will be displayed:</p><pre>kubectl apply -f deploy.yaml<br><br>The Deployment &quot;my-app&quot; is invalid: spec.selector: Invalid value: <br>v1.LabelSelector{MatchLabels:map[string]string{&quot;app&quot;:&quot;my-app&quot;, &quot;domain&quot;:&quot;example&quot;}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}:<br>field is immutable</pre><p>Same error would appear if the manifest was applied using ArgoCD.</p><p>To solve the issue manually you would need to delete and reapply the manifest:</p><pre>kubectl delete deploy my-app<br>kubectl apply -f deploy.yaml</pre><p>With ArgoCD you can solve the issue by annotating the object, in this case the Deployment:</p><pre>metadata:<br>  annotations:<br>    argocd.argoproj.io/sync-options: Force=true,Replace=true</pre><h3>Contact Information</h3><p>Got questions, want to chat, or are just keen to stay connected? Write something here in the comments, or let’s connect on <a href="https://www.linkedin.com/in/paolo-carta/">LinkedIn</a> or visit my <a href="https://www.paolocarta.com/">website</a>. Don’t forget to subscribe to the <a href="https://medium.com/@paolocarta_it/subscribe">Medium Newsletter</a> so that you will not miss any updates!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0910253d566e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A less known feature: Pod Readiness Gates in Kubernetes]]></title>
            <link>https://itnext.io/a-less-known-feature-pod-readiness-gates-in-kubernetes-bbcdc6a8cadb?source=rss-9d447107642b------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbcdc6a8cadb</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[readinessprobe]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Paolo Carta]]></dc:creator>
            <pubDate>Mon, 28 Apr 2025 11:06:39 GMT</pubDate>
            <atom:updated>2025-04-28T11:53:25.069Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*etFtZy1wfsrEEYtJ" /></figure><p>In Kubernetes a Pod is marked as ready when:</p><ul><li>All containers are running</li><li>The <strong>readiness probe</strong> passes</li></ul><h3>Readiness Gate:</h3><p>You can define <strong>custom conditions</strong> (usually set by external controllers or components) that must also be true before the pod is considered ready and added to service load balancing pool.</p><h3>Use Case:</h3><p>Suppose your app depends on an <strong>external system</strong> (e.g., database, config sync) that Kubernetes can’t check with a normal readiness probe. A custom controller can set a condition in the Pod’s status once everything is good.</p><h3>Example:</h3><h4>Pod Spec with Readiness Gate</h4><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: paolos-pod<br>spec:<br>  readinessGates:<br>  - conditionType: &quot;paolocarta.com/ready&quot;<br>  containers:<br>  - name: app<br>    image: nginx:latest<br>    readinessProbe:<br>      httpGet:<br>        path: /<br>        port: 80</pre><h3>What happens:</h3><ul><li>The container readiness probe passes ✅</li><li>Pod is <strong>still not ready</strong> ❌</li></ul><p>It will stay like this until something sets:</p><pre>status:<br>  conditions:<br>  - type: &quot;paolocarta.com/ready&quot;<br>    status: &quot;True&quot;</pre><p>You can update this condition via the Kubernetes API using a controller or custom logic.</p><h3>Conclusions</h3><p>In this short article we explained this simple but less known functionality offered by Kubernetes to enhance readiness probes in more complex scenarios.</p><h3>Contact Information</h3><p>Got questions, want to chat, or are just keen to stay connected? Write something here in the comments, or let’s connect on <a href="https://www.linkedin.com/in/paolo-carta/">LinkedIn</a> or visit my <a href="https://www.paolocarta.com/">website</a>. Don’t forget to subscribe to the <a href="https://medium.com/@paolocarta_it/subscribe">Medium Newsletter</a> so that you will not miss any updates!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbcdc6a8cadb" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/a-less-known-feature-pod-readiness-gates-in-kubernetes-bbcdc6a8cadb">A less known feature: Pod Readiness Gates in Kubernetes</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating an ArgoCD Terraform Module to install it to multiple K8s clusters on AWS]]></title>
            <link>https://itnext.io/creating-an-argocd-terraform-module-to-install-it-to-multiple-clusters-on-aws-6d47d376abbc?source=rss-9d447107642b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d47d376abbc</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[argo-cd]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[gitops]]></category>
            <dc:creator><![CDATA[Paolo Carta]]></dc:creator>
            <pubDate>Sun, 13 Apr 2025 10:30:00 GMT</pubDate>
            <atom:updated>2025-04-14T20:31:03.880Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IUnXZU5JfUWEr3J6" /></figure><h3>Introduction</h3><p>Several projects are using multiple Kubernetes clusters, for instance, to represent multiple environments, different domains, or regions. One approach is to have an ArgoCD installation in each cluster, which manages everything deployed to it. It is a common choice if you have strict security requirements and need strong isolation.</p><p>Having multiple ArgoCD instances to be managed can be cumbersome. Moreover, how do we bootstrap them at the really beginning?</p><p>One solution could be to create the Kubernetes clusters with Terraform and bootstrap ArgoCD from it leveraging providers.</p><p>This article show how you could create a Terraform ArgoCD module, which can be used to spinup multiple ArgoCD installations, one per cluster.</p><p>Repo on GitHub: <a href="https://github.com/paolocarta/argocd-install-terraform-module">https://github.com/paolocarta/argocd-install-terraform-module</a></p><h3>File/Directory Layout</h3><p>The layout for this article will look like this for simplicity:</p><pre>.<br>│<br>├── clusters<br>│   ├── cluster1<br>│   │   ├── auth.tf<br>│   │   ├── main.tf<br>│   │   ├── provider.tf<br>│   │   └── versions.tf<br>│   │<br>│   └── cluster2/<br>│<br>└── module<br>    └── argocd<br>        ├── main.tf<br>        ├── manifests<br>        │   ├── app-of-apps.tmpl.yaml<br>        │   └── argocd-values.tmpl.yaml<br>        ├── providers.tf<br>        ├── terraform.tf<br>        └── variables.tf</pre><ul><li><strong>module/argocd</strong>: A Terraform module to install Argo CD using Helm and bootstrap it with a root app of apps.</li><li><strong>clusterX/main.tf</strong>: A folder for each cluster referencing the module, using a provider that points to the target cluster.</li></ul><p>You can adapt this structure to fit your existing repository patterns.</p><h3>Create a Reusable Module</h3><p>Inside module/argocd, define your Terraform module, which installs ArgoCD in the target cluster with Helm. Afterwards, bootstraps it with an App of Apps in order to install all the rest. The App of Apps points to your GitOps Repo, which contains all YAML Manifests. For an example GitOps Repo you can check out <a href="https://medium.com/@paolocarta_it/how-to-structure-your-gitops-repository-with-per-cluster-argocd-instances-b65bcc937322">this article</a>.</p><p>Below the most important parts of the Terraform plan.</p><p><em>module/argocd/variables.tf:</em></p><pre>variable &quot;namespace&quot; {<br>  type        = string<br>  description = &quot;Kubernetes namespace to install Argo CD.&quot;<br>  default     = &quot;argocd&quot;<br>}<br><br>variable &quot;chart_version&quot; {<br>  type        = string<br>  description = &quot;Version of the Argo CD Helm chart.&quot;<br>  default     = &quot;7.8.23&quot; # https://artifacthub.io/packages/helm/argo/argo-cd<br>}<br><br>variable &quot;root_app_of_apps&quot; {<br>  type = object({<br>    repo_url = string<br>    branch = optional(string, &quot;main&quot;)<br>    manifest_path = optional(string, &quot;bootstrap&quot;)<br>    project_name = optional(string, &quot;default&quot;)<br>    recurse = optional(bool, false)<br>  })<br>  description = &quot;Git repo and path to the ArgoCD Applications&quot;<br>}<br><br>variable &quot;kubernetes&quot; {<br>  type = object({<br>    cluster_endpoint                   = string<br>    cluster_certificate_authority_data = string<br>    cluster_name                       = string<br>  })<br>  description = &quot;Cluster endpoint and credentials&quot;<br>}<br><br>variable &quot;hostname&quot; {<br>  type = string<br>  description = &quot;Hostname to expose argocd using ingress&quot;<br>}<br><br>variable &quot;ingress_class_name&quot; {<br>  type = string<br>  default = &quot;traefik&quot;<br>  description = &quot;Ingress class name to expose argocd using ingress&quot;<br>}<br><br>variable &quot;node_label&quot; {<br>  type = string<br>  description = &quot;Node label for nodeSelector&quot;<br>}</pre><p>These variables are used to adapt the installation to your needs.</p><p><em>module/argocd/main.tf</em></p><p>Here we have 3 important elements:</p><ul><li>Namespace</li><li>ArgoCD installed by Helm</li><li>Bootstrap App of Apps</li></ul><pre><br>resource &quot;kubernetes_namespace&quot; &quot;argocd&quot; {<br>  metadata {<br>    name = var.namespace<br>    labels = {<br>      name = &quot;argocd&quot;<br>    }<br>  }<br>}<br><br>resource &quot;helm_release&quot; &quot;argocd&quot; {<br>  max_history = 5<br>  name        = &quot;argo-cd&quot;<br>  chart       = &quot;argo-cd&quot;<br>  repository  = &quot;https://argoproj.github.io/argo-helm&quot;<br>  namespace   = kubernetes_namespace.argocd.id<br>  version     = var.chart_version                                # https://artifacthub.io/packages/helm/argo/argo-cd<br>  <br>  values      = [<br>    templatefile(&quot;${path.module}/manifests/argocd-values.tmpl.yaml&quot;, {<br>      hostname = var.hostname,<br>      ingress_class_name = var.ingress_class_name,<br>      node_label = var.node_label,<br>      git_url = &quot;git@gitlab.mycompany.com&quot;<br>      git_repo_url = var.application_source.repoURL<br>      secret_argocd_admin_password = &quot;&lt;my-secret&gt;&quot;<br>      gitlab_ssh_private_key = &quot;&lt;my-ssh-key&gt;&quot;<br>    })<br>  ]<br><br>  timeout    = 600<br>  wait       = true   # This is the default<br>}<br><br><br>resource &quot;kubernetes_manifest&quot; &quot;app_of_apps&quot; {<br>  depends_on = [helm_release.argocd]<br><br>  manifest = yamldecode(<br>    templatefile(&quot;${path.module}/manifests/app-of-apps.tmpl.yaml&quot;, {<br>      repo_url       = var.root_app_of_apps.repo_url<br>      branch         = var.root_app_of_apps.branch<br>      manifest_path  = var.root_app_of_apps.manifest_path<br>      project_name   = var.root_app_of_apps.project_name<br>      recurse        = var.root_app_of_apps.recurse  <br>    })<br>  )<br>}</pre><p>We defined the Namespace for ArgoCD, so that we can define additional labels and annotations according to the needs.</p><p>Then we install ArgoCD with an Helm Release, where we provide a values.yaml file which is using a few template parameters. This way we can dynamically adapt the values.yaml file for each Kubernetes Cluster.</p><p>Finally we install the Root App of Apps, which is the ArgoCD Application that points to the other Applications defined in the GitOps repo. It basically allow to bootstrap ArgoCD feeding it with all Applications and AppProjects. Keep in mind that we could even fetch it directly from the GitOps repo if we want.</p><p>For an example GitOps Repo you can check out <a href="https://medium.com/@paolocarta_it/how-to-structure-your-gitops-repository-with-per-cluster-argocd-instances-b65bcc937322">this article</a>.</p><p><em>module/argocd/providers.tf:</em></p><pre>data &quot;aws_eks_cluster_auth&quot; &quot;cluster&quot; {<br>  name = var.kubernetes.cluster_name<br>}<br><br>provider &quot;kubernetes&quot; {<br>  host                   = var.kubernetes.cluster_endpoint<br>  cluster_ca_certificate = base64decode(var.kubernetes.cluster_certificate_authority_data)<br>  token                  = data.aws_eks_cluster_auth.cluster.token<br>}<br><br>provider &quot;helm&quot; {<br>  kubernetes {<br>    host                   = var.kubernetes.cluster_endpoint<br>    cluster_ca_certificate = base64decode(var.kubernetes.cluster_certificate_authority_data)<br>    token                  = data.aws_eks_cluster_auth.cluster.token<br>  }<br>}</pre><p>As you can see we are using two providers:</p><ul><li>Helm</li><li>Kubernetes</li></ul><p>The Helm provider is used to install ArgoCD from its official Helm Chart.</p><p>The Kubernetes provider is used to install the bootstrap App of Apps. Credentials are provided to the module through variables and a Terraform datasource.</p><h3>ClusterX</h3><p>Now, for each EKS Kubernetes Cluster we will use the module to install ArgoCD and bootstrap it with a root App of Apps.</p><p><em>clusters/cluster1/main.tf:</em></p><pre>module &quot;argocd&quot; {<br>  source = &quot;../../module/argocd&quot; <br><br>  hostname = &quot;argocd.cluster1.my-company.com&quot;<br><br>  kubernetes = {<br>    cluster_endpoint                   = module.aws_eks.cluster_endpoint<br>    cluster_certificate_authority_data = module.aws_eks.cluster_certificate_authority_data<br>    cluster_name                       = module.aws_eks.cluster_name<br>  }<br><br>  node_label = &quot;system&quot;<br><br>  root_app_of_apps = {<br>    repo_url        = &quot;git@gitlab.my-company-com:infra/gitops-repo&quot;<br>    manifest_path   = &quot;argocd/applications/cluster1&quot;<br>    project_name    = &quot;system&quot;<br>    recurse         = true<br>  }<br>}<br><br># Dummy EKS cluster <br>module &quot;aws_eks&quot; {<br>  source  = &quot;terraform-aws-modules/eks/aws&quot;<br>  version = &quot;20.35.0&quot;<br><br>  cluster_name    = &quot;${local.name}-al2&quot;<br>  cluster_version = &quot;1.31&quot;<br><br>  [...]<br>}</pre><p>As you can see we reference the local ArgoCD module. Obviously, you can define it also in a separate repo and reference it, according to your structure in Git.</p><p>The module uses cluster information provided by an EKS module (or datasource) you define. Additionally we configure the bootstrap App of Apps so that it points to the correct folder in the GitOps repo.</p><p>For an example GitOps Repo you can check out <a href="https://medium.com/@paolocarta_it/how-to-structure-your-gitops-repository-with-per-cluster-argocd-instances-b65bcc937322">this article</a>.</p><h3>Conclusions</h3><p>In this article we explored the idea of having a single module for installing ArgoCD into multiple Kubernetes clusters. It allows to speed up operations and bootstrap all installations using the App of Apps pattern.</p><h3>Contact Information</h3><p>Got questions, want to chat, or are just keen to stay connected? Write something here in the comments, or let’s connect on <a href="https://www.linkedin.com/in/paolo-carta/">LinkedIn</a> or visit my <a href="https://www.paolocarta.com/">website</a>. Don’t forget to subscribe to the <a href="https://medium.com/@paolocarta_it/subscribe">Medium Newsletter</a> so that you will not miss any updates!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d47d376abbc" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/creating-an-argocd-terraform-module-to-install-it-to-multiple-clusters-on-aws-6d47d376abbc">Creating an ArgoCD Terraform Module to install it to multiple K8s clusters on AWS</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating PostgreSQL’s DB Volumes from one Kubernetes Cluster to another]]></title>
            <link>https://itnext.io/migrating-postgresqls-db-volumes-from-one-kubernetes-cluster-to-another-449544152bbd?source=rss-9d447107642b------2</link>
            <guid isPermaLink="false">https://medium.com/p/449544152bbd</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Paolo Carta]]></dc:creator>
            <pubDate>Sun, 06 Apr 2025 13:56:22 GMT</pubDate>
            <atom:updated>2025-04-16T07:22:35.640Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>A lot of teams are running Relational Databases in Kubernetes, usually using Operators. Focusing on PostgreSQL DB, two are pretty popular:</p><ul><li>Zalando Operator (The one I will use)</li><li>Cloud Native PG</li></ul><p>Databases can run smoothly for a long time, and some of them might accumulate lots of data, several Terabytes to Petabytes. This could require several days to migrate the DB to a new Kubernetes cluster by using classic backup and restore solutions provided by the operators.</p><p>Some teams have strict requirements; therefore, in some cases, it could be a good idea to directly migrate the DB Volumes from one k8s Cluster to another one. This can be carried out by shutting down the older instance and spinning up the new one in the new cluster after porting the Volumes.</p><p>In this article, we focus on a test DB Cluster managed by the Zalando Operator. This procedure is riskier compared to a DB deployed with a Helm Chart since the operator could delete or manipulate the volumes.</p><p>This page explains the process I followed for testing the procedure, highlighting potential issues and their solutions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ftbTJNir6CGM_PTpxR8XMw.png" /></figure><h3>Install the Zalando Operator</h3><p>Let’s install the operator with a specific version, for instance 1.14.0 in order to avoid unexpected behaviour in future versions.</p><pre>helm repo add postgres-operator-charts https://opensource.zalando.com/postgres-operator/charts/postgres-operator<br><br>kubectl create ns postgres<br>helm install postgres-operator postgres-operator-charts/postgres-operator -n postgres --version 1.14.0<br><br>Output:<br>NAME: postgres-operator<br>LAST DEPLOYED: Fri Mar 14 11:42:45 2025<br>NAMESPACE: default<br>STATUS: deployed<br>REVISION: 1<br>TEST SUITE: None<br>NOTES:</pre><h3>Create the origin DB Cluster</h3><p>The first step is to create a cluster which resembles a real one. A DBs like this one is using an architecture with a read/write master and a few read replicas. The architecture is managed by Patroni, which is used by the Operator.</p><p>We will create a test cluster with one master and a read replica. In other words, we will have 2 PVCs/PVs:</p><ul><li>PVC/PV for the Master</li><li>PVC/PV for the Read Replica</li></ul><p>The cluster is created by using the Operator’s Custom Resource. Below an extract of the Manifest:</p><pre>apiVersion: &quot;acid.zalan.do/v1&quot;<br>kind: postgresql<br>metadata:<br> name: acid-minimal-cluster<br> namespace: postgres<br> labels:<br>   app: test-pg<br>spec:<br> teamId: &quot;acid&quot;<br> volume:<br>   size: 1Gi<br> numberOfInstances: 2<br> users:<br>   paolo:  # database owner<br>     - superuser<br>     - createdb<br>   replication-user:<br>     - login<br>     - replication<br>   foo_user: []  # role for application foo<br> databases:<br>   foo: paolo  # dbname: owner<br> # preparedDatabases:<br> #   bar: {}<br> postgresql:<br>   version: &quot;16&quot;<br> resources:<br>   requests:<br>     cpu: 10m<br>     memory: 100Mi<br>   limits:<br>     cpu: 500m<br>     memory: 500Mi</pre><h3>Prepare the DB</h3><p>For simplicity, we login to the master Pod, which has the psql CLI installed.</p><pre>kubectl exec -it acid-minimal-cluster-0 -- sh<br>psql -U paolo -d foo<br><br>psql (17.2 (Ubuntu 17.2-1.pgdg22.04+1), server 16.6 (Ubuntu 16.6-1.pgdg22.04+1))<br>Type &quot;help&quot; for help.<br><br>foo=#</pre><p>Let’s create a test table:</p><pre>foo=# CREATE TABLE users (<br>  id SERIAL PRIMARY KEY,<br>  name VARCHAR(100) NOT NULL,<br>  email VARCHAR(100) UNIQUE NOT NULL,<br>  age INT CHECK (age &gt; 0),<br>  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP<br>  );</pre><p>Let’s insert some data:</p><pre>foo=# INSERT INTO users (name, email, age)<br>VALUES (&#39;Alice&#39;, &#39;alice@example.com&#39;, 30),<br>       (&#39;Bob&#39;, &#39;bob@example.com&#39;, 25);</pre><p>Let’s verify it:</p><pre>foo=# \dt<br>       List of relations<br> Schema | Name  | Type  | Owner<br>--------+-------+-------+-------<br> public | users | table | paolo<br>(1 row)<br><br><br>foo=# SELECT * FROM users;<br> id | name  |       email       | age |        created_at<br>----+-------+-------------------+-----+---------------------------<br>  1 | Alice | alice@example.com |  30 | 2025-03-14 17:05:50.23025<br>  2 | Bob   | bob@example.com   |  25 | 2025-03-14 17:05:50.23025<br>(2 rows)</pre><h3>Scale Down Origin DB and Backup</h3><p>In order to unmount the volumes, we scaled down the origin DB to 0 replicas:</p><pre><br>apiVersion: &quot;acid.zalan.do/v1&quot;<br>kind: postgresql<br>metadata:<br> name: acid-minimal-cluster<br> namespace: postgres<br> labels:<br>   app: test-pg<br>spec:<br> numberOfInstances: 0</pre><p>Before proceeding, consider taking a snapshot of your disks. The operation depends on the cloud provider.</p><h3>Extract Secrets, PVs and PVCs</h3><p>Here, we need to use the kubectl to get the YAML Manifests we need.</p><p>For instance, to get all required manifests, a script can be used:</p><pre>pvcs=$(kubectl get pvc -l cluster-name=acid-minimal-cluster \<br>       -o jsonpath=&#39;{range .items[*]}{.metadata.name}{&quot;,&quot;}{.spec.volumeName}{&quot;\n&quot;}{end}&#39;)<br><br><br>for pvc in $pvcs; do<br>   pvc_name=$(echo $pvc | cut -d, -f1)<br>   volume_name=$(echo $pvc | cut -d, -f2)<br>   echo &quot;PVC: $pvc_name, Volume: $volume_name&quot;<br><br><br>   kubectl get pvc $pvc_name -oyaml &gt;&gt; pvc.yaml<br>   echo &quot;---&quot; &gt;&gt; pvc.yaml<br>   kubectl get pv $volume_name -oyaml &gt;&gt; pv.yaml<br>   echo &quot;---&quot; &gt;&gt; pv.yaml<br>done<br><br><br>secrets=$(kubectl get secrets -l cluster-name=acid-minimal-cluster -o name)<br><br><br>for secret in $secrets; do<br>   echo &quot;Getting Secret: $secret&quot;<br>   kubectl get $secret -oyaml &gt;&gt; secrets.yaml<br>   echo &quot;---&quot; &gt;&gt; secrets.yaml<br>done</pre><p>As usual, we need to clean up the manifests a bit, for instance, removing some annotations or timestamps added by the Kubernetes control plane.</p><h3>Apply YAML Manifests in the New Kubernetes Cluster</h3><p>Before creating the DB Cluster, we need to manually apply the exported manifests, which are PVs, PVCs and Secrets.</p><p>In order to simplify it, a small script is used.</p><pre>required_storage_class=&quot;your-storage-class&quot;<br>if ! kubectl get storageclass $required_storage_class &gt; /dev/null 2&gt;&amp;1; then<br>   echo &quot;Required storage class &#39;$required_storage_class&#39; not found.&quot;<br>   exit 1<br>fi<br><br><br>kubectl apply -n postgres pv.yaml<br>kubectl apply -n postgres pvc.yaml<br>kubectl apply -n postgres secrets.yaml</pre><p>Please keep in mind that you need to specify your storage class.</p><h3>Patch Volumes</h3><p>Once we apply PVCs to the new cluster, they will receive a new UID. PVs need to reference the new UID to bind correctly.</p><p>We need, therefore, to patch the PVs with the newly generated UID for belonging to the PVCs.</p><p>In order to do that, we can extend the script:</p><pre>volumes=$(kubectl get pvc -l cluster-name=acid-minimal-cluster \<br>      -o jsonpath=&#39;{range .items[*]}{.spec.volumeName}{&quot;,&quot;}{.metadata.uid}{&quot;\n&quot;}{end}&#39;)<br>    <br>for volume in $volumes; do<br>  volume_name=$(echo $volume | cut -d, -f1)<br>  claim_uid=$(echo $volume | cut -d, -f2)<br>  echo &quot;Volume: $volume_name, Claim UID: $claim_uid&quot;<br>  kubectl patch pv $volume_name -p &quot;{\&quot;spec\&quot;:{\&quot;claimRef\&quot;:{\&quot;uid\&quot;:\&quot;$claim_uid\&quot;}}}&quot;<br>done</pre><p>Verify PVCs and PVs are bound.</p><pre>➜ kubectl get pvc<br><br>NAME                            STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   VOLUMEATTRIBUTESCLASS   AGE<br>pgdata-acid-minimal-cluster-0   Bound    pvc-42714f3d-cb83-4db6-9113-ddd3217a247a   1Gi        RWO            gp3            &lt;unset&gt;                 89m<br>pgdata-acid-minimal-cluster-1   Bound    pvc-2b3943ed-1de8-40eb-921f-f58a2790eab6   1Gi        RWO            gp3            &lt;unset&gt;                 89m</pre><h3>Create the same DB Cluster in the new Cluster</h3><p>In order to create the cluster, a Postgresql Custom Resource must be created in the new Kubernetes Cluster. We can reuse the definition of the origin cluster. Keep in mind that the DB name must be the same for this process to work.</p><p><strong>We need to verify that users can still login</strong> with the credentials exported from the origin cluster.</p><p>We can do that by extracting the password and setting it as an environment variable in a helper Pod for instance:</p><pre>DB_PWD=$(k get secret paolo.acid-minimal-cluster.credentials.postgresql.acid.zalan.do -oyaml -ojsonpath=&#39;{.data.password}&#39; | base64 --decode)<br><br><br>kubectl run psql -it --image postgres:16.4 -- sh -c &quot;export PGPASSWORD=$DB_PWD &amp;&amp; exec sh&quot;<br>psql -U paolo -h acid-minimal-cluster -p 5432 -d foo</pre><p>For connecting, we used the k8s service associated with the master node. We used Postgresql 16, which matches the deployed version.</p><p>In order to <strong>verify the test data,</strong> we can check if the test table exists and perform a query to it:</p><pre>psql (16.4 (Debian 16.4-1.pgdg120+2))<br>SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)<br>foo=&gt; \dt<br>       List of relations<br>Schema | Name | Type  |  Owner<br>--------+------+-------+----------<br>public | users | table | paolo<br>(1 row)<br><br>foo=# SELECT * FROM users;<br> id | name  |       email       | age |        created_at<br>----+-------+-------------------+-----+---------------------------<br>  1 | Alice | alice@example.com |  30 | 2025-03-14 17:05:50.23025<br>  2 | Bob   | bob@example.com   |  25 | 2025-03-14 17:05:50.23025<br>(2 rows)<br></pre><h3>Notes</h3><p>Since we are moving Persistent Volumes to another cluster, we must keep in mind that there are constraints related to the zone hosting the underlying EBS Disks.</p><p>Persistent volumes have a nodeAffinity rule so that the Worker Node is chosen in the matching availability zone:</p><pre> nodeAffinity:<br>   required:<br>     nodeSelectorTerms:<br>     - matchExpressions:<br>       - key: topology.kubernetes.io/zone<br>         operator: In<br>         values:<br>         - eu-central-1b</pre><p>We must ensure we have nodes in the required zones or have a cluster autoscaler in place to add nodes if necessary.</p><h3>Conclusions</h3><p>In this article, I showed that it is possible to migrate Volumes belonging to one PostgreSQL Cluster to one Kubernetes Cluster to another one. The DB Cluster is managed by the Zalando Operator, which made me skeptical at the beginning, since I thought the volumes might be erased by spinning up a new cluster.</p><h3>Contact Information</h3><p>Got questions, want to chat, or are just keen to stay connected? Write something here in the comments, or let’s connect on <a href="https://www.linkedin.com/in/paolo-carta/">LinkedIn</a> or visit my <a href="https://www.paolocarta.com/">website</a>. Don’t forget to subscribe to the <a href="https://medium.com/@paolocarta_it/subscribe">Medium Newsletter</a> so that you will not miss any updates!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=449544152bbd" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/migrating-postgresqls-db-volumes-from-one-kubernetes-cluster-to-another-449544152bbd">Migrating PostgreSQL’s DB Volumes from one Kubernetes Cluster to another</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using ArgoCD ApplicationSet templating to conditionally apply SyncPolicies]]></title>
            <link>https://blog.devops.dev/using-argocd-applicationset-templating-to-conditionally-apply-syncpolicies-9b5811a39fbd?source=rss-9d447107642b------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b5811a39fbd</guid>
            <category><![CDATA[gitops]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[argo-cd]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Paolo Carta]]></dc:creator>
            <pubDate>Sat, 29 Mar 2025 16:33:09 GMT</pubDate>
            <atom:updated>2025-06-10T15:26:01.920Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eVE-9Rkjjl_l-3qz" /></figure><h3>Introduction</h3><p><a href="https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/">ApplicationSets</a> can be really useful to generate several applications, for instance when using multiple environments. This can be achieved by using generators, for instance the list, git or cluster ones.</p><p>Sometimes the application generated might be different from one environment to another one. For instance, we might want automatic sync on dev and test, but manual sync in the prod environment.</p><p>This article shows how to use an ApplicationSet with <a href="https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/Template/#template-patch">templatePatch</a> to conditionally apply syncPolicy based on the environment. This example assumes you’re using a List or Git generator that includes an env field (e.g., test, prod) for each application.</p><p>✅ Argo CD version required: &gt;= v2.10.0</p><h3>ApplicationSet Manifest</h3><pre>apiVersion: argoproj.io/v1alpha1<br>kind: ApplicationSet<br>metadata:<br>  name: apps-appset<br>spec:<br>  goTemplate: true<br>  generators:<br>    - list:<br>        elements:<br>          - env: dev<br>            namespace: dev-apps<br>          - env: test<br>            namespace: test-apps<br>          - env: prod<br>            namespace: prod-apps<br>  template:<br>    metadata:<br>      name: &#39;my-app-{{.env}}&#39;<br>    spec:<br>      project: apps<br>      source:<br>        repoURL: https://github.com/my-org/gitops.git<br>        targetRevision: HEAD<br>        path: &#39;apps/my-app/overlays/{{.env}}&#39;<br>      destination:<br>        server: https://kubernetes.default.svc<br>        namespace: &#39;{{.namespace}}&#39;<br>  templatePatch: |<br>    {{- if ne .env &quot;prod&quot; }}<br>    spec:<br>      syncPolicy:<br>        automated:<br>          prune: true<br>          selfHeal: true<br>    {{- end }}</pre><p>You can notice the field “<em>goTemplate</em>” set to true to enable go templating. The code specified inline for the field “<em>templatePatch</em>” uses a conditional expression to allow the snippet to be created for environments that are not prod.</p><h3>📝 Notes</h3><ul><li>.env refers to the field from the generator (list.elements in this case).</li><li>For prod, the syncPolicy is omitted, so sync will be manual.</li></ul><p>You can expand this logic further using else conditions, with, etc., since templatePatch uses Go templating syntax.</p><h3>Conclusions</h3><p>We demonstrated a sample usage of the template patching functionality. You can adapt it to your needs, depending on your project requirements.</p><h3>Contact Information</h3><p>Got questions, want to chat, or just keen to stay connected? Write something here in the comments or let’s connect on <a href="https://www.linkedin.com/in/paolo-carta/">LinkedIn</a> or visit my <a href="https://www.paolocarta.com/">website</a>. Don’t forget to subscribe to the <a href="https://medium.com/@paolocarta_it/subscribe">Medium Newsletter</a> so that you will not miss any update!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b5811a39fbd" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/using-argocd-applicationset-templating-to-conditionally-apply-syncpolicies-9b5811a39fbd">Using ArgoCD ApplicationSet templating to conditionally apply SyncPolicies</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ArgoCD GitOps Repository structure with multiple instances]]></title>
            <link>https://medium.com/@paolocarta_it/how-to-structure-your-gitops-repository-with-per-cluster-argocd-instances-b65bcc937322?source=rss-9d447107642b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b65bcc937322</guid>
            <category><![CDATA[kustomize]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[argo-cd]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Paolo Carta]]></dc:creator>
            <pubDate>Fri, 28 Mar 2025 15:44:53 GMT</pubDate>
            <atom:updated>2026-05-13T06:46:46.985Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Many organizations running workloads in Kubernetes are embracing ArgoCD to deploy safely and ensure consistency and traceability.</p><p>Unfortunately there are not many guidelines or best practices yet explaining how to structure the GitOps repository for simplicity and maintainability.</p><p>In this article I would like to show my solution with a setup consisting of a multiple ArgoCD instances. Basically each Kubernetes cluster will have an instance, which will manage all resources belonging to it. ArgoCD will be bootstraped externally, for instance at cluster provisioning with Terraform.</p><p>The structure proposed allows a clear separation between applications, infrastructure and ArgoCD Apps and Projects. Moreover it supports multiple environments by leveraging Kustomize.</p><p>Source repo: <a href="https://github.com/paolocarta/gitops-argocd-repo-structure/tree/multiple-argocd-instances">https://github.com/paolocarta/gitops-argocd-repo-structure/tree/multiple-argocd-instances</a></p><p>Related article about running a single management instance → <a href="https://medium.com/@paolocarta_it/how-to-structure-your-gitops-repository-with-a-single-argocd-instance-f128b916c915">here</a>.</p><p>Tech used:</p><ul><li>Kubernetes</li><li>ArgoCD</li><li>Kustomize</li></ul><p>Architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_OZF5FcgHSerQawg" /></figure><h3>Structure</h3><p>The main idea is to have one folder (apps) where we specify custom applications developed by our dev teams. Another folder (infrastructure) is where DevOps engineers will work, deploying infrastructure and middleware to our clusters. Finally, we need a folder (argocd) to instruct the different ArgoCD instances about what to deploy and where.</p><p>To recap, we have 3 main folders:</p><ul><li>apps (Custom apps developed)</li><li>argocd (argocd Application Custom Resources)</li><li>infrastructure (All middleware deployed by Ops)</li></ul><p>High level structure:</p><pre>➜  gitops-repo git:(main) tree<br>.<br>.<br>├── README.md<br>├── apps<br>│   ├── another-app/<br>│   └── flask-app/<br>├── argocd<br>│   ├── app-projects/<br>│   ├── applications<br>│   │   ├── dev<br>│   │   └── prod<br>│   └── bootstrap<br>│       ├── root-app-dev.yaml<br>│       └── root-app-prod.yaml<br>├── infrastructure<br>│   ├── databases<br>│   │   └── postgres/<br>│   └── message-brokers<br>│       └── rabbitmq/<br>└── tools/</pre><p>In more details the structure looks like in the following diagram. Please, notice that the structure leverages kustomize and its overlays for defining multiple environments and avoid duplication.</p><p>Detailed structure:</p><pre>➜  gitops-repo git:(multiple-argocd-instances) tree<br>.<br>├── apps<br>│   ├── another-app<br>│   │   ├── base<br>│   │   │   ├── deployment.yaml<br>│   │   │   ├── kustomization.yaml<br>│   │   │   └── service.yaml<br>│   │   └── overlays<br>│   │       ├── dev<br>│   │       │   └── kustomization.yaml<br>│   │       └── prod<br>│   │           └── kustomization.yaml<br>│   └── flask-app<br>│       ├── base<br>│       │   ├── deployment.yaml<br>│       │   ├── kustomization.yaml<br>│       │   └── service.yaml<br>│       └── overlays<br>│           ├── dev<br>│           │   └── kustomization.yaml<br>│           └── prod<br>│               └── kustomization.yaml<br>│<br>├── argocd<br>│   ├── app-projects<br>│   │   ├── apps.yaml<br>│   │   ├── databases.yaml<br>│   │   └── system.yaml<br>│   ├── applications<br>│   │   ├── dev<br>│   │   │   ├── apps<br>│   │   │   │   ├── another-app.yaml<br>│   │   │   │   └── flask-app.yaml<br>│   │   │   └── infrastructure<br>│   │   │       ├── postgres.yaml<br>│   │   │       └── rabbitmq.yaml<br>│   │   └── prod/<br>│   └── bootstrap<br>│       ├── root-app-dev.yaml<br>│       └── root-app-prod.yaml<br>│<br>├── infrastructure<br>│   ├── databases<br>│   │   └── postgres<br>│   │       ├── base<br>│   │       │   ├── kustomization.yaml<br>│   │       │   ├── service.yaml<br>│   │       │   └── statefulset.yaml<br>│   │       └── overlays<br>│   │           ├── dev<br>│   │           │   └── kustomization.yaml<br>│   │           └── prod<br>│   │               └── kustomization.yaml<br>│   └── message-brokers<br>│       └── rabbitmq<br>│           ├── base<br>│           │   ├── deployment.yaml<br>│           │   ├── kustomization.yaml<br>│           │   └── service.yaml<br>│           └── overlays<br>│               ├── dev<br>│               │   └── kustomization.yaml<br>│               └── prod<br>│                   └── kustomization.yaml<br>│<br>└── tools<br>    ├── generate-secrets.sh<br>    ├── validate-argocd.sh<br>    └── validate-kustomize.sh<br></pre><p>In order to better understand each folder, each one has a dedicated paragraph below in this article.</p><h3>Infrastructure Folder</h3><p>This folder holds manifests for all infrastructure and middleware, for instance:</p><ul><li>Databases</li><li>Message Brokers</li><li>Caches</li><li>Monitoring</li><li>Logging</li><li>Others</li></ul><pre>│<br>├── infrastructure<br>│   ├── databases<br>│   │   └── postgres<br>│   │       ├── base<br>│   │       │   ├── kustomization.yaml<br>│   │       │   ├── service.yaml<br>│   │       │   └── statefulset.yaml<br>│   │       └── overlays<br>│   │           ├── dev<br>│   │           │   └── kustomization.yaml<br>│   │           └── prod<br>│   │               └── kustomization.yaml<br>│   └── message-brokers<br>│   │   └── rabbitmq<br>│   │       ├── base/<br>│   │       └── overlays/</pre><p>In the example we define a PostgreSQL Database and a RabbitMQ Broker. The middleware is deployed to a dev and prod environment. Each folder will be referenced by an ArgoCD Application. The ArgoCD Application will live in the specific cluster, for instance the dev Application will be only in the dev cluster.</p><p>Each Infrastructure component deployed is defined using Kustomize. A base layer holds common configuration. Each overlay can specify things which are environment specific.</p><h3>Apps Folder</h3><p>The Apps folder represents custom application which are developed by dev teams. Each application is a collection of classic Kubernetes manifests, for instance Deployment, Service, ConfigMaps and so on.</p><p>Each application leverages Kustomize with a base layer and overlays for the environments. An ArgoCD Application will reference each overlay.</p><p>In the example we define two apps:</p><ul><li>Flask Dummy App</li><li>Another Dummy App</li></ul><pre>│<br>├── apps<br>│   ├── another-app<br>│   │   ├── base<br>│   │   └── overlays<br>│   └── flask-app<br>│       ├── base<br>│       │   ├── deployment.yaml<br>│       │   ├── kustomization.yaml<br>│       │   └── service.yaml<br>│       └── overlays<br>│           ├── dev<br>│           │   ├── deployment.yaml<br>│           │   └── kustomization.yaml<br>│           └── prod<br>│               ├── deployment.yaml<br>│               └── kustomization.yaml</pre><h3>ArgoCD Folder</h3><p>This folder is used to define all ArgoCD Applications, divided by environment and AppProjects.</p><p>The first <strong>Application</strong> to <strong>bootstrap</strong> each cluster is the App of Apps:</p><ul><li>bootstrap/root-app-{{environment}}.yaml</li></ul><p>This is the app at the root of the tree hierarchy. It basically points to all other Applications defined for that environment. If we install ArgoCD using Terraform, we could apply this Application as well to bootstrap the system.</p><p>We have an <strong>applications folder</strong>, which is diveded by environment first, then by category, normal apps and infrastructure apps. This allows to separate ArgoCD Applications by cluster and by scope, those who manage custom services and those managing infrastructure and middleware.</p><pre>├── argocd<br>│   ├── app-projects<br>│   │   ├── apps.yaml<br>│   │   ├── databases.yaml<br>│   │   └── system.yaml<br>│   ├── applications<br>│   │   ├── dev<br>│   │   │   ├── apps<br>│   │   │   │   ├── another-app.yaml<br>│   │   │   │   └── flask-app.yaml<br>│   │   │   └── infrastructure<br>│   │   │       ├── postgres.yaml<br>│   │   │       └── rabbitmq.yaml<br>│   │   └── prod<br>│   │   │   ├── apps<br>│   │   │   └── infrastructure<br>│   └── bootstrap<br>│       ├── root-app-dev.yaml<br>│       └── root-app-prod.yaml</pre><p>Finally we have an <strong>app-projects folder</strong> for ArgoCD AppProjects, which are used to categorize and group applications, defining also the allowed source repos and destination clusters. This resource can be applied unchanged to the different environments.</p><h3>Conclusions</h3><p>I do believe such a starting structure could be benefecial for a project leveraging ArgoCD for deploying to Kubernetes. It allows to clearly identify application manifests, infrastructure manifests and ArgoCD configuration in terms of Applications and AppProjects.</p><p>Source repo: <a href="https://github.com/paolocarta/gitops-argocd-repo-structure/tree/multiple-argocd-instances">https://github.com/paolocarta/gitops-argocd-repo-structure/tree/multiple-argocd-instances</a></p><p>Related article about running a single management instance → <a href="https://medium.com/@paolocarta_it/how-to-structure-your-gitops-repository-with-a-single-argocd-instance-f128b916c915">here</a></p><h3>Contact Information</h3><p>Got questions, want to chat, or just keen to stay connected? Write something here in the comments or let’s connect on <a href="https://www.linkedin.com/in/paolo-carta/">LinkedIn</a> or visit my <a href="https://www.paolocarta.com/">website</a>. Don’t forget to subscribe to the <a href="https://medium.com/@paolocarta_it/subscribe">Medium Newsletter</a> so that you will not miss any update!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b65bcc937322" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ArgoCD GitOps Repository structure with a single management instance]]></title>
            <link>https://itnext.io/how-to-structure-your-gitops-repository-with-a-single-argocd-instance-f128b916c915?source=rss-9d447107642b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f128b916c915</guid>
            <category><![CDATA[argo-cd]]></category>
            <category><![CDATA[gitops]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Paolo Carta]]></dc:creator>
            <pubDate>Sun, 23 Mar 2025 10:07:28 GMT</pubDate>
            <atom:updated>2026-05-13T06:47:18.987Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Many organizations running workloads in Kubernetes are embracing ArgoCD to deploy safely and ensure consistency and traceability.</p><p>Unfortunately there are not many guidelines or best practices yet explaining how to structure the GitOps repository for simplicity and maintainability.</p><p>In this article I would like to show my solution with a setup consisting of a single management ArgoCD instance. It allows a clear separation between applications, infrastructure and ArgoCD Apps and Projects. Moreover it supports multiple environments by leveraging Kustomize.</p><p>Source repo: <a href="https://github.com/paolocarta/gitops-argocd-repo-structure">https://github.com/paolocarta/gitops-argocd-repo-structure</a></p><p>Related article about running a per cluster instance → <a href="https://medium.com/@paolocarta_it/how-to-structure-your-gitops-repository-with-per-cluster-argocd-instances-b65bcc937322">here</a>.</p><p>Tech used:</p><ul><li>Kubernetes</li><li>ArgoCD</li><li>Kustomize</li></ul><p>Architecture with a single management instance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4h2-ClZcrV6YyN9g" /></figure><h3>Structure</h3><p>The main idea is to have one folder (apps) where we specify custom applications developed by our dev teams. Another folder (infrastructure) is where DevOps engineers will work, deploying infrastructure and middleware to our clusters. Finally, we need a folder (argocd) to instruct the single ArgoCD about what to deploy and where.</p><p>To recap, we have 3 main folders:</p><ul><li>apps (Custom apps developed)</li><li>argocd (argocd Application Custom Resources)</li><li>infrastructure (All middleware deployed by Ops)</li></ul><p>High level structure:</p><pre>➜  gitops-repo git:(main) tree<br>.<br>│<br>├── apps<br>│   ├── another-app/<br>│   └── flask-app/<br>│<br>├── argocd<br>│   ├── app-projects/<br>│   ├── applications<br>│   │   ├── apps/<br>│   │   └── infrastructure/<br>│   └── bootstrap<br>│       └── root-app.yaml<br>│<br>├── infrastructure<br>│   ├── databases<br>│   │   └── postgres/<br>│   └── message-brokers<br>│       └── rabbitmq/</pre><p>In more details the structure looks like in the following diagram. Please, notice that the structure leverages kustomize and its overlays for defining multiple environments and avoid duplication.</p><p>Detailed structure:</p><pre>➜  gitops-repo git:(main) tree<br>.<br>│<br>├── apps<br>│   ├── another-app<br>│   │   ├── base<br>│   │   │   ├── deployment.yaml<br>│   │   │   ├── kustomization.yaml<br>│   │   │   └── service.yaml<br>│   │   └── overlays<br>│   │       ├── dev<br>│   │       │   └── kustomization.yaml<br>│   │       └── prod<br>│   │           └── kustomization.yaml<br>│   └── flask-app<br>│       ├── base<br>│       │   ├── deployment.yaml<br>│       │   ├── kustomization.yaml<br>│       │   └── service.yaml<br>│       └── overlays<br>│           ├── dev<br>│           │   ├── deployment.yaml<br>│           │   └── kustomization.yaml<br>│           └── prod<br>│               ├── deployment.yaml<br>│               └── kustomization.yaml<br>│<br>├── argocd<br>│   ├── app-projects<br>│   │   ├── apps.yaml<br>│   │   ├── brokers.yaml<br>│   │   ├── databases.yaml<br>│   │   └── system.yaml<br>│   ├── applications<br>│   │   ├── apps<br>│   │   │   ├── external<br>│   │   │   │   └── external-repo-app-of-apps.yaml<br>│   │   │   └── internal<br>│   │   │       ├── another-app-appset.yaml<br>│   │   │       └── flask-app-appset.yaml<br>│   │   └── infrastructure<br>│   │       ├── dev<br>│   │       │   ├── postgres.yaml<br>│   │       │   └── rabbitmq.yaml<br>│   │       └── prod<br>│   │           ├── postgres.yaml<br>│   │           └── rabbitmq.yaml<br>│   └── bootstrap<br>│       └── root-app.yaml<br>│<br>├── infrastructure<br>│   ├── databases<br>│   │   └── postgres<br>│   │       ├── base<br>│   │       │   ├── kustomization.yaml<br>│   │       │   ├── service.yaml<br>│   │       │   └── statefulset.yaml<br>│   │       └── overlays<br>│   │           ├── dev<br>│   │           │   └── kustomization.yaml<br>│   │           └── prod<br>│   │               └── kustomization.yaml<br>│   └── message-brokers<br>│       └── rabbitmq<br>│           ├── base<br>│           │   ├── deployment.yaml<br>│           │   ├── kustomization.yaml<br>│           │   └── service.yaml<br>│           └── overlays<br>│               ├── dev<br>│               │   └── kustomization.yaml<br>│               └── prod<br>│                   └── kustomization.yaml<br>├── tools<br>│   ├── generate-secrets.sh<br>│   ├── validate-argocd.sh<br>│   └── validate-kustomize.sh</pre><p>In order to better understand each folder, each one has a dedicated paragraph below in this article.</p><h3>Infrastructure Folder</h3><p>This folder holds manifests for all infrastructure and middleware, for instance:</p><ul><li>Databases</li><li>Message Brokers</li><li>Caches</li><li>Monitoring</li><li>Logging</li><li>Others</li></ul><pre>│<br>├── infrastructure<br>│   ├── databases<br>│   │   └── postgres<br>│   │       ├── base<br>│   │       │   ├── kustomization.yaml<br>│   │       │   ├── service.yaml<br>│   │       │   └── statefulset.yaml<br>│   │       └── overlays<br>│   │           ├── dev<br>│   │           │   └── kustomization.yaml<br>│   │           └── prod<br>│   │               └── kustomization.yaml<br>│   └── message-brokers<br>│       └── rabbitmq/</pre><p>In the example we define a PostgreSQL Database and a RabbitMQ Broker. The middleware is deployed to a dev and prod environment. Each folder will be referenced by an ArgoCD application.</p><p>Each infrastructure app deployed is defined using Kustomize. A base layer holds common configuration. Each overlay can specify things which are environment specific.</p><h3>Apps Folder</h3><p>The Apps folder represents custom application which are developed by dev teams. Each application is a collection of classic Kubernetes manifests, for instance Deployment, Service, ConfigMaps and so on.</p><p>Each application leverages Kustomize with a base layer and overlays for the environments. An ArgoCD Application will reference each overlay.</p><p>In the example we define two apps:</p><ul><li>Flask Dummy App</li><li>Another Dummy App</li></ul><pre>│<br>├── apps<br>│   ├── another-app/<br>│   └── flask-app<br>│       ├── base<br>│       │   ├── deployment.yaml<br>│       │   ├── kustomization.yaml<br>│       │   └── service.yaml<br>│       └── overlays<br>│           ├── dev<br>│           │   ├── deployment.yaml<br>│           │   └── kustomization.yaml<br>│           └── prod<br>│               ├── deployment.yaml<br>│               └── kustomization.yaml</pre><p>This folder could be actually extracted to other repositories, depending on your company and team structure.</p><h3>ArgoCD Folder</h3><p>This folder is used to define all ArgoCD Applications and AppProjects. All of them are deployed to our single ArgoCD instance.</p><p>The first Application is the <strong>App of Apps</strong>:</p><ul><li>bootstrap/root-app.yaml</li></ul><p>This is the app at the root of the tree hierarchy. It basically points to all other Applications defined. A reference to this app can be made where we actually install ArgoCD. For instance, if we install ArgoCD by using Terraform, we could apply this Application to bootstrap the system.</p><p>Then we have a folder called <strong>applications</strong>, which is divided by category, normal apps and infrastructure apps. This allows to separate ArgoCD Applications which manage custom services and those managing infrastructure middleware.</p><pre>├── argocd<br>│   ├── app-projects<br>│   │   ├── apps.yaml<br>│   │   ├── brokers.yaml<br>│   │   ├── databases.yaml<br>│   │   └── system.yaml<br>│   ├── applications<br>│   │   ├── apps<br>│   │   │   ├── external<br>│   │   │   │   └── external-repo-app-of-apps.yaml<br>│   │   │   └── internal<br>│   │   │       ├── another-app-appset.yaml<br>│   │   │       └── flask-app-appset.yaml<br>│   │   └── infrastructure<br>│   │       ├── dev<br>│   │       │   ├── postgres.yaml<br>│   │       │   └── rabbitmq.yaml<br>│   │       └── prod<br>│   │           ├── postgres.yaml<br>│   │           └── rabbitmq.yaml<br>│   └── bootstrap<br>│       └── root-app.yaml</pre><p>Please notice that for now we refer just to the apps/internal subfolder.</p><p>Finally we have a folder (<strong>app-projects</strong>) for ArgoCD AppProjects, which are used to categorize and group applications, defining also the allowed source repos and destination clusters.</p><h3>Conclusions</h3><p>I do believe such a starting structure could be beneficial for a project leveraging ArgoCD for deploying to Kubernetes. It allows to clearly identify application manifests, infrastructure manifests and ArgoCD configuration in terms of Applications and AppProjects.</p><p>Source repo: <a href="https://github.com/paolocarta/gitops-argocd-repo-structure">https://github.com/paolocarta/gitops-argocd-repo-structure</a></p><p>Related article about running a per cluster instance → <a href="https://medium.com/@paolocarta_it/how-to-structure-your-gitops-repository-with-per-cluster-argocd-instances-b65bcc937322">here</a>.</p><h3>Contact Information</h3><p>Have questions, want to chat, or just keen to stay connected? Write something here in the comments or let’s connect on <a href="https://www.linkedin.com/in/paolo-carta/">LinkedIn</a> or visit my <a href="https://www.paolocarta.com/">website</a>. Don’t forget to subscribe to the <a href="https://medium.com/@paolocarta_it/subscribe">Medium Newsletter</a> so that you will not miss any update!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f128b916c915" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/how-to-structure-your-gitops-repository-with-a-single-argocd-instance-f128b916c915">ArgoCD GitOps Repository structure with a single management instance</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>