Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[stable/nats] support for deploying nats with "Deployment" #13537

Merged
merged 5 commits into from
May 14, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stable/nats/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
1 change: 1 addition & 0 deletions stable/nats/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ The following table lists the configurable parameters of the NATS chart and thei
| `maxConnections` | Max. number of client connections | `nil` |
| `maxControlLine` | Max. protocol control line | `nil` |
| `maxPayload` | Max. payload | `nil` |
| `mode` | NATS cluster running mode | `statefulset` |
guessi marked this conversation as resolved.
Show resolved Hide resolved
| `writeDeadline` | Duration the server can block on a socket write to a client | `nil` |
| `replicaCount` | Number of NATS nodes | `1` |
| `securityContext.enabled` | Enable security context | `true` |
Expand Down
162 changes: 162 additions & 0 deletions stable/nats/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
{{- if eq .Values.mode "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/nats/gnatsd.conf
guessi marked this conversation as resolved.
Show resolved Hide resolved
{{- 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/nats/gnatsd.conf
guessi marked this conversation as resolved.
Show resolved Hide resolved
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 }}
guessi marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions stable/nats/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq .Values.mode "statefulset" }}
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
Expand Down Expand Up @@ -163,3 +164,4 @@ spec:
- name: config
configMap:
name: {{ template "nats.fullname" . }}
{{- end }}
14 changes: 13 additions & 1 deletion stable/nats/values-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,26 @@ podLabels: {}
##
# priorityClassName: ""

## Update strategy, can be set to RollingUpdate or OnDelete by default.
## nats-cluster running mode. Allowed values: statefulset (default) or deployment
## ref:
## - https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/
## - https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
mode: "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
## Partition update strategy
## 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/
Expand Down
14 changes: 13 additions & 1 deletion stable/nats/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,26 @@ podLabels: {}
##
# priorityClassName: ""

## Update strategy, can be set to RollingUpdate or OnDelete by default.
## nats-cluster running mode. Allowed values: statefulset (default) or deployment
## ref:
## - https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/
## - https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
mode: "statefulset"
guessi marked this conversation as resolved.
Show resolved Hide resolved

## 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
## Partition update strategy
## 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/
Expand Down