diff --git a/charts/argocd-notifications/templates/_helpers.tpl b/charts/argocd-notifications/templates/_helpers.tpl index bbe07b54..f1e19814 100644 --- a/charts/argocd-notifications/templates/_helpers.tpl +++ b/charts/argocd-notifications/templates/_helpers.tpl @@ -43,6 +43,18 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end -}} +{{/* +Common slack bot labels +*/}} +{{- define "argocd-notifications.bots.slack.labels" -}} +helm.sh/chart: {{ include "argocd-notifications.chart" . }} +{{ include "argocd-notifications.bots.slack.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + {{/* Selector labels */}} @@ -51,6 +63,14 @@ app.kubernetes.io/name: {{ include "argocd-notifications.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end -}} +{{/* +Selector slack bot labels +*/}} +{{- define "argocd-notifications.bots.slack.selectorLabels" -}} +app.kubernetes.io/name: {{ include "argocd-notifications.name" . }}-bot +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + {{/* Create the name of the service account to use */}} @@ -61,3 +81,14 @@ Create the name of the service account to use {{ default "default" .Values.serviceAccount.name }} {{- end -}} {{- end -}} + +{{/* +Create the name of the bot service account to use +*/}} +{{- define "argocd-notifications.bots.slack.serviceAccountName" -}} +{{- if .Values.bots.slack.serviceAccount.create -}} + {{ default (include "argocd-notifications.fullname" .) .Values.bots.slack.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.bots.slack.serviceAccount.name }} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/argocd-notifications/templates/deployment.yaml b/charts/argocd-notifications/templates/deployment.yaml index 14fd9f48..cbe71ca7 100644 --- a/charts/argocd-notifications/templates/deployment.yaml +++ b/charts/argocd-notifications/templates/deployment.yaml @@ -22,7 +22,7 @@ spec: serviceAccountName: {{ include "argocd-notifications.serviceAccountName" . }} containers: - name: {{ include "argocd-notifications.name" . }}-controller - image: "{{ .Values.image.repository }}:{{ .Values.image.tag}}" + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} resources: {{- toYaml .Values.resources | nindent 12 }} diff --git a/charts/argocd-notifications/templates/slack-bot/deployment.yaml b/charts/argocd-notifications/templates/slack-bot/deployment.yaml new file mode 100644 index 00000000..75b651ca --- /dev/null +++ b/charts/argocd-notifications/templates/slack-bot/deployment.yaml @@ -0,0 +1,43 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "argocd-notifications.name" . }}-bot + labels: + {{- include "argocd-notifications.bots.slack.labels" . | nindent 4 }} +spec: + strategy: + {{- .Values.bots.slack.updateStrategy | toYaml | nindent 4 }} + selector: + matchLabels: + {{- include "argocd-notifications.bots.slack.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "argocd-notifications.bots.slack.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.bots.slack.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "argocd-notifications.serviceAccountName" . }}-bot + containers: + - name: {{ include "argocd-notifications.name" . }}-bot + image: "{{ .Values.bots.slack.image.repository }}:{{ .Values.bots.slack.image.tag }}" + imagePullPolicy: {{ .Values.bots.slack.image.pullPolicy }} + resources: + {{- toYaml .Values.bots.slack.resources | nindent 12 }} + command: + - /app/argocd-notifications + - bot + {{- with .Values.bots.slack.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.bots.slack.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.bots.slack.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/argocd-notifications/templates/slack-bot/role.yaml b/charts/argocd-notifications/templates/slack-bot/role.yaml new file mode 100644 index 00000000..edac125e --- /dev/null +++ b/charts/argocd-notifications/templates/slack-bot/role.yaml @@ -0,0 +1,16 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ include "argocd-notifications.name" . }}-bot +rules: +- apiGroups: + - argoproj.io + resources: + - applications + - appprojects + verbs: + - get + - list + - watch + - update + - patch \ No newline at end of file diff --git a/charts/argocd-notifications/templates/slack-bot/rolebinding.yaml b/charts/argocd-notifications/templates/slack-bot/rolebinding.yaml new file mode 100644 index 00000000..225312e4 --- /dev/null +++ b/charts/argocd-notifications/templates/slack-bot/rolebinding.yaml @@ -0,0 +1,11 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ include "argocd-notifications.name" . }}-bot +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ include "argocd-notifications.name" . }}-bot +subjects: +- kind: ServiceAccount + name: {{ include "argocd-notifications.bots.slack.serviceAccountName" . }} \ No newline at end of file diff --git a/charts/argocd-notifications/templates/slack-bot/service.yaml b/charts/argocd-notifications/templates/slack-bot/service.yaml new file mode 100644 index 00000000..c2e4f181 --- /dev/null +++ b/charts/argocd-notifications/templates/slack-bot/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "argocd-notifications.name" . }}-bot +spec: + ports: + - name: server + port: 80 + protocol: TCP + targetPort: 8080 + selector: + {{- include "argocd-notifications.bots.slack.selectorLabels" . | nindent 4 }} + type: {{ .Values.bots.slack.service.type }} \ No newline at end of file diff --git a/charts/argocd-notifications/templates/slack-bot/serviceaccount.yaml b/charts/argocd-notifications/templates/slack-bot/serviceaccount.yaml new file mode 100644 index 00000000..20cfe9f2 --- /dev/null +++ b/charts/argocd-notifications/templates/slack-bot/serviceaccount.yaml @@ -0,0 +1,8 @@ +{{ if .Values.secret.create }} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "argocd-notifications.bots.slack.serviceAccountName" . }} + labels: + {{- include "argocd-notifications.bots.slack.labels" . | nindent 4 }} +{{ end }} \ No newline at end of file diff --git a/charts/argocd-notifications/values.yaml b/charts/argocd-notifications/values.yaml index df936414..1d30108c 100644 --- a/charts/argocd-notifications/values.yaml +++ b/charts/argocd-notifications/values.yaml @@ -158,3 +158,37 @@ triggers: # template: my-custom-template # # For more information: https://argoproj-labs.github.io/argocd-notifications/triggers_and_templates/ + +bots: + slack: + updateStrategy: + type: Recreate + + image: + repository: argoprojlabs/argocd-notifications + tag: v0.7.0 + pullPolicy: IfNotPresent + + imagePullSecrets: [] + + service: + type: LoadBalancer + + serviceAccount: + # Specifies whether a service account should be created + create: true + + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: argocd-notifications-bot + + resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + affinity: {} + tolerations: [] + nodeSelector: {} \ No newline at end of file