Skip to content

Commit

Permalink
Merge pull request #48 from alercebroker/prv_candidates_chart
Browse files Browse the repository at this point in the history
feat: added chart for prv candidates step
  • Loading branch information
dirodriguezm authored Mar 3, 2023
2 parents 40ae734 + a01bf08 commit a094b68
Show file tree
Hide file tree
Showing 11 changed files with 306 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
values.override.yaml
values.override.yml
*.tgz
23 changes: 23 additions & 0 deletions charts/prv_candidates/.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/
6 changes: 6 additions & 0 deletions charts/prv_candidates/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
appVersion: "rc-51c2f55"
description: A Helm chart for Kubernetes
name: prv-candidates
type: application
version: 0.1.0
68 changes: 68 additions & 0 deletions charts/prv_candidates/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "prv-candidates.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 "prv-candidates.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 "prv-candidates.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "prv-candidates.labels" -}}
helm.sh/chart: {{ include "prv-candidates.chart" . }}
{{ include "prv-candidates.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "prv-candidates.selectorLabels" -}}
app.kubernetes.io/name: {{ include "prv-candidates.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "prv-candidates.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "prv-candidates.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{- define "imagePullSecret" }}
{{- with .Values.imageCredentials }}
{{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}}" .registry .username .password .email (printf "%s:%s" .username .password | b64enc) | b64enc }}
{{- end }}
{{- end }}
11 changes: 11 additions & 0 deletions charts/prv_candidates/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "prv-candidates.fullname" . }}
namespace: {{ .Values.namespace }}
data:
consumer-topics: {{ .Values.configmap.consumerTopics }}
internal-server: {{ .Values.configmap.internalServer }}
scribe-topic: {{ .Values.configmap.scribeTopic }}
producer-topic: {{ .Values.configmap.producerTopic }}
metrics-topic: {{ .Values.configmap.metricsTopic }}
84 changes: 84 additions & 0 deletions charts/prv_candidates/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "prv-candidates.fullname" . }}
namespace: {{ .Values.namespace }}
labels:
{{- include "prv-candidates.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "prv-candidates.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "prv-candidates.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: metrics
containerPort: 8000
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: CONSUMER_TOPICS
valueFrom:
configMapKeyRef:
name: {{ include "prv-candidates.fullname" . }}
key: consumer-topics
- name: CONSUMER_SERVER
valueFrom:
configMapKeyRef:
name: {{ include "prv-candidates.fullname" . }}
key: internal-server
- name: CONSUMER_GROUP_ID
value: {{ include "prv-candidates.fullname" . }}
- name: PRODUCER_SERVER
valueFrom:
configMapKeyRef:
name: {{ include "prv-candidates.fullname" . }}
key: internal-server
- name: PRODUCER_TOPIC
valueFrom:
configMapKeyRef:
name: {{ include "prv-candidates.fullname" . }}
key: producer-topic
- name: SCRIBE_SERVER
valueFrom:
configMapKeyRef:
name: {{ include "prv-candidates.fullname" . }}
key: internal-server
- name: SCRIBE_TOPIC
valueFrom:
configMapKeyRef:
name: {{ include "prv-candidates.fullname" . }}
key: scribe-topic
- name: METRICS_HOST
valueFrom:
configMapKeyRef:
name: {{ include "prv-candidates.fullname" . }}
key: internal-server
- name: METRICS_TOPIC
valueFrom:
configMapKeyRef:
name: {{ include "prv-candidates.fullname" . }}
key: metrics-topic
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
28 changes: 28 additions & 0 deletions charts/prv_candidates/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "prv-candidates.fullname" . }}
labels:
{{- include "prv-candidates.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "prv-candidates.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
6 changes: 6 additions & 0 deletions charts/prv_candidates/templates/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: {{ .Values.namespace }}
labels:
name: {{ .Values.namespace }}
8 changes: 8 additions & 0 deletions charts/prv_candidates/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: image-pull-access
namespace: {{ .Values.namespace }}
type: kubernetes.io/dockerconfigjson
data:
.dockerconfigjson: {{ template "imagePullSecret" . }}
15 changes: 15 additions & 0 deletions charts/prv_candidates/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "prv-candidates.fullname" . }}
labels:
{{- include "prv-candidates.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "prv-candidates.selectorLabels" . | nindent 4 }}
56 changes: 56 additions & 0 deletions charts/prv_candidates/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Default values for step_starter.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

namespace: prv-candidates

image:
repository: ghcr.io/alercebroker/prv_candidates_step
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""

imagePullSecrets:
- name: "image-pull-access"
nameOverride: ""
fullnameOverride: ""

podAnnotations: {}

service:
type: ClusterIP
port: 8000

resources: {}

autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: eks.amazonaws.com/nodegroup
operator: In
## Override this value with the NodeGroup tag accordingly
values: []

configmap:
consumerTopics: ""
internalServer: ""
scribeTopic: ""
metricsTopic: ""
producerTopic: ""

imageCredentials:
registry: ""
username: ""
password: ""
email: ""

0 comments on commit a094b68

Please sign in to comment.