From cbd784128134fd0d2f0b54d79e9bbffef3e08674 Mon Sep 17 00:00:00 2001 From: Abduh Date: Wed, 16 Nov 2022 13:16:10 +0700 Subject: [PATCH] feat(siren): use app chart and upgrade version (#84) * feat(siren): use app chart and upgrade version * fix(siren): update chart deps * fix(siren): add helm ignore and remove Chart.lock --- stable/siren/.helmignore | 23 +++ stable/siren/Chart.yaml | 27 +++- stable/siren/templates/NOTES.txt | 17 --- stable/siren/templates/_helper.tpl | 25 ---- stable/siren/templates/config.yaml | 11 -- stable/siren/templates/deployment.yaml | 69 --------- stable/siren/templates/ingress.yaml | 30 ---- stable/siren/templates/secret.yaml | 14 -- stable/siren/templates/service.yaml | 30 ---- stable/siren/values.yaml | 199 ++++++++++++++----------- 10 files changed, 154 insertions(+), 291 deletions(-) create mode 100644 stable/siren/.helmignore delete mode 100644 stable/siren/templates/NOTES.txt delete mode 100644 stable/siren/templates/_helper.tpl delete mode 100644 stable/siren/templates/config.yaml delete mode 100644 stable/siren/templates/deployment.yaml delete mode 100644 stable/siren/templates/ingress.yaml delete mode 100644 stable/siren/templates/secret.yaml delete mode 100644 stable/siren/templates/service.yaml diff --git a/stable/siren/.helmignore b/stable/siren/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/stable/siren/.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/stable/siren/Chart.yaml b/stable/siren/Chart.yaml index 5e7cf82f..4c52bd44 100644 --- a/stable/siren/Chart.yaml +++ b/stable/siren/Chart.yaml @@ -1,9 +1,22 @@ -apiVersion: v1 -description: Siren Helm chart +apiVersion: v2 name: siren -version: 0.0.1 -appVersion: v0.0.1 +description: Siren Helm chart +version: 0.1.0 +appVersion: v0.5.0 home: https://github.com/odpf/siren -sources: -- https://github.com/odpf/siren -- https://github.com/odpf/charts +dependencies: +- name: app + version: "0.4.2" + repository: "https://odpf.github.io/charts/" + alias: siren-app + condition: siren-app.enabled +- name: app + version: "0.4.2" + repository: "https://odpf.github.io/charts/" + alias: siren-notification-worker + condition: siren-notification-worker.enabled +- name: app + version: "0.4.2" + repository: "https://odpf.github.io/charts/" + alias: siren-notification-dlq-worker + condition: siren-notification-dlq-worker.enabled diff --git a/stable/siren/templates/NOTES.txt b/stable/siren/templates/NOTES.txt deleted file mode 100644 index 6976657f..00000000 --- a/stable/siren/templates/NOTES.txt +++ /dev/null @@ -1,17 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.hostname }} - http://{{- .Values.ingress.hostname }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "siren.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "siren.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "siren.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.externalPort }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "siren.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - kubectl port-forward --namespace {{ .Release.Namespace }} $POD_NAME 3000:{{ .Values.service.internalPort }} - echo "Visit http://127.0.0.1:3000 to use your application" -{{- end }} diff --git a/stable/siren/templates/_helper.tpl b/stable/siren/templates/_helper.tpl deleted file mode 100644 index 9ca7a39c..00000000 --- a/stable/siren/templates/_helper.tpl +++ /dev/null @@ -1,25 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "siren.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 "siren.fullname" -}} - {{- if .Values.fullnameOverride -}} - {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} - {{- else -}} - {{- $name := default .Chart.Name .Values.nameOverride -}} - {{- if contains $name .Release.Name -}} - {{- printf .Release.Name | trunc 63 | trimSuffix "-" -}} - {{- else -}} - {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} - {{- end -}} - {{- end -}} -{{- end -}} diff --git a/stable/siren/templates/config.yaml b/stable/siren/templates/config.yaml deleted file mode 100644 index 6ff05ba9..00000000 --- a/stable/siren/templates/config.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ template "siren.fullname" . }}-config - namespace: {{ .Release.Namespace }} - labels: - {{- if .Values.labels }} - {{- toYaml .Values.labels | trim | nindent 4 }} - {{- end }} -data: - {{- toYaml .Values.config | nindent 2 }} diff --git a/stable/siren/templates/deployment.yaml b/stable/siren/templates/deployment.yaml deleted file mode 100644 index 336b9300..00000000 --- a/stable/siren/templates/deployment.yaml +++ /dev/null @@ -1,69 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ template "siren.fullname" . }} - namespace: {{ .Release.Namespace }} - labels: - {{- if .Values.labels }} - {{- toYaml .Values.labels | trim | nindent 4 }} - {{- end }} - run: {{ .Release.Name }} -spec: - replicas: {{ .Values.replicaCount }} - selector: - matchLabels: - run: {{ .Release.Name }} - template: - metadata: - annotations: - checksum/config: {{ include (print $.Template.BasePath "/config.yaml") . | sha256sum }} - {{- if .Values.podAnnotations }} - {{- toYaml .Values.podAnnotations | trim | nindent 8 }} - {{- end }} - labels: - {{- if .Values.labels }} - {{- toYaml .Values.labels | trim | nindent 8 }} - {{- end }} - run: {{ .Release.Name }} - spec: - containers: - - name: siren - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - args: ["serve"] - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - containerPort: {{ .Values.service.internalPort }} - protocol: TCP - livenessProbe: - httpGet: - path: {{ .Values.livenessProbe.httpGetPath }} - port: {{ .Values.service.internalPort }} - initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} - timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} - failureThreshold: {{ .Values.livenessProbe.failureThreshold }} - readinessProbe: - httpGet: - path: {{ .Values.readinessProbe.httpGetPath }} - port: {{ .Values.service.internalPort }} - initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }} - timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} - periodSeconds: {{ .Values.readinessProbe.periodSeconds }} - envFrom: - - configMapRef: - name: {{ template "siren.fullname" . }}-config - - secretRef: - name: {{ template "siren.fullname" . }}-secret - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/stable/siren/templates/ingress.yaml b/stable/siren/templates/ingress.yaml deleted file mode 100644 index cc3f1495..00000000 --- a/stable/siren/templates/ingress.yaml +++ /dev/null @@ -1,30 +0,0 @@ -{{- if .Values.ingress.enabled -}} - {{- $serviceName := include "siren.fullname" . -}} - {{- $servicePort := .Values.service.externalPort -}} - {{- $ingressPath := .Values.ingress.path -}} -apiVersion: networking.k8s.io/v1beta1 -kind: Ingress -metadata: - name: {{ template "siren.fullname" . }} - namespace: {{ .Release.Namespace }} - labels: - {{- if .Values.ingress.labels }} - {{- toYaml .Values.ingress.labels | nindent 4 }} - {{- end}} - run: {{ .Release.Name }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end}} -spec: - rules: - {{- range $host := .Values.ingress.hosts }} - - host: {{ $host }} - http: - paths: - - path: {{ $ingressPath }} - backend: - serviceName: {{ $serviceName }} - servicePort: {{ $servicePort }} - {{- end -}} -{{- end -}} diff --git a/stable/siren/templates/secret.yaml b/stable/siren/templates/secret.yaml deleted file mode 100644 index 00281ed8..00000000 --- a/stable/siren/templates/secret.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: {{ template "siren.fullname" . }}-secret - namespace: {{ .Release.Namespace }} - labels: - {{- if .Values.labels }} - {{- toYaml .Values.labels | trim | nindent 4 }} - {{- end }} -type: Opaque -data: - {{- range $key, $val := .Values.secretConfig -}} - {{- (print $key ": " ($val | toString | b64enc | quote )) | nindent 2 -}} - {{- end }} diff --git a/stable/siren/templates/service.yaml b/stable/siren/templates/service.yaml deleted file mode 100644 index 6bf5608e..00000000 --- a/stable/siren/templates/service.yaml +++ /dev/null @@ -1,30 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ template "siren.fullname" . }} - namespace: {{ .Release.Namespace }} - labels: - {{- if .Values.labels }} - {{- toYaml .Values.labels | trim | nindent 4 }} - {{- end }} - {{- if .Values.service.annotations }} - run: {{ .Release.Name }} - annotations: - {{- toYaml .Values.service.annotations | nindent 4 }} - {{- end }} -spec: - type: {{ .Values.service.type }} - {{- if .Values.service.loadBalancerSourceRanges}} - loadBalancerSourceRanges: - {{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }} - {{- end}} - ports: - - port: {{ .Values.service.externalPort }} - targetPort: {{ .Values.service.internalPort }} - {{- if .Values.service.nodePort }} - nodePort: {{ .Values.service.nodePort }} - {{- end}} - protocol: TCP - name: {{ template "siren.name" . }} - selector: - run: {{ .Release.Name }} diff --git a/stable/siren/values.yaml b/stable/siren/values.yaml index 319a382f..e18b17ae 100644 --- a/stable/siren/values.yaml +++ b/stable/siren/values.yaml @@ -1,99 +1,122 @@ -replicaCount: 1 -podAnnotations: {} -labels: {} -## String to fully override siren.fullname template -## -# fullnameOverride: -## String to fully override siren.name template -## -# nameOverride: +siren-app: + image: + repository: odpf/siren + pullPolicy: Always + tag: latest + container: + args: + - server + - start + livenessProbe: + httpGet: + path: /ping + port: tcp + readinessProbe: + httpGet: + path: /ping + port: tcp -image: - # -- Image to use for deploying siren - repository: odpf/siren - tag: v0.2.0 - pullPolicy: IfNotPresent + migration: + enabled: true + args: + - server + - migrate -# -- Environement variables needed by siren -config: - CORTEX_ALERTMANAGER_URL: "http://localhost:8080" + service: + annotations: + projectcontour.io/upstream-protocol.h2c: tcp -secretConfig: - # -- Postgres database connection details - DB_HOST: localhost - DB_NAME: siren - DB_USER: "" - DB_PASSWORD: "" - DB_PORT: 5432 + ingress: + enabled: true + annotations: + kubernetes.io/ingress.class: contour + hosts: + - host: siren.example.com + paths: + - path: / + pathType: ImplementationSpecific + backend: + service: + port: + number: 80 + config: + # SERVICE_PORT: 80 + DB_DRIVER: postgres + NOTIFICATION_QUEUE_KIND: postgres + NOTIFICATION_MESSAGE_HANDLER_ENABLED: false + NOTIFICATION_MESSAGE_DLQ_HANDLER_ENABLED: false + # PROVIDERS_CORTEX_WEBHOOK_BASE_API: http://localhost:8080/v1beta1/alerts/cortex + + secretConfig: + DB_URL: postgres://postgres:@localhost:5432/siren?sslmode=disable + SERVICE_ENCRYPTION_KEY: ____STRING_OF_32_CHARACTERS_____ -ingress: - # -- Kubernetes ingress details - enabled: true - # -- Used to create Ingress record (should used with service.type: ClusterIP). - hosts: - - siren.example.com - # -- The ingress path. Useful to host siren on a subpath, such as `/v1`. - path: / - labels: - # -- Used to add custom labels to the Ingress - # Useful if for example you have multiple Ingress controllers and want your Ingress controllers to bind to specific Ingresses - # traffic: internal - annotations: - kubernetes.io/ingress.class: contour - # kubernetes.io/tls-acme: "true" +siren-notification-worker: + image: + repository: odpf/siren + pullPolicy: Always + tag: latest + container: + args: + - worker + - start + - notification_handler + # livenessProbe: + # exec: + # command: + # - /bin/bash + # - -c + # - ps -ef | grep siren | grep -v grep + # initialDelaySeconds: 10 + # periodSeconds: 10 -service: - # -- Kubernetes service details - type: ClusterIP - # loadBalancerSourceRanges: - externalPort: 80 - internalPort: 3000 - # -- Used to fix NodePort when service.type: NodePort. - nodePort: - annotations: - {} - # Used to add custom annotations to the Service. - # service.beta.kubernetes.io/aws-load-balancer-internal: "0.0.0.0/0" + migration: + enabled: false -livenessProbe: - # -- Kubernetes liveness probe configs - httpGetPath: /ping - initialDelaySeconds: 120 - timeoutSeconds: 30 - failureThreshold: 6 + ingress: + enabled: false -readinessProbe: - # -- Kubernetes readiness probe configs - httpGetPath: /ping - initialDelaySeconds: 30 - timeoutSeconds: 3 - periodSeconds: 5 + config: + DB_DRIVER: postgres + NOTIFICATION_QUEUE_KIND: postgres + NOTIFICATION_MESSAGE_HANDLER_ENABLED: false + NOTIFICATION_MESSAGE_DLQ_HANDLER_ENABLED: false + + secretConfig: + DB_URL: postgres://postgres:@localhost:5432/siren?sslmode=disable + SERVICE_ENCRYPTION_KEY: ____STRING_OF_32_CHARACTERS_____ -resources: - # -- Kubernetes resource details - {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi +siren-notification-dlq-worker: + image: + repository: odpf/siren + pullPolicy: Always + tag: latest + container: + args: + - worker + - start + - notification_dlq_handler + # livenessProbe: + # exec: + # command: + # - /bin/bash + # - -c + # - ps -ef | grep siren | grep -v grep + # initialDelaySeconds: 10 + # periodSeconds: 10 -## Node labels for pod assignment -## ref: https://kubernetes.io/docs/user-guide/node-selection/ -# -nodeSelector: {} + migration: + enabled: false -## Tolerations for pod assignment -## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ -## -tolerations: [] + ingress: + enabled: false + + config: + DB_DRIVER: postgres + NOTIFICATION_QUEUE_KIND: postgres + NOTIFICATION_MESSAGE_HANDLER_ENABLED: false + NOTIFICATION_MESSAGE_DLQ_HANDLER_ENABLED: false -## Affinity for pod assignment -## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity -## -affinity: {} + secretConfig: + DB_URL: postgres://postgres:@localhost:5432/siren?sslmode=disable + SERVICE_ENCRYPTION_KEY: ____STRING_OF_32_CHARACTERS_____