From e63e00591b2cbbe7700a9d632ce030fe12926293 Mon Sep 17 00:00:00 2001 From: Dmitrii Gadeev Date: Mon, 3 Jun 2024 09:38:18 +0200 Subject: [PATCH] stage (#20) --- .../chart/ytsaurus-identity-sync/.helmignore | 23 +++++ .../chart/ytsaurus-identity-sync/Chart.yaml | 24 +++++ .../templates/_helpers.tpl | 62 +++++++++++++ .../templates/configmap.yaml | 9 ++ .../templates/deployment.yaml | 92 +++++++++++++++++++ .../templates/externalsecret.yaml | 37 ++++++++ .../templates/secret.yaml | 16 ++++ .../templates/serviceaccount.yaml | 13 +++ .../chart/ytsaurus-identity-sync/values.yaml | 91 ++++++++++++++++++ 9 files changed, 367 insertions(+) create mode 100644 deploy/chart/ytsaurus-identity-sync/.helmignore create mode 100644 deploy/chart/ytsaurus-identity-sync/Chart.yaml create mode 100644 deploy/chart/ytsaurus-identity-sync/templates/_helpers.tpl create mode 100644 deploy/chart/ytsaurus-identity-sync/templates/configmap.yaml create mode 100644 deploy/chart/ytsaurus-identity-sync/templates/deployment.yaml create mode 100644 deploy/chart/ytsaurus-identity-sync/templates/externalsecret.yaml create mode 100644 deploy/chart/ytsaurus-identity-sync/templates/secret.yaml create mode 100644 deploy/chart/ytsaurus-identity-sync/templates/serviceaccount.yaml create mode 100644 deploy/chart/ytsaurus-identity-sync/values.yaml diff --git a/deploy/chart/ytsaurus-identity-sync/.helmignore b/deploy/chart/ytsaurus-identity-sync/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/deploy/chart/ytsaurus-identity-sync/.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/deploy/chart/ytsaurus-identity-sync/Chart.yaml b/deploy/chart/ytsaurus-identity-sync/Chart.yaml new file mode 100644 index 0000000..ef5e38d --- /dev/null +++ b/deploy/chart/ytsaurus-identity-sync/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: ytsaurus-identity-sync +description: A Helm chart for Kubernetes + +# 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: "dev" diff --git a/deploy/chart/ytsaurus-identity-sync/templates/_helpers.tpl b/deploy/chart/ytsaurus-identity-sync/templates/_helpers.tpl new file mode 100644 index 0000000..8a1b121 --- /dev/null +++ b/deploy/chart/ytsaurus-identity-sync/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "ytsaurus-identity-sync.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 "ytsaurus-identity-sync.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 "ytsaurus-identity-sync.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "ytsaurus-identity-sync.labels" -}} +helm.sh/chart: {{ include "ytsaurus-identity-sync.chart" . }} +{{ include "ytsaurus-identity-sync.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "ytsaurus-identity-sync.selectorLabels" -}} +app.kubernetes.io/name: {{ include "ytsaurus-identity-sync.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "ytsaurus-identity-sync.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "ytsaurus-identity-sync.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deploy/chart/ytsaurus-identity-sync/templates/configmap.yaml b/deploy/chart/ytsaurus-identity-sync/templates/configmap.yaml new file mode 100644 index 0000000..a4bf7a8 --- /dev/null +++ b/deploy/chart/ytsaurus-identity-sync/templates/configmap.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "ytsaurus-identity-sync.fullname" . }} + labels: + {{- include "ytsaurus-identity-sync.labels" . | nindent 4 }} +data: + config.yaml: |- + {{- tpl (required "syncConfig is not provided" .Values.syncConfig) . | nindent 4 }} diff --git a/deploy/chart/ytsaurus-identity-sync/templates/deployment.yaml b/deploy/chart/ytsaurus-identity-sync/templates/deployment.yaml new file mode 100644 index 0000000..467576b --- /dev/null +++ b/deploy/chart/ytsaurus-identity-sync/templates/deployment.yaml @@ -0,0 +1,92 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "ytsaurus-identity-sync.fullname" . }} + labels: + {{- include "ytsaurus-identity-sync.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "ytsaurus-identity-sync.selectorLabels" . | nindent 6 }} + strategy: + type: Recreate + template: + metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + {{- if not .Values.externalSecrets.enabled }} + checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }} + {{- end }} + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "ytsaurus-identity-sync.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "ytsaurus-identity-sync.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 }} + command: [ "/ytsaurus-active-directory-integration", "--config", "/etc/ytsaurus-active-directory-integration/config.yaml" ] + env: + - name: YT_TOKEN + valueFrom: + secretKeyRef: + name: {{ include "ytsaurus-identity-sync.fullname" . | quote }} + key: YT_TOKEN + {{- if eq .Values.syncSource "ldap" }} + - name: LDAP_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "ytsaurus-identity-sync.fullname" . | quote }} + key: LDAP_PASSWORD + {{- else if eq .Values.syncSource "azure" }} + - name: AZURE_CLIENT_SECRET + valueFrom: + secretKeyRef: + name: {{ include "ytsaurus-identity-sync.fullname" . | quote }} + key: AZURE_CLIENT_SECRET + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: config + mountPath: /etc/ytsaurus-active-directory-integration + {{- with .Values.volumeMounts }} + {{- toYaml . | nindent 12 }} + {{- end }} + volumes: + - name: config + configMap: + name: {{ include "ytsaurus-identity-sync.fullname" . | quote }} + items: + - key: config.yaml + path: config.yaml + {{- with .Values.volumes }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- 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/deploy/chart/ytsaurus-identity-sync/templates/externalsecret.yaml b/deploy/chart/ytsaurus-identity-sync/templates/externalsecret.yaml new file mode 100644 index 0000000..a3441b4 --- /dev/null +++ b/deploy/chart/ytsaurus-identity-sync/templates/externalsecret.yaml @@ -0,0 +1,37 @@ +{{- if .Values.externalSecrets.enabled }} +{{- $syncSource := .Values.syncSource | required "neither 'ldap' nor 'azure' is not configured as the syncSource" }} +apiVersion: external-secrets.io/v1beta1 +kind: ExternalSecret +metadata: + name: {{ include "ytsaurus-identity-sync.fullname" . }} + labels: + {{- include "ytsaurus-identity-sync.labels" . | nindent 4 }} +spec: + data: + - remoteRef: + key: {{ required "externalSecretID is not set" .Values.externalSecrets.externalSecretID }} + property: YT_TOKEN + secretKey: YT_TOKEN + {{- if eq $syncSource "ldap" }} + - remoteRef: + key: {{ required "externalSecretID is not set" .Values.externalSecrets.externalSecretID }} + property: LDAP_PASSWORD + secretKey: LDAP_PASSWORD + {{- else if eq $syncSource "azure" }} + - remoteRef: + key: {{ required "externalSecretID is not set" .Values.externalSecrets.externalSecretID }} + property: AZURE_CLIENT_SECRET + secretKey: AZURE_CLIENT_SECRET + {{- end }} + secretStoreRef: + kind: {{ required "secretStore kind is not set" .Values.externalSecrets.secretStore.kind }} + name: {{ required "secretStore name is not set" .Values.externalSecrets.secretStore.name }} + target: + creationPolicy: Owner + deletionPolicy: Delete + name: {{ include "ytsaurus-identity-sync.fullname" . }} + template: + engineVersion: v2 + mergePolicy: Replace + type: Opaque +{{- end }} \ No newline at end of file diff --git a/deploy/chart/ytsaurus-identity-sync/templates/secret.yaml b/deploy/chart/ytsaurus-identity-sync/templates/secret.yaml new file mode 100644 index 0000000..de75a2a --- /dev/null +++ b/deploy/chart/ytsaurus-identity-sync/templates/secret.yaml @@ -0,0 +1,16 @@ +{{- if not .Values.externalSecrets.enabled }} +{{- $syncSource := .Values.syncSource | required "neither 'ldap' nor 'azure' is not configured as the syncSource" }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "ytsaurus-identity-sync.fullname" . }} + labels: + {{- include "ytsaurus-identity-sync.labels" . | nindent 4 }} +data: + YT_TOKEN: {{ required "YT_TOKEN is not provided" .Values.yt.token | b64enc | quote }} + {{- if eq $syncSource "ldap" }} + LDAP_PASSWORD: {{ required "LDAP_PASSWORD is not provided" .Values.ldap.password | b64enc | quote }} + {{- else if eq $syncSource "azure" }} + AZURE_CLIENT_SECRET: {{ required "AZURE_CLIENT_SECRET is not provided" .Values.azure.clientSecret | b64enc | quote }} + {{- end }} +{{- end }} diff --git a/deploy/chart/ytsaurus-identity-sync/templates/serviceaccount.yaml b/deploy/chart/ytsaurus-identity-sync/templates/serviceaccount.yaml new file mode 100644 index 0000000..a8926e7 --- /dev/null +++ b/deploy/chart/ytsaurus-identity-sync/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "ytsaurus-identity-sync.serviceAccountName" . }} + labels: + {{- include "ytsaurus-identity-sync.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/deploy/chart/ytsaurus-identity-sync/values.yaml b/deploy/chart/ytsaurus-identity-sync/values.yaml new file mode 100644 index 0000000..bb36354 --- /dev/null +++ b/deploy/chart/ytsaurus-identity-sync/values.yaml @@ -0,0 +1,91 @@ +replicaCount: 1 + +image: + repository: ghcr.io/nebius/ytsaurus-active-directory-integration + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "2024-04-19-569ba16" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: false + # 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: {} +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +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 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +yt: + proxy: yt-proxy.company.com + token: "yt-secret-token" + +# NB: 'ldap' and 'azure' are supported +# syncSource: azure + +ldap: + password: "not-here" + +azure: + clientSecret: "not-here" + +externalSecrets: + enabled: false + + secretStore: + kind: SecretStore + name: "" + externalSecretID: "" + +syncConfig: |- + # NB: Place your complete raw identity-sync config here