Skip to content

Commit

Permalink
local structurizr helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
garunski committed Mar 28, 2023
1 parent 5a0a4d0 commit 16b88c5
Show file tree
Hide file tree
Showing 11 changed files with 273 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/helm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release Charts

on:
push:
branches:
- main

jobs:
release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v3

- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.5.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
5 changes: 5 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
charts for scry specific development

```
helm upgrade -i structurizr ./charts/structurizr-local
```
23 changes: 23 additions & 0 deletions charts/structurizr-local/.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/structurizr-local/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: structurizr-local
description: Provides a tailored method for hosting Structurizr locally, enabling users to access their diagrams, documentation, and ARDs (Architecture Decision Records) with ease.
type: application
version: 1.0.1
appVersion: "latest"
62 changes: 62 additions & 0 deletions charts/structurizr-local/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "structurizr-local.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 "structurizr-local.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 "structurizr-local.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "structurizr-local.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "structurizr-local.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
51 changes: 51 additions & 0 deletions charts/structurizr-local/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "structurizr-local.fullname" . }}
labels:
{{- include "structurizr-local.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "structurizr-local.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "structurizr-local.selectorLabels" . | nindent 8 }}
spec:
serviceAccountName: {{ include "structurizr-local.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- mountPath: /usr/local/structurizr
name: local-structurizr
volumes:
- name: local-structurizr
hostPath:
path: {{ .Values.localDirectory }}
type: Directory
25 changes: 25 additions & 0 deletions charts/structurizr-local/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- $fullName := include "structurizr-local.fullname" . -}}

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "structurizr-local.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
rules:
- host: {{ .Values.ingress.host | quote }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ $fullName }}
port:
number: {{ .Values.service.port }}
15 changes: 15 additions & 0 deletions charts/structurizr-local/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "structurizr-local.fullname" . }}
labels:
{{- include "structurizr-local.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "structurizr-local.selectorLabels" . | nindent 4 }}
12 changes: 12 additions & 0 deletions charts/structurizr-local/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 "structurizr-local.serviceAccountName" . }}
labels:
{{- include "structurizr-local.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/structurizr-local/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "structurizr-local.fullname" . }}-test-connection"
labels:
{{- include "structurizr-local.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "structurizr-local.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
29 changes: 29 additions & 0 deletions charts/structurizr-local/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
localDirectory: /Users/garun/code/structurizr/examples/dsl/system-catalog

replicaCount: 1

image:
repository: structurizr/lite
pullPolicy: IfNotPresent
tag: "latest"

service:
port: 8080

ingress:
host: diagrams.local.scryapp.website
annotations: {}

serviceAccount:
create: true
annotations: {}
name: ""

podAnnotations: {}

podSecurityContext: {}

securityContext: {}

resources: {}

0 comments on commit 16b88c5

Please sign in to comment.