mirror of
https://github.com/helm/charts.git
synced 2026-08-23 22:37:45 +00:00
[stable/nats] support for deploying nats with "Deployment" (#13537)
* [stable/nats] support deploying nats with "Deployment"
Signed-off-by: guessi <guessi@gmail.com>
* [stable/nats] split statefulset/deployment with "mode" flag
Signed-off-by: guessi <guessi@gmail.com>
* [stable/nats] fix missing params in values-production.yaml
Signed-off-by: guessi <guessi@gmail.com>
* [stable/nats] enhanced resource type detection
Signed-off-by: guessi <guessi@gmail.com>
* Revert "[stable/nats] Update configuration path for gnatsd.conf (#13505)"
This reverts commit 5d1537d231.
See discussion at the following link:
- https://github.com/helm/charts/pull/13537#discussion_r283238250
Signed-off-by: guessi <guessi@gmail.com>
This commit is contained in:
committed by
Kubernetes Prow Robot
parent
dd4551f239
commit
1517cb6256
@@ -1,6 +1,6 @@
|
||||
apiVersion: v1
|
||||
name: nats
|
||||
version: 2.4.2
|
||||
version: 2.5.0
|
||||
appVersion: 1.4.1
|
||||
description: An open-source, cloud-native messaging system
|
||||
keywords:
|
||||
|
||||
@@ -70,6 +70,7 @@ The following table lists the configurable parameters of the NATS chart and thei
|
||||
| `maxPayload` | Max. payload | `nil` |
|
||||
| `writeDeadline` | Duration the server can block on a socket write to a client | `nil` |
|
||||
| `replicaCount` | Number of NATS nodes | `1` |
|
||||
| `resourceType` | NATS cluster resource type under Kubernetes (Supported: StatefulSets, or Deployment) | `statefulset` |
|
||||
| `securityContext.enabled` | Enable security context | `true` |
|
||||
| `securityContext.fsGroup` | Group ID for the container | `1001` |
|
||||
| `securityContext.runAsUser` | User ID for the container | `1001` |
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
** Please be patient while the chart is being deployed **
|
||||
|
||||
{{- if and (not (eq .Values.resourceType "statefulset")) (not (eq .Values.resourceType "deployment")) }}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
WARNING
|
||||
|
||||
"resourceType" currently only "statefulset", "deployment" are allowed
|
||||
the type specified in values.yaml >> {{ .Values.resourceType }} << is not defined in white list
|
||||
but it will still continuing deploy with default resource type "statefulset"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
{{- end }}
|
||||
|
||||
{{- if or (contains .Values.client.service.type "LoadBalancer") (contains .Values.client.service.type "nodePort") }}
|
||||
{{- if not .Values.auth.enabled }}
|
||||
{{ if and (not .Values.networkPolicy.enabled) (.Values.networkPolicy.allowExternal) }}
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
{{- if eq .Values.resourceType "deployment" }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ template "nats.fullname" . }}
|
||||
labels:
|
||||
app: "{{ template "nats.name" . }}"
|
||||
chart: "{{ template "nats.chart" . }}"
|
||||
release: {{ .Release.Name | quote }}
|
||||
heritage: {{ .Release.Service | quote }}
|
||||
spec:
|
||||
serviceName: {{ template "nats.fullname" . }}-headless
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxSurge: {{ .Values.deployment.maxSurge }}
|
||||
maxUnavailable: {{ .Values.deployment.maxUnavailable }}
|
||||
type: {{ .Values.deployment.updateType }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: "{{ template "nats.name" . }}"
|
||||
release: {{ .Release.Name | quote }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: "{{ template "nats.name" . }}"
|
||||
chart: "{{ template "nats.chart" . }}"
|
||||
release: {{ .Release.Name | quote }}
|
||||
{{- if .Values.podLabels }}
|
||||
{{ toYaml .Values.podLabels | indent 8 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.podAnnotations .Values.metrics.enabled }}
|
||||
annotations:
|
||||
{{- if .Values.podAnnotations }}
|
||||
{{ toYaml .Values.podAnnotations | indent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.podAnnotations }}
|
||||
{{ toYaml .Values.metrics.podAnnotations | indent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "nats.imagePullSecrets" . | indent 6 }}
|
||||
{{- if .Values.securityContext.enabled }}
|
||||
securityContext:
|
||||
fsGroup: {{ .Values.securityContext.fsGroup }}
|
||||
runAsUser: {{ .Values.securityContext.runAsUser }}
|
||||
{{- end }}
|
||||
{{- if .Values.priorityClassName }}
|
||||
priorityClassName: {{ .Values.priorityClassName | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{ toYaml .Values.nodeSelector | indent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.tolerations }}
|
||||
tolerations:
|
||||
{{ toYaml .Values.tolerations | indent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.schedulerName }}
|
||||
schedulerName: {{ .Values.schedulerName | quote }}
|
||||
{{- end }}
|
||||
{{- if eq .Values.antiAffinity "hard" }}
|
||||
affinity:
|
||||
podAntiAffinity:
|
||||
requiredDuringSchedulingIgnoredDuringExecution:
|
||||
- topologyKey: "kubernetes.io/hostname"
|
||||
labelSelector:
|
||||
matchLabels:
|
||||
app: "{{ template "nats.name" . }}"
|
||||
release: {{ .Release.Name | quote }}
|
||||
{{- else if eq .Values.antiAffinity "soft" }}
|
||||
affinity:
|
||||
podAntiAffinity:
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- weight: 1
|
||||
podAffinityTerm:
|
||||
topologyKey: kubernetes.io/hostname
|
||||
labelSelector:
|
||||
matchLabels:
|
||||
app: "{{ template "nats.name" . }}"
|
||||
release: {{ .Release.Name | quote }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: {{ template "nats.name" . }}
|
||||
image: {{ template "nats.image" . }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
command:
|
||||
- gnatsd
|
||||
args:
|
||||
- -c
|
||||
- /opt/bitnami/nats/gnatsd.conf
|
||||
# to ensure nats could run with non-root user, we put the configuration
|
||||
# file under `/opt/bitnami/nats/gnatsd.conf`, please check the link below
|
||||
# for the implementation inside Dockerfile:
|
||||
# - https://github.com/bitnami/bitnami-docker-nats/blob/master/1/debian-9/Dockerfile#L12
|
||||
{{- if .Values.extraArgs }}
|
||||
{{ toYaml .Values.extraArgs | indent 8 }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: client
|
||||
containerPort: {{ .Values.client.service.port }}
|
||||
- name: cluster
|
||||
containerPort: {{ .Values.cluster.service.port }}
|
||||
- name: monitoring
|
||||
containerPort: {{ .Values.monitoring.service.port }}
|
||||
{{- if .Values.livenessProbe.enabled }}
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: monitoring
|
||||
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.livenessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
|
||||
{{- end }}
|
||||
{{- if .Values.readinessProbe.enabled }}
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: monitoring
|
||||
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.readinessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
|
||||
{{- end }}
|
||||
resources:
|
||||
{{ toYaml .Values.resources | indent 10 }}
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /opt/bitnami/nats/gnatsd.conf
|
||||
subPath: gnatsd.conf
|
||||
{{- if .Values.sidecars }}
|
||||
{{ toYaml .Values.sidecars | indent 6 }}
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.enabled }}
|
||||
- name: metrics
|
||||
image: {{ template "nats.metrics.image" . }}
|
||||
imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
|
||||
args:
|
||||
{{ toYaml .Values.metrics.args | indent 10 -}}
|
||||
- "http://localhost:{{ .Values.monitoring.service.port }}"
|
||||
ports:
|
||||
- name: metrics
|
||||
containerPort: {{ .Values.metrics.port }}
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /metrics
|
||||
port: metrics
|
||||
initialDelaySeconds: 15
|
||||
timeoutSeconds: 5
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /metrics
|
||||
port: metrics
|
||||
initialDelaySeconds: 5
|
||||
timeoutSeconds: 1
|
||||
resources:
|
||||
{{ toYaml .Values.metrics.resources | indent 10 }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: {{ template "nats.fullname" . }}
|
||||
{{- end }}
|
||||
@@ -1,3 +1,4 @@
|
||||
{{- if or (eq .Values.resourceType "statefulset") (not (contains .Values.resourceType "deployment")) }}
|
||||
apiVersion: apps/v1beta2
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
@@ -92,7 +93,11 @@ spec:
|
||||
- gnatsd
|
||||
args:
|
||||
- -c
|
||||
- /opt/nats/gnatsd.conf
|
||||
- /opt/bitnami/nats/gnatsd.conf
|
||||
# to ensure nats could run with non-root user, we put the configuration
|
||||
# file under `/opt/bitnami/nats/gnatsd.conf`, please check the link below
|
||||
# for the implementation inside Dockerfile:
|
||||
# - https://github.com/bitnami/bitnami-docker-nats/blob/master/1/debian-9/Dockerfile#L12
|
||||
{{- if .Values.extraArgs }}
|
||||
{{ toYaml .Values.extraArgs | indent 8 }}
|
||||
{{- end }}
|
||||
@@ -129,7 +134,7 @@ spec:
|
||||
{{ toYaml .Values.resources | indent 10 }}
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /opt/nats/gnatsd.conf
|
||||
mountPath: /opt/bitnami/nats/gnatsd.conf
|
||||
subPath: gnatsd.conf
|
||||
{{- if .Values.sidecars }}
|
||||
{{ toYaml .Values.sidecars | indent 6 }}
|
||||
@@ -163,3 +168,4 @@ spec:
|
||||
- name: config
|
||||
configMap:
|
||||
name: {{ template "nats.fullname" . }}
|
||||
{{- end }}
|
||||
|
||||
@@ -65,7 +65,13 @@ podLabels: {}
|
||||
##
|
||||
# priorityClassName: ""
|
||||
|
||||
## Update strategy, can be set to RollingUpdate or OnDelete by default.
|
||||
## NATS cluster resource type under Kubernetes. Allowed values: statefulset (default) or deployment
|
||||
## ref:
|
||||
## - https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/
|
||||
## - https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
|
||||
resourceType: "statefulset"
|
||||
|
||||
## Update strategy for statefulset, can be set to RollingUpdate or OnDelete by default.
|
||||
## https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/#updating-statefulsets
|
||||
statefulset:
|
||||
updateStrategy: OnDelete
|
||||
@@ -73,6 +79,12 @@ statefulset:
|
||||
## https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#partitions
|
||||
# rollingUpdatePartition:
|
||||
|
||||
## Update strategy for deployment, can be set to RollingUpdate or OnDelete by default.
|
||||
## https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy
|
||||
deployment:
|
||||
updateType: RollingUpdate
|
||||
# maxSurge: 25%
|
||||
# maxUnavailable: 25%
|
||||
|
||||
## Configure resource requests and limits
|
||||
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
|
||||
|
||||
+13
-1
@@ -69,7 +69,13 @@ podLabels: {}
|
||||
##
|
||||
# priorityClassName: ""
|
||||
|
||||
## Update strategy, can be set to RollingUpdate or OnDelete by default.
|
||||
## NATS cluster resource type under Kubernetes. Allowed values: statefulset (default) or deployment
|
||||
## ref:
|
||||
## - https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/
|
||||
## - https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
|
||||
resourceType: "statefulset"
|
||||
|
||||
## Update strategy for statefulset, can be set to RollingUpdate or OnDelete by default.
|
||||
## https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/#updating-statefulsets
|
||||
statefulset:
|
||||
updateStrategy: OnDelete
|
||||
@@ -77,6 +83,12 @@ statefulset:
|
||||
## https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#partitions
|
||||
# rollingUpdatePartition:
|
||||
|
||||
## Update strategy for deployment, can be set to RollingUpdate or OnDelete by default.
|
||||
## https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy
|
||||
deployment:
|
||||
updateType: RollingUpdate
|
||||
# maxSurge: 25%
|
||||
# maxUnavailable: 25%
|
||||
|
||||
## Configure resource requests and limits
|
||||
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
|
||||
|
||||
Reference in New Issue
Block a user