From 8cead343da162e4a97893e18802528630e753047 Mon Sep 17 00:00:00 2001 From: Vegard Hagen Date: Tue, 5 Sep 2023 19:26:11 +0200 Subject: [PATCH] feat(argocd): Copying necessary binaries from main ArgoCD image for use in kustomize-with-helm plugin This enables us to use a slimmer image for the plugin instead of creating a separate image with all the tools we need. It also enables us to keep the plugin image tools in sync with the ArgoCD version. --- ...ocd-cm-cmp-kustomize-build-with-helm.yaml} | 4 ++-- infra/argocd/kustomization.yaml | 15 ++++++++------- .../patches/argocd-repo-copyutil-patch.yaml | 16 ++++++++++++++++ ...ocd-repo-server-plugin-sidecar-patch.yaml} | 19 +++++++++++-------- 4 files changed, 37 insertions(+), 17 deletions(-) rename infra/argocd/{cm-argocd-plugin.yaml => argocd-cm-cmp-kustomize-build-with-helm.yaml} (76%) create mode 100644 infra/argocd/patches/argocd-repo-copyutil-patch.yaml rename infra/argocd/patches/{argocd-repo-server-plugin-sidecar.yaml => argocd-repo-server-plugin-sidecar-patch.yaml} (57%) diff --git a/infra/argocd/cm-argocd-plugin.yaml b/infra/argocd/argocd-cm-cmp-kustomize-build-with-helm.yaml similarity index 76% rename from infra/argocd/cm-argocd-plugin.yaml rename to infra/argocd/argocd-cm-cmp-kustomize-build-with-helm.yaml index 71681ab..8bf6c3a 100644 --- a/infra/argocd/cm-argocd-plugin.yaml +++ b/infra/argocd/argocd-cm-cmp-kustomize-build-with-helm.yaml @@ -1,9 +1,9 @@ apiVersion: v1 kind: ConfigMap metadata: - name: argocd-plugin-config + name: argocd-cm-cmp-kustomize-build-with-helm data: - plugin.yaml: | + kustomize-build-with-helm.yaml: | apiVersion: argoproj.io/v1alpha1 kind: ConfigManagementPlugin metadata: diff --git a/infra/argocd/kustomization.yaml b/infra/argocd/kustomization.yaml index 9e1bddc..27eb4f6 100644 --- a/infra/argocd/kustomization.yaml +++ b/infra/argocd/kustomization.yaml @@ -6,13 +6,14 @@ resources: - namespace.yaml - https://raw.githubusercontent.com/argoproj/argo-cd/v2.8.2/manifests/install.yaml - ingress.yaml - - cm-argocd-plugin.yaml + - argocd-cm-cmp-kustomize-build-with-helm.yaml -patchesStrategicMerge: +patches: + # Copy binaries from ArgoCD-image + - path: patches/argocd-repo-copyutil-patch.yaml # Plugin to enable Kustomize with Helm - - patches/argocd-repo-server-plugin-sidecar.yaml + - path: patches/argocd-repo-server-plugin-sidecar-patch.yaml # Ignore CiliumIdentity CRDs - - patches/argocd-cm-resource-exclusion-cilium-identity-patch.yaml - # Let Traefik manage TLS-termination - - patches/argocd-cmd-params-cm-server-insecure-patch.yaml - + - path: patches/argocd-cm-resource-exclusion-cilium-identity-patch.yaml + # Traefik handles TLS + - path: patches/argocd-cmd-params-cm-server-insecure-patch.yaml diff --git a/infra/argocd/patches/argocd-repo-copyutil-patch.yaml b/infra/argocd/patches/argocd-repo-copyutil-patch.yaml new file mode 100644 index 0000000..0cb6252 --- /dev/null +++ b/infra/argocd/patches/argocd-repo-copyutil-patch.yaml @@ -0,0 +1,16 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: argocd-repo-server +spec: + template: + spec: + initContainers: + - name: copyutil + command: [ /bin/bash ] + args: + - -c + - >- + /bin/cp -n /usr/local/bin/argocd /var/run/argocd/argocd-cmp-server && + /bin/cp -n /usr/local/bin/kustomize /var/run/argocd/kustomize && + /bin/cp -n /usr/local/bin/helm /var/run/argocd/helm \ No newline at end of file diff --git a/infra/argocd/patches/argocd-repo-server-plugin-sidecar.yaml b/infra/argocd/patches/argocd-repo-server-plugin-sidecar-patch.yaml similarity index 57% rename from infra/argocd/patches/argocd-repo-server-plugin-sidecar.yaml rename to infra/argocd/patches/argocd-repo-server-plugin-sidecar-patch.yaml index 1708648..a50cccd 100644 --- a/infra/argocd/patches/argocd-repo-server-plugin-sidecar.yaml +++ b/infra/argocd/patches/argocd-repo-server-plugin-sidecar-patch.yaml @@ -3,13 +3,16 @@ kind: Deployment metadata: name: argocd-repo-server spec: - selector: {} template: spec: containers: - name: kustomize-build-with-helm - command: [/var/run/argocd/argocd-cmp-server] - image: quay.io/argoproj/argocd:v2.8.2 + env: + - name: PATH + value: "/var/run/argocd:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + command: + - argocd-cmp-server + image: alpine/git:2.40.1 securityContext: runAsNonRoot: true runAsUser: 999 @@ -18,14 +21,14 @@ spec: mountPath: /var/run/argocd - name: plugins mountPath: /home/argocd/cmp-server/plugins - - name: argocd-plugin-config + - name: cmp-kustomize-build-with-helm mountPath: /home/argocd/cmp-server/config/plugin.yaml - subPath: plugin.yaml + subPath: kustomize-build-with-helm.yaml - mountPath: /tmp name: cmp-tmp volumes: - - name: argocd-plugin-config + - name: cmp-kustomize-build-with-helm configMap: - name: argocd-plugin-config + name: argocd-cm-cmp-kustomize-build-with-helm - name: cmp-tmp - emptyDir: {} \ No newline at end of file + emptyDir: { } \ No newline at end of file