argocd-example-apps
argocd-example-apps copied to clipboard
post render plugin doesn't seem to work
I am trying to follow the post-render example using kustomize. I am pointing directly to this online repo:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: kustomized-helm-ex
namespace: argocd
spec:
destination:
namespace: default
server: https://kubernetes.default.svc
project: default
source:
repoURL: https://github.com/argoproj/argocd-example-apps
targetRevision: master
path: plugins/kustomized-helm
plugin:
name: kustomized-helm
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
I get:
status:
conditions:
- lastTransitionTime: "2021-08-31T15:30:07Z"
message: 'rpc error: code = Unknown desc = Manifest generation error (cached):
`sh -c helm template --release-name $ARGOCD_APP_NAME --namespace $ARGOCD_APP_NAMESPACE
--include-crds . > all.yaml && kustomize build` failed exit status 1: Error:
no matches for OriginalId apps_v1_Deployment|~X|release-name-helm-guestbook;
no matches for CurrentId apps_v1_Deployment|~X|release-name-helm-guestbook;
failed to find unique target for patch apps_v1_Deployment|release-name-helm-guestbook'
I did some research, and found that someone else who got this says it means the patch is targeting something that doesn't exist (in this case, release-name-helmguestbook deployment). But why would that be? we don't need to separately deploy the helm chart right? we cannot do both helm and plugin in the same app object.
unless the example readme is leaving out a step i would think you can use it "as is".
I think the plugin installed successfully, since it is indeed trying to run the provided generate command (helm template --args)
ok so i got this to work by taking the original chart and including it, then putting kustomize and its patch yaml alongside it. this example looks like it references the helm-guestbook chart as a dependency, but I don't know exactly how thats supposed to work.
basically i had to take the helm-guestbook chart (not this plugin chart), and add kustomize/patch files to it.
is this example supposed to work by only referencing it? or are there prereq steps being assumed in it like I've done?
I also add a few problems with this example:
- it doesn't use
--include-crds helm dependency buildis done globaly (a temporary dir should be created instead)helm repo addis missing
I've done a few hacks to make this work, and behave a bit like flux:
In argocd-cm:
data:
configManagementPlugins: |
- name: kustomized-helm
init:
command: ["/bin/sh", "-c"]
args:
- KUBITUS_TMP="$(mktemp -d)" &&
export XDG_CACHE_HOME="$KUBITUS_TMP/cache" &&
export XDG_CONFIG_HOME="$KUBITUS_TMP/config" &&
export XDG_DATA_HOME="$KUBITUS_TMP/data" &&
export HELM_HOME="$KUBITUS_TMP" &&
[ -z "$HELM_REPOSITORY_URLS" ] || helm repo add "$HELM_REPOSITORY_NAMES" "$HELM_REPOSITORY_URLS" &&
helm dependency build &&
rm -r "$KUBITUS_TMP"
generate:
command: [sh, -c]
args:
- helm template --release-name "$ARGOCD_APP_NAME" --namespace "$ARGOCD_APP_NAMESPACE" . > all.yaml &&
kustomize build
In application:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: "prometheus-stack"
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
source:
repoURL: "https://gitlab.example.org/gitops/infra.git"
targetRevision: main
path: "prometheus-stack"
plugin:
name: kustomized-helm
env:
- name: HELM_REPOSITORY_NAMES
value: "kube-prometheus-stack"
- name: HELM_REPOSITORY_URLS
value: "https://prometheus-community.github.io/helm-charts"
destination:
name: ''
namespace: "prometheus-stack"
server: 'https://kubernetes.default.svc'
In the repo:
$ cat prometheus-stack/kustomization.yaml
resources:
- ./all.yaml
patchesStrategicMerge:
- |-
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
argocd.argoproj.io/sync-options: Replace=true
name: prometheuses.monitoring.coreos.com
Relevant bug and commits in the kubitus-installer repo:
- Upgrade Prometheus-stack chart to >= 20.x https://gitlab.com/kubitus-project/kubitus-installer/-/issues/70
- Add support for patchesJson6902 and patchesStrategicMerge (https://gitlab.com/kubitus-project/kubitus-installer/-/commit/d09401aa059bbebe314b7eecdf8dac780d297725)
- Workaround prometheus CRD annotation too long https://gitlab.com/kubitus-project/kubitus-installer/-/commit/9edaf429bb7181d2b79a81fe14ce154fbdcdc93c