Skip to content

Commit

Permalink
[bitnami/argo-cd] Add native support for ConfigManagementPlugins
Browse files Browse the repository at this point in the history
Signed-off-by: Max Nitze <[email protected]>
  • Loading branch information
Max Nitze committed Jul 2, 2024
1 parent fcf03f8 commit 1d02ec8
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bitnami/argo-cd/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ maintainers:
name: argo-cd
sources:
- https://github.com/bitnami/charts/tree/main/bitnami/argo-cd
version: 6.5.1
version: 6.6.0
5 changes: 4 additions & 1 deletion bitnami/argo-cd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,9 @@ As an alternative, use one of the preset configurations for pod affinity, pod an
| `repoServer.command` | Override default container command (useful when using custom images) | `[]` |
| `repoServer.args` | Override default container args (useful when using custom images) | `[]` |
| `repoServer.extraArgs` | Add extra args to the default repo server args | `[]` |
| `repoServer.configManagementPlugins.enabled` | Whether the config management plugins are enabled or not. | `false` |
| `repoServer.configManagementPlugins.additionalBinaries` | Additional binaries necessary for the config management plugins. | `[]` |
| `repoServer.configManagementPlugins.plugins` | The config management plugins to be provided as sidecars alongside the repo server. | `[]` |
| `repoServer.automountServiceAccountToken` | Mount Service Account token in pod | `true` |
| `repoServer.hostAliases` | Argo CD repo server pods host aliases | `[]` |
| `repoServer.podLabels` | Extra labels for Argo CD repo server pods | `{}` |
Expand Down Expand Up @@ -1398,4 +1401,4 @@ Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
18 changes: 18 additions & 0 deletions bitnami/argo-cd/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,24 @@ Create the name of the service account to use for Dex
{{- end -}}
{{- end -}}

{{/*
Merge a list of values that contains template after rendering them.
Later values taking higher precedence. So merging two dicts with values `true` and `false` for the same key will result
in the value of the latter on that key. When using the default merge functionality this will always result in `true`.
Usage:
{{ include "argocd.tplvalues.merge-with-precedence" ( dict "values" (list .Values.path.to.the.Value1 .Values.path.to.the.Value2) "context" $ ) }}
*/}}
{{- define "argocd.tplvalues.merge-with-precedence" -}}
{{- $dst := dict -}}
{{- range .values -}}
{{- $val := include "common.tplvalues.render" (dict "value" . "context" $.context "scope" $.scope) | fromYaml }}
{{- range $key := keys $val }}
{{- $_ := set $dst $key (get $val $key) }}
{{- end }}
{{- end -}}
{{ $dst | toYaml }}
{{- end -}}

