Skip to content

Commit

Permalink
Add gitea
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonophore committed Jun 19, 2024
1 parent 54f65ea commit 1fd36d1
Show file tree
Hide file tree
Showing 26 changed files with 381 additions and 124 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ subprojects {
set( "clusterDomain", clusterDomain)
set("localDomain", it.getOrDefault("LOCAL_DOMAIN", project.properties["localDomain"]))
set("bitbucketHost", "$helmRelease-bitbucket-route-$helmNamespace.$clusterDomain")
set("giteaHost", "$helmRelease-gitea-route-$helmNamespace.$clusterDomain")
}
}

Expand Down
Binary file added deploy/.DS_Store
Binary file not shown.
7 changes: 7 additions & 0 deletions deploy/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ val helmRelease: String? = project.ext["helmRelease"] as String?
val clusterDomain: String? = project.ext["clusterDomain"] as String?
val localDomain: String? = project.ext["localDomain"] as String?
var bitbucketHost: String? = project.ext["bitbucketHost"] as String?
var giteaHost: String? = project.ext["giteaHost"] as String?
val dockerRegistry: String? = project.ext["dockerRegistry"] as String?

tasks.register("uninstallHelm") {
Expand Down Expand Up @@ -41,7 +42,11 @@ tasks.register<Exec>("deployHelm") {
if (localDomain == null) {
throw GradleException("Local domain is not set")
}
if (testProfile == null) {
throw GradleException("Test profile is not set")
}

println("Profile: $testProfile")
println("Release: $helmRelease")

val bitbucketLicense: String by project
Expand All @@ -52,10 +57,12 @@ tasks.register<Exec>("deployHelm") {
, "--set", "bitbucket.license=$bitbucketLicense"
, "--set", "vcsFacade.image.version=${project.version}"
, "--set", "bitbucket.host=${bitbucketHost}"
, "--set", "gitea.host=${giteaHost}"
, "--set", "clusterDomain=${clusterDomain}"
, "--set", "localDomain=${localDomain}"
, "--set", "dockerRegistry=$dockerRegistry"
, "--set", "platform=openshift"
, "--set", "profile=$testProfile"
)
doLast {
val execResult = executionResult.get()
Expand Down
31 changes: 31 additions & 0 deletions deploy/chart/files/application-gitea.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
vcs-facade:
vcs:
bitbucket:
enabled: false
gitea:
host: http://{{ .Values.gitea.host | default "gitea:3000" }}
username: test-admin
password: test-admin
health-check:
repo: ssh://git@gitea:3000:test-data/vcs-facade-healthcheck.git
root-commit: 9320183f5d5f5868fdb82b36e3abd6f9d1424114
last-release: 321d4908aef10bafa1488f9b053270acc29f3d78
expected-commits: 9320183f5d5f5868fdb82b36e3abd6f9d1424114,00cc61dd4c3eca64d12e6beceff1a40a436962f5
index:
webhook-secret: b59dd966-2445-4c84-b631-49502427477e
scan:
delay: 5000
gitlab:
enabled: false
opensearch:
host: {{ template "opensearch.fullname" . }}-service.{{ .Release.Namespace }}.{{ .Values.localDomain }}
ssl: false
username: admin
password: admin
index:
suffix: ft

logging:
level:
org.opensearch: DEBUG
org.octopusden.octopus.vcsfacade: TRACE
61 changes: 7 additions & 54 deletions deploy/chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -69,62 +69,9 @@ Create the name of the service account to use
{{- 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.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 "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 "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 }}
{{- printf "%s-%s" .Release.Name .Values.gitea.fullnameOverride }}
{{- end }}
{{- end }}

Expand All @@ -145,3 +92,9 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- printf "%s-%s" .Release.Name .Values.vcsFacade.fullnameOverride }}
{{- end }}
{{- end }}

{{- define "opensearch.fullname" -}}
{{- if .Values.opensearch.fullnameOverride }}
{{- printf "%s-%s" .Release.Name .Values.opensearch.fullnameOverride }}
{{- end }}
{{- end }}
7 changes: 3 additions & 4 deletions deploy/chart/templates/bitbucket-db/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq .Values.profile "bitbucket" }}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand All @@ -21,9 +22,6 @@ spec:
ports:
- name: http
containerPort: 5432
{{- if eq .Values.platform "podman" }}
hostPort: 5432
{{- end }}
protocol: TCP
env:
{{- range $key, $value := .Values.bitbucketDb.environment }}
Expand Down Expand Up @@ -55,4 +53,5 @@ spec:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storage: 5Gi
{{- end }}
2 changes: 2 additions & 0 deletions deploy/chart/templates/bitbucket-db/service.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq .Values.profile "bitbucket" }}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -14,3 +15,4 @@ spec:
name: http
selector:
app.kubernetes.io/name: {{ include "bitbucketDb.fullname" . }}
{{- end }}
18 changes: 4 additions & 14 deletions deploy/chart/templates/bitbucket/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq .Values.profile "bitbucket" }}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand All @@ -14,22 +15,16 @@ spec:
app.kubernetes.io/name: {{ include "bitbucket.fullname" . }}
spec:
containers:
- name: vcs-facade-ft-bitbucket
- name: {{ include "bitbucket.fullname" . }}
securityContext: {}
image: {{ .Values.dockerRegistry }}/atlassian/bitbucket-server:{{ .Values.bitbucket.image.version }}
imagePullPolicy: IfNotPresent
ports:
- name: ssh
containerPort: 7999
{{- if eq .Values.platform "podman" }}
hostPort: 7999
{{- end }}
protocol: TCP
- name: http
containerPort: 7990
{{- if eq .Values.platform "podman" }}
hostPort: 7990
{{- end }}
protocol: TCP
env:
{{- range $key, $value := .Values.bitbucket.environment }}
Expand Down Expand Up @@ -77,14 +72,8 @@ spec:
mountPath: /var/atlassian/application-data/bitbucket
volumes:
- name: {{ .Release.Name }}-bitbucket-volume
{{- if eq .Values.platform "podman" }}
hostPath:
path: {{ .Values.bitbucket.path }}
type: Directory
{{ else }}
persistentVolumeClaim:
claimName: {{ .Release.Name }}-bitbucket-volume
{{- end }}
---
kind: PersistentVolumeClaim
apiVersion: v1
Expand All @@ -95,4 +84,5 @@ spec:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storage: 5Gi
{{- end }}
4 changes: 3 additions & 1 deletion deploy/chart/templates/bitbucket/route.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq .Values.profile "bitbucket" }}
apiVersion: route.openshift.io/v1
kind: Route
metadata:
Expand All @@ -7,4 +8,5 @@ spec:
targetPort: 7990
to:
kind: Service
name: {{ template "bitbucket.fullname" . }}
name: {{ template "bitbucket.fullname" . }}
{{- end }}
4 changes: 3 additions & 1 deletion deploy/chart/templates/bitbucket/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{{- if eq .Values.profile "bitbucket" }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "bitbucket.fullname" . }}-bitbucket-license-secret
type: Opaque
data:
token: {{ .Values.bitbucket.license | b64enc | quote }}
token: {{ .Values.bitbucket.license | b64enc | quote }}
{{- end }}
2 changes: 2 additions & 0 deletions deploy/chart/templates/bitbucket/service.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq .Values.profile "bitbucket" }}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -18,3 +19,4 @@ spec:
name: http
selector:
app.kubernetes.io/name: {{ include "bitbucket.fullname" . }}
{{- end }}
12 changes: 12 additions & 0 deletions deploy/chart/templates/gitea/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if eq .Values.profile "gitea" }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "gitea.fullname" . }}-config
namespace: {{ .Release.Namespace | quote }}
data:
add_admin.sh: |
#!/bin/bash
until gitea admin user list &> /dev/null; do sleep 5; done
gitea admin user create --username=test-admin --password=test-admin [email protected] --admin=true
{{- end }}
91 changes: 91 additions & 0 deletions deploy/chart/templates/gitea/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{{- if eq .Values.profile "gitea" }}
###############################
# Gitea PVC
###############################
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "gitea.fullname" . }}-pvc
namespace: {{ .Release.Namespace | quote }}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi

