Skip to content

Commit

Permalink
added helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
NivEz committed Jan 30, 2024
1 parent f0d6e5f commit 01930a2
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ yarn-error.log*

.env

data
data

values-local.yaml
25 changes: 25 additions & 0 deletions .helm/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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/

README.md
18 changes: 18 additions & 0 deletions .helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v2
name: movie-info-bot
description: A Helm chart for movie-info-bot

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
18 changes: 18 additions & 0 deletions .helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Helm setup

The file `values-local.yaml` is git ignored so it can be used with sensitive data.

### Install the chart (using values-local.yaml from local machine)
```
helm install -f .helm/values-local.yaml movie-info-bot ./.helm --atomic --debug --namespace movie-info-bot --create-namespace
```

### Upgrade the chart
```
helm upgrade -f .helm/values-local.yaml movie-info-bot ./.helm --atomic --debug --reuse-values
```

### Uninstall
```
helm uninstall movie-info-bot --namespace movie-info-bot
```
8 changes: 8 additions & 0 deletions .helm/templates/app-env-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: 'app-env-vars'
namespace: {{ .Values.appName }}
type: Opaque
stringData:
API_TOKEN: {{ .Values.appEnv.apiToken }}
29 changes: 29 additions & 0 deletions .helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.appName }}
namespace: {{ .Values.appName }}
labels:
app: {{ .Values.appName }}
spec:
selector:
matchLabels:
app: {{ .Values.appName }}
template:
metadata:
labels:
app: {{ .Values.appName }}
spec:
containers:
- name: {{ .Values.appName }}
image: {{ .Values.deployment.image }}
ports:
- containerPort: 3000
env:
- name: API_TOKEN
valueFrom:
secretKeyRef:
name: app-env-vars
key: API_TOKEN
imagePullSecrets:
- name: registry-credentials
5 changes: 5 additions & 0 deletions .helm/templates/image-pull-secret.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{- define "imagePullSecret" }}
{{- with .Values.imageCredentials }}
{{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}}" .registry .username .password .email (printf "%s:%s" .username .password | b64enc) | b64enc }}
{{- end }}
{{- end }}
8 changes: 8 additions & 0 deletions .helm/templates/image-pull-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: registry-credentials
namespace: {{ .Values.appName }}
type: kubernetes.io/dockerconfigjson
data:
.dockerconfigjson: {{ template "imagePullSecret" . }}
18 changes: 18 additions & 0 deletions .helm/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
namespace: {{ .Values.appName }}
name: {{ .Values.appName }}
spec:
ingressClassName: nginx
rules:
- host: {{ .Values.ingress.host }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ .Values.appName }}
port:
number: 80
15 changes: 15 additions & 0 deletions .helm/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.appName }}
namespace: {{ .Values.appName }}
labels:
app: {{ .Values.appName }}
spec:
selector:
app: {{ .Values.appName }}
ports:
- name: http
protocol: TCP
port: 80
targetPort: 3000
15 changes: 15 additions & 0 deletions .helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
appName: movie-info-bot

deployment:
image: ''

ingress:
host: ''

appEnv:
apiToken: ''

imageCredentials:
registry: ''
username: ''
password: ''
5 changes: 4 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ node_modules
README.md

package-lock.json
yarn.lock
yarn.lock

.helm/**/*.yaml
.helm/**/*.yml

0 comments on commit 01930a2

Please sign in to comment.