From 96676dc67bd742175fc76f45e934e59d26fe62f1 Mon Sep 17 00:00:00 2001 From: Diego Date: Thu, 23 Mar 2023 16:41:54 -0300 Subject: [PATCH] feat(lightcurve): add chart --- charts/lightcurve-step/.helmignore | 23 ++++ charts/lightcurve-step/Chart.yaml | 6 + charts/lightcurve-step/templates/_helpers.tpl | 68 ++++++++++ .../lightcurve-step/templates/configmap.yaml | 14 ++ .../lightcurve-step/templates/deployment.yaml | 120 ++++++++++++++++++ charts/lightcurve-step/templates/hpa.yaml | 28 ++++ .../lightcurve-step/templates/namespace.yaml | 6 + charts/lightcurve-step/templates/secret.yaml | 22 ++++ charts/lightcurve-step/templates/service.yaml | 15 +++ charts/lightcurve-step/values.yaml | 74 +++++++++++ 10 files changed, 376 insertions(+) create mode 100644 charts/lightcurve-step/.helmignore create mode 100644 charts/lightcurve-step/Chart.yaml create mode 100644 charts/lightcurve-step/templates/_helpers.tpl create mode 100644 charts/lightcurve-step/templates/configmap.yaml create mode 100644 charts/lightcurve-step/templates/deployment.yaml create mode 100644 charts/lightcurve-step/templates/hpa.yaml create mode 100644 charts/lightcurve-step/templates/namespace.yaml create mode 100644 charts/lightcurve-step/templates/secret.yaml create mode 100644 charts/lightcurve-step/templates/service.yaml create mode 100644 charts/lightcurve-step/values.yaml diff --git a/charts/lightcurve-step/.helmignore b/charts/lightcurve-step/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/lightcurve-step/.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/lightcurve-step/Chart.yaml b/charts/lightcurve-step/Chart.yaml new file mode 100644 index 0000000..c11530c --- /dev/null +++ b/charts/lightcurve-step/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +appVersion: rc-123029d +description: Full lightcurve provider step +name: lightcurve-step +type: application +version: 0.1.0 diff --git a/charts/lightcurve-step/templates/_helpers.tpl b/charts/lightcurve-step/templates/_helpers.tpl new file mode 100644 index 0000000..00b5936 --- /dev/null +++ b/charts/lightcurve-step/templates/_helpers.tpl @@ -0,0 +1,68 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "lightcurve-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 "lightcurve-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 "lightcurve-step.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "lightcurve-step.labels" -}} +helm.sh/chart: {{ include "lightcurve-step.chart" . }} +{{ include "lightcurve-step.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "lightcurve-step.selectorLabels" -}} +app.kubernetes.io/name: {{ include "lightcurve-step.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "lightcurve-step.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "lightcurve-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 }} \ No newline at end of file diff --git a/charts/lightcurve-step/templates/configmap.yaml b/charts/lightcurve-step/templates/configmap.yaml new file mode 100644 index 0000000..b4bbcd2 --- /dev/null +++ b/charts/lightcurve-step/templates/configmap.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "lightcurve-step.fullname" . }} + namespace: {{ .Values.namespace }} +data: + consumer-topics: {{ .Values.configmap.consumerTopics }} + consume-messages: "{{ .Values.configmap.consumeMessages }}" + consumer-server: {{ .Values.configmap.consumerServer }} + producer-server: {{ .Values.configmap.producerServer }} + producer-topic: {{ .Values.configmap.producerTopic }} + metrics-server: {{ .Values.configmap.metricsServer }} + metrics-topic: {{ .Values.configmap.metricsTopic }} + use-prometheus: "{{ .Values.configmap.usePrometheus }}" \ No newline at end of file diff --git a/charts/lightcurve-step/templates/deployment.yaml b/charts/lightcurve-step/templates/deployment.yaml new file mode 100644 index 0000000..3a57382 --- /dev/null +++ b/charts/lightcurve-step/templates/deployment.yaml @@ -0,0 +1,120 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "lightcurve-step.fullname" . }} + namespace: {{ .Values.namespace }} + labels: + {{- include "lightcurve-step.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "lightcurve-step.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "lightcurve-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 "lightcurve-step.fullname" . }} + key: consumer-topics + - name: CONSUMER_SERVER + valueFrom: + configMapKeyRef: + name: {{ include "lightcurve-step.fullname" . }} + key: consumer-server + - name: CONSUME_MESSAGES + valueFrom: + configMapKeyRef: + name: {{ include "lightcurve-step.fullname" . }} + key: consume-messages + - name: CONSUMER_GROUP_ID + value: {{ include "lightcurve-step.fullname" . }} + - name: PRODUCER_SERVER + valueFrom: + configMapKeyRef: + name: {{ include "lightcurve-step.fullname" . }} + key: producer-server + - name: PRODUCER_TOPIC + valueFrom: + configMapKeyRef: + name: {{ include "lightcurve-step.fullname" . }} + key: producer-topic + - name: METRICS_SERVER + valueFrom: + configMapKeyRef: + name: {{ include "lightcurve-step.fullname" . }} + key: metrics-server + - name: METRICS_TOPIC + valueFrom: + configMapKeyRef: + name: {{ include "lightcurve-step.fullname" . }} + key: metrics-topic + {{- if .Values.secrets.kafkaAuth.consumer.enabled }} + - name: CONSUMER_KAFKA_USERNAME + valueFrom: + secretKeyRef: + name: kafka-auth + key: username + - name: CONSUMER_KAFKA_PASSWORD + valueFrom: + secretKeyRef: + name: kafka-auth + key: password + {{- end }} + {{- if .Values.secrets.kafkaAuth.producer.enabled }} + - name: PRODUCER_KAFKA_USERNAME + valueFrom: + secretKeyRef: + name: kafka-auth + key: username + - name: PRODUCER_KAFKA_PASSWORD + valueFrom: + secretKeyRef: + name: kafka-auth + key: password + {{- end }} + {{- if .Values.secrets.kafkaAuth.metrics.enabled }} + - name: METRICS_KAFKA_USERNAME + valueFrom: + secretKeyRef: + name: kafka-auth + key: username + - name: METRICS_KAFKA_PASSWORD + valueFrom: + secretKeyRef: + name: kafka-auth + key: password + {{- end }} + - name: USE_PROMETHEUS + valueFrom: + configMapKeyRef: + name: {{ include "lightcurve-step.fullname" . }} + key: use-prometheus + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/lightcurve-step/templates/hpa.yaml b/charts/lightcurve-step/templates/hpa.yaml new file mode 100644 index 0000000..f77fa3c --- /dev/null +++ b/charts/lightcurve-step/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "lightcurve-step.fullname" . }} + labels: + {{- include "lightcurve-step.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "lightcurve-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 }} diff --git a/charts/lightcurve-step/templates/namespace.yaml b/charts/lightcurve-step/templates/namespace.yaml new file mode 100644 index 0000000..4df0747 --- /dev/null +++ b/charts/lightcurve-step/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/lightcurve-step/templates/secret.yaml b/charts/lightcurve-step/templates/secret.yaml new file mode 100644 index 0000000..cc95153 --- /dev/null +++ b/charts/lightcurve-step/templates/secret.yaml @@ -0,0 +1,22 @@ +--- +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: + consumer-username: "{{ .Values.secrets.kafkaAuth.consumer.username }}" + consumer-password: "{{ .Values.secrets.kafkaAuth.consumer.password }}" + producer-username: "{{ .Values.secrets.kafkaAuth.producer.username }}" + producer-password: "{{ .Values.secrets.kafkaAuth.producer.password }}" + metrics-username: "{{ .Values.secrets.kafkaAuth.metrics.username }}" + metrics-password: "{{ .Values.secrets.kafkaAuth.metrics.password }}" \ No newline at end of file diff --git a/charts/lightcurve-step/templates/service.yaml b/charts/lightcurve-step/templates/service.yaml new file mode 100644 index 0000000..6c958a2 --- /dev/null +++ b/charts/lightcurve-step/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "lightcurve-step.fullname" . }} + labels: + {{- include "lightcurve-step.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "lightcurve-step.selectorLabels" . | nindent 4 }} diff --git a/charts/lightcurve-step/values.yaml b/charts/lightcurve-step/values.yaml new file mode 100644 index 0000000..6992015 --- /dev/null +++ b/charts/lightcurve-step/values.yaml @@ -0,0 +1,74 @@ +# Default values for step_starter. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +namespace: lightcurve-step + +image: + repository: ghcr.io/alercebroker/lightcurve_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: "" + consumeMessages: "" + consumerServer: "" + producerServer: "" + producerTopic: "" + metricsServer: "" + metricsTopic: "" + usePrometheus: "" + +secrets: + kafkaAuth: + consumer: + enabled: false + username: "" + password: "" + producer: + enabled: false + username: "" + password: "" + metrics: + enabled: false + username: "" + password: "" + +imageCredentials: + registry: "" + username: "" + password: "" + email: "" \ No newline at end of file