diff --git a/charts/forgejo/Chart.yaml b/charts/forgejo/Chart.yaml new file mode 100644 index 0000000..01b0cef --- /dev/null +++ b/charts/forgejo/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: forgejo +description: Chart for Forgejo +type: application +version: 0.1.0 +appVersionL: "15.0.3" diff --git a/charts/forgejo/templates/deployment.yaml b/charts/forgejo/templates/deployment.yaml new file mode 100644 index 0000000..7f7f903 --- /dev/null +++ b/charts/forgejo/templates/deployment.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: forgejo + namespace: {{ .Values.namespace }} +spec: + replicas: 1 + selector: + matchLabels: + app: forgejo + template: + metadata: + labels: + app: forgejo + spec: + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + containers: + - name: forgejo + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + ports: + - name: http + containerPort: 3000 + - name: ssh + containerPort: 22 + env: + - name: FORGEJO__server__ROOT_URL + value: "https://www.symcrest.com{{ .Values.route.basePath }}/" + - name: FORGEJO__server__HTTP_PORT + value: "3000" + - name: FORGEJO__database__DB_TYPE + value: "postgres" + - name: FORGEJO__database__HOST + value: "{{ .Values.database.host }}:{{ .Values.database.port }}" + - name: FORGEJO__database__NAME + value: {{ .Values.database.name | quote }} + - name: FORGEJO__database__USER + value: {{ .Values.database.user | quote }} + - name: FORGEJO__database__PASSWD + valueFrom: + secretKeyRef: + name: {{ .Values.database.existingSecret }} + key: FORGEJO_DB_PASSWORD + volumeMounts: + - name: forgejo-data + mountPath: /data + volumes: + - name: forgejo-data + persistentVolumeClaim: + claimName: forgejo-data diff --git a/charts/forgejo/templates/httproute.yaml b/charts/forgejo/templates/httproute.yaml new file mode 100644 index 0000000..24c7231 --- /dev/null +++ b/charts/forgejo/templates/httproute.yaml @@ -0,0 +1,39 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: {{ .Values.route.name }} + namespace: {{ .Values.namespace }} +spec: + parentRefs: + - name: {{ .Values.route.gatewayName }} + namespace: {{ .Values.route.gatewayNamespace }} + hostnames: +{{- range .Values.route.hostnames }} + - {{ . | quote }} +{{- end }} + rules: + - matches: + - path: + type: Exact + value: {{ .Values.route.basePath | quote }} + filters: + - type: RequestRedirect + requestRedirect: + path: + type: ReplaceFullPath + replaceFullPath: {{ printf "%s/" .Values.route.basePath | quote }} + statusCode: 301 + + - matches: + - path: + type: PathPrefix + value: {{ printf "%s/" .Values.route.basePath | quote }} + filters: + - type: URLRewrite + urlRewrite: + path: + type: ReplacePrefixMatch + replacePrefixMatch: / + backendRefs: + - name: {{ .Values.route.serviceName }} + port: {{ .Values.route.servicePort }} diff --git a/charts/forgejo/templates/pvc.yaml b/charts/forgejo/templates/pvc.yaml new file mode 100644 index 0000000..daee1e5 --- /dev/null +++ b/charts/forgejo/templates/pvc.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: forgejo-data + namespace: {{ .Values.namespace }} +spec: + accessModes: + - ReadWriteOnce + storageClassName: {{ .Values.storage.className | quote }} + resources: + requests: + storage: {{ .Values.storage.size | quote }} diff --git a/charts/forgejo/templates/service.yaml b/charts/forgejo/templates/service.yaml new file mode 100644 index 0000000..75f314f --- /dev/null +++ b/charts/forgejo/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: forgejo + namespace: {{ .Values.namespace }} +spec: + type: ClusterIP + selector: + app: forgejo + ports: + - name: http + port: 3000 + targetPort: 3000 + - name: ssh + port: 22 + targetPort: 22 diff --git a/charts/forgejo/values.yaml b/charts/forgejo/values.yaml index e69de29..013ba60 100644 --- a/charts/forgejo/values.yaml +++ b/charts/forgejo/values.yaml @@ -0,0 +1,30 @@ +namespace: forgejo + +image: + repository: codeberg.org/forgejo/forgejo + tag: "15.0.3" + +storage: + className: longhorn + size: 20Gi + +nodeSelector: + workload: app + +route: + name: forgejo + gatewayName: public-gateway + gatewayNamespace: apps + hostnames: + - symcrest.com + - www.symcrest.com + basePath: /internal/dev/forgejo + serviceName: forgejo + servicePort: 3000 + +database: + host: postgres.database.svc.cluster.local + port: 5432 + name: forgejo + user: forgejo + existingSecret: forgejo-db-secret diff --git a/charts/postgres/values.yaml b/charts/postgres/values.yaml index 4b8f32e..b6f9b6d 100644 --- a/charts/postgres/values.yaml +++ b/charts/postgres/values.yaml @@ -5,8 +5,8 @@ image: tag: "18.4" auth: - database: symcrest - username: admin + database: postgres + username: postgres secret: postgres-secret storage: diff --git a/rendered/forgejo/forgejo.yaml b/rendered/forgejo/forgejo.yaml new file mode 100644 index 0000000..03940ca --- /dev/null +++ b/rendered/forgejo/forgejo.yaml @@ -0,0 +1,124 @@ +--- +# Source: forgejo/templates/pvc.yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: forgejo-data + namespace: forgejo +spec: + accessModes: + - ReadWriteOnce + storageClassName: "longhorn" + resources: + requests: + storage: "20Gi" +--- +# Source: forgejo/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: forgejo + namespace: forgejo +spec: + type: ClusterIP + selector: + app: forgejo + ports: + - name: http + port: 3000 + targetPort: 3000 + - name: ssh + port: 22 + targetPort: 22 +--- +# Source: forgejo/templates/deployment.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: forgejo + namespace: forgejo +spec: + replicas: 1 + selector: + matchLabels: + app: forgejo + template: + metadata: + labels: + app: forgejo + spec: + nodeSelector: + workload: app + containers: + - name: forgejo + image: "codeberg.org/forgejo/forgejo:15.0.3" + ports: + - name: http + containerPort: 3000 + - name: ssh + containerPort: 22 + env: + - name: FORGEJO__server__ROOT_URL + value: "https://www.symcrest.com/internal/dev/forgejo/" + - name: FORGEJO__server__HTTP_PORT + value: "3000" + - name: FORGEJO__database__DB_TYPE + value: "postgres" + - name: FORGEJO__database__HOST + value: "postgres.database.svc.cluster.local:5432" + - name: FORGEJO__database__NAME + value: "forgejo" + - name: FORGEJO__database__USER + value: "forgejo" + - name: FORGEJO__database__PASSWD + valueFrom: + secretKeyRef: + name: forgejo-db-secret + key: FORGEJO_DB_PASSWORD + volumeMounts: + - name: forgejo-data + mountPath: /data + volumes: + - name: forgejo-data + persistentVolumeClaim: + claimName: forgejo-data +--- +# Source: forgejo/templates/httproute.yaml +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: forgejo + namespace: forgejo +spec: + parentRefs: + - name: public-gateway + namespace: apps + hostnames: + - "symcrest.com" + - "www.symcrest.com" + rules: + - matches: + - path: + type: Exact + value: "/internal/dev/forgejo" + filters: + - type: RequestRedirect + requestRedirect: + path: + type: ReplaceFullPath + replaceFullPath: "/internal/dev/forgejo/" + statusCode: 301 + + - matches: + - path: + type: PathPrefix + value: "/internal/dev/forgejo/" + filters: + - type: URLRewrite + urlRewrite: + path: + type: ReplacePrefixMatch + replacePrefixMatch: / + backendRefs: + - name: forgejo + port: 3000