[stable/mercure] Support for v0.8 and modernize the chart (#19294)

Signed-off-by: Kévin Dunglas <dunglas@gmail.com>
This commit is contained in:
Kévin Dunglas
2019-12-02 06:31:04 -08:00
committed by Kubernetes Prow Robot
parent 7c0f56bda5
commit bc39853140
13 changed files with 185 additions and 122 deletions
+5 -3
View File
@@ -1,14 +1,16 @@
apiVersion: v1
appVersion: "0.6.0"
appVersion: "0.8.0"
description: The Mercure hub allows to push data updates using the Mercure protocol to web browsers and other HTTP clients in a convenient, fast, reliable and battery-efficient way
name: mercure
version: 1.0.10
version: 2.0.0
keywords:
- mercure
- hub
- push
- streaming-api
- async-api
home: https://mercure.rocks
icon: https://cdn.jsdelivr.net/gh/dunglas/mercure/public/mercure.svg
icon: https://mercure.rocks/static/logo.svg
sources:
- https://github.com/dunglas/mercure
maintainers:
+35 -33
View File
@@ -41,40 +41,42 @@ The command removes all the Kubernetes components associated with the chart and
## Configuration
The following table lists the configurable parameters of the Moodle chart and their default values.
The following table lists the configurable parameters of the Mercure chart and their default values.
| Parameter | Description | Default | | |
|---------------------------|-----------------------------------------------------------------------------------------------------|---------------------|---|---|
| `allowAnonymous` | set to `1` to allow subscribers with no valid JWT to connect | `0` | | |
| `corsAllowedOrigins` | a comma separated list of allowed CORS origins, can be `*` for all | empty | | |
| `debug` | set to `1` to enable the debug mode (prints recovery stack traces) | `0` | | |
| `demo` | set to `1` to enable the demo mode (automatically enabled when `debug` is `1`) | `0` | | |
| `jwtKey` | the JWT key to use for both publishers and subscribers | random string | | |
| `logFormat` | the log format | `FLUENTD` | | |
| `publishAllowedOrigins` | a comma separated list of origins allowed to publish (only applicable when using cookie-based auth) | empty | | |
| `publisherJwtKey` | must contain the secret key to valid publishers' JWT, can be omitted in favor of `jwtKey` | empty | | |
| `subscriberJwtKey` | must contain the secret key to valid subscribers' JWT, can be omitted in favor of `jwtKey` | empty | | |
| `heartbeatInterval` | interval between heartbeats (useful with some proxies, and old browsers) | `0s` | | |
| `historyCleanupFrequency` | chances to trigger history cleanup when an update occurs (number between `0` and `1`) | `0.3` | | |
| `historySize` | size of the history (`0` for no limits) | `0` | | |
| `readTimeout` | maximum duration for reading the entire request, including the body | `0s` | | |
| `writeTimeout` | maximum duration before timing out writes of the response | `0s` | | |
| `useForwardedHeaders` | use the `X-Forwarded-For`, and `X-Real-IP` for the remote (client) IP address, `X-Forwarded-Proto` or `X-Forwarded-Scheme` for the scheme (http or https), `X-Forwarded-Host` for the host and the RFC 7239 `Forwarded` header, which may include both client IPs and schemes. If this option is enabled, the reverse proxy must override or remove these headers or you will be at risk. | `0` | | |
| `image.repository` | controller container image repository | `dunglas/mercure` | | |
| `image.tag` | controller container image tag | `v0.3.2` | | |
| `image.pullPolicy` | controller container image pull policy | `IfNotPresent` | | |
| `nameOverride` | Name override | empty | | |
| `fullnameOverride` | fullname override | `empty | | |
| `service.type` | Service type | `NodePort` | | |
| `service.port` | Service port | `80` | | |
| `ingress.enabled` | Enables Ingress | `false` | | |
| `ingress.annotations` | Ingress annotations | `{}` | | |
| `ingress.paths` | Ingress paths for all hostnames | `["/"]` | | |
| `ingress.hosts` | Ingress accepted hostnames | `["mercure.local"]` | | |
| `ingress.tls` | Ingress TLS configuration | `[]` | | |
| `resources` | controller pod resource requests & limits | `{}` | | |
| `nodeSelector` | node labels for controller pod assignment | `{}` | | |
| `tolerations` | controller pod toleration for taints | `{}` | | |
| Parameter | Description | Default | | |
|-------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------|---|---|
| `transportUrl` | URL representation of the history database, see [the dedicated documentation](https://mercure.rocks/docs/hub/config#bolt-adapter) | `bolt://updates.db?size=0&cleanup_frequency=0.3` | | |
| `allowAnonymous` | set to `1` to allow subscribers with no valid JWT to connect | `0` | | |
| `corsAllowedOrigins` | a space separated list of allowed CORS origins, can be `*` for all | empty | | |
| `debug` | set to `1` to enable the debug mode (prints recovery stack traces) | `0` | | |
| `demo` | set to `1` to enable the demo mode (automatically enabled when `debug` is `1`) | `0` | | |
| `jwtKey` | the JWT key to use for both publishers and subscribers | random string | | |
| `logFormat` | the log format | `FLUENTD` | | |
| `publishAllowedOrigins` | a space separated list of origins allowed to publish (only applicable when using cookie-based auth) | empty | | |
| `publisherJwtKey` | must contain the secret key to valid publishers' JWT, can be omitted in favor of `jwtKey` | empty | | |
| `subscriberJwtKey` | must contain the secret key to valid subscribers' JWT, can be omitted in favor of `jwtKey` | empty | | |
| `heartbeatInterval` | interval between heartbeats (useful with some proxies, and old browsers) | `0s` | | |
| `readTimeout` | maximum duration for reading the entire request, including the body | `0s` | | |
| `writeTimeout` | maximum duration before timing out writes of the response | `0s` | | |
| `useForwardedHeaders` | use the `X-Forwarded-For`, and `X-Real-IP` for the remote (client) IP address, `X-Forwarded-Proto` or `X-Forwarded-Scheme` for the scheme (http or https), `X-Forwarded-Host` for the host and the RFC 7239 `Forwarded` header, which may include both client IPs and schemes. If this option is enabled, the reverse proxy must override or remove these headers or you will be at risk. | `0` | | |
| `image.repository` | controller container image repository | `dunglas/mercure` | | |
| `image.tag` | controller container image tag | `v0.3.2` | | |
| `image.pullPolicy` | controller container image pull policy | `IfNotPresent` | | |
| `nameOverride` | Name override | empty | | |
| `fullnameOverride` | fullname override | `empty | | |
| `service.type` | Service type | `NodePort` | | |
| `service.port` | Service port | `80` | | |
| `ingress.enabled` | Enables Ingress | `false` | | |
| `ingress.annotations` | Ingress annotations | `{}` | | |
| `ingress.hosts` | Ingress accepted hostnames | `[{ host: chart-example.local, paths: [] }]` | | |
| `ingress.tls` | Ingress TLS configuration | `[]` | | |
| `serviceAccount.create` | Whether or not to create dedicated serviceAccount for ignite | `true` | | |
| `serviceAccount.name` | If `serviceAccount.create` is enabled, what should the `serviceAccount` name be - otherwise randomly generated | `nil` | | |
| `podSecurityContext` | Pod Security Context | `{}` | | |
| `securityContext` | Container Security Context | `{}` | | |
| `resources` | controller pod resource requests & limits | `{}` | | |
| `nodeSelector` | node labels for controller pod assignment | `{}` | | |
| `tolerations` | controller pod toleration for taints | `{}` | | |
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
+3 -3
View File
@@ -3,8 +3,8 @@ The Mercure Hub is now running in the cluster.
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range $.Values.ingress.paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ . }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
@@ -14,7 +14,7 @@ The Mercure Hub is now running in the cluster.
{{- 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 "mercure.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "mercure.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "mercure.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 "mercure.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+24
View File
@@ -30,3 +30,27 @@ Create chart name and version as used by the chart label.
{{- define "mercure.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Common labels
*/}}
{{- define "mercure.labels" -}}
app.kubernetes.io/name: {{ include "mercure.name" . }}
helm.sh/chart: {{ include "mercure.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "mercure.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "mercure.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
@@ -3,6 +3,8 @@ apiVersion: cloud.google.com/v1beta1
kind: BackendConfig
metadata:
name: {{ include "mercure.fullname" . }}
labels:
{{ include "mercure.labels" . | indent 4 }}
spec:
timeoutSec: {{ .Values.backendConfig.timeoutSec }}
{{- end }}
+2 -7
View File
@@ -2,14 +2,11 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "mercure.fullname" . }}
labels:
{{ include "mercure.labels" . | indent 4 }}
annotations:
"helm.sh/hook": "pre-install,pre-upgrade"
"helm.sh/hook-delete-policy": "before-hook-creation"
labels:
app.kubernetes.io/name: {{ include "mercure.name" . }}
helm.sh/chart: {{ include "mercure.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
data:
allowAnonymous: {{ .Values.allowAnonymous | quote }}
corsAllowedOrigins: {{ .Values.corsAllowedOrigins | quote }}
@@ -18,8 +15,6 @@ data:
logFormat: {{ .Values.logFormat | quote }}
publishAllowedOrigins: {{ .Values.publishAllowedOrigins | quote }}
heartbeatInterval: {{ .Values.heartbeatInterval | quote }}
historyCleanupFrequency: {{ .Values.historyCleanupFrequency | quote }}
historySize: {{ .Values.historySize | quote }}
readTimeout: {{ .Values.readTimeout | quote }}
writeTimeout: {{ .Values.writeTimeout | quote }}
useForwardedHeaders: {{ .Values.useForwardedHeaders | quote }}
+26 -27
View File
@@ -3,12 +3,9 @@ kind: Deployment
metadata:
name: {{ include "mercure.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "mercure.name" . }}
helm.sh/chart: {{ include "mercure.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{ include "mercure.labels" . | indent 4 }}
spec:
replicas: 1
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "mercure.name" . }}
@@ -17,19 +14,41 @@ spec:
metadata:
labels:
app.kubernetes.io/name: {{ include "mercure.name" . }}
helm.sh/chart: {{ include "mercure.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ template "mercure.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: TRANSPORT_URL
valueFrom:
secretKeyRef:
name: {{ include "mercure.fullname" . }}
key: transportUrl
- name: ALLOW_ANONYMOUS
valueFrom:
configMapKeyRef:
@@ -80,16 +99,6 @@ spec:
configMapKeyRef:
name: {{ include "mercure.fullname" . }}
key: heartbeatInterval
- name: HISTORY_CLEANUP_FREQUENCY
valueFrom:
configMapKeyRef:
name: {{ include "mercure.fullname" . }}
key: historyCleanupFrequency
- name: HISTORY_SIZE
valueFrom:
configMapKeyRef:
name: {{ include "mercure.fullname" . }}
key: historySize
- name: READ_TIMEOUT
valueFrom:
configMapKeyRef:
@@ -105,16 +114,6 @@ spec:
configMapKeyRef:
name: {{ include "mercure.fullname" . }}
key: useForwardedHeaders
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
+9 -8
View File
@@ -1,15 +1,16 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "mercure.fullname" . -}}
{{- $ingressPaths := .Values.ingress.paths -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
app.kubernetes.io/name: {{ include "mercure.name" . }}
helm.sh/chart: {{ include "mercure.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{ include "mercure.labels" . | indent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
@@ -27,14 +28,14 @@ spec:
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . | quote }}
- host: {{ .host | quote }}
http:
paths:
{{- range $ingressPaths }}
{{- range .paths }}
- path: {{ . }}
backend:
serviceName: {{ $fullName }}
servicePort: http
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
+2 -4
View File
@@ -6,12 +6,10 @@ metadata:
"helm.sh/hook": "pre-install,pre-upgrade"
"helm.sh/hook-delete-policy": "before-hook-creation"
labels:
app.kubernetes.io/name: {{ include "mercure.name" . }}
helm.sh/chart: {{ include "mercure.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{ include "mercure.labels" . | indent 4 }}
type: Opaque
data:
transportUrl: {{ .Values.transportUrl | b64enc | quote }}
jwtKey: {{ .Values.jwtKey | default (randAlphaNum 12) | b64enc | quote }}
publisherJwtKey: {{ .Values.publisherJwtKey | b64enc | quote }}
subscriberJwtKey: {{ .Values.subscriberJwtKey | b64enc | quote }}
+1 -4
View File
@@ -3,10 +3,7 @@ kind: Service
metadata:
name: {{ include "mercure.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "mercure.name" . }}
helm.sh/chart: {{ include "mercure.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{ include "mercure.labels" . | indent 4 }}
{{- if .Values.backendConfig.enabled }}
annotations:
beta.cloud.google.com/backend-config: '{"default": "{{ include "mercure.fullname" . }}"}'
@@ -0,0 +1,8 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "mercure.serviceAccountName" . }}
labels:
{{ include "mercure.labels" . | indent 4 }}
{{- end -}}
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "mercure.fullname" . }}-test-connection"
labels:
{{ include "mercure.labels" . | indent 4 }}
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "mercure.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
+53 -33
View File
@@ -1,7 +1,8 @@
# Default values for chart.
# Default values for mercure.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
transportUrl: "bolt://updates.db?size=0&cleanup_frequency=0.3"
allowAnonymous: "0"
corsAllowedOrigins: ""
debug: "0"
@@ -12,38 +13,10 @@ publishAllowedOrigins: ""
publisherJwtKey: ""
subscriberJwtKey: ""
heartbeatInterval: "0s"
historyCleanupFrequency: 0.3
historySize: 0
readTimeout: "0s"
writeTimeout: "0s"
useForwardedHeaders: "0"
image:
repository: dunglas/mercure
tag: v0
pullPolicy: IfNotPresent
nameOverride: ""
fullnameOverride: ""
service:
type: NodePort
port: 80
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
paths:
- /
hosts:
- mercure.local
tls: []
# - secretName: chart-example-tls
# hosts:
# - mercure.local
# GCP load balancers by default terminate connections after 30 seconds. This can be changed by
# enabling the following backendConfig and changing the `timeoutSec` property.
# More info at: https://github.com/dunglas/mercure/issues/106 and
@@ -52,6 +25,53 @@ backendConfig:
enabled: false
timeoutSec: 30
# replicaCount MUST be 1 if you use the BoltDB transport (the default)
replicaCount: 1
image:
repository: dunglas/mercure
tag: v0
pullPolicy: IfNotPresent
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name:
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 80
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: mercure.local
paths: []
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
@@ -59,11 +79,11 @@ resources: {}
# 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
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
# cpu: 100m
# memory: 128Mi
nodeSelector: {}