feat: add pdb to chart create util

Signed-off-by: Naseem Ullah <24660299+naseemkullah@users.noreply.github.com>
pull/10740/head
Naseem Ullah 4 years ago
parent 2153f70747
commit 5746c7593c
No known key found for this signature in database
GPG Key ID: 86CADBF6CB95B15F

@ -30,6 +30,8 @@ import (
"helm.sh/helm/v3/pkg/helmpath"
)
const expectedNumberOfTemplates = 10
func TestCreateCmd(t *testing.T) {
defer ensure.HelmHome(t)()
cname := "testchart"
@ -106,7 +108,6 @@ func TestCreateStarterCmd(t *testing.T) {
t.Errorf("Wrong API version: %q", c.Metadata.APIVersion)
}
expectedNumberOfTemplates := 9
if l := len(c.Templates); l != expectedNumberOfTemplates {
t.Errorf("Expected %d templates, got %d", expectedNumberOfTemplates, l)
}
@ -174,7 +175,6 @@ func TestCreateStarterAbsoluteCmd(t *testing.T) {
t.Errorf("Wrong API version: %q", c.Metadata.APIVersion)
}
expectedNumberOfTemplates := 9
if l := len(c.Templates); l != expectedNumberOfTemplates {
t.Errorf("Expected %d templates, got %d", expectedNumberOfTemplates, l)
}

@ -63,6 +63,8 @@ const (
ServiceAccountName = TemplatesDir + sep + "serviceaccount.yaml"
// HorizontalPodAutoscalerName is the name of the example hpa file.
HorizontalPodAutoscalerName = TemplatesDir + sep + "hpa.yaml"
// PodDisruptionBudgetName is the name of the example pdb file.
PodDisruptionBudgetName = TemplatesDir + sep + "pdb.yaml"
// NotesName is the name of the example NOTES.txt file.
NotesName = TemplatesDir + sep + "NOTES.txt"
// HelpersName is the name of the example helpers file.
@ -180,6 +182,9 @@ autoscaling:
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
podDisruptionBudget: {}
# maxUnavailable: 1
nodeSelector: {}
tolerations: []
@ -399,6 +404,20 @@ spec:
{{- end }}
`
const defaultPodDisruptionBudget = `{{- if .Values.podDisruptionBudget -}}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ include "<CHARTNAME>.fullname" . }}
labels:
{{- include "<CHARTNAME>.labels" . | nindent 4 }}
spec:
{{- toYaml .Values.podDisruptionBudget | nindent 2 }}
selector:
{{- include "<CHARTNAME>.selectorLabels" . | nindent 4 }}
{{- end }}
`
const defaultNotes = `1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
@ -630,6 +649,11 @@ func Create(name, dir string) (string, error) {
path: filepath.Join(cdir, HorizontalPodAutoscalerName),
content: transform(defaultHorizontalPodAutoscaler, name),
},
{
// pdb.yaml
path: filepath.Join(cdir, PodDisruptionBudgetName),
content: transform(defaultPodDisruptionBudget, name),
},
{
// NOTES.txt
path: filepath.Join(cdir, NotesName),

@ -50,8 +50,11 @@ func TestCreate(t *testing.T) {
ChartfileName,
DeploymentName,
HelpersName,
HorizontalPodAutoscalerName,
IgnorefileName,
IngressFileName,
NotesName,
PodDisruptionBudgetName,
ServiceAccountName,
ServiceName,
TemplatesDir,

Loading…
Cancel
Save