Skip to content

Commit

Permalink
Add templates to HELM
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonophore committed May 10, 2024
1 parent 7190509 commit 80cc21a
Show file tree
Hide file tree
Showing 12 changed files with 536 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ft/deploy/chart/.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/
24 changes: 24 additions & 0 deletions ft/deploy/chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: vcs-facade
description: A Helm chart for Kubernetes

# 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.
# It is recommended to use it with quotes.
appVersion: "0.0.1"
17 changes: 17 additions & 0 deletions ft/deploy/chart/files/application-bitbucket.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
vcs-facade:
vcs:
bitbucket:
host: http://bitbucket:7990
username: admin
password: admin
health-check:
repo: ssh://git@bitbucket:7990/test-data/vcs-facade-healthcheck.git
root-commit: 9320183f5d5f5868fdb82b36e3abd6f9d1424114
last-release: 321d4908aef10bafa1488f9b053270acc29f3d78
expected-commits: 9320183f5d5f5868fdb82b36e3abd6f9d1424114,00cc61dd4c3eca64d12e6beceff1a40a436962f5
gitea:
enabled: false
gitlab:
enabled: false
opensearch:
enabled: false
4 changes: 4 additions & 0 deletions ft/deploy/chart/files/application-ft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vcs-facade:
job:
fast-work-timout-secs: 0
retry-interval-secs: 1
4 changes: 4 additions & 0 deletions ft/deploy/chart/files/bootstrap-ft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
spring:
cloud:
config:
enabled: false
159 changes: 159 additions & 0 deletions ft/deploy/chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "chart-test.name" -}}
{{- default .Chart.Name .Values.testComponent.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 "chart-test.fullname" -}}
{{- if .Values.testComponent.fullnameOverride }}
{{- .Values.testComponent.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.testComponent.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 "chart-test.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "chart-test.serviceAccountName" -}}
{{- if .Values.testComponent.serviceAccount.create }}
{{- default (include "chart-test.fullname" .) .Values.testComponent.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.testComponent.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Create a test-component 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 "test-component.fullname" -}}
{{- if .Values.testComponent.fullnameOverride }}
{{- .Values.testComponent.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.testComponent.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "test-component-%s" .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create a components-registry 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 "components-registry.fullname" -}}
{{- if .Values.componentsRegisty.fullnameOverride }}
{{- .Values.componentsRegisty.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.componentsRegisty.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "components-registy-%s" .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}


{{/*
Components-registry labels
*/}}
{{- define "components-registry.labels" -}}
helm.sh/chart: {{ include "chart-test.chart" . }}
{{ include "chart-test.selectorLabels" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}


{{- define "bitbucket.fullname" -}}
{{- if .Values.bitbucket.fullnameOverride }}
{{- .Values.bitbucket.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.bitbucket.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "bitbucket-%s" .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{- define "bitbucketDb.fullname" -}}
{{- if .Values.bitbucketDb.fullnameOverride }}
{{- .Values.bitbucketDb.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.bitbucketDb.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "bitbucket-db-%s" .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{- define "vcsFacade.fullname" -}}
{{- if .Values.vcsFacade.fullnameOverride }}
{{- .Values.vcsFacade.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.vcsFacade.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "vcs-facade-%s" .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{- define "test-component.ingress-host" -}}
{{- if .Values.testComponent.ingress.enabled }}
{{- if .Values.clusterDomain -}}
{{- printf "test-component-%s.%s" .Release.Name .Values.clusterDomain | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
46 changes: 46 additions & 0 deletions ft/deploy/chart/templates/bitbucket-db/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "bitbucketDb.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: {{ include "bitbucketDb.fullname" . }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "bitbucketDb.fullname" . }}
spec:
containers:
- name: {{ include "bitbucketDb.fullname" . }}
securityContext: {}
image: {{ .Values.dockerRegistry }}/postgres:{{ .Values.bitbucketDb.image.version }}
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 5432
{{- if eq .Values.platform "podman" }}
hostPort: 5432
{{- end }}
protocol: TCP
env:
{{- range $key, $value := .Values.bitbucketDb.environment }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
volumeMounts:
- name: postgres-storage
mountPath: /var/lib/postgresql/data
livenessProbe:
exec:
command:
- /bin/sh
- -c
- exec pg_isready -U postgres
initialDelaySeconds: 90
resources: {}
volumes:
- name: postgres-storage
emptyDir: {}
54 changes: 54 additions & 0 deletions ft/deploy/chart/templates/bitbucket/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "bitbucket.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: {{ include "bitbucket.fullname" . }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "bitbucket.fullname" . }}
spec:
containers:
- name: vcs-facade-ft-bitbucket
securityContext: {}
image: {{ .Values.dockerRegistry }}/atlassian/bitbucket-server:{{ .Values.bitbucket.image.version }}
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 7999
{{- if eq .Values.platform "podman" }}
hostPort: 7999
{{- end }}
protocol: TCP
- name: http-internal
containerPort: 7990
{{- if eq .Values.platform "podman" }}
hostPort: 7990
{{- end }}
protocol: TCP
env:
{{- range $key, $value := .Values.bitbucket.environment }}
{{- if contains $key "SETUP_LICENSE" }}
- name: {{ $key }}
valueFrom:
secretKeyRef:
name: {{ $value }}
key: token
{{- else }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
livenessProbe:
exec:
command:
- sh
- -c
- curl -s -k http://localhost:8081/status
initialDelaySeconds: 90
resources: {}
7 changes: 7 additions & 0 deletions ft/deploy/chart/templates/bitbucket/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: bitbucket-license-secret
type: Opaque
data:
token: {{ .Values.bitbucket.license | b64enc | quote }}
32 changes: 32 additions & 0 deletions ft/deploy/chart/templates/vcs-facade/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if eq .Values.platform "openshift" }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "vcsFacade.fullname" . }}-bitbucket-conf
namespace: {{ .Release.Namespace | quote }}
data:
application-bitbucket.yml: |
{{ tpl (.Files.Get "files/application-bitbucket.yml") . | indent 4 }}
{{- end }}
---
{{- if eq .Values.platform "openshift" }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "vcsFacade.fullname" . }}-ft-conf
namespace: {{ .Release.Namespace | quote }}
data:
application-ft.yml: |
{{ tpl (.Files.Get "files/application-ft.yml") . | indent 4 }}
{{- end }}
---
{{- if eq .Values.platform "openshift" }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "vcsFacade.fullname" . }}-bootstrap-ft
namespace: {{ .Release.Namespace | quote }}
data:
bootstrap-ft.yml: |
{{ tpl (.Files.Get "files/bootstrap-ft.yml") . | indent 4 }}
{{- end }}
Loading

0 comments on commit 80cc21a

Please sign in to comment.