Skip to content

Commit

Permalink
Add helm templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonophore committed May 26, 2024
1 parent 80cc21a commit efcc760
Show file tree
Hide file tree
Showing 14 changed files with 295 additions and 130 deletions.
36 changes: 36 additions & 0 deletions ft/deploy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
### Required enveraments

- Helm
- OC (Openshift Client)

### OC login

```shell
oc login --token=<token> --server=<cluster-host>
```

### To show deployments

```shell
helm template chart --set bitbucket.license=<license> --set vcsFacade.image.version=<version>
```

```shell
helm install vcs-facade ./chart --namespace test-env --set bitbucket.license=<license> --set vcsFacade.image.version=<version> --set bitbucket.host=<vcsHost>
```

```shell
helm uninstall vcs-facade --namespace test-env
```

#### Parameters

- bitbucket.license - license token for BitBucket server
- dockerRegistry - Docker registry with images.
- vcsHost - Route host for vcs(bitbucket, gitea, gitlab)

### To run from gradle

```shell
./gradlew clean build
```
2 changes: 1 addition & 1 deletion ft/deploy/chart/files/application-bitbucket.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
vcs-facade:
vcs:
bitbucket:
host: http://bitbucket:7990
host: http://{{ .Values.bitbucket.host | default "bitbucket:7990" }}
username: admin
password: admin
health-check:
Expand Down
58 changes: 30 additions & 28 deletions ft/deploy/chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Expand the name of the chart.
*/}}
{{- define "chart-test.name" -}}
{{- default .Chart.Name .Values.testComponent.nameOverride | trunc 63 | trimSuffix "-" }}
{{- default .Chart.Name .Values.vcsFacade.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Expand All @@ -11,10 +11,10 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
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 "-" }}
{{- if .Values.vcsFacade.fullnameOverride }}
{{- .Values.vcsFacade.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.testComponent.nameOverride }}
{{- $name := default .Chart.Name .Values.vcsFacade.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
Expand All @@ -36,8 +36,8 @@ 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 }}
{{- if .Values.vcsFacade.image.version }}
app/version: {{ .Values.vcsFacade.image.version | quote }}
{{- end }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
Expand All @@ -53,14 +53,19 @@ app.kubernetes.io/name: {{ include "chart-test.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "bitbucket-db.selectorLabels" -}}
app.kubernetes.io/name: {{ include "bitbucketDb.fullname" . }}
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 }}
{{- if .Values.vcsFacade.serviceAccount.create }}
{{- default (include "chart-test.fullname" .) .Values.vcsFacade.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.testComponent.serviceAccount.name }}
{{- default "default" .Values.vcsFacade.serviceAccount.name }}
{{- end }}
{{- end }}

Expand All @@ -70,10 +75,10 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
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 "-" }}
{{- if .Values.vcsFacade.fullnameOverride }}
{{- .Values.vcsFacade.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.testComponent.nameOverride }}
{{- $name := default .Chart.Name .Values.vcsFacade.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
Expand Down Expand Up @@ -110,6 +115,18 @@ helm.sh/chart: {{ include "chart-test.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

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

{{- define "bitbucket.fullname" -}}
{{- if .Values.bitbucket.fullnameOverride }}
Expand All @@ -126,14 +143,7 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}

{{- 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 }}
{{- printf "%s-%s" .Release.Name .Values.bitbucketDb.fullnameOverride }}
{{- end }}
{{- end }}

Expand All @@ -149,11 +159,3 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- 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 }}
24 changes: 18 additions & 6 deletions ft/deploy/chart/templates/bitbucket-db/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,36 @@ spec:
containerPort: 5432
{{- if eq .Values.platform "podman" }}
hostPort: 5432
{{- end }}
{{- 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
- name: bitbucket-db-storage
mountPath: /var/lib/postgresql/
livenessProbe:
exec:
command:
- /bin/sh
- -c
- exec pg_isready -U postgres
- exec pg_isready -U {{ .Values.bitbucket.environment.JDBC_USER }}
initialDelaySeconds: 90
resources: {}
volumes:
- name: postgres-storage
emptyDir: {}
- name: bitbucket-db-storage
persistentVolumeClaim:
claimName: bitbucket-db-storage
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: bitbucket-db-storage
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
16 changes: 16 additions & 0 deletions ft/deploy/chart/templates/bitbucket-db/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "bitbucketDb.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
labels:
{{- include "chart-test.labels" . | nindent 4 }}
spec:
type: {{ .Values.bitbucketDb.service.type }}
ports:
- port: {{ .Values.bitbucketDb.service.port }}
targetPort: {{ .Values.bitbucketDb.service.targetPort }}
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ include "bitbucketDb.fullname" . }}
48 changes: 43 additions & 5 deletions ft/deploy/chart/templates/bitbucket/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ spec:
image: {{ .Values.dockerRegistry }}/atlassian/bitbucket-server:{{ .Values.bitbucket.image.version }}
imagePullPolicy: IfNotPresent
ports:
- name: http
- name: ssh
containerPort: 7999
{{- if eq .Values.platform "podman" }}
hostPort: 7999
{{- end }}
protocol: TCP
- name: http-internal
- name: http
containerPort: 7990
{{- if eq .Values.platform "podman" }}
hostPort: 7990
Expand All @@ -41,14 +41,52 @@ spec:
key: token
{{- else }}
- name: {{ $key }}
value: {{ $value | quote }}
value: "{{ tpl $value $ }}"
{{- end }}
{{- end }}
livenessProbe:
exec:
command:
- sh
- -c
- curl -s -k http://localhost:8081/status
initialDelaySeconds: 90
- |
if curl -s http://localhost:7990/status | grep -q '"state":"RUNNING"'; then
exit 0
else
exit 1
fi
initialDelaySeconds: 120
readinessProbe:
exec:
command:
- sh
- -c
- |
if curl -s http://localhost:7990/status | grep -q '"state":"RUNNING"'; then
exit 0
else
exit 1
fi
initialDelaySeconds: 30
periodSeconds: 15
timeoutSeconds: 5
failureThreshold: 5
resources: {}
volumeMounts:
- name: bitbucket-volume
mountPath: /var/atlassian/application-data/bitbucket
volumes:
- name: bitbucket-volume
persistentVolumeClaim:
claimName: bitbucket-volume
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: bitbucket-volume
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
10 changes: 10 additions & 0 deletions ft/deploy/chart/templates/bitbucket/route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: {{ template "bitbucket.fullname" . }}-route
spec:
port:
targetPort: 7990
to:
kind: Service
name: {{ template "bitbucket.fullname" . }}
20 changes: 20 additions & 0 deletions ft/deploy/chart/templates/bitbucket/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "bitbucket.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
labels:
{{- include "chart-test.labels" . | nindent 4 }}
spec:
type: {{ .Values.bitbucket.service.type }}
ports:
- port: {{ .Values.bitbucket.service.ssh.port }}
targetPort: {{ .Values.bitbucket.service.ssh.targetPort }}
protocol: TCP
name: ssh
- port: {{ .Values.bitbucket.service.http.port }}
targetPort: {{ .Values.bitbucket.service.http.targetPort }}
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ include "bitbucket.fullname" . }}
50 changes: 50 additions & 0 deletions ft/deploy/chart/templates/gitea/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#apiVersion: apps/v1
#kind: Deployment
#metadata:
# name: gitea
# labels:
# app: gitea
#spec:
# replicas: 1
# selector:
# matchLabels:
# app: gitea
# template:
# metadata:
# labels:
# app: gitea
# spec:
# containers:
# - name: gitea
# image: gitea/gitea:latest
# ports:
# - containerPort: 3000
# - containerPort: 22
# env:
# - name: USER_UID
# value: "1000"
# - name: USER_GID
# value: "1000"
# securityContext:
# runAsUser: 1000
# runAsGroup: 1000
# fsGroup: 1000
# volumeMounts:
# - name: gitea-data
# mountPath: /data
# volumes:
# - name: gitea-data
# persistentVolumeClaim:
# claimName: gitea-pvc
#
#---
#apiVersion: v1
#kind: PersistentVolumeClaim
#metadata:
# name: gitea-pvc
#spec:
# accessModes:
# - ReadWriteOnce
# resources:
# requests:
# storage: 10Gi
Loading

0 comments on commit efcc760

Please sign in to comment.