From 0866ba1a51b0a1196e99269542b80cb600eaeb2e Mon Sep 17 00:00:00 2001 From: Chi-En Wu Date: Thu, 23 Apr 2020 14:02:58 +0800 Subject: [PATCH] docs: add description about `common.pdb` --- README.md | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/README.md b/README.md index 2c44e83..5dbc003 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ It provides utilities that reflect best practices of Kubernetes chart developmen * [`common.deployment`](#commondeployment) * [`common.hpa`](#commonhpa) * [`common.ingress`](#commoningress) + * [`common.pdb`](#commonpdb) * [`common.secret`](#commonsecret) * [`common.service`](#commonservice) * [`common.serviceAccount`](#commonserviceaccount) @@ -331,6 +332,68 @@ spec: +### `common.pdb` + +The `common.pdb` template accepts a list of five values: + +- `$top`, the top context +- `$pdb`, a dictionary of values used in the hpa template +- `$deployment`, a dictionary of values used in the deployment template +- `$autoscaling`, a dictionary of values used in the hpa template +- [optional] the template name of the overrides + +It creates a basic `PodDisruptionBudget` resource with the following defaults: + +- Selector is set to + ```yaml + app.kubernetes.io/name: {{ include "common.name" }} + app.kubernetes.io/instance: {{ .Release.Name }} + ``` + to match the default used in the `Pod` resource + +An example values file that can be used to configure the `PodDisruptionBudget` resource is: + +```yaml +podDisruptionBudget: + ## You can specify only one of maxUnavailable and minAvailable in a single PodDisruptionBudget + minAvailable: 2 + # maxUnavailable: 1 +``` + +Example use: + +```yaml +{{- include "common.pdb" (list . .Values.podDisruptionBudget .Values .Values.autoscaling) -}} + +## The following is the same as above: +# {{- include "common.pdb" (list . .Values.podDisruptionBudget .Values .Values.autoscaling "mychart.pdb") -}} +# {{- define "mychart.pdb" -}} +# {{- end -}} +``` + +Output: + +```yaml +apiVersion: policy/v1beta1 +kind: PodDisruptionBudget +metadata: + labels: + app.kubernetes.io/instance: release-name + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: mychart + app.kubernetes.io/version: 1.16.0 + helm.sh/chart: mychart-0.1.0 + name: release-name-mychart +spec: + minAvailable: 2 + selector: + matchLabels: + app.kubernetes.io/instance: release-name + app.kubernetes.io/name: mychart +``` + + + ### `common.secret` The `common.secret` template accepts a list of two values: