Reputation: 43
I'm trying to deploy multiple operators as ArgoCD applications across all clusters, with the flexibility to skip deployment of certain operators in specific clusters. To achieve this, I've set up an ArgoCD ApplicationSet with a matrix generator, as shown below:
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: core-operators
namespace: argocd
spec:
goTemplate: true
goTemplateOptions: ["missingkey=error"]
generators:
- matrix:
generators:
- merge:
mergeKeys:
- server
generators:
- clusters: {}
- list:
elements:
- server: '{{.server}}'
clusterName: '{{.name}}'
enableMetricsServer: true
enablePrometheus: true
- server: https://kubernetes.default.svc
clusterName: in-cluster
enableMetricsServer: true
enablePrometheus: false
- list:
elements:
- operatorName: metrics-server
namespace: monitoring
enable: '{{.enableMetricsServer}}'
- operatorName: prometheus
namespace: monitoring
enable: '{{.enablePrometheus}}'
template:
metadata:
name: '{{.name}}-{{.operatorName}}-{{.enable}}'
annotations:
argocd.argoproj.io/manifest-generate-paths: ".;.."
spec:
project: default
source:
repoURL: [email protected]/operators.git
targetRevision: HEAD
path: null-deployment
destination:
server: '{{.server}}'
namespace: '{{.namespace}}'
syncPolicy:
syncOptions:
- CreateNamespace=true
- ServerSideApply=true
- Replace=true
- Force=true
retry:
limit: 2
templatePatch: |
{{- if eq .enable "true" }}
spec:
source:
repoURL: [email protected]/operators.git
targetRevision: HEAD
path: {{.operatorName}}
helm:
releaseName: "{{.operatorName}}-parent"
values: |
clusterName: {{.name}}
syncPolicy:
automated:
prune: true
{{- end }}
However, when applying this ApplicationSet, I encounter the following error:
Status:
Conditions:
Last Transition Time: 2024-07-31T05:22:57Z
Message: failed to get params for second generator in the matrix generator: child generator returned an error on parameter generation: failed to replace parameters in generator: failed to deeply replace JSON field contents: failed to execute go template {{.enableMetricsServer}}: template: :1:2: executing "" at <.enableMetricsServer>: map has no entry for key "enableMetricsServer"
Reason: ApplicationGenerationFromParamsError
Status: True
Type: ErrorOccurred
Last Transition Time: 2024-07-31T05:22:57Z
Message: failed to get params for second generator in the matrix generator: child generator returned an error on parameter generation: failed to replace parameters in generator: failed to deeply replace JSON field contents: failed to execute go template {{.enableMetricsServer}}: template: :1:2: executing "" at <.enableMetricsServer>: map has no entry for key "enableMetricsServer"
Reason: ErrorOccurred
Status: False
Type: ParametersGenerated
Last Transition Time: 2024-07-31T05:22:57Z
Message: failed to get params for second generator in the matrix generator: child generator returned an error on parameter generation: failed to replace parameters in generator: failed to deeply replace JSON field contents: failed to execute go template {{.enableMetricsServer}}: template: :1:2: executing "" at <.enableMetricsServer>: map has no entry for key "enableMetricsServer"
Reason: ApplicationGenerationFromParamsError
Status: False
Type: ResourcesUpToDate
I came across this closed issue on GitHub, which suggests that this problem has been fixed, but I still encounter the error. Am I missing something in the configuration, or is there another workaround I should consider?
ArgoCD Slack conversation link: https://cloud-native.slack.com/archives/C01U45M2SVB/p1722362317180959?thread_ts=1722277849.358909&cid=C01U45M2SVB
Details:
ArgoCD version: v2.11.7 Any help or suggestions would be appreciated!
Upvotes: 1
Views: 268