From 6c94a52bc2b6e54164a8c9d5ffafe4da3a4221bd Mon Sep 17 00:00:00 2001 From: Kyle Espinola Date: Mon, 27 Feb 2023 12:56:30 +0100 Subject: [PATCH] feat: chart for hub-credentials and hub-identitites and hub-orgs updates --- charts/hub-credentials/.helmignore | 23 ++++++ charts/hub-credentials/Chart.yaml | 27 +++++++ charts/hub-credentials/templates/NOTES.txt | 0 charts/hub-credentials/templates/_helpers.tpl | 62 +++++++++++++++ .../hub-credentials/templates/deployment.yaml | 69 +++++++++++++++++ .../templates/environment.yaml | 10 +++ charts/hub-credentials/templates/hpa.yaml | 28 +++++++ charts/hub-credentials/templates/secrets.yaml | 13 ++++ charts/hub-credentials/templates/service.yaml | 17 +++++ .../templates/serviceaccount.yaml | 12 +++ charts/hub-credentials/values.yaml | 76 +++++++++++++++++++ charts/hub-identities/Chart.yaml | 2 +- .../hub-identities/templates/deployment.yaml | 2 + .../hub-identities/templates/environment.yaml | 2 +- charts/hub-identities/templates/secrets.yaml | 13 ++++ charts/hub-identities/values.yaml | 7 +- charts/hub-orgs/Chart.yaml | 2 +- charts/hub-orgs/templates/environment.yaml | 1 - charts/hub-orgs/templates/secrets.yaml | 1 - charts/hub-orgs/values.yaml | 6 +- 20 files changed, 363 insertions(+), 10 deletions(-) create mode 100644 charts/hub-credentials/.helmignore create mode 100644 charts/hub-credentials/Chart.yaml create mode 100644 charts/hub-credentials/templates/NOTES.txt create mode 100644 charts/hub-credentials/templates/_helpers.tpl create mode 100644 charts/hub-credentials/templates/deployment.yaml create mode 100644 charts/hub-credentials/templates/environment.yaml create mode 100644 charts/hub-credentials/templates/hpa.yaml create mode 100644 charts/hub-credentials/templates/secrets.yaml create mode 100644 charts/hub-credentials/templates/service.yaml create mode 100644 charts/hub-credentials/templates/serviceaccount.yaml create mode 100644 charts/hub-credentials/values.yaml create mode 100644 charts/hub-identities/templates/secrets.yaml diff --git a/charts/hub-credentials/.helmignore b/charts/hub-credentials/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/hub-credentials/.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/hub-credentials/Chart.yaml b/charts/hub-credentials/Chart.yaml new file mode 100644 index 0000000..8a29a6a --- /dev/null +++ b/charts/hub-credentials/Chart.yaml @@ -0,0 +1,27 @@ +apiVersion: v2 +name: hub-credentials +description: Helm chart for hub-credentials +maintainers: + - name: Holaplex Engineering + email: engineering@holaplex.com + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "0.1.0" diff --git a/charts/hub-credentials/templates/NOTES.txt b/charts/hub-credentials/templates/NOTES.txt new file mode 100644 index 0000000..e69de29 diff --git a/charts/hub-credentials/templates/_helpers.tpl b/charts/hub-credentials/templates/_helpers.tpl new file mode 100644 index 0000000..d593358 --- /dev/null +++ b/charts/hub-credentials/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "hub-credentials.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 "hub-credentials.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 "hub-credentials.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "hub-credentials.labels" -}} +helm.sh/chart: {{ include "hub-credentials.chart" . }} +{{ include "hub-credentials.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "hub-credentials.selectorLabels" -}} +app.kubernetes.io/name: {{ include "hub-credentials.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "hub-credentials.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "hub-credentials.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/hub-credentials/templates/deployment.yaml b/charts/hub-credentials/templates/deployment.yaml new file mode 100644 index 0000000..2688c77 --- /dev/null +++ b/charts/hub-credentials/templates/deployment.yaml @@ -0,0 +1,69 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "hub-credentials.fullname" . }} + labels: + {{- include "hub-credentials.labels" . | nindent 4 }} + app.kubernetes.io/component: api +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "hub-credentials.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: api + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "hub-credentials.selectorLabels" . | nindent 8 }} + app.kubernetes.io/component: api + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "hub-credentials.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: api + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + envFrom: + - configMapRef: + name: {{ include "hub-credentials.fullname" . }} + - secretRef: + name: {{ include "hub-credentials.fullname" . }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + httpGet: + path: /health + port: http + readinessProbe: + httpGet: + path: /health + port: http + 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/charts/hub-credentials/templates/environment.yaml b/charts/hub-credentials/templates/environment.yaml new file mode 100644 index 0000000..0d79147 --- /dev/null +++ b/charts/hub-credentials/templates/environment.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "hub-credentials.fullname" . }} +data: + {{- with .Values.environment }} + ORY_ADMIN_BASE_URL: {{ .oryAdminBaseUrl }} + ORY_PUBLIC_BASE_URL: {{ .oryPublicBaseUrl }} + PORT: {{ .port | quote }} + {{- end }} diff --git a/charts/hub-credentials/templates/hpa.yaml b/charts/hub-credentials/templates/hpa.yaml new file mode 100644 index 0000000..9824763 --- /dev/null +++ b/charts/hub-credentials/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "hub-credentials.fullname" . }} + labels: + {{- include "hub-credentials.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "hub-credentials.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/hub-credentials/templates/secrets.yaml b/charts/hub-credentials/templates/secrets.yaml new file mode 100644 index 0000000..10c464b --- /dev/null +++ b/charts/hub-credentials/templates/secrets.yaml @@ -0,0 +1,13 @@ +{{- with .Values.secrets }} +{{- if .enabled }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "hub-credentials.fullname" $ }} + annotations: + "helm.sh/hook": pre-install +type: Opaque +data: + ORY_AUTH_TOKEN: {{ .entries.oryAuthToken | b64enc }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/hub-credentials/templates/service.yaml b/charts/hub-credentials/templates/service.yaml new file mode 100644 index 0000000..8176e7d --- /dev/null +++ b/charts/hub-credentials/templates/service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "hub-credentials.fullname" . }} + labels: + {{- include "hub-credentials.labels" . | nindent 4 }} + app.kubernetes.io/component: api +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "hub-credentials.selectorLabels" . | nindent 4 }} + app.kubernetes.io/component: api diff --git a/charts/hub-credentials/templates/serviceaccount.yaml b/charts/hub-credentials/templates/serviceaccount.yaml new file mode 100644 index 0000000..b9adf9c --- /dev/null +++ b/charts/hub-credentials/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "hub-credentials.serviceAccountName" . }} + labels: + {{- include "hub-credentials.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/hub-credentials/values.yaml b/charts/hub-credentials/values.yaml new file mode 100644 index 0000000..b4cbee9 --- /dev/null +++ b/charts/hub-credentials/values.yaml @@ -0,0 +1,76 @@ +# Default values for hub-credentials. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: holaplex/hub-credentials + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +resources: {} + # 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 + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +secrets: + enabled: true + entries: + oryAuthToken: "" + +environment: + port: "80" + oryAdminBaseUrl: "http://hydra-admin:4445" + oryPublicBaseUrl: "http://hydra-public:4444" diff --git a/charts/hub-identities/Chart.yaml b/charts/hub-identities/Chart.yaml index 5f04a4b..930e598 100644 --- a/charts/hub-identities/Chart.yaml +++ b/charts/hub-identities/Chart.yaml @@ -18,7 +18,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 +version: 0.2.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/hub-identities/templates/deployment.yaml b/charts/hub-identities/templates/deployment.yaml index 4cb8e90..eee77c6 100644 --- a/charts/hub-identities/templates/deployment.yaml +++ b/charts/hub-identities/templates/deployment.yaml @@ -36,6 +36,8 @@ spec: envFrom: - configMapRef: name: {{ include "hub-identities.fullname" . }} + - secretRef: + name: {{ include "hub-identities.fullname" . }} ports: - name: http containerPort: {{ .Values.service.port }} diff --git a/charts/hub-identities/templates/environment.yaml b/charts/hub-identities/templates/environment.yaml index 2a7c72c..662e197 100644 --- a/charts/hub-identities/templates/environment.yaml +++ b/charts/hub-identities/templates/environment.yaml @@ -3,5 +3,5 @@ kind: ConfigMap metadata: name: {{ include "hub-identities.fullname" . }} data: - KRATOS_ADMIN_ENDPOINT: {{ .Values.environment.kratosAdminEndpoint }} + ORY_BASE_URL: {{ .Values.environment.oryBaseUrl }} PORT: "{{ .Values.environment.port }}" \ No newline at end of file diff --git a/charts/hub-identities/templates/secrets.yaml b/charts/hub-identities/templates/secrets.yaml new file mode 100644 index 0000000..1ad4549 --- /dev/null +++ b/charts/hub-identities/templates/secrets.yaml @@ -0,0 +1,13 @@ +{{- with .Values.secrets }} +{{- if .enabled }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "hub-identities.fullname" $ }} + annotations: + "helm.sh/hook": pre-install +type: Opaque +data: + ORY_AUTH_TOKEN: {{ .entries.oryAuthToken | b64enc }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/hub-identities/values.yaml b/charts/hub-identities/values.yaml index 1f6b355..3e1210a 100644 --- a/charts/hub-identities/values.yaml +++ b/charts/hub-identities/values.yaml @@ -66,5 +66,10 @@ tolerations: [] affinity: {} environment: - kratosAdminEndpoint: http://kratos-admin + oryBaseUrl: http://kratos-admin port: "80" + +secrets: + enabled: true + entries: + oryAuthToken: "" diff --git a/charts/hub-orgs/Chart.yaml b/charts/hub-orgs/Chart.yaml index 07b864d..353ed82 100644 --- a/charts/hub-orgs/Chart.yaml +++ b/charts/hub-orgs/Chart.yaml @@ -18,7 +18,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.3.2 +version: 0.4.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/hub-orgs/templates/environment.yaml b/charts/hub-orgs/templates/environment.yaml index a7dc36e..4cf1ff1 100644 --- a/charts/hub-orgs/templates/environment.yaml +++ b/charts/hub-orgs/templates/environment.yaml @@ -4,7 +4,6 @@ metadata: name: {{ include "hub-orgs.fullname" . }} data: {{- with .Values.environment }} - ORY_BASE_URL: {{ .oryBaseUrl }} PORT: {{ .port | quote }} KAFKA_BROKERS: {{ required "must set kafka brokers" .kafkaBrokers | quote }} KAFKA_USERNAME: {{ .kafkaUsername | quote }} diff --git a/charts/hub-orgs/templates/secrets.yaml b/charts/hub-orgs/templates/secrets.yaml index 9d2a5f2..919d39f 100644 --- a/charts/hub-orgs/templates/secrets.yaml +++ b/charts/hub-orgs/templates/secrets.yaml @@ -10,7 +10,6 @@ type: Opaque data: SVIX_AUTH_TOKEN: {{ .entries.svixAuthToken | b64enc }} DATABASE_URL: {{ .entries.databaseUrl | b64enc }} - ORY_AUTH_TOKEN: {{ .entries.oryAuthToken | b64enc }} KAFKA_PASSWORD: {{ .entries.kafkaPassword | b64enc }} {{- end }} {{- end }} diff --git a/charts/hub-orgs/values.yaml b/charts/hub-orgs/values.yaml index e2a8347..c45f923 100644 --- a/charts/hub-orgs/values.yaml +++ b/charts/hub-orgs/values.yaml @@ -75,15 +75,13 @@ affinity: {} secrets: enabled: true entries: - oryAuthToken: "" databaseUrl: "" svixAuthToken: "" kafkaPassword: "" environment: port: "80" - oryBaseUrl: "http://hydra-admin" - kafkaBrokers: + kafkaBrokers: "hub-eventbus-cluster-0.hub-eventbus-cluster.default.svc.cluster.local.:9093" kafkaUsername: "" kafkaSsl: false - svixBaseUrl: + svixBaseUrl: http://svix