From ba467c8a4bc2f0c8a56bb016142cbd90a9e2562b Mon Sep 17 00:00:00 2001 From: georgekaz Date: Wed, 3 Feb 2021 20:48:19 +0000 Subject: [PATCH] feat(argocd-notifications): update to support argocd-notification v1.0.1 (#567) Signed-off-by: George Kaz --- charts/argocd-notifications/Chart.yaml | 4 +- .../templates/bots/slack/deployment.yaml | 3 +- .../templates/configmap.yaml | 24 +- .../templates/deployment.yaml | 5 +- .../templates/secret.yaml | 34 +- charts/argocd-notifications/values.yaml | 388 ++++++++++++------ 6 files changed, 286 insertions(+), 172 deletions(-) diff --git a/charts/argocd-notifications/Chart.yaml b/charts/argocd-notifications/Chart.yaml index 9d73681c..ab4f6520 100644 --- a/charts/argocd-notifications/Chart.yaml +++ b/charts/argocd-notifications/Chart.yaml @@ -1,9 +1,9 @@ apiVersion: v2 -appVersion: 0.7.0 +appVersion: 1.0.1 description: A Helm chart for ArgoCD notifications, an add-on to ArgoCD. name: argocd-notifications type: application -version: 1.0.11 +version: 1.0.12 home: https://github.com/argoproj/argo-helm icon: https://raw.githubusercontent.com/argoproj/argo/master/docs/assets/argo.png keywords: diff --git a/charts/argocd-notifications/templates/bots/slack/deployment.yaml b/charts/argocd-notifications/templates/bots/slack/deployment.yaml index 75883073..112266ed 100644 --- a/charts/argocd-notifications/templates/bots/slack/deployment.yaml +++ b/charts/argocd-notifications/templates/bots/slack/deployment.yaml @@ -28,8 +28,9 @@ spec: resources: {{- toYaml .Values.bots.slack.resources | nindent 12 }} command: - - /app/argocd-notifications + - /app/argocd-notifications-backend - bot + workingDir: /app ports: - containerPort: 8080 name: http diff --git a/charts/argocd-notifications/templates/configmap.yaml b/charts/argocd-notifications/templates/configmap.yaml index 757d8475..9090a162 100644 --- a/charts/argocd-notifications/templates/configmap.yaml +++ b/charts/argocd-notifications/templates/configmap.yaml @@ -5,12 +5,18 @@ metadata: labels: {{- include "argocd-notifications.labels" . | nindent 4 }} data: - config.yaml: | - context: - argocdUrl: {{ .Values.argocdUrl | quote }} - subscriptions: - {{- toYaml .Values.subscriptions | nindent 6 }} - templates: - {{- toYaml .Values.templates | nindent 6 }} - triggers: - {{- toYaml .Values.triggers | nindent 6 }} + context: | + argocdUrl: {{ .Values.argocdUrl | quote }} + {{- with .Values.notifiers }} + {{- toYaml . | nindent 2 }} + {{- end }} + {{- with .Values.subscriptions }} + subscriptions: | + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.templates }} + {{- toYaml . | nindent 2 }} + {{- end }} + {{- with .Values.triggers }} + {{- toYaml . | nindent 2 }} + {{- end }} \ No newline at end of file diff --git a/charts/argocd-notifications/templates/deployment.yaml b/charts/argocd-notifications/templates/deployment.yaml index 239c6eb7..10627fc3 100644 --- a/charts/argocd-notifications/templates/deployment.yaml +++ b/charts/argocd-notifications/templates/deployment.yaml @@ -26,6 +26,8 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} serviceAccountName: {{ include "argocd-notifications.serviceAccountName" . }} + securityContext: + runAsNonRoot: true containers: - name: {{ include "argocd-notifications.name" . }}-controller image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" @@ -33,7 +35,7 @@ spec: resources: {{- toYaml .Values.resources | nindent 12 }} command: - - /app/argocd-notifications + - /app/argocd-notifications-backend - controller - --loglevel={{ .Values.logLevel }} {{- if .Values.metrics.enabled }} @@ -42,6 +44,7 @@ spec: {{- range .Values.extraArgs }} - {{ . | squote }} {{- end }} + workingDir: /app ports: {{- if .Values.metrics.enabled }} - containerPort: {{ .Values.metrics.port }} diff --git a/charts/argocd-notifications/templates/secret.yaml b/charts/argocd-notifications/templates/secret.yaml index 74c76992..c29e8311 100644 --- a/charts/argocd-notifications/templates/secret.yaml +++ b/charts/argocd-notifications/templates/secret.yaml @@ -7,33 +7,7 @@ metadata: {{- include "argocd-notifications.labels" . | nindent 4 }} type: Opaque stringData: - notifiers.yaml: | -{{- if .Values.secret.notifiers.slack.enabled }} - slack: - token: {{ .Values.secret.notifiers.slack.token }} - username: {{ .Values.secret.notifiers.slack.username }} - icon: {{ .Values.secret.notifiers.slack.icon | quote }} - signingSecret: {{ .Values.secret.notifiers.slack.signingSecret }} -{{- end }} -{{- if .Values.secret.notifiers.grafana.enabled }} - grafana: - apiUrl: {{ .Values.secret.notifiers.grafana.apiUrl }} - apiKey: {{ .Values.secret.notifiers.grafana.apiKey }} -{{- end }} -{{- if .Values.secret.notifiers.webhooks }} - webhook: -{{- range $k, $v := .Values.secret.notifiers.webhooks }} - - name: {{ $k }} - {{- $v | toYaml | nindent 8 }} -{{- end }} -{{- end }} -{{- if .Values.secret.notifiers.email.enabled }} - email: - host: {{ .Values.secret.notifiers.email.host | quote }} - port: {{ .Values.secret.notifiers.email.port }} - insecure_skip_verify: {{ .Values.secret.notifiers.email.insecure_skip_verify }} - username: {{ .Values.secret.notifiers.email.username | quote }} - password: {{ .Values.secret.notifiers.email.password | quote }} - from: {{ .Values.secret.notifiers.email.from | quote }} -{{- end }} -{{ end }} + {{- with .Values.secret.items }} + {{ toYaml . | indent 2 }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/argocd-notifications/values.yaml b/charts/argocd-notifications/values.yaml index 93ce5390..e0ce9cdd 100644 --- a/charts/argocd-notifications/values.yaml +++ b/charts/argocd-notifications/values.yaml @@ -7,7 +7,7 @@ fullnameOverride: "" image: repository: argoprojlabs/argocd-notifications - tag: v0.7.0 + tag: v1.0.1 pullPolicy: IfNotPresent imagePullSecrets: [] @@ -23,69 +23,22 @@ secret: # Whether helm chart creates controller secret create: true - notifiers: - # For more information: https://argoproj-labs.github.io/argocd-notifications/services/overview/ + items: + # Generic key:value pairs to be inserted into the secret + # Can be used for templates, notification services etc. Some examples given below. + # For more information: https://argocd-notifications.readthedocs.io/en/stable/services/overview/ - slack: - # For more information: https://argoproj-labs.github.io/argocd-notifications/services/slack/ + # slack-token: + # # For more information: https://argocd-notifications.readthedocs.io/en/stable/services/slack/ - # Specifies whether Slack notifier should be configured - enabled: false - # OAuth Access Token - token: - # Optional override username - username: - # Optional override icon - icon: - # Optional override signingSecret: https://argoproj-labs.github.io/argocd-notifications/recipients/slack-bot/ - signingSecret: + # grafana-apiKey: + # # For more information: https://argocd-notifications.readthedocs.io/en/stable/services/grafana/ - grafana: - # For more information: https://argoproj-labs.github.io/argocd-notifications/services/grafana/ + # webhooks-github-token: - # Specifies whether Grafana notifier should be configured - enabled: false - # Grafana api endpoint; for example: https://grafana.example.com/api - apiUrl: - # Grafana api key - apiKey: - - webhooks: {} - # For more information: https://argoproj-labs.github.io/argocd-notifications/services/webhook/ - # mywebhook: - # url: http://example.com - # headers: - # - name: headerName - # value: headerValue - # basicAuth: - # username: username - # password: mypassword - # mywebhook2: - # url: http://example.com - # headers: - # - name: headerName - # value: headerValue - # basicAuth: - # username: username - # password: mypassword - - email: - # For more information: https://argoproj-labs.github.io/argocd-notifications/services/overview/ - - # Specifies whether email notifier should be configured - enabled: false - # SMTP endpoint - host: - # SMTP port - port: - # enable/disable check on TLS certificate - insecure_skip_verify: - # SMTP username - username: - # SMTP password - password: - # email address in from field - from: + # email-username: + # email-password: + # For more information: https://argocd-notifications.readthedocs.io/en/stable/services/email/ logLevel: info @@ -101,6 +54,12 @@ metrics: # interval: 30s # scrapeTimeout: 10s +notifiers: +# For more information: https://argocd-notifications.readthedocs.io/en/stable/services/overview/ + + service.slack: | + token: $slack-token + podAnnotations: {} resources: {} @@ -119,82 +78,253 @@ serviceAccount: # If not set and create is true, a name is generated using the fullname template name: argocd-notifications-controller -subscriptions: [] - # Assignment of recipients by notification channel to triggers in several forms: - # - # global subscription for all type of notifications - # - recipients: - # - slack:test1 - # - webhook:github - # - # subscription for on-sync-status-unknown trigger notifications - # - recipients: - # - slack:test2 - # - email:test@gmail.com - # trigger: on-sync-status-unknown - # - # global subscription restricted to applications with matching labels only - # - recipients: - # - slack:test3 - # selector: test=true - # - # For more information: https://argoproj-labs.github.io/argocd-notifications/triggers_and_templates/ +subscriptions: + # For more information: https://argocd-notifications.readthedocs.io/en/stable/subscriptions/ -templates: [] - # The notification template is used to generate the notification content. The template is leveraging html/template - # golang package and allow to define notification title and body. The template is meant to be reusable and can be - # referenced by multiple triggers. - # - # Add your custom template - # - name: my-custom-template - # title: Hello {{.app.metadata.name}} - # body: | + # # subscription for on-sync-status-unknown trigger notifications + # - recipients: + # - slack:test2 + # - email:test@gmail.com + # triggers: + # - on-sync-status-unknown + # # subscription restricted to applications with matching labels only + # - recipients: + # - slack:test3 + # selector: test=true + # triggers: + # - on-sync-status-unknown + +templates: + # For more information: https://argocd-notifications.readthedocs.io/en/stable/templates/ + + # template.app-deployed: | + # email: + # subject: New version of an application {{.app.metadata.name}} is up and running. + # message: | + # {{if eq .serviceType "slack"}}:white_check_mark:{{end}} Application {{.app.metadata.name}} is now running new version of deployments manifests. + # slack: + # attachments: | + # [{ + # "title": "{{ .app.metadata.name}}", + # "title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", + # "color": "#18be52", + # "fields": [ + # { + # "title": "Sync Status", + # "value": "{{.app.status.sync.status}}", + # "short": true + # }, + # { + # "title": "Repository", + # "value": "{{.app.spec.source.repoURL}}", + # "short": true + # }, + # { + # "title": "Revision", + # "value": "{{.app.status.sync.revision}}", + # "short": true + # } + # {{range $index, $c := .app.status.conditions}} + # {{if not $index}},{{end}} + # {{if $index}},{{end}} + # { + # "title": "{{$c.type}}", + # "value": "{{$c.message}}", + # "short": true + # } + # {{end}} + # ] + # }] + # template.app-health-degraded: | + # email: + # subject: Application {{.app.metadata.name}} has degraded. + # message: | + # {{if eq .serviceType "slack"}}:exclamation:{{end}} Application {{.app.metadata.name}} has degraded. # Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}. - # - # Override one field in built-in template - # - name: on-sync-succeeded - # title: Application {{.app.metadata.name}} sync status is {{.app.status.sync.status}} - # - # For more information: https://argoproj-labs.github.io/argocd-notifications/triggers_and_templates/ + # slack: + # attachments: |- + # [{ + # "title": "{{ .app.metadata.name}}", + # "title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", + # "color": "#f4c030", + # "fields": [ + # { + # "title": "Sync Status", + # "value": "{{.app.status.sync.status}}", + # "short": true + # }, + # { + # "title": "Repository", + # "value": "{{.app.spec.source.repoURL}}", + # "short": true + # } + # {{range $index, $c := .app.status.conditions}} + # {{if not $index}},{{end}} + # {{if $index}},{{end}} + # { + # "title": "{{$c.type}}", + # "value": "{{$c.message}}", + # "short": true + # } + # {{end}} + # ] + # }] + # template.app-sync-failed: | + # email: + # subject: Failed to sync application {{.app.metadata.name}}. + # message: | + # {{if eq .serviceType "slack"}}:exclamation:{{end}} The sync operation of application {{.app.metadata.name}} has failed at {{.app.status.operationState.finishedAt}} with the following error: {{.app.status.operationState.message}} + # Sync operation details are available at: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true . + # slack: + # attachments: |- + # [{ + # "title": "{{ .app.metadata.name}}", + # "title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", + # "color": "#E96D76", + # "fields": [ + # { + # "title": "Sync Status", + # "value": "{{.app.status.sync.status}}", + # "short": true + # }, + # { + # "title": "Repository", + # "value": "{{.app.spec.source.repoURL}}", + # "short": true + # } + # {{range $index, $c := .app.status.conditions}} + # {{if not $index}},{{end}} + # {{if $index}},{{end}} + # { + # "title": "{{$c.type}}", + # "value": "{{$c.message}}", + # "short": true + # } + # {{end}} + # ] + # }] + # template.app-sync-running: | + # email: + # subject: Start syncing application {{.app.metadata.name}}. + # message: | + # The sync operation of application {{.app.metadata.name}} has started at {{.app.status.operationState.startedAt}}. + # Sync operation details are available at: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true . + # slack: + # attachments: |- + # [{ + # "title": "{{ .app.metadata.name}}", + # "title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", + # "color": "#0DADEA", + # "fields": [ + # { + # "title": "Sync Status", + # "value": "{{.app.status.sync.status}}", + # "short": true + # }, + # { + # "title": "Repository", + # "value": "{{.app.spec.source.repoURL}}", + # "short": true + # } + # {{range $index, $c := .app.status.conditions}} + # {{if not $index}},{{end}} + # {{if $index}},{{end}} + # { + # "title": "{{$c.type}}", + # "value": "{{$c.message}}", + # "short": true + # } + # {{end}} + # ] + # }] + # template.app-sync-status-unknown: | + # email: + # subject: Application {{.app.metadata.name}} sync status is 'Unknown' + # message: | + # {{if eq .serviceType "slack"}}:exclamation:{{end}} Application {{.app.metadata.name}} sync is 'Unknown'. + # Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}. + # {{if ne .serviceType "slack"}} + # {{range $c := .app.status.conditions}} + # * {{$c.message}} + # {{end}} + # {{end}} + # slack: + # attachments: |- + # [{ + # "title": "{{ .app.metadata.name}}", + # "title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", + # "color": "#E96D76", + # "fields": [ + # { + # "title": "Sync Status", + # "value": "{{.app.status.sync.status}}", + # "short": true + # }, + # { + # "title": "Repository", + # "value": "{{.app.spec.source.repoURL}}", + # "short": true + # } + # {{range $index, $c := .app.status.conditions}} + # {{if not $index}},{{end}} + # {{if $index}},{{end}} + # { + # "title": "{{$c.type}}", + # "value": "{{$c.message}}", + # "short": true + # } + # {{end}} + # ] + # }] + # template.app-sync-succeeded: | + # email: + # subject: Application {{.app.metadata.name}} has been successfully synced. + # message: | + # {{if eq .serviceType "slack"}}:white_check_mark:{{end}} Application {{.app.metadata.name}} has been successfully synced at {{.app.status.operationState.finishedAt}}. + # Sync operation details are available at: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true . + # slack: + # attachments: "[{\n \"title\": \"{{ .app.metadata.name}}\",\n \"title_link\":\"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}\",\n \"color\": \"#18be52\",\n \"fields\": [\n {\n \"title\": \"Sync Status\",\n \"value\": \"{{.app.status.sync.status}}\",\n \"short\": true\n },\n {\n \"title\": \"Repository\",\n \"value\": \"{{.app.spec.source.repoURL}}\",\n \"short\": true\n }\n {{range $index, $c := .app.status.conditions}}\n {{if not $index}},{{end}}\n {{if $index}},{{end}}\n {\n \"title\": \"{{$c.type}}\",\n \"value\": \"{{$c.message}}\",\n \"short\": true\n }\n {{end}}\n ]\n}] " + tolerations: [] triggers: - # The condition when the notification should be sent. The definition includes name, condition and notification template reference. - # - # Enable built-in triggers: - # - # Application has degraded - # - name: on-health-degraded - # enabled: true - # - # Application syncing has failed - # - name: on-sync-failed - # enabled: true - # - # Application is being synced - # - name: on-sync-running - # enabled: true - # - # Application status is 'Unknown' - # - name: on-sync-status-unknown - # enabled: true - # - # Application syncing has succeeded - # - name: on-sync-succeeded - # enabled: true - # - # - # Or define your custom triggers: - # - # - name: my-custom-trigger - # condition: app.status.sync.status == 'Unknown' - # template: my-custom-template - # - # For more information: https://argoproj-labs.github.io/argocd-notifications/triggers_and_templates/ + # For more information: https://argocd-notifications.readthedocs.io/en/stable/triggers/ + + # trigger.on-deployed: | + # - description: Application is synced and healthy. Triggered once per commit. + # oncePer: app.status.sync.revision + # send: + # - app-deployed + # when: app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy' + # trigger.on-health-degraded: | + # - description: Application has degraded + # send: + # - app-health-degraded + # when: app.status.health.status == 'Degraded' + # trigger.on-sync-failed: | + # - description: Application syncing has failed + # send: + # - app-sync-failed + # when: app.status.operationState.phase in ['Error', 'Failed'] + # trigger.on-sync-running: | + # - description: Application is being synced + # send: + # - app-sync-running + # when: app.status.operationState.phase in ['Running'] + # trigger.on-sync-status-unknown: | + # - description: Application status is 'Unknown' + # send: + # - app-sync-status-unknown + # when: app.status.sync.status == 'Unknown' + # trigger.on-sync-succeeded: | + # - description: Application syncing has succeeded + # send: + # - app-sync-succeeded + # when: app.status.operationState.phase in ['Succeeded'] bots: - # For more information: https://argoproj-labs.github.io/argocd-notifications/recipients/bot/ + # For more information: https://argocd-notifications.readthedocs.io/en/stable/bots/overview/ slack: # You have to set secret.notifiers.slack.signingSecret enabled: false @@ -204,7 +334,7 @@ bots: image: repository: argoprojlabs/argocd-notifications - tag: v0.7.0 + tag: v1.0.1 pullPolicy: IfNotPresent imagePullSecrets: []