{{/*
Compile all warnings into a single message.
*/}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if .Values.repoServer.configManagementPlugins.enabled }}
{{- range $plugin := .Values.repoServer.configManagementPlugins.plugins }}
{{- if not $plugin.existingConfigMap }}
---
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ printf "%s-cmp-%s" (include "argocd.repo-server" $) $plugin.name | trunc 63 | trimSuffix "-" }}
namespace: {{ include "common.names.namespace" $ | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $.Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: repo-server
{{- if $.Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $.Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
data:
plugin.yaml: |
kind: ConfigManagementPlugin
apiVersion: argoproj.io/v1alpha1
metadata:
name: {{ $plugin.name }}
spec: {{- include "common.tplvalues.render" ( dict "value" $plugin.spec "context" $ ) | nindent 6 }}
{{- end }}
{{- end }}
{{- end -}}
129 changes: 129 additions & 0 deletions bitnami/argo-cd/templates/repo-server/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,45 @@ spec:
key: {{ include "argocd.redis.secretPasswordKey" . }}
{{- end }}
{{- end }}
{{- if .Values.repoServer.configManagementPlugins.enabled }}
- name: copy-cmp-server-binary
image: {{ include "argocd.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- /bin/cp
- -n
- /opt/bitnami/argo-cd/bin/argocd
- /additional-binaries/argocd-cmp-server
{{- if .Values.repoServer.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.repoServer.containerSecurityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
volumeMounts:
- mountPath: /additional-binaries
name: cmp-additional-binaries
{{- if .Values.repoServer.configManagementPlugins.additionalBinaries }}
- name: download-additional-binaries
image: {{ include "common.images.image" (dict "imageRoot" (dict "repository" "curlimages/curl" "tag" "latest") "global" .Values.global) }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- sh
- -c
args:
- |-
{{- range $additionalBinary := .Values.repoServer.configManagementPlugins.additionalBinaries }}
{{- if $additionalBinary.customScript }}
# downloading {{ $additionalBinary.name }}
{{ $additionalBinary.customScript | nindent 14 }}
{{- else }}
# downloading {{ $additionalBinary.name }}
curl -L {{ $additionalBinary.url }} -o /additional-binaries/{{ $additionalBinary.name }}
chmod +x /additional-binaries/{{ $additionalBinary.name }}
{{- end }}
{{- end }}
volumeMounts:
- mountPath: /additional-binaries
name: cmp-additional-binaries
{{- end }}
{{- end }}
{{- if .Values.repoServer.initContainers }}
{{- include "common.tplvalues.render" (dict "value" .Values.repoServer.initContainers "context" $) | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -273,9 +312,82 @@ spec:
- name: empty-dir
mountPath: /tmp
subPath: tmp-dir
{{- if .Values.repoServer.configManagementPlugins.enabled }}
# The sidecars register their sockets to this volume for the repo server to find them.
- name: cmp-server-plugins
mountPath: /home/argocd/cmp-server/plugins
{{- end }}
{{- if .Values.repoServer.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.repoServer.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.repoServer.configManagementPlugins.enabled }}
{{- range $plugin := .Values.repoServer.configManagementPlugins.plugins }}
{{- $additionalBinariesDir := $plugin.additionalBinariesDir | default "/usr/local/bin" | trimSuffix "/" }}
- name: {{ $plugin.name }}
image: {{ include "common.images.image" (dict "imageRoot" $plugin.sidecar.image "global" $.Values.global) }}
imagePullPolicy: {{ $plugin.sidecar.image.pullPolicy | default $.Values.image.pullPolicy }}
{{- if $plugin.sidecar.lifecycleHooks }}
lifecycle: {{- include "common.tplvalues.render" (dict "value" $plugin.sidecar.lifecycleHooks "context" $) | nindent 12 }}
{{- end }}
{{- $cmpSidecarSecurityContext := include "argocd.tplvalues.merge-with-precedence" (dict "values" (list $.Values.repoServer.containerSecurityContext $plugin.sidecar.containerSecurityContext) "context" $) | fromYaml }}
{{- if $cmpSidecarSecurityContext.enabled }}
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" $cmpSidecarSecurityContext "context" $) | nindent 12 }}
{{- end }}
{{- if $plugin.sidecar.customCommand }}
command: {{- include "common.tplvalues.render" (dict "value" $plugin.sidecar.customCommand "context" $) | nindent 12 }}
{{- else }}
command:
- {{ $additionalBinariesDir }}/argocd-cmp-server
{{- end }}
{{- if $plugin.sidecar.customArgs }}
args: {{- include "common.tplvalues.render" (dict "value" $plugin.sidecar.customArgs "context" $) | nindent 12 }}
{{- end }}
env:
{{- if $plugin.sidecar.extraEnvVars }}
{{- include "common.tplvalues.render" (dict "value" $plugin.sidecar.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
envFrom:
{{- if $plugin.sidecar.extraEnvVarsCM }}
- configMapRef:
name: {{ include "common.tplvalues.render" (dict "value" $plugin.sidecar.extraEnvVarsCM "context" $) }}
{{- end }}
{{- if $plugin.sidecar.extraEnvVarsSecret }}
- secretRef:
name: {{ include "common.tplvalues.render" (dict "value" $plugin.sidecar.extraEnvVarsSecret "context" $) }}
{{- end }}
{{- if $plugin.sidecar.resources }}
resources: {{- toYaml $plugin.sidecar.resources | nindent 12 }}
{{- else if and $plugin.sidecar.resourcePreset (ne $plugin.sidecar.resourcesPreset "none") }}
resources: {{- include "common.resources.preset" (dict "type" $plugin.sidecar.resourcesPreset) | nindent 12 }}
{{- end }}
{{- if $plugin.sidecar.startupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" $plugin.sidecar.startupProbe "context" $) | nindent 12 }}
{{- end }}
{{- if $plugin.sidecar.livenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" $plugin.sidecar.livenessProbe "context" $) | nindent 12 }}
{{- end }}
{{- if $plugin.sidecar.readinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" $plugin.sidecar.readinessProbe "context" $) | nindent 12 }}
{{- end }}
volumeMounts:
- name: cmp-{{ $plugin.name }}
mountPath: /home/argocd/cmp-server/config/plugin.yaml
{{- if $plugin.existingConfigMap }}
subPath: {{ $plugin.existingConfigMapKey | default "plugin.yaml" }}
{{- else }}
subPath: plugin.yaml
{{- end }}
- name: cmp-server-plugins
mountPath: /home/argocd/cmp-server/plugins
- name: cmp-additional-binaries
mountPath: {{ $additionalBinariesDir }}/
- name: cmp-server-tmp-dir
mountPath: /tmp
{{- if $plugin.sidecar.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" $plugin.sidecar.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.repoServer.sidecars }}
{{- include "common.tplvalues.render" ( dict "value" .Values.repoServer.sidecars "context" $) | nindent 8 }}
{{- end }}
Expand All @@ -301,6 +413,23 @@ spec:
secretName: argocd-repo-server-tls
- name: empty-dir
emptyDir: {}
{{- if .Values.repoServer.configManagementPlugins.enabled }}
- name: cmp-server-plugins
emptyDir: {}
- name: cmp-server-tmp-dir
emptyDir: {}
- name: cmp-additional-binaries
emptyDir: {}
{{- range $plugin := .Values.repoServer.configManagementPlugins.plugins }}
- name: cmp-{{ $plugin.name }}
configMap:
{{- if $plugin.existingConfigMap }}
name: {{ include "common.tplvalues.render" (dict "value" $plugin.existingConfigMap "context" $) }}
{{- else }}
name: {{ printf "%s-cmp-%s" (include "argocd.repo-server" $) $plugin.name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.repoServer.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.repoServer.extraVolumes "context" $) | nindent 8 }}
{{- end }}
34 changes: 34 additions & 0 deletions bitnami/argo-cd/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3132,6 +3132,40 @@ repoServer:
## @param repoServer.extraArgs Add extra args to the default repo server args
##
extraArgs: []

## ref: https://argo-cd.readthedocs.io/en/stable/operator-manual/config-management-plugins/
##
configManagementPlugins:
## @param repoServer.configManagementPlugins.enabled Whether the config management plugins are enabled or not.
enabled: false
## @param repoServer.configManagementPlugins.additionalBinaries Additional binaries necessary for the config management plugins.
## Will be downloaded from the given URL and made available as `name` in the configured `additionalBinariesDir` of the plugin.
## If a custom script is used to download the binary, make sure to eventually provide your binary in an executable format in the
## shared volume mounted to `/additional-binaries`.`
## E.g.
## additionalBinaries:
## - name: my-custom-binary
## url: https://www.example.com/my-custom-binary-1.2.3
## customScript: ""
additionalBinaries: []
## @param repoServer.configManagementPlugins.plugins The config management plugins to be provided as sidecars alongside the repo server.
## E.g.
## plugins:
## - name: my-custom-helm-plugin
## existingConfigMap: "" # takes precedence over `spec`, if given
## existingConfigMapKey: "" # defaults to `plugin.yaml`
## additionalBinariesDir: "" # defaults to `/usr/local/bin/`
## spec:
## # ConfigManagementPlugin spec here
## # https://argo-cd.readthedocs.io/en/stable/operator-manual/config-management-plugins/#write-the-plugin-configuration-file
## sidecar:
## image:
## registry: docker.io
## repository: alpine/helm
## tag: latest
## # can also define a custom security context, a custom command, extra env variables, extra mounts, ...
plugins: []

## @param repoServer.automountServiceAccountToken Mount Service Account token in pod
##
automountServiceAccountToken: true
Expand Down

0 comments on commit 1d02ec8

Please sign in to comment.