diff --git a/.github/workflows/helm-release.yml b/.github/workflows/helm-release.yml index 8b3a71e..92a8595 100644 --- a/.github/workflows/helm-release.yml +++ b/.github/workflows/helm-release.yml @@ -137,6 +137,7 @@ jobs: id: helm-tests continue-on-error: true run: | + # Create log directory mkdir -p /tmp/helm-logs diff --git a/charts/postmortem-bot/.helmignore b/charts/postmortem-bot/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/postmortem-bot/.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/postmortem-bot/Chart.yaml b/charts/postmortem-bot/Chart.yaml new file mode 100644 index 0000000..658f98c --- /dev/null +++ b/charts/postmortem-bot/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: postmortem-bot +version: 0.1.0 +description: A Helm chart for deploying the Postmortem Automation Bot (Webhook Server & Discord Bot) +appVersion: "1.0.0" diff --git a/charts/postmortem-bot/README.md b/charts/postmortem-bot/README.md new file mode 100644 index 0000000..7b3e75f --- /dev/null +++ b/charts/postmortem-bot/README.md @@ -0,0 +1,145 @@ +# Postmortem Bot Helm Chart + +This Helm chart deploys the Postmortem Automation Bot to your Kubernetes cluster, including both the webhook server and Discord bot. + +## Prerequisites + +- Kubernetes cluster (1.19+) +- Helm 3.x +- Docker image built and pushed to container registry + +## Installation + +### Quick Install + +```bash +helm install postmortem-bot ./helm/postmortem-bot +``` + +### Install with Custom Values + +```bash +helm install postmortem-bot ./helm/postmortem-bot \ + --set webhook.image.repository=ghcr.io/techops-services/postmortem-automation \ + --set webhook.image.tag=v1.0.0 \ + --set discordbot.image.repository=ghcr.io/techops-services/postmortem-automation \ + --set discordbot.image.tag=v1.0.0 +``` + +### Install with Values File + +Create a `custom-values.yaml`: + +```yaml +webhook: + enabled: true + replicaCount: 2 + image: + repository: ghcr.io/techops-services/postmortem-automation + tag: v1.0.0 + env: + - name: PAGERDUTY_API_KEY + valueFrom: + secretKeyRef: + name: postmortem-secrets + key: pagerduty-api-key + - name: DISCORD_WEBHOOK_URL + valueFrom: + secretKeyRef: + name: postmortem-secrets + key: discord-webhook-url + +discordbot: + enabled: true + replicaCount: 1 + image: + repository: ghcr.io/techops-services/postmortem-automation + tag: v1.0.0 + env: + - name: DISCORD_BOT_TOKEN + valueFrom: + secretKeyRef: + name: postmortem-secrets + key: discord-bot-token +``` + +Then install: + +```bash +helm install postmortem-bot ./helm/postmortem-bot -f custom-values.yaml +``` + +## Configuration + +### Webhook Server Configuration + +| Parameter | Description | Default | +|-----------|-------------|---------| +| `webhook.enabled` | Enable webhook deployment | `true` | +| `webhook.replicaCount` | Number of replicas | `1` | +| `webhook.image.repository` | Image repository | `ghcr.io/techops-services/postmortem-automation` | +| `webhook.image.tag` | Image tag | `latest` | +| `webhook.service.type` | Service type | `ClusterIP` | +| `webhook.service.port` | Service port | `8080` | +| `webhook.resources` | Resource limits/requests | See values.yaml | +| `webhook.env` | Environment variables | `[]` | + +### Discord Bot Configuration + +| Parameter | Description | Default | +|-----------|-------------|---------| +| `discordbot.enabled` | Enable Discord bot deployment | `true` | +| `discordbot.replicaCount` | Number of replicas | `1` | +| `discordbot.image.repository` | Image repository | `ghcr.io/techops-services/postmortem-automation` | +| `discordbot.image.tag` | Image tag | `latest` | +| `discordbot.service.type` | Service type | `ClusterIP` | +| `discordbot.service.port` | Service port | `8081` | +| `discordbot.resources` | Resource limits/requests | See values.yaml | +| `discordbot.env` | Environment variables | `[]` | + +## Creating Secrets + +Before deploying, create a Kubernetes secret with your credentials: + +```bash +kubectl create secret generic postmortem-secrets \ + --from-literal=pagerduty-api-key=YOUR_PAGERDUTY_KEY \ + --from-literal=discord-webhook-url=YOUR_DISCORD_WEBHOOK \ + --from-literal=discord-bot-token=YOUR_DISCORD_BOT_TOKEN \ + --from-literal=google-drive-folder-id=YOUR_FOLDER_ID +``` + +## Upgrading + +```bash +helm upgrade postmortem-bot ./helm/postmortem-bot -f custom-values.yaml +``` + +## Uninstalling + +```bash +helm uninstall postmortem-bot +``` + +## Examples + +### Deploy Only Webhook Server + +```bash +helm install postmortem-bot ./helm/postmortem-bot \ + --set discordbot.enabled=false +``` + +### Deploy Only Discord Bot + +```bash +helm install postmortem-bot ./helm/postmortem-bot \ + --set webhook.enabled=false +``` + +### Scale Webhook Replicas + +```bash +helm upgrade postmortem-bot ./helm/postmortem-bot \ + --set webhook.replicaCount=3 +``` diff --git a/charts/postmortem-bot/templates/_helpers.tpl b/charts/postmortem-bot/templates/_helpers.tpl new file mode 100644 index 0000000..291334b --- /dev/null +++ b/charts/postmortem-bot/templates/_helpers.tpl @@ -0,0 +1,45 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "postmortem-bot.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +*/}} +{{- define "postmortem-bot.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s" $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "postmortem-bot.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "postmortem-bot.labels" -}} +helm.sh/chart: {{ include "postmortem-bot.chart" . }} +{{ include "postmortem-bot.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "postmortem-bot.selectorLabels" -}} +app.kubernetes.io/name: {{ include "postmortem-bot.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} diff --git a/charts/postmortem-bot/templates/discordbot-deployment.yaml b/charts/postmortem-bot/templates/discordbot-deployment.yaml new file mode 100644 index 0000000..0296c93 --- /dev/null +++ b/charts/postmortem-bot/templates/discordbot-deployment.yaml @@ -0,0 +1,46 @@ +{{- if .Values.discordbot.enabled }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "postmortem-bot.fullname" . }}-discordbot + labels: + {{- include "postmortem-bot.labels" . | nindent 4 }} + app.kubernetes.io/component: discordbot +spec: + replicas: {{ .Values.discordbot.replicaCount }} + selector: + matchLabels: + {{- include "postmortem-bot.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: discordbot + template: + metadata: + labels: + {{- include "postmortem-bot.selectorLabels" . | nindent 8 }} + app.kubernetes.io/component: discordbot + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: discordbot + image: "{{ .Values.discordbot.image.repository }}:{{ .Values.discordbot.image.tag }}" + imagePullPolicy: {{ .Values.discordbot.image.pullPolicy }} + args: ["discordbot"] + ports: + - name: http + containerPort: 8081 + protocol: TCP + env: + {{- range .Values.discordbot.env }} + - name: {{ .name }} + {{- if .value }} + value: {{ .value | quote }} + {{- else if .valueFrom }} + valueFrom: + {{- toYaml .valueFrom | nindent 16 }} + {{- end }} + {{- end }} + resources: + {{- toYaml .Values.discordbot.resources | nindent 12 }} +{{- end }} diff --git a/charts/postmortem-bot/templates/discordbot-service.yaml b/charts/postmortem-bot/templates/discordbot-service.yaml new file mode 100644 index 0000000..81b3d4f --- /dev/null +++ b/charts/postmortem-bot/templates/discordbot-service.yaml @@ -0,0 +1,19 @@ +{{- if .Values.discordbot.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "postmortem-bot.fullname" . }}-discordbot + labels: + {{- include "postmortem-bot.labels" . | nindent 4 }} + app.kubernetes.io/component: discordbot +spec: + type: {{ .Values.discordbot.service.type }} + ports: + - port: {{ .Values.discordbot.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "postmortem-bot.selectorLabels" . | nindent 4 }} + app.kubernetes.io/component: discordbot +{{- end }} diff --git a/charts/postmortem-bot/templates/webhook-deployment.yaml b/charts/postmortem-bot/templates/webhook-deployment.yaml new file mode 100644 index 0000000..f4e3bf4 --- /dev/null +++ b/charts/postmortem-bot/templates/webhook-deployment.yaml @@ -0,0 +1,58 @@ +{{- if .Values.webhook.enabled }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "postmortem-bot.fullname" . }}-webhook + labels: + {{- include "postmortem-bot.labels" . | nindent 4 }} + app.kubernetes.io/component: webhook +spec: + replicas: {{ .Values.webhook.replicaCount }} + selector: + matchLabels: + {{- include "postmortem-bot.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: webhook + template: + metadata: + labels: + {{- include "postmortem-bot.selectorLabels" . | nindent 8 }} + app.kubernetes.io/component: webhook + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: webhook + image: "{{ .Values.webhook.image.repository }}:{{ .Values.webhook.image.tag }}" + imagePullPolicy: {{ .Values.webhook.image.pullPolicy }} + args: ["webhook"] + ports: + - name: http + containerPort: 8080 + protocol: TCP + env: + {{- range .Values.webhook.env }} + - name: {{ .name }} + {{- if .value }} + value: {{ .value | quote }} + {{- else if .valueFrom }} + valueFrom: + {{- toYaml .valueFrom | nindent 16 }} + {{- end }} + {{- end }} + resources: + {{- toYaml .Values.webhook.resources | nindent 12 }} + livenessProbe: + httpGet: + path: /health + port: http + initialDelaySeconds: 30 + periodSeconds: 10 + readinessProbe: + httpGet: + path: /health + port: http + initialDelaySeconds: 5 + periodSeconds: 5 +{{- end }} diff --git a/charts/postmortem-bot/templates/webhook-service.yaml b/charts/postmortem-bot/templates/webhook-service.yaml new file mode 100644 index 0000000..99867c2 --- /dev/null +++ b/charts/postmortem-bot/templates/webhook-service.yaml @@ -0,0 +1,19 @@ +{{- if .Values.webhook.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "postmortem-bot.fullname" . }}-webhook + labels: + {{- include "postmortem-bot.labels" . | nindent 4 }} + app.kubernetes.io/component: webhook +spec: + type: {{ .Values.webhook.service.type }} + ports: + - port: {{ .Values.webhook.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "postmortem-bot.selectorLabels" . | nindent 4 }} + app.kubernetes.io/component: webhook +{{- end }} diff --git a/charts/postmortem-bot/test-values.yaml b/charts/postmortem-bot/test-values.yaml new file mode 100644 index 0000000..b05b24b --- /dev/null +++ b/charts/postmortem-bot/test-values.yaml @@ -0,0 +1,65 @@ +# Test values for postmortem-bot Helm chart +# Override values for testing/development environment + +webhook: + enabled: true + replicaCount: 1 + image: + repository: ghcr.io/techops-services/postmortem-automation + tag: latest + pullPolicy: Always + service: + type: ClusterIP + port: 8080 + resources: + limits: + cpu: 500m + memory: 512Mi + requests: + cpu: 250m + memory: 256Mi + env: + - name: PAGERDUTY_API_KEY + valueFrom: + secretKeyRef: + name: postmortem-secrets + key: pagerduty-api-key + - name: DISCORD_WEBHOOK_URL + valueFrom: + secretKeyRef: + name: postmortem-secrets + key: discord-webhook-url + - name: GOOGLE_DRIVE_FOLDER_ID + valueFrom: + secretKeyRef: + name: postmortem-secrets + key: google-drive-folder-id + +discordbot: + enabled: true + replicaCount: 1 + image: + repository: ghcr.io/techops-services/postmortem-automation + tag: latest + pullPolicy: Always + service: + type: ClusterIP + port: 8081 + resources: + limits: + cpu: 500m + memory: 512Mi + requests: + cpu: 250m + memory: 256Mi + env: + - name: DISCORD_BOT_TOKEN + valueFrom: + secretKeyRef: + name: postmortem-secrets + key: discord-bot-token + +imagePullSecrets: [] + +commonLabels: + environment: test diff --git a/charts/postmortem-bot/values.yaml b/charts/postmortem-bot/values.yaml new file mode 100644 index 0000000..7367655 --- /dev/null +++ b/charts/postmortem-bot/values.yaml @@ -0,0 +1,55 @@ +webhook: + enabled: true + replicaCount: 1 + image: + repository: ghcr.io/techops-services/postmortem-automation + tag: latest + pullPolicy: IfNotPresent + service: + type: ClusterIP + port: 8080 + resources: + limits: + cpu: 500m + memory: 512Mi + requests: + cpu: 250m + memory: 256Mi + env: [] + # Example environment variables: + # - name: PAGERDUTY_API_KEY + # valueFrom: + # secretKeyRef: + # name: postmortem-secrets + # key: pagerduty-api-key + +discordbot: + enabled: true + replicaCount: 1 + image: + repository: ghcr.io/techops-services/postmortem-automation + tag: latest + pullPolicy: IfNotPresent + service: + type: ClusterIP + port: 8081 + resources: + limits: + cpu: 500m + memory: 512Mi + requests: + cpu: 250m + memory: 256Mi + env: [] + # Example environment variables: + # - name: DISCORD_BOT_TOKEN + # valueFrom: + # secretKeyRef: + # name: postmortem-secrets + # key: discord-bot-token + +# Common image pull secrets +imagePullSecrets: [] + +# Common labels +commonLabels: {}