diff --git a/charts/centrifugo/Chart.yaml b/charts/centrifugo/Chart.yaml index 8d6d70b..99ad1a0 100644 --- a/charts/centrifugo/Chart.yaml +++ b/charts/centrifugo/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v1 name: centrifugo description: Centrifugo is a scalable real-time messaging server in language-agnostic way -version: 5.0.3 -appVersion: 2.7.2 +version: 6.0.0 +appVersion: 2.8.0 home: https://centrifugal.github.io/centrifugo/ icon: https://centrifugal.github.io/centrifugo/images/favicon.png maintainers: diff --git a/charts/centrifugo/README.md b/charts/centrifugo/README.md index 42d7299..e547039 100644 --- a/charts/centrifugo/README.md +++ b/charts/centrifugo/README.md @@ -50,13 +50,81 @@ _See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command doc $ helm upgrade [RELEASE_NAME] [CHART] --install ``` +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Parameters + +The following table lists the configurable parameters of the Centrifugo chart and their default values. + +| Parameter | Description | Default | +|---------------------------------------------|----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------| +| `global.imageRegistry` | Global Docker Image registry | `nil` | +| `global.imagePullSecrets` | Global Docker registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) | +### Common parameters + +| Parameter | Description | Default | +|---------------------------------------------|----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------| +| `nameOverride` | String to partially override centrifugo.fullname | `nil` | +| `fullnameOverride` | String to fully override centrifugo.fullname | `nil` | + +### Centrifugo common parameters + +| Parameter | Description | Default | +|---------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------| +| `image.registry` | Centrifugo image registry | `docker.io` | +| `image.repository` | Centrifugo image name | `centrifugo/centrifugo` | +| `image.tag` | Centrifugo image tag | Taken from chart `appVersion` | +| `image.pullPolicy` | Centrifugo image pull policy | `IfNotPresent` | +| `image.pullSecrets` | Specify docker-registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) | +| `service.type` | service type | `ClusterIP` | +| `service.clusterIP` | service clusterIP IP | `nil` | +| `service.port` | service port | `8000` | +| `service.nodePort` | K8s service node port | `nil` | +| `service.useSeparateInternalService` | Use separate service for internal endpoints. It could be useful for configuring same port number for all services. | `false` | +| `service.useSeparateGrpcService` | Use separate service for GRPC endpoints. It could be useful for configuring same port number for all services. | `false` | +| `internalService.type` | internal (for API, Prometheus metrics, admin web interface, health checks) port service type | `ClusterIP` | +| `internalService.clusterIP` | internal (for API, Prometheus metrics, admin web interface, health checks) service clusterIP IP | `nil` | +| `internalService.port` | internal (for API, Prometheus metrics, admin web interface, health checks) service port | `9000` | +| `internalService.nodePort` | internal (for API, Prometheus metrics, admin web interface, health checks) K8s service node port | `nil` | +| `grpcService.type` | GRPC API port service type | `ClusterIP` | +| `grpcService.clusterIP` | GRPC API service clusterIP IP | `nil` | +| `grpcService.port` | GRPC API service port | `10000` | +| `grpcService.nodePort` | GRPC API K8s service node port | `nil` | +| `env` | Additional environment variables to be passed to Centrifugo container. | `nil` | +| `config` | Centrifugo configuration, will be transformed into config.json file | `{"admin":true,"engine":"memory","namespaces":[],"v3_use_offset":true}` | +| `existingSecret` | Name of existing secret to use for secret's parameters. The secret has to contain the keys below | `nil` | +| `secret.tokenHmacSecretKey` | Secret key for HMAC tokens. | `nil` | +| `secret.adminPassword` | Admin password used to protect access to web interface. | `nil` | +| `secret.adminSecret` | Admin secret used to create auth tokens on user login into admin web interface. | `nil` | +| `secret.apiKey` | Centrifugo api_key for Centrifugo API endpoint authorization. | `nil` | +| `secret.grpcApiKey` | Centrifugo grpc_api_key for Centrifugo GRPC API authorization. | `nil` | +| `secret.redisUrl` | Connection string to Redis. | `nil` | +| `secret.redisPassword` | Password for Redis. | `nil` | +| `secret.natsUrl` | Connection string to Nats. | `nil` | + + +### Metrics parameters + +| Parameter | Description | Default | +|---------------------------------------------|----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------| +| `metrics.enabled` | Start a side-car prometheus exporter | `false` | +| `metrics.serviceMonitor.enabled` | Create ServiceMonitor Resource for scraping metrics using PrometheusOperator | `false` | +| `metrics.serviceMonitor.namespace` | Namespace which Prometheus is running in | `nil` | +| `metrics.serviceMonitor.interval` | Interval at which metrics should be scraped | `30s` | +| `metrics.serviceMonitor.scrapeTimeout` | Specify the timeout after which the scrape is ended | `nil` | +| `metrics.serviceMonitor.relabellings` | Specify Metric Relabellings to add to the scrape endpoint | `nil` | +| `metrics.serviceMonitor.honorLabels` | honorLabels chooses the metric's labels on collisions with target labels. | `false` | +| `metrics.serviceMonitor.additionalLabels` | Used to pass Labels that are required by the Installed Prometheus Operator | `{}` | +| `metrics.serviceMonitor.release` | Used to pass Labels release that sometimes should be custom for Prometheus Operator | `nil` | + + _See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) for command documentation._ ## Concepts This chart by default starts Centrifugo with Memory engine. This means that you can only run one Centrifugo instance pod in default setup. If you need to run more pods to scale and load-balance connections between them – run Centrifugo with Redis engine or with Nats broker (for at most once PUB/SUB only). See examples below. -Centrifugo service exposes 3 ports: +Centrifugo service exposes 3 ports: * for client connections from the outside of your cluster. This is called external port: 8000 by default. * internal port for API, Prometheus metrics, admin web interface, health checks. So these endpoints not available from the outside when enabling ingress. This is called internal port: 9000 by default. @@ -69,30 +137,29 @@ Ingress proxies on external port. Chart follows usual practices when working with Helm. All Centrifugo configuration options can be set. You can set them using custom `values.yaml`: ```yaml -centrifugo: - config: - admin: false - namespaces: - - name: "chat" - publish: true +config: + admin: false + namespaces: + - name: "chat" + publish: true ``` And deploy with: -``` +```console helm install [RELEASE_NAME] -f values.yaml centrifugal/centrifugo ``` Or you can override options using `--set` flag, for example: -``` -helm install [RELEASE_NAME] centrifugal/centrifugo --set centrifugo.config.namespaces[0].name=chat --set centrifugo.config.namespaces[0].publish=true +```console +helm install [RELEASE_NAME] centrifugal/centrifugo --set config.namespaces[0].name=chat --set config.namespaces[0].publish=true ``` This chart also defines several secrets. For example here is an example that configures HTTP API key and token HMAC secret key. -``` -helm install [RELEASE_NAME] centrifugal/centrifugo --set centrifugo.secrets.apiKey= --set centrifugo.secrets.tokenHmacSecretKey= +```console +helm install [RELEASE_NAME] centrifugal/centrifugo --set secrets.apiKey= --set secrets.tokenHmacSecretKey= ``` See full list of supported secrets inside chart [values.yaml](https://github.com/centrifugal/helm-charts/blob/master/charts/centrifugo/values.yaml). @@ -101,54 +168,67 @@ See full list of supported secrets inside chart [values.yaml](https://github.com Run Redis (here we are using Redis chart from bitnami, but you can use any other Redis deployment): -``` +```console helm repo add bitnami https://charts.bitnami.com/bitnami helm install redis bitnami/redis --set usePassword=false ``` Then start Centrifugo with `redis` engine and pointing it to Redis: -``` -helm install centrifugo -f values.yaml ./centrifugo --set centrifugo.config.engine=redis --set centrifugo.config.redis_url=redis://redis-master:6379 --set replicaCount=3 +```console +helm install centrifugo -f values.yaml ./centrifugo --set config.engine=redis --set config.redis_url=redis://redis-master:6379 --set replicaCount=3 ``` Now example with Redis Sentinel (again using chart from bitnami): -``` +```console helm install redis bitnami/redis --set usePassword=false --set cluster.enabled=true --set sentinel.enabled=true ``` Then point Centrifugo to Sentinel: -``` -helm install centrifugo -f values.yaml ./centrifugo --set centrifugo.config.engine=redis --set centrifugo.config.redis_master_name=mymaster --set centrifugo.config.redis_sentinels=redis:26379 --set replicaCount=3 +```console +helm install centrifugo -f values.yaml ./centrifugo --set config.engine=redis --set config.redis_master_name=mymaster --set config.redis_sentinels=redis:26379 --set replicaCount=3 ``` Example with Redis Cluster (using `bitnami/redis-cluster` chart, but again the way you run Redis is up to you actually): -``` +```console helm install redis bitnami/redis-cluster --set usePassword=false ``` Then point Centrifugo to Redis Cluster: -``` -helm install centrifugo -f values.yaml ./centrifugo --set centrifugo.config.engine=redis --set centrifugo.config.redis_cluster_addrs=redis-redis-cluster-0:6379 --set replicaCount=3 +```console +helm install centrifugo -f values.yaml ./centrifugo --set config.engine=redis --set config.redis_cluster_addrs=redis-redis-cluster-0:6379 --set replicaCount=3 ``` Note: it's possible to set Redis URL and Redis/Sentinel passwords over secrets if needed. ## With Nats broker -``` +```console helm repo add nats https://nats-io.github.io/k8s/helm/charts/ helm install nats nats/nats --set cluster.enabled=true ``` Then start Centrifugo pointing to Nats broker: -``` -helm install centrifugo -f values.yaml ./centrifugo --set centrifugo.config.broker=nats --set centrifugo.config.nats_url=nats://nats:4222 --set replicaCount=3 +```console +helm install centrifugo -f values.yaml ./centrifugo --set config.broker=nats --set config.nats_url=nats://nats:4222 --set replicaCount=3 ``` Note: it's possible to set Nats URL over secrets if needed. + +## Upgrading + +### v5 -> v6 + +v6 aims to simplify chart configuration and make it a bit more idiomatic. See pull request [#6](https://github.com/centrifugal/helm-charts/pull/6) for all the changes. + +- Several parameters were renamed or disappeared in favor of new ones on this major version: + - Three type of services were moved to their own block. + - To enable separate services use `useSeparateInternalService` and `useSeparateGrpcService` flags. + - `ServiceMonitor` move to block `metrics` with additional parameters, `labels` renamed to `additionalLabels` - removed configuration block `centrifugo`, all configuration under that block moved to top level. + +[On November 13, 2020, Helm v2 support was formally finished](https://github.com/helm/charts#status-of-the-project), this major version is the result of the required changes applied to the Helm Chart to be able to incorporate the different features added in Helm v3 and to be consistent with the Helm project itself regarding the Helm v2 EOL. diff --git a/charts/centrifugo/templates/_helpers.tpl b/charts/centrifugo/templates/_helpers.tpl index c2c8c09..36cb73a 100644 --- a/charts/centrifugo/templates/_helpers.tpl +++ b/charts/centrifugo/templates/_helpers.tpl @@ -72,3 +72,52 @@ Allow the release namespace to be overridden for multi-namespace deployments in {{- .Release.Namespace -}} {{- end -}} {{- end -}} + +{{- define "centrifugo.image" -}} +{{- $registryName := .Values.image.registry -}} +{{- $repositoryName := .Values.image.repository -}} +{{- $tag := coalesce .Values.image.tag (printf "v%s" .Chart.AppVersion ) | toString -}} +{{- if .Values.global -}} + {{- if .Values.global.imageRegistry }} + {{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}} + {{- else -}} + {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} + {{- end -}} +{{- else -}} + {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} +{{- end -}} +{{- end -}} + +{{/* +Return the proper Docker Image Registry Secret Names +*/}} +{{- define "centrifugo.imagePullSecrets" -}} +{{- if .Values.global }} +{{- if .Values.global.imagePullSecrets }} +imagePullSecrets: +{{- range .Values.global.imagePullSecrets }} + - name: {{ . }} +{{- end }} +{{- else if .Values.image.pullSecrets}} +imagePullSecrets: +{{- range .Values.image.pullSecrets }} + - name: {{ . }} +{{- end }} +{{- end -}} +{{- else if .Values.image.pullSecrets }} +imagePullSecrets: +{{- range .Values.image.pullSecrets }} + - name: {{ . }} +{{- end }} +{{- end -}} +{{- end -}} + +{{- define "centrifugo.secretName" -}} +{{- if .Values.existingSecret -}} + {{- printf "%s" (tpl .Values.existingSecret $) -}} +{{- else -}} + {{- printf "%s" (include "centrifugo.fullname" .) -}} +{{- end -}} +{{- end -}} + + diff --git a/charts/centrifugo/templates/configmap.yaml b/charts/centrifugo/templates/configmap.yaml index d7cbd60..4942c02 100644 --- a/charts/centrifugo/templates/configmap.yaml +++ b/charts/centrifugo/templates/configmap.yaml @@ -7,4 +7,4 @@ metadata: {{- include "centrifugo.labels" . | nindent 4 }} data: config.json: |- -{{ toJson .Values.centrifugo.config| indent 4 }} +{{ toJson .Values.config| indent 4 }} diff --git a/charts/centrifugo/templates/deployment.yaml b/charts/centrifugo/templates/deployment.yaml index f794da0..6dcf4b8 100644 --- a/charts/centrifugo/templates/deployment.yaml +++ b/charts/centrifugo/templates/deployment.yaml @@ -27,10 +27,7 @@ spec: labels: {{- include "centrifugo.selectorLabels" . | nindent 8 }} spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} + {{- include "centrifugo.imagePullSecrets" . | indent 6 }} serviceAccountName: {{ include "centrifugo.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} @@ -43,7 +40,7 @@ spec: - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ if .Values.image.tag }}{{ .Values.image.tag }}{{ else }}v{{ .Chart.AppVersion }}{{ end }}" + image: {{ include "centrifugo.image" .}} imagePullPolicy: {{ .Values.image.pullPolicy }} command: - centrifugo @@ -51,73 +48,73 @@ spec: - --health - --prometheus - --port - - "{{ .Values.centrifugo.ports.external }}" + - "{{ .Values.service.port }}" - --internal_port - - "{{ .Values.centrifugo.ports.internal }}" + - "{{ .Values.internalService.port }}" - --grpc_api - --grpc_api_port - - "{{ .Values.centrifugo.ports.grpc }}" + - "{{ .Values.grpcService.port }}" env: - name: CENTRIFUGO_ADMIN_PASSWORD valueFrom: secretKeyRef: - name: {{ include "centrifugo.fullname" . }} + name: {{ include "centrifugo.secretName" . }} key: admin_password - name: CENTRIFUGO_ADMIN_SECRET valueFrom: secretKeyRef: - name: {{ include "centrifugo.fullname" . }} + name: {{ include "centrifugo.secretName" . }} key: admin_secret - {{- if .Values.centrifugo.secrets.tokenHmacSecretKey }} + {{- if .Values.secrets.tokenHmacSecretKey }} - name: CENTRIFUGO_TOKEN_HMAC_SECRET_KEY valueFrom: secretKeyRef: - name: {{ include "centrifugo.fullname" . }} + name: {{ include "centrifugo.secretName" . }} key: token_hmac_secret_key {{- end }} - {{- if .Values.centrifugo.secrets.apiKey }} + {{- if .Values.secrets.apiKey }} - name: CENTRIFUGO_API_KEY valueFrom: secretKeyRef: - name: {{ include "centrifugo.fullname" . }} + name: {{ include "centrifugo.secretName" . }} key: api_key {{- end }} - {{- if .Values.centrifugo.secrets.grpcApiKey }} + {{- if .Values.secrets.grpcApiKey }} - name: CENTRIFUGO_GRPC_API_KEY valueFrom: secretKeyRef: - name: {{ include "centrifugo.fullname" . }} + name: {{ include "centrifugo.secretName" . }} key: grpc_api_key {{- end }} - {{- if .Values.centrifugo.secrets.redisUrl }} + {{- if .Values.secrets.redisUrl }} - name: CENTRIFUGO_REDIS_URL valueFrom: secretKeyRef: - name: {{ include "centrifugo.fullname" . }} + name: {{ include "centrifugo.secretName" . }} key: redis_url {{- end }} - {{- if .Values.centrifugo.secrets.redisPassword }} + {{- if .Values.secrets.redisPassword }} - name: CENTRIFUGO_REDIS_PASSWORD valueFrom: secretKeyRef: - name: {{ include "centrifugo.fullname" . }} + name: {{ include "centrifugo.secretName" . }} key: redis_password {{- end }} - {{- if .Values.centrifugo.secrets.redisSentinelPassword }} + {{- if .Values.secrets.redisSentinelPassword }} - name: CENTRIFUGO_REDIS_SENTINEL_PASSWORD valueFrom: secretKeyRef: - name: {{ include "centrifugo.fullname" . }} + name: {{ include "centrifugo.secretName" . }} key: redis_sentinel_password {{- end }} - {{- if .Values.centrifugo.secrets.natsUrl }} + {{- if .Values.secrets.natsUrl }} - name: CENTRIFUGO_NATS_URL valueFrom: secretKeyRef: - name: {{ include "centrifugo.fullname" . }} + name: {{ include "centrifugo.secretName" . }} key: nats_url {{- end }} - {{- range $key, $value := .Values.centrifugo.env }} + {{- range $key, $value := .Values.env }} - name: {{ $key }} value: {{ $value }} {{- end }} @@ -127,21 +124,21 @@ spec: readOnly: true ports: - name: external - containerPort: {{ .Values.centrifugo.ports.external }} + containerPort: {{ .Values.service.port }} - name: internal - containerPort: {{ .Values.centrifugo.ports.internal }} + containerPort: {{ .Values.internalService.port }} - name: grpc - containerPort: {{ .Values.centrifugo.ports.grpc }} + containerPort: {{ .Values.grpcService.port }} livenessProbe: httpGet: path: /health - port: {{ .Values.centrifugo.ports.internal }} + port: {{ .Values.internalService.port }} initialDelaySeconds: 30 periodSeconds: 10 readinessProbe: httpGet: path: /health - port: {{ .Values.centrifugo.ports.internal }} + port: {{ .Values.internalService.port }} initialDelaySeconds: 3 periodSeconds: 10 resources: diff --git a/charts/centrifugo/templates/ingress.yaml b/charts/centrifugo/templates/ingress.yaml index e62c858..b0ec8e1 100644 --- a/charts/centrifugo/templates/ingress.yaml +++ b/charts/centrifugo/templates/ingress.yaml @@ -1,7 +1,7 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "centrifugo.fullname" . -}} {{- $namespace := include "centrifugo.namespace" . -}} -{{- $svcPort := .Values.service.externalPort -}} +{{- $svcPort := .Values.service.port -}} {{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} apiVersion: networking.k8s.io/v1beta1 {{- else -}} diff --git a/charts/centrifugo/templates/secret.yaml b/charts/centrifugo/templates/secret.yaml index 4d34226..7d6b2ec 100644 --- a/charts/centrifugo/templates/secret.yaml +++ b/charts/centrifugo/templates/secret.yaml @@ -1,3 +1,4 @@ +{{- if not .Values.existingSecret }} apiVersion: v1 kind: Secret metadata: @@ -7,34 +8,35 @@ metadata: {{- include "centrifugo.labels" . | nindent 4 }} type: Opaque data: - {{- if .Values.centrifugo.secrets.tokenHmacSecretKey }} - token_hmac_secret_key: {{ .Values.centrifugo.secrets.tokenHmacSecretKey | b64enc | quote }} + {{- if .Values.secrets.tokenHmacSecretKey }} + token_hmac_secret_key: {{ .Values.secrets.tokenHmacSecretKey | b64enc | quote }} {{- end }} - {{- if .Values.centrifugo.secrets.apiKey }} - api_key: {{ .Values.centrifugo.secrets.apiKey | b64enc | quote }} + {{- if .Values.secrets.apiKey }} + api_key: {{ .Values.secrets.apiKey | b64enc | quote }} {{- end }} - {{- if .Values.centrifugo.secrets.grpcApiKey }} - grpc_api_key: {{ .Values.centrifugo.secrets.grpcApiKey | b64enc | quote }} + {{- if .Values.secrets.grpcApiKey }} + grpc_api_key: {{ .Values.secrets.grpcApiKey | b64enc | quote }} {{- end }} - {{- if .Values.centrifugo.secrets.adminPassword }} - admin_password: {{ .Values.centrifugo.secrets.adminPassword | b64enc | quote }} + {{- if .Values.secrets.adminPassword }} + admin_password: {{ .Values.secrets.adminPassword | b64enc | quote }} {{- else }} admin_password: {{ randAlphaNum 12 | b64enc | quote }} {{- end }} - {{- if .Values.centrifugo.secrets.adminSecret }} - admin_secret: {{ .Values.centrifugo.secrets.adminSecret | b64enc | quote }} + {{- if .Values.secrets.adminSecret }} + admin_secret: {{ .Values.secrets.adminSecret | b64enc | quote }} {{- else }} admin_secret: {{ randAlphaNum 24 | b64enc | quote }} {{- end }} - {{- if .Values.centrifugo.secrets.redisUrl }} - redis_url: {{ .Values.centrifugo.secrets.redisUrl | b64enc | quote }} + {{- if .Values.secrets.redisUrl }} + redis_url: {{ .Values.secrets.redisUrl | b64enc | quote }} {{- end }} - {{- if .Values.centrifugo.secrets.redisPassword }} - redis_password: {{ .Values.centrifugo.secrets.redisPassword | b64enc | quote }} + {{- if .Values.secrets.redisPassword }} + redis_password: {{ .Values.secrets.redisPassword | b64enc | quote }} {{- end }} - {{- if .Values.centrifugo.secrets.redisSentinelPassword }} - redis_sentinel_password: {{ .Values.centrifugo.secrets.redisSentinelPassword | b64enc | quote }} + {{- if .Values.secrets.redisSentinelPassword }} + redis_sentinel_password: {{ .Values.secrets.redisSentinelPassword | b64enc | quote }} {{- end }} - {{- if .Values.centrifugo.secrets.natsUrl }} - nats_url: {{ .Values.centrifugo.secrets.natsUrl | b64enc | quote }} + {{- if .Values.secrets.natsUrl }} + nats_url: {{ .Values.secrets.natsUrl | b64enc | quote }} {{- end }} +{{- end }} diff --git a/charts/centrifugo/templates/service-grpc-api.yaml b/charts/centrifugo/templates/service-grpc-api.yaml index 1ec7b5b..75bcf63 100644 --- a/charts/centrifugo/templates/service-grpc-api.yaml +++ b/charts/centrifugo/templates/service-grpc-api.yaml @@ -1,4 +1,4 @@ -{{- if .Values.grpcService.enabled -}} +{{- if .Values.service.useSeparateGrpcService -}} apiVersion: v1 kind: Service metadata: diff --git a/charts/centrifugo/templates/service-internal.yaml b/charts/centrifugo/templates/service-internal.yaml index c7ba586..e469597 100644 --- a/charts/centrifugo/templates/service-internal.yaml +++ b/charts/centrifugo/templates/service-internal.yaml @@ -1,4 +1,4 @@ -{{- if .Values.internalService.enabled -}} +{{- if .Values.service.useSeparateInternalService -}} apiVersion: v1 kind: Service metadata: diff --git a/charts/centrifugo/templates/service.yaml b/charts/centrifugo/templates/service.yaml index 631ee02..312e887 100644 --- a/charts/centrifugo/templates/service.yaml +++ b/charts/centrifugo/templates/service.yaml @@ -12,30 +12,30 @@ metadata: spec: type: {{ .Values.service.type }} ports: - - port: {{ .Values.service.externalPort }} + - port: {{ .Values.service.port }} targetPort: external protocol: TCP name: external - {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.externalNodePort))) }} - nodePort: {{ .Values.service.externalNodePort }} + {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }} + nodePort: {{ .Values.service.nodePort }} {{- end }} - {{- if not .Values.internalService.enabled }} - - port: {{ .Values.service.internalPort }} +{{- if not .Values.service.useSeparateInternalService }} + - port: {{ .Values.internalService.port }} targetPort: internal protocol: TCP name: internal - {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.internalNodePort))) }} - nodePort: {{ .Values.service.internalNodePort }} + {{- if (and (eq .Values.internalService.type "NodePort") (not (empty .Values.internalService.nodePort))) }} + nodePort: {{ .Values.internalService.nodePort }} {{- end }} - {{- end }} - {{- if not .Values.grpcService.enabled }} - - port: {{ .Values.service.grpcPort }} +{{- end }} +{{- if not .Values.service.useSeparateGrpcService }} + - port: {{ .Values.grpcService.port }} targetPort: grpc protocol: TCP name: grpc - {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.grpcNodePort))) }} - nodePort: {{ .Values.service.grpcNodePort }} + {{- if (and (eq .Values.grpcService.type "NodePort") (not (empty .Values.grpcService.nodePort))) }} + nodePort: {{ .Values.grpcService.nodePort }} {{- end }} - {{- end }} +{{- end }} selector: {{- include "centrifugo.selectorLabels" . | nindent 4 }} diff --git a/charts/centrifugo/templates/servicemonitor.yaml b/charts/centrifugo/templates/servicemonitor.yaml index 4a04a29..be31067 100644 --- a/charts/centrifugo/templates/servicemonitor.yaml +++ b/charts/centrifugo/templates/servicemonitor.yaml @@ -1,22 +1,31 @@ -{{- if .Values.serviceMonitor.enabled }} +{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: {{ template "centrifugo.fullname" . }} - {{- if .Values.serviceMonitor.namespace }} - namespace: {{ .Values.serviceMonitor.namespace }} + {{- if .Values.metrics.serviceMonitor.namespace }} + namespace: {{ .Values.metrics.serviceMonitor.namespace }} {{- end }} labels: {{- include "centrifugo.labels" . | nindent 4 }} - {{- range $key, $value := .Values.serviceMonitor.labels }} + {{- range $key, $value := .Values.metrics.serviceMonitor.additionalLabels }} {{ $key }}: {{ $value | quote }} {{- end }} spec: endpoints: - - port: internal - {{- if .Values.serviceMonitor.interval }} - interval: {{ .Values.serviceMonitor.interval }} + - port: metrics + {{- if .Values.metrics.serviceMonitor.interval }} + interval: {{ .Values.metrics.serviceMonitor.interval }} {{- end }} + {{- if .Values.metrics.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }} + {{- end }} + {{- if .Values.metrics.serviceMonitor.honorLabels }} + honorLabels: {{ .Values.metrics.serviceMonitor.honorLabels }} + {{- end }} + {{- if .Values.metrics.serviceMonitor.relabellings }} + metricRelabelings: {{- toYaml .Values.metrics.serviceMonitor.relabellings | nindent 6 }} + {{- end }} selector: matchLabels: {{- include "centrifugo.selectorLabels" . | nindent 6 }} diff --git a/charts/centrifugo/values.yaml b/charts/centrifugo/values.yaml index 5a44ebb..64939f8 100644 --- a/charts/centrifugo/values.yaml +++ b/charts/centrifugo/values.yaml @@ -1,6 +1,16 @@ +## Global Docker image parameters +## Please, note that this will override the image parameters, including dependencies, configured to use the global value +## Current available global Docker image parameters: imageRegistry and imagePullSecrets +## +# global: +# imageRegistry: myRegistryName +# imagePullSecrets: +# - myRegistryKeySecretName + replicaCount: 1 image: + registry: docker.io repository: centrifugo/centrifugo pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. @@ -12,22 +22,29 @@ fullnameOverride: "" namespaceOverride: "" service: + ## Service type + ## type: ClusterIP - externalPort: 8000 - internalPort: 9000 - grpcPort: 10000 - # externalNodePort: 30100 - # internalNodePort: 30101 - # grpcNodePort: 30102 + ## Service port + ## + port: 8000 + ## Specify the nodePort value for the LoadBalancer and NodePort service types. + ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport + ## + nodePort: "" + ## Provide any additional annotations which may be required + ## annotations: {} - # prometheus.io/scrape: "true" - # prometheus.io/path: "/metrics" - # prometheus.io/port: "9000" + ## + ## Use separate service for internal endpoints. It could be useful for configuring same port number for all services. + useSeparateInternalService: false + ## Use separate service for GRPC endpoints. It could be useful for configuring same port number for all services. + useSeparateGrpcService: false internalService: - enabled: false port: 9000 type: ClusterIP + nodePort: "" # Static NodePort, if set. # nodePort: 30101 annotations: {} @@ -36,9 +53,9 @@ internalService: # prometheus.io/port: "9000" grpcService: - enabled: false port: 10000 type: ClusterIP + nodePort: "" # Static NodePort, if set. # nodePort: 30102 annotations: {} @@ -108,13 +125,33 @@ deploymentStrategy: {} # maxSurge: 0 # maxUnavailable: 1 -serviceMonitor: +metrics: enabled: false - # namespace: monitoring - # interval: 10 + serviceMonitor: + enabled: false + ## Specify the namespace in which the serviceMonitor resource will be created + ## + # namespace: "" + ## Specify the interval at which metrics should be scraped + ## + interval: 30s + ## Specify the timeout after which the scrape is ended + ## + # scrapeTimeout: 30s + ## Specify Metric Relabellings to add to the scrape endpoint + ## + # relabellings: + ## Specify honorLabels parameter to add the scrape endpoint + ## + honorLabels: false + ## Specify the release for ServiceMonitor. Sometimes it should be custom for prometheus operator to work + ## + # release: "" + ## Used to pass Labels that are used by the Prometheus installed in your cluster to select Service Monitors to work with + ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec + ## + additionalLabels: {} - # Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator. - labels: {} nodeSelector: {} @@ -122,61 +159,52 @@ tolerations: [] affinity: {} -centrifugo: - # Additional environment variables to be passed to Centrifugo container. - env: {} - - # Centrifugo container ports. - ports: - external: 8000 - internal: 9000 - grpc: 10000 +# Additional environment variables to be passed to Centrifugo container. +env: {} - # Centrifugo configuration, will be transformed into config.json file. - config: - # Engine to use. Default memory engine allows running only one Centrifugo pod. - # Scale to many pods with Redis engine or Nats broker. Refer to Centrifugo - # documentation: https://centrifugal.github.io/centrifugo/server/engines/ - engine: "memory" +# Centrifugo configuration, will be transformed into config.json file. +config: + # Engine to use. Default memory engine allows running only one Centrifugo pod. + # Scale to many pods with Redis engine or Nats broker. Refer to Centrifugo + # documentation: https://centrifugal.github.io/centrifugo/server/engines/ + engine: "memory" - # Broker to use, not used by default. You can enable Nats broker settings - # this option to "nats". Refer to https://centrifugal.github.io/centrifugo/server/engines/ - broker: "" + # Use offset protocol field. + v3_use_offset: true - # Use offset protocol field. - v3_use_offset: true + # Enable admin web interface by default. + admin: true - # Enable admin web interface by default. - admin: true + # Array of namespaces. + namespaces: [] - # Array of namespaces. - namespaces: [] +# existingSecret: my-secret - # Centrifugo secrets. - secrets: - # Secret key for HMAC tokens. - tokenHmacSecretKey: "" +# Centrifugo secrets. +secrets: + # Secret key for HMAC tokens. + tokenHmacSecretKey: "" - # Admin password used to protect access to web interface. - adminPassword: "" + # Admin password used to protect access to web interface. + adminPassword: "" - # Admin secret used to create auth tokens on user login into admin web interface. - adminSecret: "" + # Admin secret used to create auth tokens on user login into admin web interface. + adminSecret: "" - # Centrifugo api_key for Centrifugo API endpoint authorization. - apiKey: "" + # Centrifugo api_key for Centrifugo API endpoint authorization. + apiKey: "" - # Centrifugo grpc_api_key for Centrifugo GRPC API authorization. - grpcApiKey: "" + # Centrifugo grpc_api_key for Centrifugo GRPC API authorization. + grpcApiKey: "" - # Connection string to Redis. - redisUrl: "" + # Connection string to Redis. + redisUrl: "" - # Password for Redis. - redisPassword: "" + # Password for Redis. + redisPassword: "" - # Password for Redis Sentinel. - redisSentinelPassword: "" + # Password for Redis Sentinel. + redisSentinelPassword: "" - # Connection string to Nats. - natsUrl: "" + # Connection string to Nats. + natsUrl: ""