From 1ece353a33225e17996f083d67c5ebee1e987bc8 Mon Sep 17 00:00:00 2001 From: Saurabh Lohe <105858985+slohe1@users.noreply.github.com> Date: Thu, 18 May 2023 19:16:06 +0530 Subject: [PATCH] OPSEXP-1858 create a chart for ms Teams connector (#43) --- charts/alfresco-connector-msteams/.helmignore | 23 ++++++ charts/alfresco-connector-msteams/Chart.lock | 6 ++ charts/alfresco-connector-msteams/Chart.yaml | 10 +++ charts/alfresco-connector-msteams/README.md | 55 +++++++++++++ .../ci/default-values.yaml | 8 ++ .../templates/_helpers.tpl | 51 ++++++++++++ .../templates/config-connector-msteams.yaml | 20 +++++ .../deployment-connector-msteams.yaml | 81 +++++++++++++++++++ .../templates/ingress-connector-msteams.yaml | 36 +++++++++ .../templates/svc-connector-msteams.yaml | 14 ++++ .../deployment-connector-msteams_test.yaml | 27 +++++++ .../tests/values/test_values.yaml | 5 ++ charts/alfresco-connector-msteams/values.yaml | 58 +++++++++++++ 13 files changed, 394 insertions(+) create mode 100644 charts/alfresco-connector-msteams/.helmignore create mode 100644 charts/alfresco-connector-msteams/Chart.lock create mode 100644 charts/alfresco-connector-msteams/Chart.yaml create mode 100644 charts/alfresco-connector-msteams/README.md create mode 100644 charts/alfresco-connector-msteams/ci/default-values.yaml create mode 100644 charts/alfresco-connector-msteams/templates/_helpers.tpl create mode 100644 charts/alfresco-connector-msteams/templates/config-connector-msteams.yaml create mode 100644 charts/alfresco-connector-msteams/templates/deployment-connector-msteams.yaml create mode 100644 charts/alfresco-connector-msteams/templates/ingress-connector-msteams.yaml create mode 100644 charts/alfresco-connector-msteams/templates/svc-connector-msteams.yaml create mode 100644 charts/alfresco-connector-msteams/tests/deployment-connector-msteams_test.yaml create mode 100644 charts/alfresco-connector-msteams/tests/values/test_values.yaml create mode 100644 charts/alfresco-connector-msteams/values.yaml diff --git a/charts/alfresco-connector-msteams/.helmignore b/charts/alfresco-connector-msteams/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/alfresco-connector-msteams/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/alfresco-connector-msteams/Chart.lock b/charts/alfresco-connector-msteams/Chart.lock new file mode 100644 index 00000000..54d8e82d --- /dev/null +++ b/charts/alfresco-connector-msteams/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: alfresco-common + repository: https://alfresco.github.io/alfresco-helm-charts/ + version: 2.0.0 +digest: sha256:04d458edc1a42ae7a4e4bc73d5872cc5cab9ef5960e5b6226af605a661bff71f +generated: "2023-05-16T18:14:54.877997+05:30" diff --git a/charts/alfresco-connector-msteams/Chart.yaml b/charts/alfresco-connector-msteams/Chart.yaml new file mode 100644 index 00000000..46157c74 --- /dev/null +++ b/charts/alfresco-connector-msteams/Chart.yaml @@ -0,0 +1,10 @@ +apiVersion: v2 +name: alfresco-connector-msteams +description: A Helm chart for deploying Alfresco connector msteams service +type: application +version: 0.1.0-alpha.0 +appVersion: "2.0.0-A2" +dependencies: + - name: alfresco-common + version: 2.0.0 + repository: https://alfresco.github.io/alfresco-helm-charts/ diff --git a/charts/alfresco-connector-msteams/README.md b/charts/alfresco-connector-msteams/README.md new file mode 100644 index 00000000..8a092e63 --- /dev/null +++ b/charts/alfresco-connector-msteams/README.md @@ -0,0 +1,55 @@ +# alfresco-connector-msteams + +![Version: 0.1.0-alpha.0](https://img.shields.io/badge/Version-0.1.0--alpha.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.0.0-A2](https://img.shields.io/badge/AppVersion-2.0.0--A2-informational?style=flat-square) + +A Helm chart for deploying Alfresco connector msteams service + +## Requirements + +| Repository | Name | Version | +|------------|------|---------| +| https://alfresco.github.io/alfresco-helm-charts/ | alfresco-common | 2.0.0 | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| alfresco.baseUrl | string | `"change_me_alf_base_url"` | | +| alfresco.digitalWorkspace.contextPath | string | `"/workspace/"` | | +| environment | string | `nil` | | +| global.alfrescoRegistryPullSecrets | string | `"quay-registry-secret"` | | +| image.internalPort | int | `3978` | | +| image.pullPolicy | string | `"IfNotPresent"` | | +| image.repository | string | `"quay.io/alfresco/alfresco-ms-teams-service"` | | +| image.tag | string | `"2.0.0-A2"` | | +| ingress.extraAnnotations | string | `nil` | | +| ingress.path | string | `"/ms-teams-service"` | | +| ingress.tls | list | `[]` | | +| livenessProbe.initialDelaySeconds | int | `10` | | +| livenessProbe.periodSeconds | int | `20` | | +| livenessProbe.timeoutSeconds | int | `10` | | +| microsoft.app.id | string | `"change_me_app_id"` | | +| microsoft.app.oauth.connectionName | string | `"alfresco"` | | +| microsoft.app.password | string | `"change_me_app_pwd"` | | +| nodeSelector | object | `{}` | | +| podSecurityContext.runAsNonRoot | bool | `true` | | +| podSecurityContext.runAsUser | int | `33041` | | +| readinessProbe.initialDelaySeconds | int | `20` | | +| readinessProbe.periodSeconds | int | `60` | | +| readinessProbe.timeoutSeconds | int | `10` | | +| replicaCount | int | `2` | | +| resources.limits.cpu | string | `"1"` | | +| resources.limits.memory | string | `"1000Mi"` | | +| resources.requests.cpu | string | `"0.5"` | | +| resources.requests.memory | string | `"1000Mi"` | | +| service.externalPort | int | `80` | | +| service.name | string | `"ms-teams-service"` | | +| service.type | string | `"ClusterIP"` | | +| strategy.rollingUpdate.maxSurge | int | `1` | | +| strategy.rollingUpdate.maxUnavailable | int | `0` | | +| teams.chat.filenameEnabled | bool | `true` | | +| teams.chat.imageEnabled | bool | `true` | | +| teams.chat.metadataEnabled | bool | `true` | | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0) diff --git a/charts/alfresco-connector-msteams/ci/default-values.yaml b/charts/alfresco-connector-msteams/ci/default-values.yaml new file mode 100644 index 00000000..7638b9b9 --- /dev/null +++ b/charts/alfresco-connector-msteams/ci/default-values.yaml @@ -0,0 +1,8 @@ +replicaCount: 1 +resources: + requests: + cpu: "0.01" + memory: "256Mi" + limits: + cpu: "1" + memory: "500Mi" diff --git a/charts/alfresco-connector-msteams/templates/_helpers.tpl b/charts/alfresco-connector-msteams/templates/_helpers.tpl new file mode 100644 index 00000000..e89b3453 --- /dev/null +++ b/charts/alfresco-connector-msteams/templates/_helpers.tpl @@ -0,0 +1,51 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "alfresco-connector-msteams.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "alfresco-connector-msteams.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "alfresco-connector-msteams.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "alfresco-connector-msteams.labels" -}} +helm.sh/chart: {{ include "alfresco-connector-msteams.chart" . }} +{{ include "alfresco-connector-msteams.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "alfresco-connector-msteams.selectorLabels" -}} +app.kubernetes.io/name: {{ include "alfresco-connector-msteams.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/charts/alfresco-connector-msteams/templates/config-connector-msteams.yaml b/charts/alfresco-connector-msteams/templates/config-connector-msteams.yaml new file mode 100644 index 00000000..d9d95cc9 --- /dev/null +++ b/charts/alfresco-connector-msteams/templates/config-connector-msteams.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "alfresco-connector-msteams.fullname" . }} + labels: + {{- include "alfresco-connector-msteams.labels" . | nindent 4 }} +data: + {{- if .Values.environment }} + {{- range $key, $val := .Values.environment }} + {{ $key }}: {{ $val | quote }} + {{- end }} + {{- end }} + ALFRESCO_BASE_URL: "{{ .Values.alfresco.baseUrl }}" + ALFRESCO_DIGITAL_WORKSPACE_CONTEXT_PATH: "{{ .Values.alfresco.digitalWorkspace.contextPath }}" + MICROSOFT_APP_ID: "{{ .Values.microsoft.app.id }}" + MICROSOFT_APP_PASSWORD: "{{ .Values.microsoft.app.password }}" + MICROSOFT_APP_OAUTH_CONNECTION_NAME: "{{ .Values.microsoft.app.oauth.connectionName }}" + TEAMS_CHAT_FILENAME_ENABLED: "{{ .Values.teams.chat.filenameEnabled }}" + TEAMS_CHAT_METADATA_ENABLED: "{{ .Values.teams.chat.metadataEnabled }}" + TEAMS_CHAT_IMAGE_ENABLED: "{{ .Values.teams.chat.imageEnabled }}" diff --git a/charts/alfresco-connector-msteams/templates/deployment-connector-msteams.yaml b/charts/alfresco-connector-msteams/templates/deployment-connector-msteams.yaml new file mode 100644 index 00000000..555c0e5c --- /dev/null +++ b/charts/alfresco-connector-msteams/templates/deployment-connector-msteams.yaml @@ -0,0 +1,81 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "alfresco-connector-msteams.fullname" . }} + labels: + {{- include "alfresco-connector-msteams.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "alfresco-connector-msteams.selectorLabels" . | nindent 6 }} + strategy: + type: RollingUpdate + rollingUpdate: + {{- toYaml .Values.strategy.rollingUpdate | nindent 6 }} + template: + metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/config-connector-msteams.yaml") . | sha256sum }} + labels: + {{- include "alfresco-connector-msteams.selectorLabels" . | nindent 8 }} + spec: + {{- include "component-pod-security-context" .Values | indent 4 }} + {{- if .Values.nodeSelector }} + nodeSelector: {{- .Values.nodeSelector | toYaml | nindent 8 }} + {{- end }} + {{- include "alfresco-content-services.imagePullSecrets" . | indent 6 }} + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 10 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - {{ template "alfresco-connector-msteams.name" . }} + - key: app.kubernetes.io/instance + operator: In + values: + - {{ .Release.Name }} + topologyKey: failure-domain.beta.kubernetes.io/zone + - weight: 5 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - {{ template "alfresco-connector-msteams.name" . }} + - key: app.kubernetes.io/instance + operator: In + values: + - {{ .Release.Name }} + topologyKey: kubernetes.io/hostname + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- include "component-security-context" .Values.msTeams | indent 8 }} + envFrom: + - configMapRef: + name: {{ template "alfresco-connector-msteams.fullname" . }} + ports: + - containerPort: {{ .Values.image.internalPort }} + resources: {{- toYaml .Values.resources | nindent 12 }} + readinessProbe: + tcpSocket: + port: {{ .Values.image.internalPort }} + initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.readinessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} + livenessProbe: + tcpSocket: + port: {{ .Values.image.internalPort }} + initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.livenessProbe.periodSeconds }} + failureThreshold: 1 + timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} diff --git a/charts/alfresco-connector-msteams/templates/ingress-connector-msteams.yaml b/charts/alfresco-connector-msteams/templates/ingress-connector-msteams.yaml new file mode 100644 index 00000000..6b767f8b --- /dev/null +++ b/charts/alfresco-connector-msteams/templates/ingress-connector-msteams.yaml @@ -0,0 +1,36 @@ +{{- $serviceName := (include "alfresco-connector-msteams.fullname" .) -}} +{{- $servicePort := .Values.service.externalPort -}} +apiVersion: {{ template "common.capabilities.ingress.apiVersion" . }} +kind: Ingress +metadata: + name: {{ $serviceName }} + labels: + {{- include "alfresco-connector-msteams.labels" . | nindent 4 }} + annotations: + kubernetes.io/ingress.class: "nginx" + {{- if .Values.ingress.extraAnnotations }} + {{ toYaml .Values.ingress.extraAnnotations }} + {{- end }} + +spec: + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + - http: + paths: + - path: {{ .Values.ingress.path }} + {{- if eq "true" (include "common.ingress.supportsPathType" .) }} + pathType: Prefix + {{- end }} + backend: {{- include "common.ingress.backend" (dict "serviceName" $serviceName "servicePort" $servicePort "context" $) | nindent 10 }} + {{- if .Values.ingress.hostName }} + host: {{ tpl .Values.ingress.hostName $ }} + {{- end }} diff --git a/charts/alfresco-connector-msteams/templates/svc-connector-msteams.yaml b/charts/alfresco-connector-msteams/templates/svc-connector-msteams.yaml new file mode 100644 index 00000000..c55724fd --- /dev/null +++ b/charts/alfresco-connector-msteams/templates/svc-connector-msteams.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "alfresco-connector-msteams.fullname" . }} + labels: + {{- include "alfresco-connector-msteams.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.image.internalPort }} + name: {{ .Values.service.name }} + selector: + {{- include "alfresco-connector-msteams.selectorLabels" . | nindent 4 }} diff --git a/charts/alfresco-connector-msteams/tests/deployment-connector-msteams_test.yaml b/charts/alfresco-connector-msteams/tests/deployment-connector-msteams_test.yaml new file mode 100644 index 00000000..8e26fc40 --- /dev/null +++ b/charts/alfresco-connector-msteams/tests/deployment-connector-msteams_test.yaml @@ -0,0 +1,27 @@ +suite: test connector-msteams deployment +templates: +- deployment-connector-msteams.yaml +- config-connector-msteams.yaml +tests: +- it: should have basic metadata in place + values: &testvalues + - values/test_values.yaml + asserts: + - equal: + path: metadata.name + value: RELEASE-NAME-alfresco-connector-msteams + template: deployment-connector-msteams.yaml + +- it: should render cpu and memory limits + values: *testvalues + asserts: + - equal: + path: spec.template.spec.containers[0].resources + value: + requests: + cpu: "0.5" + memory: "1000Mi" + limits: + cpu: "1" + memory: "1000Mi" + template: deployment-connector-msteams.yaml diff --git a/charts/alfresco-connector-msteams/tests/values/test_values.yaml b/charts/alfresco-connector-msteams/tests/values/test_values.yaml new file mode 100644 index 00000000..6968a5a1 --- /dev/null +++ b/charts/alfresco-connector-msteams/tests/values/test_values.yaml @@ -0,0 +1,5 @@ +--- +global: + tracking: + sharedsecret: dummy + alfrescoRegistryPullSecrets: secretsecret diff --git a/charts/alfresco-connector-msteams/values.yaml b/charts/alfresco-connector-msteams/values.yaml new file mode 100644 index 00000000..087a5ca7 --- /dev/null +++ b/charts/alfresco-connector-msteams/values.yaml @@ -0,0 +1,58 @@ +global: + alfrescoRegistryPullSecrets: quay-registry-secret +strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 +replicaCount: 2 +nodeSelector: {} +image: + repository: quay.io/alfresco/alfresco-ms-teams-service + tag: 2.0.0-A2 + pullPolicy: IfNotPresent + internalPort: 3978 +service: + name: ms-teams-service + type: ClusterIP + externalPort: 80 +ingress: + path: /ms-teams-service + tls: [] + extraAnnotations: + # - secretName: chart-example-tls + # hosts: + # - chart-example.local +podSecurityContext: + runAsNonRoot: true + runAsUser: 33041 +resources: + requests: + cpu: "0.5" + memory: "1000Mi" + limits: + cpu: "1" + memory: "1000Mi" +readinessProbe: + initialDelaySeconds: 20 + periodSeconds: 60 + timeoutSeconds: 10 +livenessProbe: + initialDelaySeconds: 10 + periodSeconds: 20 + timeoutSeconds: 10 +environment: +alfresco: + baseUrl: change_me_alf_base_url + digitalWorkspace: + contextPath: /workspace/ +microsoft: + app: + id: change_me_app_id + password: change_me_app_pwd + oauth: + connectionName: alfresco +teams: + chat: + filenameEnabled: true + metadataEnabled: true + imageEnabled: true