Skip to content

Commit e15f3b3

Browse files
heyvitoofeefo
authored andcommitted
Initial commit
0 parents  commit e15f3b3

27 files changed

+2596
-0
lines changed

.helmignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

Chart.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: cocov
3+
description: A Helm chart for Cocov
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "0.1.0"

LICENSE

+674
Large diffs are not rendered by default.

templates/_deployment-worker.yaml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "cocov-chart.fullname" . }}
5+
labels:
6+
{{- include "cocov-chart.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "cocov-chart.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
{{- with .Values.podAnnotations }}
17+
annotations:
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
labels:
21+
{{- include "cocov-chart.selectorLabels" . | nindent 8 }}
22+
spec:
23+
serviceAccountName: {{ include "cocov-chart.serviceAccountName" . }}
24+
securityContext:
25+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
26+
containers:
27+
- name: {{ .Chart.Name }}
28+
securityContext:
29+
{{- toYaml .Values.securityContext | nindent 12 }}
30+
image: "registry.docker.io/cocov/worker:{{ .Values.worker.version | default .Chart.AppVersion }}"
31+
imagePullPolicy: {{ .Values.image.pullPolicy }}
32+
ports:
33+
- name: http
34+
containerPort: 3000
35+
protocol: TCP
36+
livenessProbe:
37+
httpGet:
38+
path: /v1/ping
39+
port: http
40+
readinessProbe:
41+
httpGet:
42+
path: /v1/ping
43+
port: http
44+
resources:
45+
{{- toYaml .Values.resources | nindent 12 }}
46+
{{- with .Values.nodeSelector }}
47+
nodeSelector:
48+
{{- toYaml . | nindent 8 }}
49+
{{- end }}
50+
{{- with .Values.affinity }}
51+
affinity:
52+
{{- toYaml . | nindent 8 }}
53+
{{- end }}
54+
{{- with .Values.tolerations }}
55+
tolerations:
56+
{{- toYaml . | nindent 8 }}
57+
{{- end }}

templates/_helpers.tpl

+155
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "cocov-chart.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "cocov-chart.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "cocov-chart.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{- define "cocov-chart.appVersion" }}
34+
{{- printf "%s" .Chart.AppVersion }}
35+
{{- end }}
36+
37+
{{/*
38+
Common labels
39+
*/}}
40+
{{- define "cocov-chart.labels" -}}
41+
helm.sh/chart: {{ include "cocov-chart.chart" . }}
42+
{{ include "cocov-chart.selectorLabels" . }}
43+
{{- if .Chart.AppVersion }}
44+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
45+
{{- end }}
46+
app.kubernetes.io/managed-by: {{ .Release.Service }}
47+
{{- end }}
48+
49+
{{/*
50+
Selector labels
51+
*/}}
52+
{{- define "cocov-chart.selectorLabels" -}}
53+
app.kubernetes.io/name: {{ include "cocov-chart.name" . }}
54+
app.kubernetes.io/instance: {{ .Release.Name }}
55+
{{- end }}
56+
57+
{{/*
58+
Create the name of the service account to use
59+
*/}}
60+
{{- define "cocov-chart.serviceAccountName" -}}
61+
{{- if .Values.serviceAccount.create }}
62+
{{- default (include "cocov-chart.fullname" .) .Values.serviceAccount.name }}
63+
{{- else }}
64+
{{- default "default" .Values.serviceAccount.name }}
65+
{{- end }}
66+
{{- end }}
67+
68+
{{ define "sizeInBytes" -}}
69+
{{- if hasSuffix "Mi" . }}
70+
{{- mulf (float64 (trimSuffix "Mi" .)) 1024 1024 }}
71+
{{- else if hasSuffix "M" (.| quote) }}
72+
{{- mulf (float64 (trimSuffix "M" .)) 1000 1000 }}
73+
{{- else if hasSuffix "Gi" (.| quote) }}
74+
{{- mulf (float64 (trimSuffix "Gi" .)) 1024 1024 1024 }}
75+
{{- else if hasSuffix "G" (.| quote) }}
76+
{{- mulf (float64 (trimSuffix "G" .)) 1000 1000 1000 }}
77+
{{- else if hasSuffix "Ti" (.| quote) }}
78+
{{- mulf (float64 (trimSuffix "Ti" .)) 1024 1024 1024 1024 }}
79+
{{- else if hasSuffix "T" (.| quote) }}
80+
{{- mulf (float64 (trimSuffix "T" .)) 1000 1000 1000 1000 }}
81+
{{- else }}
82+
{{- fail "invalid size definition" -}}
83+
{{- end }}
84+
{{- end }}
85+
86+
{{ define "dockerHubImage" -}}
87+
"registry-1.docker.io/cocov/{{ mustFirst .}}:{{ index . 1 }}"
88+
{{- end }}
89+
90+
{{ define "clusterLocalHost" -}}
91+
{{ mustFirst . }}.{{ (index . 1).Release.Namespace }}.svc.cluster.local
92+
{{- end }}
93+
94+
{{ define "apiEnvs" -}}
95+
- name: COCOV_GITHUB_ORG_NAME
96+
value: {{ .Values.api.github.orgName | quote }}
97+
- name: COCOV_GITHUB_APP_ID
98+
value: {{ .Values.api.github.app.id | quote }}
99+
- name: COCOV_GITHUB_APP_PRIVATE_KEY
100+
value: {{ .Values.api.github.app.privateKey | quote }}
101+
- name: COCOV_GITHUB_APP_INSTALLATION_ID
102+
value: {{ .Values.api.github.app.installationID | quote }}
103+
- name: COCOV_GITHUB_WEBHOOK_SECRET_KEY
104+
value: {{ .Values.api.github.app.webhookSecret | quote }}
105+
- name: COCOV_GITHUB_OAUTH_CLIENT_ID
106+
value: {{ .Values.api.github.app.clientID | quote }}
107+
- name: COCOV_GITHUB_OAUTH_CLIENT_SECRET
108+
value: {{ .Values.api.github.app.clientSecret | quote }}
109+
- name: COCOV_DATABASE_USERNAME
110+
value: {{ .Values.api.db.username | quote }}
111+
- name: COCOV_DATABASE_PASSWORD
112+
value: {{ .Values.api.db.password | quote }}
113+
- name: COCOV_DATABASE_NAME
114+
value: {{ .Values.api.db.name | quote }}
115+
- name: COCOV_DATABASE_HOST
116+
value: {{ .Values.api.db.host | quote }}
117+
- name: COCOV_DATABASE_PORT
118+
value: {{ .Values.api.db.port | quote }}
119+
- name: SECRET_KEY_BASE
120+
value: {{ .Values.api.secretKeyBase | quote }}
121+
- name: COCOV_CRYPTOGRAPHIC_KEY
122+
value: {{ .Values.api.cryptoKey | quote }}
123+
- name: COCOV_UI_BASE_URL
124+
value: {{ .Values.ui.externalURL | quote }}
125+
- name: COCOV_ALLOW_OUTSIDE_COLLABORATORS
126+
value: {{ .Values.api.github.allowOutsideCollaborators | quote}}
127+
- name: COCOV_REDIS_URL
128+
value: {{ .Values.redis.commonURL | quote }}
129+
- name: COCOV_REDIS_CACHE_URL
130+
value: {{ .Values.redis.cacheURL | quote }}
131+
- name: COCOV_SIDEKIQ_REDIS_URL
132+
value: {{ .Values.redis.sidekiqURL | quote }}
133+
{{ if and .Values.storage.local.enabled .Values.storage.s3.enabled -}}
134+
{{ fail "Only a single storage mode must be enabled at a single time. Review configuration for cocov.storage."}}
135+
{{- end -}}
136+
{{- if .Values.storage.s3.enabled -}}
137+
- name: COCOV_GIT_SERVICE_STORAGE_MODE
138+
value: "s3"
139+
- name: COCOV_GIT_SERVICE_S3_STORAGE_BUCKET_NAME
140+
value: {{ .Values.storage.s3.bucketName | quote }}
141+
{{- else if .Values.storage.local.enabled -}}
142+
- name: COCOV_GIT_SERVICE_STORAGE_MODE
143+
value: "local"
144+
- name: COCOV_GIT_SERVICE_LOCAL_STORAGE_PATH
145+
value: {{ .Values.storage.local.mountPath | quote }}
146+
{{- else -}}
147+
{{ fail "No storage mode is configured. Review configuration for cocov.storage"}}
148+
{{- end -}}
149+
{{- if .Values.cache.enabled }}
150+
- name: COCOV_REPOSITORY_CACHE_MAX_SIZE
151+
value: {{ (include "sizeInBytes" .Values.cache.repositoryMaxSize) | quote }}
152+
- name: COCOV_CACHE_SERVICE_URL
153+
value: {{ include "clusterLocalHost" (list "cocov-cache" .) }}
154+
{{- end }}
155+
{{- end }}

templates/api-deployment.yaml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "cocov-chart.fullname" . }}-api
5+
labels:
6+
{{- include "cocov-chart.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.api.hpa.enabled }}
9+
replicas: {{ .Values.api.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "cocov-chart.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
annotations:
17+
{{- with (mergeOverwrite .Values.general.podAnnotations .Values.api.podAnnotations) }}
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
labels:
21+
dev.cocov.k8s/component: api
22+
{{- $defaultSelectors := (include "cocov-chart.selectorLabels" .) | fromYaml }}
23+
{{- range $key, $value := mergeOverwrite $defaultSelectors .Values.api.labels .Values.general.labels }}
24+
{{ $key }}: {{ toYaml $value }}
25+
{{- end }}
26+
spec:
27+
serviceAccountName: {{ include "cocov-chart.serviceAccountName" . }}
28+
securityContext:
29+
{{- range $key, $value := mergeOverwrite .Values.general.podSecurityContext .Values.api.podSecurityContext }}
30+
{{ $key }}: {{ toYaml $value }}
31+
{{- end }}
32+
containers:
33+
- name: api
34+
env:
35+
{{- include "apiEnvs" . | nindent 12 }}
36+
securityContext:
37+
{{- range $key, $value := mergeOverwrite .Values.general.securityContext .Values.api.securityContext }}
38+
{{ $key }}: {{ toYaml $value }}
39+
{{- end }}
40+
image: {{ include "dockerHubImage" (list "api" (.Values.api.version | default .Values.defaultVersions.api )) }}
41+
imagePullPolicy: {{ .Values.general.imagePullPolicy | default "IfNotPresent" }}
42+
{{- if and .Values.storage.local.enabled .Values.storage.local.volume }}
43+
volumeMounts:
44+
- mountPath: {{ .Values.storage.local.mountPath }}
45+
name: cocov-git-storage-volume
46+
{{- end }}
47+
ports:
48+
- name: http
49+
containerPort: 3000
50+
protocol: TCP
51+
livenessProbe:
52+
httpGet:
53+
path: /v1/ping
54+
port: http
55+
readinessProbe:
56+
httpGet:
57+
path: /v1/ping
58+
port: http
59+
resources:
60+
{{- toYaml .Values.api.resources | nindent 12 }}
61+
{{- if and .Values.storage.local.enabled .Values.storage.local.volume }}
62+
volumes:
63+
{{- list (mergeOverwrite .Values.storage.local.volume ("{ name: cocov-git-storage-volume }" | fromYaml)) | toYaml | nindent 8 }}
64+
{{- end }}
65+
{{- with mergeOverwrite .Values.general.nodeSelector .Values.api.nodeSelector }}
66+
nodeSelector:
67+
{{- toYaml . | nindent 8 }}
68+
{{- end }}
69+
{{- with mergeOverwrite .Values.general.affinity .Values.api.affinity }}
70+
affinity:
71+
{{- toYaml . | nindent 8 }}
72+
{{- end }}
73+
{{- with concat .Values.general.tolerations .Values.api.tolerations }}
74+
tolerations:
75+
{{- toYaml . | nindent 8 }}
76+
{{- end }}

templates/api-hpa.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{{- if .Values.api.hpa.enabled }}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "cocov-chart.fullname" . }}-api-hpa
6+
labels:
7+
{{- include "cocov-chart.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "cocov-chart.fullname" . }}-api
13+
minReplicas: {{ .Values.api.hpa.minReplicas }}
14+
maxReplicas: {{ .Values.api.hpa.maxReplicas }}
15+
metrics:
16+
{{- if .Values.api.hpa.targetCPUUtilizationPercentage }}
17+
- type: Resource
18+
resource:
19+
name: cpu
20+
target:
21+
type: AverageValue
22+
averageUtilization: {{ .Values.api.hpa.targetCPUUtilizationPercentage }}
23+
{{- end }}
24+
{{- if .Values.api.hpa.targetMemoryUtilizationPercentage }}
25+
- type: Resource
26+
resource:
27+
name: memory
28+
target:
29+
type: AverageValue
30+
averageUtilization: {{ .Values.api.hpa.targetMemoryUtilizationPercentage }}
31+
{{- end }}
32+
{{- range $idx, $el := .Values.api.hpa.metrics }}
33+
- {{ $el }}
34+
{{- end }}
35+
{{- end }}

0 commit comments

Comments
 (0)