###############################
# Deplyoment Gitea
###############################
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "gitea.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
labels:
app: {{ include "gitea.fullname" . }}
spec:
replicas: 1
template:
metadata:
name: gitea
labels:
app: gitea
app.kubernetes.io/name: {{ include "gitea.fullname" . }}
spec:
containers:
- name: gitea
image: {{ .Values.dockerRegistry }}/gitea/gitea:{{ .Values.gitea.image.version }}
imagePullPolicy: Always
lifecycle:
postStart:
exec:
command: ["/bin/sh", "/conf/add_admin.sh"]
env:
- name: GITEA__ADMIN_USER
value: test-admin
- name: GITEA__ADMIN_PASSWORD
value: test-admin
- name: GITEA__security__INSTALL_LOCK
value: "true"
- name: GITEA__webhook__ALLOWED_HOST_LIST
value: "*"
volumeMounts:
- mountPath: "/etc/gitea"
name: gitea-data
subPath: var-etc-gitea
- mountPath: "/var/lib/gitea"
name: gitea-data
subPath: var-lib-gitea
- name: gitea-conf-add-script
mountPath: /conf
ports:
- containerPort: 22
name: ssh
protocol: TCP
- containerPort: 3000
name: http
protocol: TCP
readinessProbe:
httpGet:
path: /user/login
port: 3000
scheme: HTTP
imagePullSecrets:
- name: artifactory-okd-puller
restartPolicy: Always
volumes:
- name: gitea-data
persistentVolumeClaim:
claimName: {{ include "gitea.fullname" . }}-pvc
- name: gitea-conf-add-script
configMap:
name: {{ include "gitea.fullname" . }}-config
items:
- key: add_admin.sh
path: add_admin.sh
selector:
matchLabels:
app: gitea
{{- end }}
15 changes: 15 additions & 0 deletions deploy/chart/templates/gitea/route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if eq .Values.profile "gitea" }}
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: {{ include "gitea.fullname" . }}-route
namespace: {{ .Release.Namespace | quote }}
labels:
app: {{ include "gitea.fullname" . }}-route
spec:
port:
targetPort: 3000
to:
kind: Service
name: {{ include "gitea.fullname" . }}-service
{{- end }}
Loading

0 comments on commit 1fd36d1

Please sign in to comment.