Skip to content

Commit

Permalink
Support helm lookup by ArgoCD (#634)
Browse files Browse the repository at this point in the history
  • Loading branch information
motoki317 authored Oct 12, 2024
1 parent 09cbe84 commit ff27eae
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 1 deletion.
20 changes: 20 additions & 0 deletions argocd/config/helm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

HELM_BIN=${HELM_BIN:-helm}

new_args=()
template_found=false

for arg in "$@"; do
if [[ "$arg" == "template" ]]; then
template_found=true
new_args+=("$arg")
elif $template_found && [[ "${#new_args[@]}" -eq 1 ]]; then
new_args+=("--dry-run=server" "$arg")
template_found=false
else
new_args+=("$arg")
fi
done

$HELM_BIN "${new_args[@]}"
11 changes: 10 additions & 1 deletion argocd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@ resources:
- appset-ingress-route.yaml
- certificate.yaml
- ingress-route.yaml
# https://github.com/argoproj/argo-cd/issues/5202#issuecomment-2081661930
- repo-server-cr.yaml
- repo-server-crb.yaml

configMapGenerator:
- name: helm-replace
files:
- config/helm

patches:
- path: patches/argocd-cm.yaml
- path: patches/argocd-cmd-params-cm.yaml
- path: patches/argocd-notifications-cm.yaml
- path: patches/argocd-rbac-cm.yaml
- path: patches/argocd-repo-server.yaml
- path: patches/argocd-repo-server-helm.yaml
- path: patches/argocd-repo-server-ksops.yaml
- path: patches/argocd-ssh-known-hosts-cm.yaml

generators:
Expand Down
24 changes: 24 additions & 0 deletions argocd/patches/argocd-repo-server-helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# https://github.com/argoproj/argo-cd/issues/5202#issuecomment-2081661930
apiVersion: apps/v1
kind: Deployment
metadata:
name: argocd-repo-server

spec:
template:
spec:
volumes:
- name: helm-replace
configMap:
name: helm-replace
defaultMode: 0777
containers:
- name: argocd-repo-server
volumeMounts:
# https://github.com/argoproj/argo-cd/issues/5202#issuecomment-2081661930
- name: helm-replace
mountPath: /usr/local/sbin/helm
subPath: helm
env:
- name: HELM_BIN
value: /usr/local/bin/helm
File renamed without changes.
8 changes: 8 additions & 0 deletions argocd/repo-server-cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: argocd-repo-server
rules:
- apiGroups: [""]
resources: ["configmaps", "secrets"]
verbs: ["get", "list", "watch"]
12 changes: 12 additions & 0 deletions argocd/repo-server-crb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: argocd-repo-server
subjects:
- kind: ServiceAccount
name: argocd-repo-server
namespace: argocd
roleRef:
kind: ClusterRole
name: argocd-repo-server
apiGroup: rbac.authorization.k8s.io

0 comments on commit ff27eae

Please sign in to comment.