Skip to content

Commit

Permalink
feat: helm chart for server
Browse files Browse the repository at this point in the history
  • Loading branch information
drew-viles committed Oct 3, 2023
1 parent 5e87474 commit 9d694f9
Show file tree
Hide file tree
Showing 9 changed files with 273 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,26 @@ jobs:
cosign-tlog: true
dockerfile-path: docker/server

package-and-push-charts:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
id: install-helm

- name: Push Chart to Harbor
shell: bash
run: |
helm registry login -u ${{ secrets.HELM_USER }} -p ${{ secrets.HELM_PASSWORD }} https://harbor.infra.nl1.eschercloud.dev
# Release the baski-server chart
helm package charts/baski-server --version ${{ github.ref_name }} --app-version ${{ github.ref_name }}
helm push baski-server-${{ github.ref_name }}.tgz oci://harbor.infra.nl1.eschercloud.dev/charts
release:
name: Create Release
runs-on: 'ubuntu-22.04'
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* Pipelines updated to support new server build requirements
* Updated to latest Golang
* Added tests for Server
* Added charts for deploying server

### Fixed

Expand Down
23 changes: 23 additions & 0 deletions charts/baski-server/.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/
6 changes: 6 additions & 0 deletions charts/baski-server/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: baski-server
description: A Helm chart for Kubernetes
type: application
version: 0.0.0
appVersion: "0.0.0"
62 changes: 62 additions & 0 deletions charts/baski-server/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "baski-server.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 "baski-server.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 "baski-server.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "baski-server.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "baski-server.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
69 changes: 69 additions & 0 deletions charts/baski-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "baski-server.fullname" . }}
labels:
{{- include "baski-server.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "baski-server.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "baski-server.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "baski-server.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 }}
args:
- -a 0.0.0.0
- -p 80
- --endpoint {{ .Values.server.s3.endpoint }}
- --access-key {{ .Values.server.s3.accessKey }}
- --secret-key {{ .Values.server.s3.secretKey }}
- --bucket {{ .Values.server.s3.bucket }}
{{- if .Values.server.dev}}
- -d
{{- end}}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /healthz
port: http
readinessProbe:
httpGet:
path: /healthz
port: http
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 }}
15 changes: 15 additions & 0 deletions charts/baski-server/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "baski-server.fullname" . }}
labels:
{{- include "baski-server.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
{{- include "baski-server.selectorLabels" . | nindent 4 }}
12 changes: 12 additions & 0 deletions charts/baski-server/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 "baski-server.serviceAccountName" . }}
labels:
{{- include "baski-server.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
65 changes: 65 additions & 0 deletions charts/baski-server/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Default values for baski-server.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
repository: baski-server
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "v0.1.0-beta.10"

imagePullSecrets: [ ]
nameOverride: ""
fullnameOverride: ""

serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: { }
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations: { }

podSecurityContext: { }
# fsGroup: 2000

securityContext: { }
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

resources: { }
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

nodeSelector: { }

tolerations: [ ]

affinity: { }

# These settings are passed through to the server as args.
server:
dev: false
# All S3 values are required.
s3:
endpoint: "" # https://some-s3-endpoint:PORT
accessKey: "" # Access key to authenticate
secretKey: "" # Secret key to authenticate
bucket: "baski" # The name of the bucket

0 comments on commit 9d694f9

Please sign in to comment.