Skip to content

Commit

Permalink
Add codecov chart (#55)
Browse files Browse the repository at this point in the history
* init commit

* add codecov chart

* add readme

* update ct

* add auto rollout after config change, fix hpa

* update chart lock

* fix lint

* fix lint
  • Loading branch information
LeoQuote authored Sep 3, 2023
1 parent f60061e commit bb6397a
Show file tree
Hide file tree
Showing 15 changed files with 1,271 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/codecov/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
15 changes: 15 additions & 0 deletions charts/codecov/Chart.lock
Original file line number Diff line number Diff line change
@@ -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"
48 changes: 48 additions & 0 deletions charts/codecov/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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
48 changes: 48 additions & 0 deletions charts/codecov/README.md
Original file line number Diff line number Diff line change
@@ -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.
22 changes: 22 additions & 0 deletions charts/codecov/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -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 }}
97 changes: 97 additions & 0 deletions charts/codecov/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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 }}
12 changes: 12 additions & 0 deletions charts/codecov/templates/configMap.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
Loading

0 comments on commit bb6397a

Please sign in to comment.