From 524b3839f385653ad00236715861b79010e213a4 Mon Sep 17 00:00:00 2001 From: Kyle Espinola Date: Mon, 16 Jan 2023 11:33:38 +0100 Subject: [PATCH 1/2] feat: helm chart for hub-identities --- .github/workflows/lint-test.yaml | 6 +- charts/hub-identities/.helmignore | 23 ++++++ charts/hub-identities/Chart.yaml | 27 +++++++ charts/hub-identities/templates/_helpers.tpl | 62 ++++++++++++++++ .../hub-identities/templates/deployment.yaml | 64 +++++++++++++++++ .../hub-identities/templates/environment.yaml | 7 ++ charts/hub-identities/templates/hpa.yaml | 28 ++++++++ charts/hub-identities/templates/service.yaml | 15 ++++ .../templates/serviceaccount.yaml | 12 ++++ charts/hub-identities/values.yaml | 70 +++++++++++++++++++ 10 files changed, 311 insertions(+), 3 deletions(-) create mode 100644 charts/hub-identities/.helmignore create mode 100644 charts/hub-identities/Chart.yaml create mode 100644 charts/hub-identities/templates/_helpers.tpl create mode 100644 charts/hub-identities/templates/deployment.yaml create mode 100644 charts/hub-identities/templates/environment.yaml create mode 100644 charts/hub-identities/templates/hpa.yaml create mode 100644 charts/hub-identities/templates/service.yaml create mode 100644 charts/hub-identities/templates/serviceaccount.yaml create mode 100644 charts/hub-identities/values.yaml diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml index cd8cd87..037415e 100644 --- a/.github/workflows/lint-test.yaml +++ b/.github/workflows/lint-test.yaml @@ -26,7 +26,7 @@ jobs: - name: Run chart-testing (list-changed) id: list-changed run: | - changed=$(ct list-changed --config .github/linters/ct.yaml) + changed=$(ct list-changed --config .github/workflows/linters/ct.yaml) if [[ -n "$changed" ]]; then echo "::set-output name=changed::true" fi @@ -38,11 +38,11 @@ jobs: # helm plugin install https://github.com/quintush/helm-unittest.git --version 0.2.8 - name: Run chart-testing (lint) - run: ct lint --config .github/linters/ct.yaml + run: ct lint --config .github/workflows/linters/ct.yaml - name: Create kind cluster uses: helm/kind-action@v1.5.0 if: steps.list-changed.outputs.changed == 'true' - name: Run chart-testing (install) - run: ct install --config .github/linters/ct.yaml + run: ct install --config .github/workflows/linters/ct.yaml diff --git a/charts/hub-identities/.helmignore b/charts/hub-identities/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/hub-identities/.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-identities/Chart.yaml b/charts/hub-identities/Chart.yaml new file mode 100644 index 0000000..5f04a4b --- /dev/null +++ b/charts/hub-identities/Chart.yaml @@ -0,0 +1,27 @@ +apiVersion: v2 +name: hub-identities +description: Helm chart for hub-identities +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-identities/templates/_helpers.tpl b/charts/hub-identities/templates/_helpers.tpl new file mode 100644 index 0000000..d677dc8 --- /dev/null +++ b/charts/hub-identities/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "hub-identities.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-identities.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-identities.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "hub-identities.labels" -}} +helm.sh/chart: {{ include "hub-identities.chart" . }} +{{ include "hub-identities.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "hub-identities.selectorLabels" -}} +app.kubernetes.io/name: {{ include "hub-identities.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "hub-identities.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "hub-identities.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/hub-identities/templates/deployment.yaml b/charts/hub-identities/templates/deployment.yaml new file mode 100644 index 0000000..4cb8e90 --- /dev/null +++ b/charts/hub-identities/templates/deployment.yaml @@ -0,0 +1,64 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "hub-identities.fullname" . }} + labels: + {{- include "hub-identities.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "hub-identities.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "hub-identities.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "hub-identities.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + envFrom: + - configMapRef: + name: {{ include "hub-identities.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-identities/templates/environment.yaml b/charts/hub-identities/templates/environment.yaml new file mode 100644 index 0000000..2a7c72c --- /dev/null +++ b/charts/hub-identities/templates/environment.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "hub-identities.fullname" . }} +data: + KRATOS_ADMIN_ENDPOINT: {{ .Values.environment.kratosAdminEndpoint }} + PORT: "{{ .Values.environment.port }}" \ No newline at end of file diff --git a/charts/hub-identities/templates/hpa.yaml b/charts/hub-identities/templates/hpa.yaml new file mode 100644 index 0000000..2de2c5c --- /dev/null +++ b/charts/hub-identities/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "hub-identities.fullname" . }} + labels: + {{- include "hub-identities.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "hub-identities.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-identities/templates/service.yaml b/charts/hub-identities/templates/service.yaml new file mode 100644 index 0000000..90c2cdf --- /dev/null +++ b/charts/hub-identities/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "hub-identities.fullname" . }} + labels: + {{- include "hub-identities.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "hub-identities.selectorLabels" . | nindent 4 }} diff --git a/charts/hub-identities/templates/serviceaccount.yaml b/charts/hub-identities/templates/serviceaccount.yaml new file mode 100644 index 0000000..6e466e2 --- /dev/null +++ b/charts/hub-identities/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "hub-identities.serviceAccountName" . }} + labels: + {{- include "hub-identities.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/hub-identities/values.yaml b/charts/hub-identities/values.yaml new file mode 100644 index 0000000..1e50071 --- /dev/null +++ b/charts/hub-identities/values.yaml @@ -0,0 +1,70 @@ +# Default values for hub-identities. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: holaplex/hub-identities + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +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: {} + +environment: + kratosAdminEndpoint: http://kratos-admin + port: "80" From 8a766c3b1f6bc1a96c679f3983e31d042ffb1777 Mon Sep 17 00:00:00 2001 From: Kyle Espinola Date: Mon, 16 Jan 2023 13:46:42 +0100 Subject: [PATCH 2/2] fix: disable maintainer check --- .github/workflows/linters/ct.yaml | 1 + .github/workflows/superlinter.yml | 31 ------------------------------- charts/hub-identities/values.yaml | 2 +- 3 files changed, 2 insertions(+), 32 deletions(-) delete mode 100644 .github/workflows/superlinter.yml diff --git a/.github/workflows/linters/ct.yaml b/.github/workflows/linters/ct.yaml index 73401c5..5085c17 100644 --- a/.github/workflows/linters/ct.yaml +++ b/.github/workflows/linters/ct.yaml @@ -6,6 +6,7 @@ chart-dirs: chart-repos: - holaplex=https://holaplex.github.io/helm-charts helm-extra-args: --timeout 600s +validate-maintainers: false excluded-charts: additional-commands: # - helm unittest --helm3 --strict --file unittests/*.yaml --file 'unittests/**/*.yaml' {{ .Path }} diff --git a/.github/workflows/superlinter.yml b/.github/workflows/superlinter.yml deleted file mode 100644 index 889cc94..0000000 --- a/.github/workflows/superlinter.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Lint Code Base - -# Documentation: -# https://help.github.com/en/articles/workflow-syntax-for-github-actions - -on: pull_request - -jobs: - build: - name: Lint Code Base - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Lint Code Base - uses: docker://github/super-linter:slim-v4 - env: - DEFAULT_BRANCH: main - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - LINTER_RULES_PATH: .github/linters - VALIDATE_ALL_CODEBASE: false - VALIDATE_BASH: false - VALIDATE_JSCPD: false - VALIDATE_KUBERNETES_KUBEVAL: false - VALIDATE_PYTHON: false - VALIDATE_PYTHON_FLAKE8: false - VALIDATE_PYTHON_BLACK: false - VALIDATE_YAML: false diff --git a/charts/hub-identities/values.yaml b/charts/hub-identities/values.yaml index 1e50071..1f6b355 100644 --- a/charts/hub-identities/values.yaml +++ b/charts/hub-identities/values.yaml @@ -8,7 +8,7 @@ image: repository: holaplex/hub-identities pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. - tag: "" + tag: "latest" imagePullSecrets: [] nameOverride: ""