diff --git a/charts/gitea/custom-values.yaml b/charts/gitea/custom-values.yaml new file mode 100644 index 0000000..fc81bb1 --- /dev/null +++ b/charts/gitea/custom-values.yaml @@ -0,0 +1,114 @@ +global: + imageRegistry: "" + +# ingress 배포 전 인증서 secret 배포 필요(secret 이름은 platform) +ingress: + enabled: true + annotations: + kubernetes.io/ingress.class: nginx + nginx.ingress.kubernetes.io/proxy-body-size: 200m + hosts: + - host: gitea.example.org + paths: + - path: / + pathType: Prefix + tls: + - hosts: + host: gitea.example.org + secretName: platform + +# 사설 인증서를 사용 시 아래 내용 추가 +extraVolumes: + - name: gitea-tls + secret: + secretName: platform + +extraContainerVolumeMounts: + - name: gitea-tls + mountPath: /data/gitea/https + +lifecycleHooks: + postStart: + exec: + command: ["/bin/sh", "-c", "cp /data/gitea/https/tls.crt /usr/local/share/ca-certificates/; update-ca-certificates"] + # command: + # - "/bin/sh" + # - "-c" + # - | + # /bin/bash <<'EOF' > /tmp/post_start.log + # cp /data/gitea/https/tls.crt /usr/local/share/ca-certificates/ + # update-ca-certificates + # su git + # OAUTH_NAME='keycloak' + # AUTH_ID=$(gitea admin auth list --vertical-bars | grep -E "\|${OAUTH_NAME}\s+\|" | grep -iE '\|OAuth2\s+\|' | awk -F " " "{print \$1}") + # KEYCLOAK_URL="https://keycloak.example.org" + # REALM=paasup + # if [[ -z "${AUTH_ID}" ]]; then + # echo "No oauth configuration found with name '${OAUTH_NAME}'. Installing it now..." + # gitea admin auth add-oauth --auto-discover-url "${KEYCLOAK_URL}/auth/realms/${REALM}/.well-known/openid-configuration" --key "gitea" --name "keycloak" --provider "openidConnect" --secret "" + # echo '...installed.' + # else + # echo "Existing oauth configuration with name '${OAUTH_NAME}': '${AUTH_ID}'. Running update to sync settings..." + # gitea admin auth update-oauth --id "${AUTH_ID}" --auto-discover-url "${KEYCLOAK_URL}/auth/realms/${REALM}/.well-known/openid-configuration" --key "gitea" --name "keycloak" --provider "openidConnect" --secret "" + # echo '...sync settings done.' + # fi + # EOF + + + +## pod 설정 +replicaCount: 1 + +tolerations: [] + +nodeSelector: {} + +resources: + requests: + cpu: 100m + memory: 300Mi + limits: + cpu: 300m + memory: 500Mi + +persistence: + enabled: true + size: 1Gi + accessModes: + - ReadWriteOnce + storageClass: "" + +# oauth setting + + +## 같은 네임스페이스에 postgresql 배포 가정 +gitea: + admin: + username: sudouser + password: password + email: "sudouser@cro.com" + config: + APP_NAME: paasup git + RUN_MODE: prod + server: + ROOT_URL: https://gitea.example.org + database: + DB_TYPE: postgres + # HOST: postgresql-postgresql-ha-pgpool:5432 + HOST: postgresql-postgresql-ha-postgresql:5432 + NAME: postgres # database name + USER: postgres # username + PASSWD: postgres # user password + CHARSET: utf8 + SCHEMA: public + SSL_MODE: disable + session: + PROVIDER: postgres + # PROVIDER_CONFIG: user=gitea password=gitea host=postgresql-postgresql-ha-pgpool port=5432 dbname=gitea_session sslmode=disable + PROVIDER_CONFIG: user=postgres password=postgres host=postgresql-postgresql-ha-postgresql port=5432 dbname=postgres sslmode=disable + COOKIE_NAME: i_hate_gitea + service: + DEFAULT_ALLOW_CREATE_ORGANIZATION: true + repository: + DEFAULT_BRANCH: master + diff --git a/charts/gitea/templates/_helpers.tpl b/charts/gitea/templates/_helpers.tpl index 0e481e0..082d46d 100644 --- a/charts/gitea/templates/_helpers.tpl +++ b/charts/gitea/templates/_helpers.tpl @@ -331,3 +331,17 @@ https {{- toYaml .Values.extraVolumeMounts -}} {{- end -}} {{- end -}} + +{{/* +Renders a value that contains template. +Usage: +{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $) }} +*/}} +{{- define "common.tplvalues.render" -}} + {{- if typeIs "string" .value }} + {{- tpl .value .context }} + {{- else }} + {{- tpl (.value | toYaml) .context }} + {{- end }} +{{- end -}} + diff --git a/charts/gitea/templates/gitea/statefulset.yaml b/charts/gitea/templates/gitea/statefulset.yaml index ed9a887..07f8192 100644 --- a/charts/gitea/templates/gitea/statefulset.yaml +++ b/charts/gitea/templates/gitea/statefulset.yaml @@ -203,6 +203,9 @@ spec: - name: {{ .Chart.Name }} image: "{{ include "gitea.image" . }}" imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if .Values.lifecycleHooks }} + lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }} + {{- end }} env: # SSH Port values have to be set here as well for openssh configuration - name: SSH_LISTEN_PORT diff --git a/charts/gitea/values.yaml b/charts/gitea/values.yaml index bd8c4d0..110d59b 100644 --- a/charts/gitea/values.yaml +++ b/charts/gitea/values.yaml @@ -21,6 +21,11 @@ replicaCount: 1 ## @param clusterDomain cluster domain clusterDomain: cluster.local +## @param lifecycleHooks LifecycleHook to set additional configuration at startup Evaluated as a template +## +lifecycleHooks: {} + + ## @section Image ## @param image.registry image registry, e.g. gcr.io,docker.io ## @param image.repository Image to start for this pod @@ -400,7 +405,7 @@ gitea: ## @param memcached.enabled Memcached is loaded as a dependency from [Bitnami](https://github.com/bitnami/charts/tree/master/bitnami/memcached) if enabled in the values. Complete Configuration can be taken from their website. ## @param memcached.service.port Port for Memcached memcached: - enabled: true + enabled: false service: port: 11211 @@ -413,7 +418,7 @@ memcached: ## @param postgresql.global.postgresql.servicePort PostgreSQL port (overrides service.port) ## @param postgresql.persistence.size PVC Storage Request for PostgreSQL volume postgresql: - enabled: true + enabled: false global: postgresql: postgresqlDatabase: gitea