Skip to content

Commit

Permalink
Merge pull request #67 from alercebroker/feat/chart-for-feature-step
Browse files Browse the repository at this point in the history
Feat/chart for feature step
  • Loading branch information
dirodriguezm authored Mar 20, 2023
2 parents d7dfdcd + 02cac31 commit 530c143
Show file tree
Hide file tree
Showing 10 changed files with 377 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/feature-step/.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/feature-step/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
appVersion: "rc"
description: Step for feature calculation
name: feature-step
type: application
version: 0.1.0
68 changes: 68 additions & 0 deletions charts/feature-step/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "feature-step.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 "feature-step.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 "feature-step.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "feature-step.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "feature-step.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 }}
15 changes: 15 additions & 0 deletions charts/feature-step/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "feature-step.fullname" . }}
namespace: {{ .Values.namespace }}
data:
consumer-topics: {{ .Values.configmap.consumerTopics }}
internal-server: {{ .Values.configmap.internalServer }}
producer-topic: {{ .Values.configmap.producerTopic }}
feature-version: {{ .Values.configmap.featureVersion }}
step-version: {{ .Values.configmap.stepVersion }}
db-engine: {{ .Values.configmap.dbEngine }}
db-host: {{ .Values.configmap.dbHost }}
db-port: "{{ .Values.configmap.dbPort }}"
db-name: {{ .Values.configmap.dbName }}
123 changes: 123 additions & 0 deletions charts/feature-step/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "feature-step.fullname" . }}
namespace: {{ .Values.namespace }}
labels:
{{- include "feature-step.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "feature-step.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "feature-step.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 "feature-step.fullname" . }}
key: consumer-topics
- name: CONSUMER_SERVER
valueFrom:
configMapKeyRef:
name: {{ include "feature-step.fullname" . }}
key: internal-server
- name: CONSUMER_GROUP_ID
value: {{ include "feature-step.fullname" . }}
- name: PRODUCER_SERVER
valueFrom:
configMapKeyRef:
name: {{ include "feature-step.fullname" . }}
key: internal-server
- name: PRODUCER_TOPIC
valueFrom:
configMapKeyRef:
name: {{ include "feature-step.fullname" . }}
key: producer-topic
- name: METRICS_HOST
valueFrom:
configMapKeyRef:
name: {{ include "feature-step.fullname" . }}
key: internal-server
- name: METRICS_TOPIC
value: "metrics"
- name: FEATURE_VERSION
valueFrom:
configMapKeyRef:
name: {{ include "feature-step.fullname" . }}
key: feature-version
- name: STEP_VERSION
valueFrom:
configMapKeyRef:
name: {{ include "feature-step.fullname" . }}
key: step-version
- name: DB_ENGINE
valueFrom:
configMapKeyRef:
name: {{ include "feature-step.fullname" . }}
key: db-engine
- name: DB_HOST
valueFrom:
configMapKeyRef:
name: {{ include "feature-step.fullname" . }}
key: db-host
- name: DB_PORT
valueFrom:
configMapKeyRef:
name: {{ include "feature-step.fullname" . }}
key: db-port
- name: DB_NAME
valueFrom:
configMapKeyRef:
name: {{ include "feature-step.fullname" . }}
key: db-name
- name: DB_USER
valueFrom:
secretKeyRef:
name: '{{ include "feature-step.fullname" . }}-db'
key: username
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: '{{ include "feature-step.fullname" . }}-db'
key: password
{{- if .Values.secrets.kafkaAuth.enabled }}
- name: KAFKA_USERNAME
valueFrom:
secretKeyRef:
name: kafka-auth
key: username
- name: KAFKA_PASSWORD
valueFrom:
secretKeyRef:
name: kafka-auth
key: password
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
28 changes: 28 additions & 0 deletions charts/feature-step/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 "feature-step.fullname" . }}
labels:
{{- include "feature-step.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "feature-step.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/feature-step/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 }}
26 changes: 26 additions & 0 deletions charts/feature-step/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v1
kind: Secret
metadata:
name: '{{ include "feature-step.fullname" . }}-db'
namespace: {{ .Values.namespace }}
stringData:
username: {{ .Values.secrets.db.username }}
password: {{ .Values.secrets.db.password }}
---
apiVersion: v1
kind: Secret
metadata:
name: image-pull-access
namespace: {{ .Values.namespace }}
type: kubernetes.io/dockerconfigjson
data:
.dockerconfigjson: {{ template "imagePullSecret" . }}
---
apiVersion: v1
kind: Secret
metadata:
name: kafka-auth
namespace: {{ .Values.namespace }}
stringData:
username: {{ .Values.secrets.kafkaAuth.username }}
password: {{ .Values.secrets.kafkaAuth.password }}
15 changes: 15 additions & 0 deletions charts/feature-step/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "feature-step.fullname" . }}
labels:
{{- include "feature-step.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "feature-step.selectorLabels" . | nindent 4 }}
67 changes: 67 additions & 0 deletions charts/feature-step/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Default values for step_starter.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

namespace: feature-step

image:
repository: ghcr.io/alercebroker/feature_step
pullPolicy: Always
# 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: ""
producerTopic: ""
dbEngine: ""
dbHost: ""
dbPort: ""
dbName: ""

secrets:
db:
username: ""
password: ""
kafkaAuth:
enabled: false
username: ""
password: ""

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

0 comments on commit 530c143

Please sign in to comment.