From a01bf08bf09e979303e1cc2b4267e363aff598e5 Mon Sep 17 00:00:00 2001 From: Pedro Gallardo Date: Fri, 3 Mar 2023 14:22:00 -0300 Subject: [PATCH] feat: added chart for prv candidates step --- .gitignore | 1 + charts/prv_candidates/.helmignore | 23 +++++ charts/prv_candidates/Chart.yaml | 6 ++ charts/prv_candidates/templates/_helpers.tpl | 68 +++++++++++++++ .../prv_candidates/templates/configmap.yaml | 11 +++ .../prv_candidates/templates/deployment.yaml | 84 +++++++++++++++++++ charts/prv_candidates/templates/hpa.yaml | 28 +++++++ .../prv_candidates/templates/namespace.yaml | 6 ++ charts/prv_candidates/templates/secret.yaml | 8 ++ charts/prv_candidates/templates/service.yaml | 15 ++++ charts/prv_candidates/values.yaml | 56 +++++++++++++ 11 files changed, 306 insertions(+) create mode 100644 charts/prv_candidates/.helmignore create mode 100644 charts/prv_candidates/Chart.yaml create mode 100644 charts/prv_candidates/templates/_helpers.tpl create mode 100644 charts/prv_candidates/templates/configmap.yaml create mode 100644 charts/prv_candidates/templates/deployment.yaml create mode 100644 charts/prv_candidates/templates/hpa.yaml create mode 100644 charts/prv_candidates/templates/namespace.yaml create mode 100644 charts/prv_candidates/templates/secret.yaml create mode 100644 charts/prv_candidates/templates/service.yaml create mode 100644 charts/prv_candidates/values.yaml diff --git a/.gitignore b/.gitignore index 189a4ce..e7921df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ values.override.yaml +values.override.yml *.tgz \ No newline at end of file diff --git a/charts/prv_candidates/.helmignore b/charts/prv_candidates/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/prv_candidates/.helmignore @@ -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/ diff --git a/charts/prv_candidates/Chart.yaml b/charts/prv_candidates/Chart.yaml new file mode 100644 index 0000000..f28411d --- /dev/null +++ b/charts/prv_candidates/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +appVersion: "rc-51c2f55" +description: A Helm chart for Kubernetes +name: prv-candidates +type: application +version: 0.1.0 diff --git a/charts/prv_candidates/templates/_helpers.tpl b/charts/prv_candidates/templates/_helpers.tpl new file mode 100644 index 0000000..944ebae --- /dev/null +++ b/charts/prv_candidates/templates/_helpers.tpl @@ -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 }} \ No newline at end of file diff --git a/charts/prv_candidates/templates/configmap.yaml b/charts/prv_candidates/templates/configmap.yaml new file mode 100644 index 0000000..d14140c --- /dev/null +++ b/charts/prv_candidates/templates/configmap.yaml @@ -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 }} \ No newline at end of file diff --git a/charts/prv_candidates/templates/deployment.yaml b/charts/prv_candidates/templates/deployment.yaml new file mode 100644 index 0000000..4d10667 --- /dev/null +++ b/charts/prv_candidates/templates/deployment.yaml @@ -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 }} diff --git a/charts/prv_candidates/templates/hpa.yaml b/charts/prv_candidates/templates/hpa.yaml new file mode 100644 index 0000000..37399a6 --- /dev/null +++ b/charts/prv_candidates/templates/hpa.yaml @@ -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 }} diff --git a/charts/prv_candidates/templates/namespace.yaml b/charts/prv_candidates/templates/namespace.yaml new file mode 100644 index 0000000..4df0747 --- /dev/null +++ b/charts/prv_candidates/templates/namespace.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: {{ .Values.namespace }} + labels: + name: {{ .Values.namespace }} \ No newline at end of file diff --git a/charts/prv_candidates/templates/secret.yaml b/charts/prv_candidates/templates/secret.yaml new file mode 100644 index 0000000..a36eb4d --- /dev/null +++ b/charts/prv_candidates/templates/secret.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: image-pull-access + namespace: {{ .Values.namespace }} +type: kubernetes.io/dockerconfigjson +data: + .dockerconfigjson: {{ template "imagePullSecret" . }} \ No newline at end of file diff --git a/charts/prv_candidates/templates/service.yaml b/charts/prv_candidates/templates/service.yaml new file mode 100644 index 0000000..ba1f5b3 --- /dev/null +++ b/charts/prv_candidates/templates/service.yaml @@ -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 }} diff --git a/charts/prv_candidates/values.yaml b/charts/prv_candidates/values.yaml new file mode 100644 index 0000000..a2c306a --- /dev/null +++ b/charts/prv_candidates/values.yaml @@ -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: "" \ No newline at end of file