diff --git a/.mapping.json b/.mapping.json index a580fd5..918c531 100644 --- a/.mapping.json +++ b/.mapping.json @@ -6,6 +6,15 @@ "CONTRIBUTING.md":"yt/opensource/repos/ytsaurus-excel-integration/github_toplevel/CONTRIBUTING.md", "LICENSE":"yt/opensource/repos/ytsaurus-excel-integration/github_toplevel/LICENSE", "README.md":"yt/microservices/excel/README.md", + "deployments/ytsaurus-excel-chart/.helmignore":"yt/microservices/excel/deployments/ytsaurus-excel-chart/.helmignore", + "deployments/ytsaurus-excel-chart/Chart.yaml":"yt/microservices/excel/deployments/ytsaurus-excel-chart/Chart.yaml", + "deployments/ytsaurus-excel-chart/templates/_helpers.tpl":"yt/microservices/excel/deployments/ytsaurus-excel-chart/templates/_helpers.tpl", + "deployments/ytsaurus-excel-chart/templates/config-map.yaml":"yt/microservices/excel/deployments/ytsaurus-excel-chart/templates/config-map.yaml", + "deployments/ytsaurus-excel-chart/templates/exporter-service.yaml":"yt/microservices/excel/deployments/ytsaurus-excel-chart/templates/exporter-service.yaml", + "deployments/ytsaurus-excel-chart/templates/exporter-statefulset.yaml":"yt/microservices/excel/deployments/ytsaurus-excel-chart/templates/exporter-statefulset.yaml", + "deployments/ytsaurus-excel-chart/templates/uploader-service.yaml":"yt/microservices/excel/deployments/ytsaurus-excel-chart/templates/uploader-service.yaml", + "deployments/ytsaurus-excel-chart/templates/uploader-statefulset.yaml":"yt/microservices/excel/deployments/ytsaurus-excel-chart/templates/uploader-statefulset.yaml", + "deployments/ytsaurus-excel-chart/values.yaml":"yt/microservices/excel/deployments/ytsaurus-excel-chart/values.yaml", "exporter/README.md":"yt/microservices/excel/exporter/README.md", "exporter/build/docker/Dockerfile":"yt/microservices/excel/exporter/build/docker/Dockerfile", "exporter/build/docker/build.sh":"yt/microservices/excel/exporter/build/docker/build.sh", diff --git a/deployments/ytsaurus-excel-chart/.helmignore b/deployments/ytsaurus-excel-chart/.helmignore new file mode 100644 index 0000000..ec1ef7e --- /dev/null +++ b/deployments/ytsaurus-excel-chart/.helmignore @@ -0,0 +1,25 @@ +# 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/ + +ya.make diff --git a/deployments/ytsaurus-excel-chart/Chart.yaml b/deployments/ytsaurus-excel-chart/Chart.yaml new file mode 100644 index 0000000..0b17eaa --- /dev/null +++ b/deployments/ytsaurus-excel-chart/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: ytsaurus-excel-chart +description: A Helm chart for Kubernetes +type: application +version: 0.1.0 +appVersion: "0.0.1" diff --git a/deployments/ytsaurus-excel-chart/templates/_helpers.tpl b/deployments/ytsaurus-excel-chart/templates/_helpers.tpl new file mode 100644 index 0000000..cf17d8e --- /dev/null +++ b/deployments/ytsaurus-excel-chart/templates/_helpers.tpl @@ -0,0 +1,78 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "ytsaurus-excel-chart.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-excel-chart.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-excel-chart.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} + +{{- define "ytsaurus-excel-chart.commonLabels" -}} +helm.sh/chart: {{ include "ytsaurus-excel-chart.chart" . }} +{{ include "ytsaurus-excel-chart.commonSelectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + + + + + +{{- define "ytsaurus-excel-chart.exporterLabels" -}} +{{ include "ytsaurus-excel-chart.exporterSelectorLabels" . }} +{{ include "ytsaurus-excel-chart.commonLabels" .}} +{{- end }} + +{{- define "ytsaurus-excel-chart.uploaderLabels" -}} +{{ include "ytsaurus-excel-chart.uploaderSelectorLabels" . }} +{{ include "ytsaurus-excel-chart.commonLabels" .}} +{{- end }} + +{{/* +Selector labels +*/}} + +{{- define "ytsaurus-excel-chart.commonSelectorLabels" -}} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{- define "ytsaurus-excel-chart.exporterSelectorLabels" -}} +app.kubernetes.io/name: "ytsaurus-excel-exporter" +{{ include "ytsaurus-excel-chart.commonSelectorLabels" . }} +{{- end }} + +{{- define "ytsaurus-excel-chart.uploaderSelectorLabels" -}} +app.kubernetes.io/name: "ytsaurus-excel-uploader" +{{ include "ytsaurus-excel-chart.commonSelectorLabels" . }} +{{- end }} + + diff --git a/deployments/ytsaurus-excel-chart/templates/config-map.yaml b/deployments/ytsaurus-excel-chart/templates/config-map.yaml new file mode 100644 index 0000000..8392a76 --- /dev/null +++ b/deployments/ytsaurus-excel-chart/templates/config-map.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: ytsaurus-excel-cm + namespace: {{ .Release.Namespace }} + labels: + {{- include "ytsaurus-excel-chart.commonLabels" . | nindent 4 }} +data: + uploader-config.yaml: | + cors: {{ .Values.settings.cors | toYaml | nindent 8 }} + http_addr: ":{{- .Values.settings.uploader.http_port -}}" + debug_http_addr: ":{{- .Values.settings.uploader.debug_http_port -}}" + http_handler_timeout: {{ .Values.settings.uploader.http_handler_timeout }} + max_excel_file_size_bytes: {{ .Values.settings.uploader.max_excel_file_size_bytes | int64 }} + auth_cookie_name: {{ .Values.settings.uploader.auth_cookie_name | quote }} + + clusters: {{ .Values.settings.uploader.clusters | toYaml | nindent 4 }} + + exporter-config.yaml: | + cors: {{ .Values.settings.cors | toYaml | nindent 8 }} + http_addr: ":{{- .Values.settings.exporter.http_port -}}" + debug_http_addr: ":{{- .Values.settings.exporter.debug_http_port -}}" + http_handler_timeout: {{ .Values.settings.exporter.http_handler_timeout }} + max_excel_file_size_bytes: {{ .Values.settings.exporter.max_excel_file_size_bytes | int64 }} + auth_cookie_name: {{ .Values.settings.exporter.auth_cookie_name | quote }} + + clusters: {{ .Values.settings.exporter.clusters | toYaml | nindent 4 }} \ No newline at end of file diff --git a/deployments/ytsaurus-excel-chart/templates/exporter-service.yaml b/deployments/ytsaurus-excel-chart/templates/exporter-service.yaml new file mode 100644 index 0000000..5f92d6a --- /dev/null +++ b/deployments/ytsaurus-excel-chart/templates/exporter-service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: "ytsaurus-excel-exporter-svc" + labels: + {{- include "ytsaurus-excel-chart.exporterLabels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + - port: {{ .Values.service.metricsPort }} + targetPort: metrics + protocol: TCP + name: mertics + selector: + {{- include "ytsaurus-excel-chart.exporterSelectorLabels" . | nindent 4 }} diff --git a/deployments/ytsaurus-excel-chart/templates/exporter-statefulset.yaml b/deployments/ytsaurus-excel-chart/templates/exporter-statefulset.yaml new file mode 100644 index 0000000..f0d783c --- /dev/null +++ b/deployments/ytsaurus-excel-chart/templates/exporter-statefulset.yaml @@ -0,0 +1,82 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: "ytsaurus-excel-exporter" + labels: + {{- include "ytsaurus-excel-chart.exporterLabels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "ytsaurus-excel-chart.exporterSelectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "ytsaurus-excel-chart.exporterLabels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + command: ["/usr/bin/excel-exporter", "-config", "/etc/config.yaml"] + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.exporter.repository }}:{{ .Values.image.exporter.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.exporter.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.settings.exporter.http_port }} + protocol: TCP + - name: metrics + containerPort: {{ .Values.settings.exporter.debug_http_port }} + protocol: TCP + livenessProbe: + httpGet: + {{- with (first .Values.settings.exporter.clusters) }} + path: /{{- .api_endpoint_name -}}/api/ready + {{- end }} + port: {{ .Values.settings.exporter.http_port }} + + readinessProbe: + httpGet: + {{- with (first .Values.settings.exporter.clusters) }} + path: /{{- .api_endpoint_name -}}/api/ready + {{- end }} + port: {{ .Values.settings.exporter.http_port }} + volumeMounts: + - mountPath: /etc/config.yaml + name: config + readOnly: true + subPath: exporter-config.yaml + - name: exporter-logs + mountPath: /tmp + volumes: + - configMap: + defaultMode: 420 + name: "ytsaurus-excel-cm" + name: config + + + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + volumeClaimTemplates: + - metadata: + name: exporter-logs + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 5Gi diff --git a/deployments/ytsaurus-excel-chart/templates/uploader-service.yaml b/deployments/ytsaurus-excel-chart/templates/uploader-service.yaml new file mode 100644 index 0000000..94e60ed --- /dev/null +++ b/deployments/ytsaurus-excel-chart/templates/uploader-service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: "ytsaurus-excel-uploader-svc" + labels: + {{- include "ytsaurus-excel-chart.uploaderLabels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + - port: {{ .Values.service.metricsPort }} + targetPort: metrics + protocol: TCP + name: mertics + selector: + {{- include "ytsaurus-excel-chart.uploaderSelectorLabels" . | nindent 4 }} diff --git a/deployments/ytsaurus-excel-chart/templates/uploader-statefulset.yaml b/deployments/ytsaurus-excel-chart/templates/uploader-statefulset.yaml new file mode 100644 index 0000000..a5024b7 --- /dev/null +++ b/deployments/ytsaurus-excel-chart/templates/uploader-statefulset.yaml @@ -0,0 +1,82 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: "ytsaurus-excel-uploader" + labels: + {{- include "ytsaurus-excel-chart.uploaderLabels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "ytsaurus-excel-chart.uploaderSelectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "ytsaurus-excel-chart.uploaderLabels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + command: ["/usr/bin/excel-uploader", "-config", "/etc/config.yaml"] + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.uploader.repository }}:{{ .Values.image.uploader.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.uploader.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.settings.uploader.http_port }} + protocol: TCP + - name: metrics + containerPort: {{ .Values.settings.uploader.debug_http_port }} + protocol: TCP + livenessProbe: + httpGet: + {{- with (first .Values.settings.uploader.clusters) }} + path: /{{- .api_endpoint_name -}}/api/ready + {{- end }} + port: {{ .Values.settings.uploader.http_port }} + + readinessProbe: + httpGet: + {{- with (first .Values.settings.uploader.clusters) }} + path: /{{- .api_endpoint_name -}}/api/ready + {{- end }} + port: {{ .Values.settings.uploader.http_port }} + volumeMounts: + - mountPath: /etc/config.yaml + name: config + readOnly: true + subPath: uploader-config.yaml + - name: uploader-logs + mountPath: /tmp + volumes: + - configMap: + defaultMode: 420 + name: "ytsaurus-excel-cm" + name: config + + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + + volumeClaimTemplates: + - metadata: + name: uploader-logs + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 5Gi diff --git a/deployments/ytsaurus-excel-chart/values.yaml b/deployments/ytsaurus-excel-chart/values.yaml new file mode 100644 index 0000000..ccd444e --- /dev/null +++ b/deployments/ytsaurus-excel-chart/values.yaml @@ -0,0 +1,112 @@ +replicaCount: 1 + +image: + exporter: + repository: ghcr.io/ytsaurus/excel-uploader + pullPolicy: IfNotPresent + tag: "dev" + uploader: + repository: ghcr.io/ytsaurus/excel-uploader + pullPolicy: IfNotPresent + tag: "dev" + + +settings: + cors: + # Allowed hostnames e.g. myorigin.com, checked via exact match: origin.Host == "myorigin.com" + allowed_hosts: [] + # Allowed hostname suffixes e.g. .myorigin.com, checked via HasSuffix(origin.Host, ".myorigin.com") + allowed_host_suffixes: [] + exporter: + # http_port: ":80" + http_port: 80 + # Metrics & pprof. + # debug_http_port: ":6060" + debug_http_port: 6060 + # Max request processing time. + # Default: 2m. + http_handler_timeout: 2m + + # Max input file size. + # Default: 10485760 (10 Mb). + max_excel_file_size_bytes: 104857600 # (100 MB) + + # Name of the request cookie that service forwards to YT. + # YT proxy uses this cookie to authorize requester. + # Default: Session_id. + # Reasonable value for OS installation: YTCypressCookie + auth_cookie_name: "YTCypressCookie" + + # List of clusters with cluster-specific settings. + clusters: + - proxy: hahn + # Specifies proxy alias used in API endpoint path: + # //api/ + # Default: equals to proxy. + api_endpoint_name: hahn + uploader: + # http_port: ":80" + http_port: 80 + # Metrics & pprof. + # debug_http_port: ":6060" + debug_http_port: 6060 + # Max request processing time. + # Default: 2m. + http_handler_timeout: 2m + + # Max input file size. + # Default: 10485760 (10 Mb). + max_excel_file_size_bytes: 104857600 # (100 MB) + + # Name of the request cookie that service forwards to YT. + # YT proxy uses this cookie to authorize requester. + # Default: Session_id. + # Reasonable value for OS installation: YTCypressCookie + auth_cookie_name: "YTCypressCookie" + + # List of clusters with cluster-specific settings. + clusters: + - proxy: hahn + # Specifies proxy alias used in API endpoint path: + # //api/ + # Default: equals to proxy. + api_endpoint_name: hahn + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + + +podAnnotations: {} +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + metricsPort: 6060 + +livenessProbe: + httpGet: + path: / + port: http +readinessProbe: + httpGet: + path: / + port: http + + +nodeSelector: {} + + +