Skip to content

Commit bdd43c1

Browse files
committed
Moved the helm charts
0 parents  commit bdd43c1

14 files changed

+678
-0
lines changed

.helmignore

Lines changed: 23 additions & 0 deletions
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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: v2
2+
name: opszero
3+
description: A Helm chart for Kubernetes
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+
appVersion: 1.16.0

templates/NOTES.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.service.enabled }}
3+
{{- range $host := .Values.service.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.service.tls }}s{{ end }}://{{ $host.host }}{{ . }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "opszero.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "opszero.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "opszero.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "opszero.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
echo "Visit http://127.0.0.1:8080 to use your application"
20+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
21+
{{- end }}

templates/_helpers.tpl

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "opszero.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 "opszero.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 "opszero.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "opszero.labels" -}}
37+
helm.sh/chart: {{ include "opszero.chart" . }}
38+
{{ include "opszero.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "opszero.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "opszero.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Selector labels for Flower
55+
*/}}
56+
{{- define "opszero.selectorFlowerLabels" -}}
57+
app.kubernetes.io/name: {{ include "opszero.name" . }}-flower
58+
app.kubernetes.io/instance: {{ .Release.Name }}
59+
{{- end }}
60+
61+
{{/*
62+
Create the name of the service account to use
63+
*/}}
64+
{{- define "opszero.serviceAccountName" -}}
65+
{{- if .Values.serviceAccount.create }}
66+
{{- default (include "opszero.fullname" .) .Values.serviceAccount.name }}
67+
{{- else }}
68+
{{- default "default" .Values.serviceAccount.name }}
69+
{{- end }}
70+
{{- end }}

templates/celery.yaml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "opszero.fullname" . }}-celery
5+
labels:
6+
{{- include "opszero.labels" . | nindent 4 }}
7+
tags.datadoghq.com/env: {{ .Values.secrets.DD_ENV | quote }}
8+
tags.datadoghq.com/service: {{ include "opszero.fullname" . }}-celery
9+
tags.datadoghq.com/version: {{ .Values.image.tag | quote }}
10+
spec:
11+
{{- if not .Values.autoscaling.enabled }}
12+
replicas: {{ .Values.replicaCount }}
13+
{{- end }}
14+
selector:
15+
matchLabels:
16+
{{- include "opszero.selectorLabels" . | nindent 6 }}
17+
template:
18+
metadata:
19+
annotations:
20+
rollme: {{ randAlphaNum 5 | quote }}
21+
ad.datadoghq.com/celery.logs: '[{"source": "celery","service": "celery"}]'
22+
{{- with .Values.podAnnotations }}
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
labels:
26+
{{- include "opszero.selectorLabels" . | nindent 8 }}
27+
tags.datadoghq.com/env: {{ .Values.secrets.DD_ENV | quote }}
28+
tags.datadoghq.com/service: {{ include "opszero.fullname" . }}-celery
29+
tags.datadoghq.com/version: {{ .Values.image.tag | quote }}
30+
spec:
31+
{{- with .Values.imagePullSecrets }}
32+
imagePullSecrets:
33+
{{- toYaml . | nindent 8 }}
34+
{{- end }}
35+
serviceAccountName: {{ include "opszero.serviceAccountName" . }}
36+
securityContext:
37+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
38+
containers:
39+
- name: {{ .Chart.Name }}
40+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
41+
imagePullPolicy: {{ .Values.image.pullPolicy }}
42+
command: ["ddtrace-run", "celery", "--app=opszero.celery", "worker", "--loglevel=info", "--concurrency=2"]
43+
envFrom:
44+
- secretRef:
45+
name: {{ template "opszero.fullname" . }}
46+
env:
47+
- name: DD_AGENT_HOST
48+
valueFrom:
49+
fieldRef:
50+
fieldPath: status.hostIP
51+
- name: DD_LOGS_INJECTION
52+
value: "true"
53+
- name: DD_APM_ENABLED
54+
value: "true"
55+
- name: DD_ENV
56+
valueFrom:
57+
fieldRef:
58+
fieldPath: metadata.labels['tags.datadoghq.com/env']
59+
- name: DD_SERVICE
60+
valueFrom:
61+
fieldRef:
62+
fieldPath: metadata.labels['tags.datadoghq.com/service']
63+
- name: DD_VERSION
64+
valueFrom:
65+
fieldRef:
66+
fieldPath: metadata.labels['tags.datadoghq.com/version']
67+
68+
resources:
69+
{{- toYaml .Values.resources | nindent 12 }}
70+
{{- with .Values.nodeSelector }}
71+
nodeSelector:
72+
{{- toYaml . | nindent 8 }}
73+
{{- end }}
74+
{{- with .Values.affinity }}
75+
affinity:
76+
{{- toYaml . | nindent 8 }}
77+
{{- end }}
78+
{{- with .Values.tolerations }}
79+
tolerations:
80+
{{- toYaml . | nindent 8 }}
81+
{{- end }}
82+
---
83+
apiVersion: keda.sh/v1alpha1
84+
kind: ScaledObject
85+
metadata:
86+
name: {{ include "opszero.fullname" . }}-celery
87+
labels:
88+
{{- include "opszero.labels" . | nindent 4 }}
89+
spec:
90+
scaleTargetRef:
91+
name: {{ include "opszero.fullname" . }}-celery
92+
kind: Deployment
93+
minReplicaCount: {{ .Values.autoscaling.minReplicas }}
94+
maxReplicaCount: {{ .Values.autoscaling.maxReplicas }}
95+
cooldownPeriod: 7200
96+
triggers:
97+
- type: redis
98+
metadata:
99+
address: "{{ .Values.secrets.REDIS_ADDRESS }}:6379"
100+
databaseIndex: "1"
101+
listName: celery
102+
listLength: "5"

