Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
frjaraur authored Oct 4, 2023
2 parents 6618be1 + aa4b593 commit c56287a
Show file tree
Hide file tree
Showing 44 changed files with 1,267 additions and 106 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@ name: "Validate PR"

on:
pull_request:
branches: [ master ]
push:
branches:
- master

jobs:
lint:
name: Lint Project
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
# Checkout everything since ct uses git diff to determine charts
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b #v3.0.2
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
with:
fetch-depth: 0
- name: Execute Lint
run: make lint

test:
name: Test
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs:
- lint
steps:
# Checkout everything since ct uses git diff to determine charts
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b #v3.0.2
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
with:
fetch-depth: 0
- name: Execute Tests
run: make test


2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CLUSTER_NAME ?= mattermost-helm-test
DOCKER_IMAGE_SHELLCHECK ?= koalaman/shellcheck:v0.8.0@sha256:4c4427336d2b4bdb054a1e97396fa2e9ca0c329a1f43f831b99bcaae4ac24fcd
# Official image of chart-testing[https://github.com/helm/chart-testing].
# Contains chart-testing cli, helm and kubectl.
DOCKER_IMAGE_CT ?= quay.io/helmpack/chart-testing:v3.7.0@sha256:2f87e56a0cebc6d9bb78d51cb6adac97858afb0887cac4d65f7f8c6a16054568
DOCKER_IMAGE_CT ?= quay.io/helmpack/chart-testing:v3.7.1@sha256:ef453de0be68d5ded26f3b3ea0c5431b396c8c48f89e2a07be7b19c4c9a68b31

# Official image of chart-releaser[https://github.com/helm/chart-releaser].
# Contains chart-releaser cli.
Expand Down
23 changes: 23 additions & 0 deletions charts/mattermost-calls-offloader/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
15 changes: 15 additions & 0 deletions charts/mattermost-calls-offloader/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v2
name: mattermost-calls-offloader
description: A Helm chart for Kubernetes to deploy Mattermost's Calls Offloader service
type: application
version: 0.1.2
appVersion: "0.3.3"
keywords:
- mattermost
- calls-offloader
maintainers:
- name: SRE Team
email: [email protected]
sources:
- https://github.com/mattermost/mattermost-helm
- https://github.com/mattermost/calls-offloader
35 changes: 35 additions & 0 deletions charts/mattermost-calls-offloader/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# mattermost-calls-offloader

A Helm chart for Kubernetes and Mattermost Application Calls Offloader

## How to install this chart

Add Mattermost public chart repo:

```console
helm repo add mattermost https://helm.mattermost.com
```

A simple install with default values:

```console
helm install mattermost/mattermost-calls-offloader
```

To install the chart with the release name `my-release`:

```console
helm install my-release mattermost/mattermost-calls-offloader
```

To install with some set values:

```console
helm install my-release mattermost/mattermost-calls-offloader --set values_key1=value1 --set values_key2=value2
```

To install with custom values file:

```console
helm install my-release mattermost/mattermost-calls-offloader -f values.yaml
```
16 changes: 16 additions & 0 deletions charts/mattermost-calls-offloader/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
1. Get the application URL by running these commands:
{{- if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "mattermost-calls-offloader.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "mattermost-calls-offloader.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "mattermost-calls-offloader.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "mattermost-calls-offloader.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
62 changes: 62 additions & 0 deletions charts/mattermost-calls-offloader/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "mattermost-calls-offloader.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 "mattermost-calls-offloader.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 "mattermost-calls-offloader.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "mattermost-calls-offloader.labels" -}}
helm.sh/chart: {{ include "mattermost-calls-offloader.chart" . }}
{{ include "mattermost-calls-offloader.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "mattermost-calls-offloader.selectorLabels" -}}
app.kubernetes.io/name: {{ include "mattermost-calls-offloader.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "mattermost-calls-offloader.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "mattermost-calls-offloader.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
63 changes: 63 additions & 0 deletions charts/mattermost-calls-offloader/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "mattermost-calls-offloader.fullname" . }}
labels:
{{- include "mattermost-calls-offloader.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "mattermost-calls-offloader.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "mattermost-calls-offloader.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "mattermost-calls-offloader.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: offloader
containerPort: 4545
protocol: TCP
env:
{{- toYaml .Values.config | nindent 12 }}
livenessProbe:
httpGet:
path: /version
port: offloader
readinessProbe:
httpGet:
path: /version
port: offloader
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
28 changes: 28 additions & 0 deletions charts/mattermost-calls-offloader/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "mattermost-calls-offloader.fullname" . }}
labels:
{{- include "mattermost-calls-offloader.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "mattermost-calls-offloader.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
11 changes: 11 additions & 0 deletions charts/mattermost-calls-offloader/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "mattermost-calls-offloader.name" . }}
rules:
- apiGroups: ["batch"]
resources: ["jobs"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups: [""]
resources: ["pods", "pods/log"]
verbs: ["get", "list"]
11 changes: 11 additions & 0 deletions charts/mattermost-calls-offloader/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "mattermost-calls-offloader.name" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "mattermost-calls-offloader.name" . }}
subjects:
- kind: ServiceAccount
name: {{ include "mattermost-calls-offloader.serviceAccountName" . }}
15 changes: 15 additions & 0 deletions charts/mattermost-calls-offloader/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "mattermost-calls-offloader.fullname" . }}
labels:
{{- include "mattermost-calls-offloader.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.service.targetPort }}
protocol: TCP
name: offloader
selector:
{{- include "mattermost-calls-offloader.selectorLabels" . | nindent 4 }}
12 changes: 12 additions & 0 deletions charts/mattermost-calls-offloader/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "mattermost-calls-offloader.serviceAccountName" . }}
labels:
{{- include "mattermost-calls-offloader.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
Loading

0 comments on commit c56287a

Please sign in to comment.