Skip to content

Commit

Permalink
deploy with helm for less pain
Browse files Browse the repository at this point in the history
  • Loading branch information
cromega committed Sep 10, 2020
1 parent 0226257 commit 2ec2ac5
Show file tree
Hide file tree
Showing 14 changed files with 144 additions and 60 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,16 @@ jobs:
run: docker build -t cromega/keyguard .
- name: Push
run: docker push cromega/keyguard

trigger-deploy:
needs: [push]
runs-on: ubuntu-latest
steps:
- name: Trigger deployment
env:
TOKEN: ${{ secrets.repo_token }}
run: |
curl -X POST \
-H "Authorization: token $TOKEN" \
https://api.github.com/repos/cromega/sublimia-platform/dispatches \
--data '{"event_type":"deploy:keyguard"}'
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ _testmain.go
*.test
*.prof

keyguard
/keyguard
config.json
23 changes: 23 additions & 0 deletions chart/keyguard/.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/
23 changes: 23 additions & 0 deletions chart/keyguard/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v2
name: keyguard
description: https://github.com/cromega/keyguard

# 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

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: 1.0.0
62 changes: 62 additions & 0 deletions chart/keyguard/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "keyguard.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 "keyguard.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 "keyguard.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "keyguard.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "keyguard.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ spec:
imagePullPolicy: Always
env:
- name: KG_PUBLIC_URL
value: "$KG_PUBLIC_URL"
value: "{{ .Values.public_url }}"
- name: KG_PRIVATE_KEY
value: "/etc/keyguard/private_key"
- name: KG_YUBI_CLIENT_ID
value: "$KG_YUBI_CLIENT_ID"
value: "{{ .Values.yubico.client_id }}"
- name: KG_YUBI_API_KEY
value: "$KG_YUBI_API_KEY"
value: "{{ .Values.yubico.api_key }}"
resources:
requests:
memory: 64Mi
limits:
memory: 64Mi
volumeMounts:
- name: private-key
mountPath: "/etc/keyguard"
Expand All @@ -35,4 +40,4 @@ spec:
- name: private-key
secret:
secretName: keyguard-private-key
defaultMode: 0600
defaultMode: 0444
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: keyguard
spec:
rules:
- host: key.platform.sublimia.nl
- host: {{ .Values.public_url }}
http:
paths:
- backend:
Expand Down
2 changes: 1 addition & 1 deletion ci/k8s/secret.yml → chart/keyguard/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ kind: Secret
metadata:
name: keyguard-private-key
data:
private_key: $KG_PRIVATE_KEY
private_key: "{{ .Values.private_key_base64 }}"
type: Opaque
File renamed without changes.
11 changes: 11 additions & 0 deletions chart/keyguard/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Default values for keyguard.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

public_url: ""

yubico:
client_id: ""
api_key: ""

private_key_base64: ""
23 changes: 0 additions & 23 deletions ci/pipeline.yml

This file was deleted.

7 changes: 0 additions & 7 deletions ci/set_pipeline.sh

This file was deleted.

10 changes: 0 additions & 10 deletions ci/test.sh

This file was deleted.

13 changes: 0 additions & 13 deletions ci/test.yml

This file was deleted.

0 comments on commit 2ec2ac5

Please sign in to comment.