chore: helm files
This commit is contained in:
parent
5aa9b32c03
commit
4c11d1c2aa
12 changed files with 452 additions and 0 deletions
23
helm/nextjs-slack-clone/.helmignore
Normal file
23
helm/nextjs-slack-clone/.helmignore
Normal file
|
|
@ -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/
|
||||
6
helm/nextjs-slack-clone/Chart.yaml
Normal file
6
helm/nextjs-slack-clone/Chart.yaml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
apiVersion: v2
|
||||
name: nextjs-slack-clone
|
||||
description: A Helm chart for NextJS Slack Clone application
|
||||
type: application
|
||||
version: 0.1.0
|
||||
appVersion: "1.0.0"
|
||||
89
helm/nextjs-slack-clone/README.md
Normal file
89
helm/nextjs-slack-clone/README.md
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
# NextJS Slack Clone Helm Chart
|
||||
|
||||
This Helm chart deploys the NextJS Slack Clone application to a Kubernetes cluster.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Kubernetes 1.19+
|
||||
- Helm 3.2.0+
|
||||
|
||||
## Installing the Chart
|
||||
|
||||
To install the chart with the release name `my-release`:
|
||||
|
||||
```bash
|
||||
# For deployments without private registry
|
||||
helm install my-release ./helm/nextjs-slack-clone
|
||||
|
||||
# For deployments with private registry authentication
|
||||
helm install my-release ./helm/nextjs-slack-clone \
|
||||
--set registry.username=your-username \
|
||||
--set registry.password=your-password
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
The following table lists the configurable parameters of the NextJS Slack Clone chart and their default values.
|
||||
|
||||
### Private Registry Authentication
|
||||
|
||||
This Helm chart supports pulling images from a private Docker registry with basic authentication. Configure the following values:
|
||||
|
||||
| Parameter | Description | Default |
|
||||
|-----------|-------------|---------|
|
||||
| `registry.url` | URL of the private registry | `registry.mattiaswiberg.com` |
|
||||
| `registry.username` | Username for registry authentication | `""` |
|
||||
| `registry.password` | Password for registry authentication | `""` |
|
||||
|
||||
For security reasons, it's recommended to provide the registry credentials during installation rather than storing them in the values.yaml file.
|
||||
|
||||
| Parameter | Description | Default |
|
||||
| --------- | ----------- | ------- |
|
||||
| `replicaCount` | Number of replicas | `1` |
|
||||
| `image.repository` | Image repository | `nextjs-slack-clone` |
|
||||
| `image.tag` | Image tag | `latest` |
|
||||
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
|
||||
| `service.type` | Kubernetes service type | `ClusterIP` |
|
||||
| `service.port` | Kubernetes service port | `80` |
|
||||
| `service.targetPort` | Application port | `3000` |
|
||||
| `ingress.enabled` | Enable ingress | `false` |
|
||||
| `resources` | CPU/Memory resource requests/limits | `{}` |
|
||||
| `env.NEXT_PUBLIC_SUPABASE_URL` | Supabase URL | `""` |
|
||||
| `env.NEXT_PUBLIC_SUPABASE_ANON_KEY` | Supabase anonymous key | `""` |
|
||||
|
||||
## Setting Environment Variables
|
||||
|
||||
To set the required Supabase environment variables, use the `--set` flag when installing the chart:
|
||||
|
||||
```bash
|
||||
helm install my-release ./helm/nextjs-slack-clone \
|
||||
--set env.NEXT_PUBLIC_SUPABASE_URL=your-supabase-url \
|
||||
--set env.NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
|
||||
```
|
||||
|
||||
Alternatively, you can create a custom values file with your environment variables:
|
||||
|
||||
```yaml
|
||||
# my-values.yaml
|
||||
env:
|
||||
NEXT_PUBLIC_SUPABASE_URL: your-supabase-url
|
||||
NEXT_PUBLIC_SUPABASE_ANON_KEY: your-supabase-anon-key
|
||||
```
|
||||
|
||||
And then install the chart using:
|
||||
|
||||
```bash
|
||||
helm install my-release ./helm/nextjs-slack-clone -f my-values.yaml
|
||||
```
|
||||
|
||||
## Enabling Ingress
|
||||
|
||||
To enable the ingress and configure a hostname:
|
||||
|
||||
```bash
|
||||
helm install my-release ./helm/nextjs-slack-clone \
|
||||
--set ingress.enabled=true \
|
||||
--set ingress.hosts[0].host=your-hostname.com \
|
||||
--set ingress.hosts[0].paths[0].path=/ \
|
||||
--set ingress.hosts[0].paths[0].pathType=Prefix
|
||||
```
|
||||
62
helm/nextjs-slack-clone/templates/_helpers.tpl
Normal file
62
helm/nextjs-slack-clone/templates/_helpers.tpl
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "nextjs-slack-clone.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 "nextjs-slack-clone.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 "nextjs-slack-clone.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "nextjs-slack-clone.labels" -}}
|
||||
helm.sh/chart: {{ include "nextjs-slack-clone.chart" . }}
|
||||
{{ include "nextjs-slack-clone.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "nextjs-slack-clone.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "nextjs-slack-clone.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "nextjs-slack-clone.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
{{- default (include "nextjs-slack-clone.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
76
helm/nextjs-slack-clone/templates/deployment.yaml
Normal file
76
helm/nextjs-slack-clone/templates/deployment.yaml
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "nextjs-slack-clone.fullname" . }}
|
||||
labels:
|
||||
{{- include "nextjs-slack-clone.labels" . | nindent 4 }}
|
||||
spec:
|
||||
{{- if not .Values.autoscaling.enabled }}
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
{{- end }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "nextjs-slack-clone.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
{{- with .Values.podAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "nextjs-slack-clone.selectorLabels" . | nindent 8 }}
|
||||
spec:
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ include "nextjs-slack-clone.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 }}
|
||||
env:
|
||||
- name: NEXT_PUBLIC_SUPABASE_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "nextjs-slack-clone.fullname" . }}-env
|
||||
key: NEXT_PUBLIC_SUPABASE_URL
|
||||
- name: NEXT_PUBLIC_SUPABASE_ANON_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "nextjs-slack-clone.fullname" . }}-env
|
||||
key: NEXT_PUBLIC_SUPABASE_ANON_KEY
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 3000
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: http
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: http
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
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 }}
|
||||
24
helm/nextjs-slack-clone/templates/hpa.yaml
Normal file
24
helm/nextjs-slack-clone/templates/hpa.yaml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{{- if .Values.autoscaling.enabled }}
|
||||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: {{ include "nextjs-slack-clone.fullname" . }}
|
||||
labels:
|
||||
{{- include "nextjs-slack-clone.labels" . | nindent 4 }}
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: {{ include "nextjs-slack-clone.fullname" . }}
|
||||
minReplicas: {{ .Values.autoscaling.minReplicas }}
|
||||
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
|
||||
metrics:
|
||||
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
17
helm/nextjs-slack-clone/templates/image-pull-secret.yaml
Normal file
17
helm/nextjs-slack-clone/templates/image-pull-secret.yaml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{{- if .Values.registry }}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: registry-creds
|
||||
labels:
|
||||
{{- include "nextjs-slack-clone.labels" . | nindent 4 }}
|
||||
type: kubernetes.io/dockerconfigjson
|
||||
data:
|
||||
.dockerconfigjson: {{ template "imagePullSecret" . }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "imagePullSecret" }}
|
||||
{{- with .Values.registry }}
|
||||
{{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"auth\":\"%s\"}}}" .url .username .password (printf "%s:%s" .username .password | b64enc) | b64enc }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
48
helm/nextjs-slack-clone/templates/ingress.yaml
Normal file
48
helm/nextjs-slack-clone/templates/ingress.yaml
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
{{- if .Values.ingress.enabled -}}
|
||||
{{- $fullName := include "nextjs-slack-clone.fullname" . -}}
|
||||
{{- $svcPort := .Values.service.port -}}
|
||||
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
|
||||
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
|
||||
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ $fullName }}
|
||||
labels:
|
||||
{{- include "nextjs-slack-clone.labels" . | nindent 4 }}
|
||||
{{- with .Values.ingress.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
|
||||
ingressClassName: {{ .Values.ingress.className }}
|
||||
{{- end }}
|
||||
{{- if .Values.ingress.tls }}
|
||||
tls:
|
||||
{{- range .Values.ingress.tls }}
|
||||
- hosts:
|
||||
{{- range .hosts }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
secretName: {{ .secretName }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- range .Values.ingress.hosts }}
|
||||
- host: {{ .host | quote }}
|
||||
http:
|
||||
paths:
|
||||
{{- range .paths }}
|
||||
- path: {{ .path }}
|
||||
pathType: {{ .pathType }}
|
||||
backend:
|
||||
service:
|
||||
name: {{ $fullName }}
|
||||
port:
|
||||
number: {{ $svcPort }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
10
helm/nextjs-slack-clone/templates/secret.yaml
Normal file
10
helm/nextjs-slack-clone/templates/secret.yaml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ include "nextjs-slack-clone.fullname" . }}-env
|
||||
labels:
|
||||
{{- include "nextjs-slack-clone.labels" . | nindent 4 }}
|
||||
type: Opaque
|
||||
data:
|
||||
NEXT_PUBLIC_SUPABASE_URL: {{ .Values.env.NEXT_PUBLIC_SUPABASE_URL | b64enc | quote }}
|
||||
NEXT_PUBLIC_SUPABASE_ANON_KEY: {{ .Values.env.NEXT_PUBLIC_SUPABASE_ANON_KEY | b64enc | quote }}
|
||||
15
helm/nextjs-slack-clone/templates/service.yaml
Normal file
15
helm/nextjs-slack-clone/templates/service.yaml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "nextjs-slack-clone.fullname" . }}
|
||||
labels:
|
||||
{{- include "nextjs-slack-clone.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: {{ .Values.service.targetPort }}
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
{{- include "nextjs-slack-clone.selectorLabels" . | nindent 4 }}
|
||||
12
helm/nextjs-slack-clone/templates/serviceaccount.yaml
Normal file
12
helm/nextjs-slack-clone/templates/serviceaccount.yaml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{{- if .Values.serviceAccount.create -}}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "nextjs-slack-clone.serviceAccountName" . }}
|
||||
labels:
|
||||
{{- include "nextjs-slack-clone.labels" . | nindent 4 }}
|
||||
{{- with .Values.serviceAccount.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
70
helm/nextjs-slack-clone/values.yaml
Normal file
70
helm/nextjs-slack-clone/values.yaml
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: registry.mattiaswiberg.com/nextjs-slack-clone
|
||||
tag: latest
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
# Image pull secrets for private registry authentication
|
||||
imagePullSecrets:
|
||||
- name: registry-creds
|
||||
|
||||
nameOverride: ""
|
||||
fullnameOverride: ""
|
||||
|
||||
serviceAccount:
|
||||
create: true
|
||||
annotations: {}
|
||||
name: ""
|
||||
|
||||
podAnnotations: {}
|
||||
|
||||
podSecurityContext: {}
|
||||
|
||||
securityContext: {}
|
||||
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 80
|
||||
targetPort: 3000
|
||||
|
||||
ingress:
|
||||
enabled: true
|
||||
className: "nginx"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt
|
||||
hosts:
|
||||
- host: chat.mattiaswiberg.com
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
tls:
|
||||
- secretName: chat-tls
|
||||
hosts:
|
||||
- chat.mattiaswiberg.com
|
||||
|
||||
resources:
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 512Mi
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 256Mi
|
||||
|
||||
autoscaling:
|
||||
enabled: false
|
||||
minReplicas: 1
|
||||
maxReplicas: 10
|
||||
targetCPUUtilizationPercentage: 80
|
||||
|
||||
nodeSelector: {}
|
||||
|
||||
tolerations: []
|
||||
|
||||
affinity: {}
|
||||
|
||||
# Registry settings for private registry access
|
||||
registry:
|
||||
url: registry.mattiaswiberg.com
|
||||
username: "" # To be provided during deployment
|
||||
password: "" # To be provided during deployment
|
||||
Loading…
Add table
Add a link
Reference in a new issue