From bb6397ad001233f215486cdc8247fbd09cae3aeb Mon Sep 17 00:00:00 2001 From: Leo Q Date: Sun, 3 Sep 2023 23:51:01 +0800 Subject: [PATCH] Add codecov chart (#55) * init commit * add codecov chart * add readme * update ct * add auto rollout after config change, fix hpa * update chart lock * fix lint * fix lint --- charts/codecov/.helmignore | 23 + charts/codecov/Chart.lock | 15 + charts/codecov/Chart.yaml | 48 +++ charts/codecov/README.md | 48 +++ charts/codecov/templates/NOTES.txt | 22 + charts/codecov/templates/_helpers.tpl | 97 +++++ charts/codecov/templates/configMap.yaml | 12 + charts/codecov/templates/deployment.yaml | 338 +++++++++++++++ charts/codecov/templates/hpa.yaml | 121 ++++++ charts/codecov/templates/ingress.yaml | 61 +++ charts/codecov/templates/service.yaml | 58 +++ charts/codecov/templates/serviceaccount.yaml | 12 + .../templates/tests/test-connection.yaml | 15 + charts/codecov/values.yaml | 400 ++++++++++++++++++ ct.yaml | 1 + 15 files changed, 1271 insertions(+) create mode 100644 charts/codecov/.helmignore create mode 100644 charts/codecov/Chart.lock create mode 100644 charts/codecov/Chart.yaml create mode 100644 charts/codecov/README.md create mode 100644 charts/codecov/templates/NOTES.txt create mode 100644 charts/codecov/templates/_helpers.tpl create mode 100644 charts/codecov/templates/configMap.yaml create mode 100644 charts/codecov/templates/deployment.yaml create mode 100644 charts/codecov/templates/hpa.yaml create mode 100644 charts/codecov/templates/ingress.yaml create mode 100644 charts/codecov/templates/service.yaml create mode 100644 charts/codecov/templates/serviceaccount.yaml create mode 100644 charts/codecov/templates/tests/test-connection.yaml create mode 100644 charts/codecov/values.yaml diff --git a/charts/codecov/.helmignore b/charts/codecov/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/codecov/.helmignore @@ -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/ diff --git a/charts/codecov/Chart.lock b/charts/codecov/Chart.lock new file mode 100644 index 0000000..927b8ab --- /dev/null +++ b/charts/codecov/Chart.lock @@ -0,0 +1,15 @@ +dependencies: +- name: redis + repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami + version: 17.15.6 +- name: postgresql + repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami + version: 12.8.5 +- name: timescaledb-single + repository: https://charts.timescale.com/ + version: 0.33.1 +- name: minio + repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami + version: 12.7.0 +digest: sha256:3cc72ea521ef6f19bf3dee5798097f42f40dfdc5f432b4cb519184d073648347 +generated: "2023-09-03T23:34:20.6365107+08:00" diff --git a/charts/codecov/Chart.yaml b/charts/codecov/Chart.yaml new file mode 100644 index 0000000..7a5f9e2 --- /dev/null +++ b/charts/codecov/Chart.yaml @@ -0,0 +1,48 @@ +apiVersion: v2 +name: codecov +description: A Helm chart for Kubernetes + +home: https://github.com/codecov/self-hosted + +maintainers: + - name: douban + +# 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: "v5.0.1" + +dependencies: + - name: redis + version: ~17.15.6 + repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami + condition: redis.embedded + - name: postgresql + version: ~12.8.5 + repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami + condition: postgresql.embedded + - name: timescaledb-single + alias: timescaledb + version: 0.33.* + repository: https://charts.timescale.com/ + condition: timescaledb.enabled + - name: minio + version: ~12.7.0 + repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami + condition: minio.embedded diff --git a/charts/codecov/README.md b/charts/codecov/README.md new file mode 100644 index 0000000..ae8ee93 --- /dev/null +++ b/charts/codecov/README.md @@ -0,0 +1,48 @@ +# codecov + +This helm chart is based on docker-compose provided by [codecov](https://github.com/codecov/self-hosted) + +codecov is distributed with `BUSL` instead of any open source license. + +this helm is distributed with `Apache License 2.0` + +## install + +create your own values file , save as `values.yaml` + +```yaml +codecov_host: "codecov.example.com" + + +codecov_config: | + # edit your config here + +extraEnvs: [] + +ingress: + enabled: true + className: "nginx" + + hosts: + - host: codecov.example.com + paths: + - path: / + pathType: ImplementationSpecific + + +postgresql: + # use external postgresql + embedded: false +``` + +``` +# install it +helm repo add douban https://douban.github.io/charts/ +helm upgrade codecov douban/codecov -f values.yaml --install --debug +``` +## known issues + +### must use external minio/s3 +I setup minio chart to use , but codecov requires a external available s3 service, it is adviced to use external cloud service instead. + +pr are welcomed. diff --git a/charts/codecov/templates/NOTES.txt b/charts/codecov/templates/NOTES.txt new file mode 100644 index 0000000..15dd795 --- /dev/null +++ b/charts/codecov/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.gateway.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "codecov.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.gateway.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "codecov.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "codecov.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.gateway.service.port }} +{{- else if contains "ClusterIP" .Values.gateway.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "codecov.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/charts/codecov/templates/_helpers.tpl b/charts/codecov/templates/_helpers.tpl new file mode 100644 index 0000000..7bb1364 --- /dev/null +++ b/charts/codecov/templates/_helpers.tpl @@ -0,0 +1,97 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "codecov.name" -}} +{{- default .Chart.Name .Values.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 "codecov.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.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 "codecov.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "codecov.labels" -}} +helm.sh/chart: {{ include "codecov.chart" . }} +{{ include "codecov.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "codecov.selectorLabels" -}} +app.kubernetes.io/name: {{ include "codecov.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "codecov.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "codecov.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +codecov dependency settings +*/}} +{{- define "codecov.commonEnvs" -}} +- name: setup__codecov_url + value: "{{ .Values.codecov_scheme }}://{{ .Values.codecov_host }}" +{{- if .Values.redis.embedded }} +- name: services__redis_url + value: redis://:{{ .Values.redis.auth.password }}@{{ include "codecov.fullname" . }}-redis-master:6379/0 +{{- end }} +{{- if .Values.postgresql.embedded }} +- name: services__database_url + value: postgres://postgres:{{ .Values.postgresql.auth.postgresPassword }}@{{ include "codecov.fullname" . }}-postgresql:5432/{{ .Values.postgresql.auth.database }} +{{- end }} +{{- if .Values.timescaledb.enabled }} +- name: services__timeseries_database_url + value: postgres://postgres:{{ .Values.timescaledb.secrets.credentials.PATRONI_SUPERUSER_PASSWORD }}@{{ .Values.timescaledb.fullnameOverride }}:5432/postgres?sslmode=require +{{- end }} +{{- if .Values.minio.embedded }} +- name: services__minio__host + value: {{ include "codecov.fullname" . }}-minio +- name: services__minio__port + value: {{ .Values.minio.service.ports.api | quote }} +- name: services__minio__access_key_id + value: {{ .Values.minio.auth.rootUser }} +- name: services__minio__secret_access_key + value: {{ .Values.minio.auth.rootPassword }} +{{- else }} +- name: services__minio__host + value: {{ .Values.minio.externalHost | quote }} +- name: services__minio__port + value: {{ .Values.minio.externalPort | quote }} +{{- end }} +{{- end }} diff --git a/charts/codecov/templates/configMap.yaml b/charts/codecov/templates/configMap.yaml new file mode 100644 index 0000000..eff0b77 --- /dev/null +++ b/charts/codecov/templates/configMap.yaml @@ -0,0 +1,12 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: {{ include "codecov.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "codecov.name" . }} + helm.sh/chart: {{ include "codecov.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +data: + codecov.yml: | +{{ .Values.codecov_config | indent 4 }} diff --git a/charts/codecov/templates/deployment.yaml b/charts/codecov/templates/deployment.yaml new file mode 100644 index 0000000..e768cbd --- /dev/null +++ b/charts/codecov/templates/deployment.yaml @@ -0,0 +1,338 @@ +# api +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "codecov.fullname" . }}-api + labels: + {{- include "codecov.labels" . | nindent 4 }} + app.kubernetes.io/component: api +spec: + {{- if not .Values.api.autoscaling.enabled }} + replicas: {{ .Values.api.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "codecov.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: api + template: + metadata: + annotations: + checksum/config: {{ .Values.codecov_config | sha256sum }} + {{- if .Values.api.podAnnotations }} +{{ tpl (toYaml .Values.api.podAnnotations | indent 8) . }} + {{- end }} + labels: + {{- include "codecov.selectorLabels" . | nindent 8 }} + app.kubernetes.io/component: api + spec: + {{- with .Values.api.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "codecov.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.api.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }}-api + securityContext: + {{- toYaml .Values.api.securityContext | nindent 12 }} + image: "{{ .Values.api.image.repository }}:{{ .Values.api.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.api.image.pullPolicy }} + env: + - name: placeholder + value: "1" + {{- include "codecov.commonEnvs" . | nindent 12 }} + {{- with .Values.extraEnvs }} + {{- toYaml . | nindent 12 }} + {{- end }} + volumeMounts: + - name: {{ include "codecov.name" . }} + mountPath: /config + readOnly: true + {{- with .Values.volumeMounts }} + {{- toYaml . | nindent 12 }} + {{- end }} + ports: + - name: http + containerPort: {{ .Values.api.containerPort }} + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.api.resources | nindent 12 }} + volumes: + - name: {{ include "codecov.name" . }} + configMap: + name: {{ include "codecov.fullname" . }} + {{- with .Values.volumes }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.api.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.api.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.api.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + +# worker +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "codecov.fullname" . }}-worker + labels: + {{- include "codecov.labels" . | nindent 4 }} + app.kubernetes.io/component: worker +spec: + {{- if not .Values.worker.autoscaling.enabled }} + replicas: {{ .Values.worker.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "codecov.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: worker + template: + metadata: + annotations: + checksum/config: {{ .Values.codecov_config | sha256sum }} + {{- if .Values.worker.podAnnotations }} +{{ tpl (toYaml .Values.worker.podAnnotations | indent 8) . }} + {{- end }} + {{- with .Values.worker.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "codecov.selectorLabels" . | nindent 8 }} + app.kubernetes.io/component: worker + spec: + {{- with .Values.worker.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "codecov.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.worker.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.worker.securityContext | nindent 12 }} + image: "{{ .Values.worker.image.repository }}:{{ .Values.worker.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.worker.image.pullPolicy }} + args: + - worker + env: + - name: RUN_ENV + value: "ENTERPRISE" + {{- include "codecov.commonEnvs" . | nindent 12 }} + {{- with .Values.extraEnvs }} + {{- toYaml . | nindent 12 }} + {{- end }} + volumeMounts: + - name: {{ include "codecov.name" . }} + mountPath: /config + readOnly: true + {{- with .Values.volumeMounts }} + {{- toYaml . | nindent 10 }} + {{- end }} + resources: + {{- toYaml .Values.worker.resources | nindent 12 }} + volumes: + - name: {{ include "codecov.name" . }} + configMap: + name: {{ include "codecov.fullname" . }} + {{- with .Values.volumes }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.worker.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.worker.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.worker.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + +# gateway +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "codecov.fullname" . }}-gateway + labels: + {{- include "codecov.labels" . | nindent 4 }} + app.kubernetes.io/component: gateway +spec: + {{- if not .Values.gateway.autoscaling.enabled }} + replicas: {{ .Values.gateway.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "codecov.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: gateway + template: + metadata: + {{- with .Values.gateway.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "codecov.selectorLabels" . | nindent 8 }} + app.kubernetes.io/component: gateway + spec: + {{- with .Values.gateway.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "codecov.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.gateway.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.gateway.securityContext | nindent 12 }} + image: "{{ .Values.gateway.image.repository }}:{{ .Values.gateway.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.gateway.image.pullPolicy }} + env: + - name: CODECOV_API_HOST + value: {{ include "codecov.fullname" . }}-api-svc + - name: CODECOV_API_PORT + value: {{ .Values.api.service.port | quote }} + - name: CODECOV_IA_HOST + value: {{ include "codecov.fullname" . }}-api-svc + - name: CODECOV_IA_PORT + value: {{ .Values.api.service.port | quote }} + - name: CODECOV_FRONTEND_HOST + value: {{ include "codecov.fullname" . }}-frontend + - name: CODECOV_FRONTEND_PORT + value: {{ .Values.frontend.service.port | quote }} + {{- if .Values.minio.embedded }} + - name: CODECOV_MINIO_HOST + value: {{ include "codecov.fullname" . }}-minio + - name: CODECOV_MINIO_PORT + value: {{ .Values.minio.service.ports.api | quote }} + {{- else }} + - name: CODECOV_MINIO_HOST + value: {{ .Values.minio.externalHost | quote }} + - name: CODECOV_MINIO_PORT + value: {{ .Values.minio.externalPort | quote }} + {{- end }} + ports: + - name: http + containerPort: {{ .Values.gateway.containerPort }} + protocol: TCP + livenessProbe: + httpGet: + path: /gateway_health + port: http + readinessProbe: + httpGet: + path: /gateway_health + port: http + resources: + {{- toYaml .Values.gateway.resources | nindent 12 }} + {{- with .Values.gateway.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.gateway.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.gateway.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + +# frontend +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "codecov.fullname" . }}-frontend + labels: + {{- include "codecov.labels" . | nindent 4 }} + app.kubernetes.io/component: frontend +spec: + {{- if not .Values.frontend.autoscaling.enabled }} + replicas: {{ .Values.frontend.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "codecov.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: frontend + template: + metadata: + {{- with .Values.frontend.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "codecov.selectorLabels" . | nindent 8 }} + app.kubernetes.io/component: frontend + spec: + {{- with .Values.frontend.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "codecov.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.frontend.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.frontend.securityContext | nindent 12 }} + image: "{{ .Values.frontend.image.repository }}:{{ .Values.frontend.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.frontend.image.pullPolicy }} + env: + - name: CODECOV_BASE_HOST + value: {{ .Values.codecov_host }} + - name: CODECOV_API_HOST + value: {{ .Values.codecov_host }} + - name: CODECOV_IA_HOST + value: {{ .Values.codecov_host }} + - name: CODECOV_SCHEME + value: {{ .Values.codecov_scheme }} + ports: + - name: http + containerPort: {{ .Values.frontend.containerPort }} + protocol: TCP + livenessProbe: + httpGet: + path: /frontend_health + port: http + readinessProbe: + httpGet: + path: /frontend_health + port: http + resources: + {{- toYaml .Values.frontend.resources | nindent 12 }} + {{- with .Values.frontend.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.frontend.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.frontend.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/codecov/templates/hpa.yaml b/charts/codecov/templates/hpa.yaml new file mode 100644 index 0000000..ef37982 --- /dev/null +++ b/charts/codecov/templates/hpa.yaml @@ -0,0 +1,121 @@ +{{- if .Values.api.autoscaling.enabled }} +--- +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "codecov.fullname" . }}-api + labels: + {{- include "codecov.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "codecov.fullname" . }}-api + minReplicas: {{ .Values.api.autoscaling.minReplicas }} + maxReplicas: {{ .Values.api.autoscaling.maxReplicas }} + metrics: + {{- if .Values.api.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.api.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.api.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.api.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} + + +{{- if .Values.frontend.autoscaling.enabled }} +--- +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "codecov.fullname" . }}-frontend + labels: + {{- include "codecov.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "codecov.fullname" . }}-frontend + minReplicas: {{ .Values.frontend.autoscaling.minReplicas }} + maxReplicas: {{ .Values.frontend.autoscaling.maxReplicas }} + metrics: + {{- if .Values.frontend.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.frontend.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.frontend.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.frontend.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} + +{{- if .Values.worker.autoscaling.enabled }} +--- +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "codecov.fullname" . }}-worker + labels: + {{- include "codecov.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "codecov.fullname" . }}-worker + minReplicas: {{ .Values.worker.autoscaling.minReplicas }} + maxReplicas: {{ .Values.worker.autoscaling.maxReplicas }} + metrics: + {{- if .Values.worker.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.worker.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.worker.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.worker.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} + +{{- if .Values.gateway.autoscaling.enabled }} +--- +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "codecov.fullname" . }}-gateway + labels: + {{- include "codecov.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "codecov.fullname" . }}-gateway + minReplicas: {{ .Values.gateway.autoscaling.minReplicas }} + maxReplicas: {{ .Values.gateway.autoscaling.maxReplicas }} + metrics: + {{- if .Values.gateway.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.gateway.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.gateway.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.gateway.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} + diff --git a/charts/codecov/templates/ingress.yaml b/charts/codecov/templates/ingress.yaml new file mode 100644 index 0000000..ccd051c --- /dev/null +++ b/charts/codecov/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "codecov.fullname" . -}} +{{- $svcPort := .Values.gateway.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "codecov.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }}-gateway + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }}-gateway + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/codecov/templates/service.yaml b/charts/codecov/templates/service.yaml new file mode 100644 index 0000000..9f6b05b --- /dev/null +++ b/charts/codecov/templates/service.yaml @@ -0,0 +1,58 @@ +--- +apiVersion: v1 +kind: Service +metadata: + # codecov-api would confict with codecov-api program + # use another name + name: {{ include "codecov.fullname" . }}-api-svc + labels: + {{- include "codecov.labels" . | nindent 4 }} + app.kubernetes.io/component: api +spec: + type: {{ .Values.api.service.type }} + ports: + - port: {{ .Values.api.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "codecov.selectorLabels" . | nindent 4 }} + app.kubernetes.io/component: api + +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "codecov.fullname" . }}-gateway + labels: + {{- include "codecov.labels" . | nindent 4 }} + app.kubernetes.io/component: gateway +spec: + type: {{ .Values.gateway.service.type }} + ports: + - port: {{ .Values.gateway.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "codecov.selectorLabels" . | nindent 4 }} + app.kubernetes.io/component: gateway + +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "codecov.fullname" . }}-frontend + labels: + {{- include "codecov.labels" . | nindent 4 }} + app.kubernetes.io/component: frontend +spec: + type: {{ .Values.frontend.service.type }} + ports: + - port: {{ .Values.frontend.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "codecov.selectorLabels" . | nindent 4 }} + app.kubernetes.io/component: frontend diff --git a/charts/codecov/templates/serviceaccount.yaml b/charts/codecov/templates/serviceaccount.yaml new file mode 100644 index 0000000..4fecce1 --- /dev/null +++ b/charts/codecov/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "codecov.serviceAccountName" . }} + labels: + {{- include "codecov.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/codecov/templates/tests/test-connection.yaml b/charts/codecov/templates/tests/test-connection.yaml new file mode 100644 index 0000000..4f38aef --- /dev/null +++ b/charts/codecov/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "codecov.fullname" . }}-test-connection" + labels: + {{- include "codecov.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "codecov.fullname" . }}-gateway:{{ .Values.gateway.service.port }}'] + restartPolicy: Never diff --git a/charts/codecov/values.yaml b/charts/codecov/values.yaml new file mode 100644 index 0000000..379ea8e --- /dev/null +++ b/charts/codecov/values.yaml @@ -0,0 +1,400 @@ +# Default values for codecov. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +codecov_host: "codecov.example.com" + +codecov_scheme: https + +codecov_config: | + # please read https://docs.codecov.io/docs/configuration to have further understanding + # if there's anything secret needs to set, please use envrinment variable + # https://docs.codecov.com/docs/configuration#overview + setup: + # do not set codecov_url, this value is controlled by codecov_host and codecov_scheme + # codecov_url: http://set-this-value-only-if-you-know-what-you-are-doing.com + # codecov_api_url: # this defaults to and is designed to work out of the box like this + # api_allowed_hosts: [] # this defaults to and is designed to work out of the box like this + # Replace with your Codecov Enterprise License key. This is required for the containers to function. + # https://docs.codecov.io/docs/configuration#section-enterprise-license + enterprise_license: "F5O0Fu5ASFTPtWXM51BK8YQlq7IM2s+8TBGULrf9Um7wHjfPwI+Z3E4PfF/dPs6Uc5A+MLti+2etHq5dnFEfZgoiIVCLZ8x+0BVmUSWwPS42vJXnf1veY9Bglang4mDIhmfWfp5l6AT6cxmAVFpGrwobiK6OcN9pjWx4iWabazmsOiF9LM++v0WtuHNvhgzRcKmnJPgqahEB7qqF6KQ1hg==" + # https://docs.codecov.com/docs/configuration#instance-wide-admins + admins: + - service: github + username: "LeoQuote" + # Replace with a random string + # https://docs.codecov.io/docs/configuration#section-cookie-secret + http: + cookie_secret: "some-random-string" + timeseries: + # timeseries are disabled by default as the timescaledb helm chart is not working + enabled: false + # global coverage.yml config + site: + comment: + # default layout is wierd with duplicated reach + layout: "reach,diff,flags,tree" + github: + client_id: "Iv1.42f4f7d056e37182" + client_secret: "secretxxx" + # global_upload_token: "" + webhook_secret: "verysecret" + intergration: + id: 22 + pem: /config/file.pem +# If using external storage. Comment above and uncomment below +# host: s3.amazonaws.com or storage.googleapis.com if using GCS +# bucket: +# region: +# verify_ssl: true +# port: 443 +# access_key_id: # or if using GCS +# secret_access_key: # or if using GCS +# iam_auth: # set to true in AWS to attempt to authenticate via Instance role + +# the following extra configs would be injected into: +# * api +# * worker +extraEnvs: [] + +volumes: [] + +volumeMounts: [] + +nameOverride: "" +fullnameOverride: "" + +ingress: + enabled: false + className: "" + annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +frontend: + replicaCount: 1 + + image: + repository: codecov/enterprise-frontend + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + + imagePullSecrets: [] + + podAnnotations: {} + + podSecurityContext: {} + # fsGroup: 2000 + + securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + service: + type: ClusterIP + port: 80 + + containerPort: 8080 + + + resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + + nodeSelector: {} + + tolerations: [] + + affinity: {} + +api: + replicaCount: 1 + + image: + repository: codecov/enterprise-api + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + + imagePullSecrets: [] + + podAnnotations: {} + + podSecurityContext: {} + # fsGroup: 2000 + + securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + service: + type: ClusterIP + port: 80 + + containerPort: 8000 + + resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + + nodeSelector: {} + + tolerations: [] + + affinity: {} + +worker: + replicaCount: 1 + + image: + repository: codecov/enterprise-worker + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + + imagePullSecrets: [] + + podAnnotations: {} + + podSecurityContext: {} + # fsGroup: 2000 + + securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + + resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + + nodeSelector: {} + + tolerations: [] + + affinity: {} + +gateway: + replicaCount: 1 + + image: + repository: codecov/enterprise-gateway + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + + imagePullSecrets: [] + + podAnnotations: {} + + podSecurityContext: {} + # fsGroup: 2000 + + securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + service: + type: ClusterIP + port: 80 + + containerPort: 8080 + + + resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + + nodeSelector: {} + + tolerations: [] + + affinity: {} + + +##### dependencies ##### + +redis: + # using embedded redis + # connection info would be set automatically + # best to use external redis if you have one + embedded: true + # embedded: false + # url: "redis://127.0.0.1:6379/0" + # urlSecret: "" + # urlSecretKey: "CACHE_URL" + # please consult to chart manual if you want to change it. + # https://artifacthub.io/packages/helm/bitnami/redis + architecture: standalone + auth: + password: "REDIS_PASSWORD" + master: + persistence: + enabled: false + size: 8Gi + +postgresql: + # using embedded redis + # connection info would be set automatically + # best to use external redis if you have one + # setting embedded to false and set redis url in envrionment variable + embedded: true + # embedded: false + # url: "postgres://postgres:testpassword@postgres:5432/postgres" + # urlSecret: "" + # urlSecretKey: "CACHE_URL" + architecture: standalone + auth: + postgresPassword: "testpassword" + database: "codecov" + primary: + persistence: + enabled: false + +timescaledb: + enabled: true + # timescaledb is not enabled by default, it is actually not working, pr are welcome + # it is recommended to use external timescaledb as the helm chart using proviode timescaledb with tls support + # which is currently not supported by codecov + # enable means that the timescaledb would be embedded in the chart + # you can set to false and provide your own + # enabled: false + # url: "postgres://postgres:testpassword@timescale:5432/postgres" + # urlSecret: "" + # urlSecretKey: "CACHE_URL" + fullnameOverride: "timescale-codecov" + image: + pullPolicy: IfNotPresent + secrets: + # This map should contain environment variables that influence Patroni, + # for example PATRONI_SUPERUSER_PASSWORD or PATRONI_REPLICATION_PASSWORD + # https://patroni.readthedocs.io/en/latest/ENVIRONMENT.html#postgresql + credentials: + PATRONI_SUPERUSER_PASSWORD: "testpassword" + # disable ssl as codecov does not support it + persistentVolumes: + data: + enabled: false + wal: + enabled: false + + +minio: + embedded: false + # externalHost: "minio.example.com" + # externalPort: "443" + # embedded minio is not supported + # codecov needs a external available minio + # please use external minio + # pr are welcomed + # embedded: false + # externalMinio: +# If using external storage. Comment above and uncomment below +# host: s3.amazonaws.com or storage.googleapis.com if using GCS +# bucket: +# region: +# verify_ssl: true +# port: 443 +# access_key_id: # or if using GCS +# secret_access_key: # or if using GCS +# iam_auth: # set to true in AWS to attempt to authenticate via Instance role + auth: + rootUser: minioadmin + rootPassword: minioadmin + persistence: + enabled: false diff --git a/ct.yaml b/ct.yaml index c2cdf63..8eb138a 100644 --- a/ct.yaml +++ b/ct.yaml @@ -6,4 +6,5 @@ chart-repos: - stable=https://charts.helm.sh/stable/ - douban=https://douban.github.io/charts/ - bitnami=https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami + - timescale=https://charts.timescale.com/ helm-extra-args: --timeout 600s