Skip to content

Commit

Permalink
pro-api serviceAccountOverride support (#456)
Browse files Browse the repository at this point in the history
* changes

* update

* value description added

* readme update

* readme update

---------

Co-authored-by: Dmitrii Moskalev <d.moskalev@2gis.ru>
  • Loading branch information
DAMoskalev and Dmitrii Moskalev authored Jun 26, 2024
1 parent 2b50f21 commit 5785840
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
23 changes: 12 additions & 11 deletions charts/pro-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,18 @@

### 2GIS PRO API configuration

| Name | Description | Value |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `api.serviceAccount` | Kubernetes service account | `runner` |
| `api.tempPath` | Path to directory used for temp data | `/tmp` |
| `api.allowAnyOrigin` | Cors policy: allow any origin to perform requests to pro-api service | `false` |
| `api.logging` | Logging settings | |
| `api.logging.format` | Log message format, possible options: 'default' - compact json, 'renderedCompactJson' - rendered json format, 'simple' - plain text | `simple` |
| `api.logging.targets` | Collection of logging targets divided by comma. Currently only 'console' and 'database' are supported. Console is used by default (no need to specify). | `""` |
| `api.rateLimiter` | rate limiter settings | |
| `api.rateLimiter.requestsLimit` | max number of requests from one user during time window (0 means rate limiter is disabled) | `1024` |
| `api.rateLimiter.windowSizeInSeconds` | the size of time windows to count and limit incoming requests | `1` |
| Name | Description | Value |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- |
| `api.serviceAccount` | Kubernetes service account | `runner` |
| `api.serviceAccountOverride` | The name of an existing custom service account. If specified, the services in the chart will use this existing service account. If not specified, a new service account will be created and used with the name from the variable `api.serviceAccount`. | `""` |
| `api.tempPath` | Path to directory used for temp data | `/tmp` |
| `api.allowAnyOrigin` | Cors policy: allow any origin to perform requests to pro-api service | `false` |
| `api.logging` | Logging settings | |
| `api.logging.format` | Log message format, possible options: 'default' - compact json, 'renderedCompactJson' - rendered json format, 'simple' - plain text | `simple` |
| `api.logging.targets` | Collection of logging targets divided by comma. Currently only 'console' and 'database' are supported. Console is used by default (no need to specify). | `""` |
| `api.rateLimiter` | rate limiter settings | |
| `api.rateLimiter.requestsLimit` | max number of requests from one user during time window (0 means rate limiter is disabled) | `1024` |
| `api.rateLimiter.windowSizeInSeconds` | the size of time windows to count and limit incoming requests | `1` |

### Auth configuration

Expand Down
13 changes: 9 additions & 4 deletions charts/pro-api/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,17 @@
{{- end -}}
{{- end -}}


{{- define "pro-api.service-account-name" -}}
{{- $name := default .Values.api.serviceAccount -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- if empty .Values.api.serviceAccountOverride }}
{{- $name := default .Values.api.serviceAccount -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- .Values.api.serviceAccountOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}

Expand Down
2 changes: 2 additions & 0 deletions charts/pro-api/templates/service-account.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{{- if empty .Values.api.serviceAccountOverride }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "pro-api.service-account-name" . }}
{{- end }}
4 changes: 3 additions & 1 deletion charts/pro-api/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ s3:

# @section 2GIS PRO API configuration

# @param api.serviceAccount Kubernetes service account
# @param api.serviceAccount Kubernetes service account
# @param api.serviceAccountOverride The name of an existing custom service account. If specified, the services in the chart will use this existing service account. If not specified, a new service account will be created and used with the name from the variable `api.serviceAccount`.
# @param api.tempPath Path to directory used for temp data
# @param api.allowAnyOrigin Cors policy: allow any origin to perform requests to pro-api service
# @extra api.logging Logging settings
Expand All @@ -169,6 +170,7 @@ s3:

api:
serviceAccount: runner
serviceAccountOverride: ''
tempPath: /tmp
allowAnyOrigin: false
logEsQueries: false
Expand Down

0 comments on commit 5785840

Please sign in to comment.