templates/flower.yaml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "opszero.fullname" . }}-flower
5+
labels:
6+
{{- include "opszero.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.flowerService.type }}
9+
ports:
10+
- port: 80
11+
targetPort: {{ .Values.flowerService.port }}
12+
protocol: TCP
13+
name: http
14+
selector:
15+
{{- include "opszero.selectorFlowerLabels" . | nindent 4 }}
16+
---
17+
apiVersion: apps/v1
18+
kind: Deployment
19+
metadata:
20+
name: {{ include "opszero.fullname" . }}-flower
21+
labels:
22+
{{- include "opszero.labels" . | nindent 4 }}
23+
tags.datadoghq.com/env: {{ .Values.secrets.DD_ENV | quote }}
24+
tags.datadoghq.com/service: {{ include "opszero.fullname" . }}-flower
25+
tags.datadoghq.com/version: {{ .Values.image.tag | quote }}
26+
spec:
27+
{{- if not .Values.autoscaling.enabled }}
28+
replicas: {{ .Values.replicaCount }}
29+
{{- end }}
30+
selector:
31+
matchLabels:
32+
{{- include "opszero.selectorFlowerLabels" . | nindent 6 }}
33+
template:
34+
metadata:
35+
annotations:
36+
rollme: {{ randAlphaNum 5 | quote }}
37+
ad.datadoghq.com/celery.logs: '[{"source": "celery","service": "celery"}]'
38+
{{- with .Values.podAnnotations }}
39+
{{- toYaml . | nindent 8 }}
40+
{{- end }}
41+
labels:
42+
{{- include "opszero.selectorFlowerLabels" . | nindent 8 }}
43+
tags.datadoghq.com/env: {{ .Values.secrets.DD_ENV | quote }}
44+
tags.datadoghq.com/service: {{ include "opszero.fullname" . }}-flower
45+
tags.datadoghq.com/version: {{ .Values.image.tag | quote }}
46+
spec:
47+
{{- with .Values.imagePullSecrets }}
48+
imagePullSecrets:
49+
{{- toYaml . | nindent 8 }}
50+
{{- end }}
51+
serviceAccountName: {{ include "opszero.serviceAccountName" . }}
52+
securityContext:
53+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
54+
containers:
55+
- name: {{ .Chart.Name }}
56+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
57+
imagePullPolicy: {{ .Values.image.pullPolicy }}
58+
command: [ 'ddtrace-run', 'celery', 'flower', '-A', 'opszero.celery', '--address=0.0.0.0', '--port=5555','--basic_auth=$(FLOWER_BASIC_AUTH)']
59+
ports:
60+
- name: http
61+
containerPort: {{ .Values.flowerService.port }}
62+
protocol: TCP
63+
envFrom:
64+
- secretRef:
65+
name: {{ template "opszero.fullname" . }}
66+
env:
67+
- name: DD_AGENT_HOST
68+
valueFrom:
69+
fieldRef:
70+
fieldPath: status.hostIP
71+
- name: DD_APM_ENABLED
72+
value: "true"
73+
- name: DD_ENV
74+
valueFrom:
75+
fieldRef:
76+
fieldPath: metadata.labels['tags.datadoghq.com/env']
77+
- name: DD_SERVICE
78+
valueFrom:
79+
fieldRef:
80+
fieldPath: metadata.labels['tags.datadoghq.com/service']
81+
- name: DD_VERSION
82+
valueFrom:
83+
fieldRef:
84+
fieldPath: metadata.labels['tags.datadoghq.com/version']
85+
86+
- name: REDIS_HOST
87+
value: {{ .Values.secrets.REDIS_URL }}
88+
- name: FLOWER_BASIC_AUTH
89+
value: {{ .Values.secrets.FLOWER_BASIC_AUTH }}
90+
resources:
91+
{{- toYaml .Values.resources | nindent 12 }}
92+
{{- with .Values.nodeSelector }}
93+
nodeSelector:
94+
{{- toYaml . | nindent 8 }}
95+
{{- end }}
96+
{{- with .Values.affinity }}
97+
affinity:
98+
{{- toYaml . | nindent 8 }}
99+
{{- end }}
100+
{{- with .Values.tolerations }}
101+
tolerations:
102+
{{- toYaml . | nindent 8 }}
103+
{{- end }}

templates/hpa.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{{- if .Values.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2beta1
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "opszero.fullname" . }}
6+
labels:
7+
{{- include "opszero.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "opszero.fullname" . }}
13+
minReplicas: {{ .Values.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
15+
metrics:
16+
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
17+
- type: Resource
18+
resource:
19+
name: cpu
20+
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
21+
{{- end }}
22+
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
23+
- type: Resource
24+
resource:
25+
name: memory
26+
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
27+
{{- end }}
28+
{{- end }}

0 commit comments

Comments
 (0)