diff --git a/deploy/charts/bloom/Chart.yaml b/deploy/charts/bloom/Chart.yaml new file mode 100644 index 0000000..627ab77 --- /dev/null +++ b/deploy/charts/bloom/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: bloom +description: A Helm chart for Kubernetes deployment of the Rust-API-Proxy Bloom + +# 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: 1.0.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: "1.32" diff --git a/deploy/charts/bloom/README.md b/deploy/charts/bloom/README.md new file mode 100644 index 0000000..88f6d13 --- /dev/null +++ b/deploy/charts/bloom/README.md @@ -0,0 +1,63 @@ +# bloom + +![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.32](https://img.shields.io/badge/AppVersion-1.32-informational?style=flat-square) + +A Helm chart for Kubernetes deployment of the Rust-API-Proxy Bloom + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| affinity | object | `{}` | | +| autoscaling | object | `{"enabled":false,"maxReplicas":100,"minReplicas":1,"targetCPUUtilizationPercentage":80,"targetMemoryUtilizationPercentage":80}` | This Horizontal Pod Autoscaler works from K8S version 1.23 onwards | +| bloom.cache.compress_body | bool | `true` | | +| bloom.cache.disable_read | bool | `false` | | +| bloom.cache.disable_write | bool | `false` | | +| bloom.cache.executor_pool | int | `64` | | +| bloom.cache.ttl_default | int | `600` | | +| bloom.control.inet | string | `"[::1]:8811"` | | +| bloom.control.tcp_timeout | int | `300` | | +| bloom.proxy.shard_default | int | `0` | sets the default shard if none is set in the request | +| bloom.proxy.shards[0].host | string | `""` | | +| bloom.proxy.shards[0].ingress.annotations | object | `{}` | | +| bloom.proxy.shards[0].ingress.className | string | `""` | | +| bloom.proxy.shards[0].ingress.enabled | bool | `true` | | +| bloom.proxy.shards[0].ingress.hosts[0].host | string | `"chart-example.local"` | | +| bloom.proxy.shards[0].ingress.hosts[0].paths[0].path | string | `"/"` | | +| bloom.proxy.shards[0].ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | | +| bloom.proxy.shards[0].ingress.tls | list | `[]` | | +| bloom.proxy.shards[0].port | string | `""` | | +| bloom.proxy.shards[0].shard | int | `0` | | +| bloom.redis.connection_timeout_seconds | int | `1` | | +| bloom.redis.database | int | `0` | | +| bloom.redis.host | string | `nil` | | +| bloom.redis.idle_timeout_seconds | int | `600` | | +| bloom.redis.max_key_expiration | int | `2592000` | | +| bloom.redis.max_key_size | int | `256000` | | +| bloom.redis.max_lifetime_seconds | int | `60` | | +| bloom.redis.pool_size | int | `80` | | +| bloom.redis.port | string | `nil` | | +| bloom.server.inet | string | `"[::1]:8080"` | | +| bloom.server.log_level | string | `"error"` | | +| fullnameOverride | string | `""` | | +| image.pullPolicy | string | `"IfNotPresent"` | | +| image.repository | string | `"valeriansaliou/bloom"` | | +| image.tag | string | `""` | | +| imagePullSecrets | list | `[]` | | +| nameOverride | string | `""` | | +| nodeSelector | object | `{}` | | +| podAnnotations | object | `{}` | | +| podSecurityContext | object | `{}` | | +| replicaCount | int | `1` | | +| resources | object | `{}` | | +| securityContext | object | `{}` | | +| service.control.port | int | `8811` | | +| service.http.port | int | `80` | | +| service.type | string | `"ClusterIP"` | | +| serviceAccount.annotations | object | `{}` | | +| serviceAccount.create | bool | `true` | | +| serviceAccount.name | string | `""` | | +| tolerations | list | `[]` | | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0) diff --git a/deploy/charts/bloom/templates/NOTES.txt b/deploy/charts/bloom/templates/NOTES.txt new file mode 100644 index 0000000..2363a6a --- /dev/null +++ b/deploy/charts/bloom/templates/NOTES.txt @@ -0,0 +1,25 @@ +1. Get the application URL by running these commands: +{{- range $shard := .Values.bloom.proxy.shards }} +{{- if $shard.ingress.enabled }} + {{- range $host := .ingress.host }} + {{- range $host.paths }} + http{{ if $shard.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} + {{- end }} + +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "bloom.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 --namespace {{ .Release.Namespace }} svc -w {{ include "bloom.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "bloom.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "bloom.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} +{{- end }} \ No newline at end of file diff --git a/deploy/charts/bloom/templates/_helpers.tpl b/deploy/charts/bloom/templates/_helpers.tpl new file mode 100644 index 0000000..20ac4e2 --- /dev/null +++ b/deploy/charts/bloom/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "bloom.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 "bloom.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 "bloom.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "bloom.labels" -}} +helm.sh/chart: {{ include "bloom.chart" . }} +{{ include "bloom.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "bloom.selectorLabels" -}} +app.kubernetes.io/name: {{ include "bloom.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "bloom.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "bloom.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deploy/charts/bloom/templates/config.yaml b/deploy/charts/bloom/templates/config.yaml new file mode 100644 index 0000000..e1a6d97 --- /dev/null +++ b/deploy/charts/bloom/templates/config.yaml @@ -0,0 +1,56 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "bloom.fullname" . }}-config + labels: + {{- include "bloom.labels" . | nindent 4 }} +data: + bloom.cfg: | + [server] + + log_level = {{ .Values.bloom.server.log_level | default "error" | quote }} + inet = {{ .Values.bloom.server.inet | default "[::1]:8080" | quote }} + + + [control] + + inet = {{ .Values.bloom.control.inet | default "[::1]:8811" | quote }} + tcp_timeout = {{ .Values.bloom.control.tcp_timeout | default "300" }} + + + [proxy] + + shard_default = {{ .Values.bloom.proxy.shard_default | default 0 }} + + {{ range .Values.bloom.proxy.shards | required "At least one valid list entry is required" }} + [[proxy.shard]] + shard = {{ .shard }} + host = {{ .host | quote}} + port = {{ .port }} + {{end}} + + [cache] + + ttl_default = {{ .Values.bloom.cache.ttl_default | default 600 }} + executor_pool = {{ .Values.bloom.cache.executor_pool | default 64 }} + + disable_read = {{ .Values.bloom.cache.disable_read | default false}} + disable_write = {{ .Values.bloom.cache.disable_write | default false }} + + compress_body = {{ .Values.bloom.cache.compress_body | default true }} + + + [redis] + + host = {{.Values.bloom.redis.host | default "redis.svc.cluster.local" | quote }} + port = {{.Values.bloom.redis.port | default 6379 }} + + database = {{ .Values.bloom.redis.database |default 0 }} + + pool_size = {{ .Values.bloom.redis.pool_size | default 80 }} + max_lifetime_seconds = {{ .Values.bloom.redis.max_lifetime_seconds | default 60 }} + idle_timeout_seconds = {{ .Values.bloom.redis.idle_timeout_seconds | default 600 }} + connection_timeout_seconds = {{ .Values.bloom.redis.connection_timeout_seconds | default 1 }} + + max_key_size = {{ .Values.bloom.redis.max_key_size | default 256000 }} + max_key_expiration = {{ .Values.bloom.redis.max_key_expiration | default 2592000 | int}} \ No newline at end of file diff --git a/deploy/charts/bloom/templates/deployment.yaml b/deploy/charts/bloom/templates/deployment.yaml new file mode 100644 index 0000000..2e2f46f --- /dev/null +++ b/deploy/charts/bloom/templates/deployment.yaml @@ -0,0 +1,72 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "bloom.fullname" . }} + labels: + {{- include "bloom.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "bloom.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "bloom.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + - name: config + configMap: + name: {{ include "bloom.fullname" . }}-config + serviceAccountName: {{ include "bloom.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 }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + - name: control + containerPort: 8811 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - mountPath: /etc/bloom.cfg + subPath: bloom.cfg + name: config + {{- 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/charts/bloom/templates/hpa.yaml b/deploy/charts/bloom/templates/hpa.yaml new file mode 100644 index 0000000..9d6a215 --- /dev/null +++ b/deploy/charts/bloom/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "bloom.fullname" . }} + labels: + {{- include "bloom.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "bloom.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/deploy/charts/bloom/templates/ingress.yaml b/deploy/charts/bloom/templates/ingress.yaml new file mode 100644 index 0000000..bb6da37 --- /dev/null +++ b/deploy/charts/bloom/templates/ingress.yaml @@ -0,0 +1,69 @@ +{{- $fullName := include "bloom.fullname" . -}} +{{- $labels := include "bloom.labels" . }} +{{- $svcPort := .Values.service.http.port -}} +{{- $kubeversion := .Capabilities.KubeVersion.GitVersion}} +{{ range .Values.bloom.proxy.shards }} +{{- if .ingress.enabled -}} +{{- if and .ingress.className (not (semverCompare ">=1.18-0" $kubeversion)) }} + {{- if not (hasKey .ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .ingress.annotations "kubernetes.io/ingress.class" .ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" $kubeversion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" $kubeversion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }}-shard-{{ .shard }} + labels: + {{$labels | nindent 4 }} + + annotations: + {{- with .ingress.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} + nginx.ingress.kubernetes.io/configuration-snippet: | + more_set_headers Bloom-Request-Shard {{ .shard }}; + +spec: + {{- if and .ingress.className (semverCompare ">=1.18-0" $kubeversion) }} + ingressClassName: {{ .ingress.className }} + {{- end }} + {{- if .ingress.tls }} + tls: + {{- range .ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $kubeversion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $kubeversion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/deploy/charts/bloom/templates/service.yaml b/deploy/charts/bloom/templates/service.yaml new file mode 100644 index 0000000..0379cec --- /dev/null +++ b/deploy/charts/bloom/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "bloom.fullname" . }} + labels: + {{- include "bloom.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.http.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "bloom.selectorLabels" . | nindent 4 }} diff --git a/deploy/charts/bloom/templates/serviceaccount.yaml b/deploy/charts/bloom/templates/serviceaccount.yaml new file mode 100644 index 0000000..e2bc7d3 --- /dev/null +++ b/deploy/charts/bloom/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "bloom.serviceAccountName" . }} + labels: + {{- include "bloom.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deploy/charts/bloom/templates/tests/test-connection.yaml b/deploy/charts/bloom/templates/tests/test-connection.yaml new file mode 100644 index 0000000..e4a59e9 --- /dev/null +++ b/deploy/charts/bloom/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "bloom.fullname" . }}-test-connection" + labels: + {{- include "bloom.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "bloom.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/deploy/charts/bloom/values.yaml b/deploy/charts/bloom/values.yaml new file mode 100644 index 0000000..eb1d104 --- /dev/null +++ b/deploy/charts/bloom/values.yaml @@ -0,0 +1,115 @@ +# Default values for bloom. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: valeriansaliou/bloom + 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: "" +bloom: + server: + log_level: "debug" + inet: "0.0.0.0:8080" + control: + tcp_timeout: 300 + inet: "0.0.0.0:8811" + proxy: + # -- sets the default shard if none is set in the request + shard_default: 0 + shards: + - shard: 0 + host: "someservice.namespace.svc.cluster.local" + port: someport + ingress: + enabled: true + className: "nginx" + annotations: + # kubernetes.io/ingress.class: nginx + kubernetes.io/tls-acme: "true" + hosts: + - host: service.example.com + paths: + - path: / + pathType: ImplementationSpecific + tls: + - secretName: chart-example-tls + hosts: + - service.example.com + cache: + ttl_default: 600 + executor_pool: 64 + disable_read: false + disable_write: false + compress_body: true + redis: + host: "redis.redis.svc.cluster.local" + port: 6379 + database: 0 + pool_size: 80 + max_lifetime_seconds: 60 + idle_timeout_seconds: 600 + connection_timeout_seconds: 1 + max_key_size: 256000 + max_key_expiration: 2592000 + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + http: + port: 8080 + control: + port: 8811 + +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 + +# -- This Horizontal Pod Autoscaler works from K8S version 1.23 onwards +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {}