From e7e92cbeb51dcb8a3331a6feabec59aa61b772b9 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Thu, 6 Nov 2025 17:36:02 +0100 Subject: [PATCH] test: add max-chart-size validation test case Signed-off-by: Benoit Tigeot --- pkg/cmd/pull_test.go | 4 +- .../testdata/testcharts/bigchart-0.1.0.tgz | Bin 0 -> 7092 bytes .../testdata/testcharts/bigchart/.helmignore | 23 ++ .../testdata/testcharts/bigchart/Chart.yaml | 24 +++ .../testcharts/bigchart/templates/NOTES.txt | 35 ++++ .../bigchart/templates/_helpers.tpl | 62 ++++++ .../bigchart/templates/deployment.yaml | 78 +++++++ .../testcharts/bigchart/templates/hpa.yaml | 32 +++ .../bigchart/templates/httproute.yaml | 38 ++++ .../bigchart/templates/ingress.yaml | 43 ++++ .../bigchart/templates/service.yaml | 15 ++ .../bigchart/templates/serviceaccount.yaml | 13 ++ .../templates/tests/test-connection.yaml | 15 ++ .../testdata/testcharts/bigchart/values.yaml | 198 ++++++++++++++++++ 14 files changed, 578 insertions(+), 2 deletions(-) create mode 100644 pkg/cmd/testdata/testcharts/bigchart-0.1.0.tgz create mode 100644 pkg/cmd/testdata/testcharts/bigchart/.helmignore create mode 100644 pkg/cmd/testdata/testcharts/bigchart/Chart.yaml create mode 100644 pkg/cmd/testdata/testcharts/bigchart/templates/NOTES.txt create mode 100644 pkg/cmd/testdata/testcharts/bigchart/templates/_helpers.tpl create mode 100644 pkg/cmd/testdata/testcharts/bigchart/templates/deployment.yaml create mode 100644 pkg/cmd/testdata/testcharts/bigchart/templates/hpa.yaml create mode 100644 pkg/cmd/testdata/testcharts/bigchart/templates/httproute.yaml create mode 100644 pkg/cmd/testdata/testcharts/bigchart/templates/ingress.yaml create mode 100644 pkg/cmd/testdata/testcharts/bigchart/templates/service.yaml create mode 100644 pkg/cmd/testdata/testcharts/bigchart/templates/serviceaccount.yaml create mode 100644 pkg/cmd/testdata/testcharts/bigchart/templates/tests/test-connection.yaml create mode 100644 pkg/cmd/testdata/testcharts/bigchart/values.yaml diff --git a/pkg/cmd/pull_test.go b/pkg/cmd/pull_test.go index eae095e2b..6d34d9f80 100644 --- a/pkg/cmd/pull_test.go +++ b/pkg/cmd/pull_test.go @@ -213,9 +213,9 @@ func TestPullCmd(t *testing.T) { }, { name: "Fail because of small max chart size", - args: "test/signtest --untar --max-chart-size=1Ki", + args: "test/bigchart --untar --max-chart-size=3Ki", wantError: true, - wantErrorMsg: "decompressed chart is larger than the maximum size 1Ki", + wantErrorMsg: "decompressed chart is larger than the maximum size 3Ki", }, } diff --git a/pkg/cmd/testdata/testcharts/bigchart-0.1.0.tgz b/pkg/cmd/testdata/testcharts/bigchart-0.1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..f00a831e972e971c7f0d9ef3470a06df63318290 GIT binary patch literal 7092 zcmV;l8%yLLiwFSq$_!}$1MOXVa~n63-@o}OaJ08%=ft5T>yctr>Pjnn6V=+X&T_J~ zwY8N3XFv+^yfP0;isSq2_v;2QFAgc%mgP;YW;Zf91E3rIZlDL8>bZX@vts>M2&2>$o*i2vQ$+c*E(OY9!(?mXMwKiE5bCU)@e;m)7L!574-y2`we8Bm$3IMIby z=($RYo_1(9o2?ng&ZGMG4{}W%|4--#Lk^# z(sTWX^IxX=Cza(oi6>&QH;84VCc+8DAW*rV>9pX-$KnSSMuMM+S(1srl~a|)s!;i0 z@Cc916JN$+s)W+TrOE`pY{@hYwJ&LuErEVgY=wH7$?Rs!^zjCdXn?wzxt$A{DYW*J zFjPL@PiCS}Q5s4B6~(2jz@^fEC+8{K;VDMCY0!?wB?c)>MiCLIWs5w;O$t$HAWKYsd#Qm%-k826wPzmLZz3)u$cD%- zlQIlwT#zJFk%|jYMM?is6gpDkCMiWE-|<-S+;OQMoUqhHABXq0r7dR8&46Bo0Xkbz zHiDzBQ&1G}Fyss(lw64m70I~JzH3OsJh?22G@p#exr#89mt^zt)4{?i#g4b@?R2N! znI=i4L8fBtRMFTKHP=%Iqi;qZN1X;FuRUpEV`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LXPSK!Qn?0;8g zY;Io=1i~~IQ{_wAV9XOB)i}7Cr_1N|nx9YOg9nv8VO;0p$@GRv@%-$9+VcDIh%cXd zgVP!P(hcoEnn9{v==ywk^Gj%9NEHNp{um$pNXT1kS5vkQFdcOpM!I{*yd&Dm=bI4R zR?u@k(TV?8vy! zH7Gj&N;uL_f_eF+`E9rr&fHGPGe9?57HLRy&#QWaRk>iUp2=1ryQlijXC@Bih4wUb(o z)Ork3f7IA<3s2Uj(N9+m7B}bEumf(`q5ZH_^3yxO!{$}zTDkv2f9ZhQ*c`n1Icean z>;FgH`u}G~&mQVO?&a!D>&}y)Czl&;uoO1xh|TbGbGoGzZRniRWs+^6uTo2dRy#5~#10hNPga81#5#%BO literal 0 HcmV?d00001 diff --git a/pkg/cmd/testdata/testcharts/bigchart/.helmignore b/pkg/cmd/testdata/testcharts/bigchart/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/pkg/cmd/testdata/testcharts/bigchart/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/pkg/cmd/testdata/testcharts/bigchart/Chart.yaml b/pkg/cmd/testdata/testcharts/bigchart/Chart.yaml new file mode 100644 index 000000000..9a46e7810 --- /dev/null +++ b/pkg/cmd/testdata/testcharts/bigchart/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: bigchart +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/pkg/cmd/testdata/testcharts/bigchart/templates/NOTES.txt b/pkg/cmd/testdata/testcharts/bigchart/templates/NOTES.txt new file mode 100644 index 000000000..534829abd --- /dev/null +++ b/pkg/cmd/testdata/testcharts/bigchart/templates/NOTES.txt @@ -0,0 +1,35 @@ +1. Get the application URL by running these commands: +{{- if .Values.httpRoute.enabled }} +{{- if .Values.httpRoute.hostnames }} + export APP_HOSTNAME={{ .Values.httpRoute.hostnames | first }} +{{- else }} + export APP_HOSTNAME=$(kubectl get --namespace {{(first .Values.httpRoute.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.httpRoute.parentRefs).name }} -o jsonpath="{.spec.listeners[0].hostname}") + {{- end }} +{{- if and .Values.httpRoute.rules (first .Values.httpRoute.rules).matches (first (first .Values.httpRoute.rules).matches).path.value }} + echo "Visit http://$APP_HOSTNAME{{ (first (first .Values.httpRoute.rules).matches).path.value }} to use your application" + + NOTE: Your HTTPRoute depends on the listener configuration of your gateway and your HTTPRoute rules. + The rules can be set for path, method, header and query parameters. + You can check the gateway configuration with 'kubectl get --namespace {{(first .Values.httpRoute.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.httpRoute.parentRefs).name }} -o yaml' +{{- end }} +{{- else if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "bigchart.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "bigchart.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "bigchart.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 "bigchart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/pkg/cmd/testdata/testcharts/bigchart/templates/_helpers.tpl b/pkg/cmd/testdata/testcharts/bigchart/templates/_helpers.tpl new file mode 100644 index 000000000..3f9a279f9 --- /dev/null +++ b/pkg/cmd/testdata/testcharts/bigchart/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "bigchart.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "bigchart.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "bigchart.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "bigchart.labels" -}} +helm.sh/chart: {{ include "bigchart.chart" . }} +{{ include "bigchart.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "bigchart.selectorLabels" -}} +app.kubernetes.io/name: {{ include "bigchart.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "bigchart.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "bigchart.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/pkg/cmd/testdata/testcharts/bigchart/templates/deployment.yaml b/pkg/cmd/testdata/testcharts/bigchart/templates/deployment.yaml new file mode 100644 index 000000000..777a486ab --- /dev/null +++ b/pkg/cmd/testdata/testcharts/bigchart/templates/deployment.yaml @@ -0,0 +1,78 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "bigchart.fullname" . }} + labels: + {{- include "bigchart.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "bigchart.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "bigchart.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "bigchart.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + {{- with .Values.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + {{- with .Values.livenessProbe }} + livenessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.readinessProbe }} + readinessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/pkg/cmd/testdata/testcharts/bigchart/templates/hpa.yaml b/pkg/cmd/testdata/testcharts/bigchart/templates/hpa.yaml new file mode 100644 index 000000000..1dbc7c2d0 --- /dev/null +++ b/pkg/cmd/testdata/testcharts/bigchart/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "bigchart.fullname" . }} + labels: + {{- include "bigchart.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "bigchart.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/pkg/cmd/testdata/testcharts/bigchart/templates/httproute.yaml b/pkg/cmd/testdata/testcharts/bigchart/templates/httproute.yaml new file mode 100644 index 000000000..cc0c5c66f --- /dev/null +++ b/pkg/cmd/testdata/testcharts/bigchart/templates/httproute.yaml @@ -0,0 +1,38 @@ +{{- if .Values.httpRoute.enabled -}} +{{- $fullName := include "bigchart.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: {{ $fullName }} + labels: + {{- include "bigchart.labels" . | nindent 4 }} + {{- with .Values.httpRoute.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + parentRefs: + {{- with .Values.httpRoute.parentRefs }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.httpRoute.hostnames }} + hostnames: + {{- toYaml . | nindent 4 }} + {{- end }} + rules: + {{- range .Values.httpRoute.rules }} + {{- with .matches }} + - matches: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .filters }} + filters: + {{- toYaml . | nindent 8 }} + {{- end }} + backendRefs: + - name: {{ $fullName }} + port: {{ $svcPort }} + weight: 1 + {{- end }} +{{- end }} diff --git a/pkg/cmd/testdata/testcharts/bigchart/templates/ingress.yaml b/pkg/cmd/testdata/testcharts/bigchart/templates/ingress.yaml new file mode 100644 index 000000000..d6010215b --- /dev/null +++ b/pkg/cmd/testdata/testcharts/bigchart/templates/ingress.yaml @@ -0,0 +1,43 @@ +{{- if .Values.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "bigchart.fullname" . }} + labels: + {{- include "bigchart.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- with .Values.ingress.className }} + ingressClassName: {{ . }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- with .pathType }} + pathType: {{ . }} + {{- end }} + backend: + service: + name: {{ include "bigchart.fullname" $ }} + port: + number: {{ $.Values.service.port }} + {{- end }} + {{- end }} +{{- end }} diff --git a/pkg/cmd/testdata/testcharts/bigchart/templates/service.yaml b/pkg/cmd/testdata/testcharts/bigchart/templates/service.yaml new file mode 100644 index 000000000..ce0599f5f --- /dev/null +++ b/pkg/cmd/testdata/testcharts/bigchart/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "bigchart.fullname" . }} + labels: + {{- include "bigchart.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "bigchart.selectorLabels" . | nindent 4 }} diff --git a/pkg/cmd/testdata/testcharts/bigchart/templates/serviceaccount.yaml b/pkg/cmd/testdata/testcharts/bigchart/templates/serviceaccount.yaml new file mode 100644 index 000000000..31c7bb778 --- /dev/null +++ b/pkg/cmd/testdata/testcharts/bigchart/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "bigchart.serviceAccountName" . }} + labels: + {{- include "bigchart.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/pkg/cmd/testdata/testcharts/bigchart/templates/tests/test-connection.yaml b/pkg/cmd/testdata/testcharts/bigchart/templates/tests/test-connection.yaml new file mode 100644 index 000000000..9b25bdeff --- /dev/null +++ b/pkg/cmd/testdata/testcharts/bigchart/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "bigchart.fullname" . }}-test-connection" + labels: + {{- include "bigchart.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "bigchart.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/pkg/cmd/testdata/testcharts/bigchart/values.yaml b/pkg/cmd/testdata/testcharts/bigchart/values.yaml new file mode 100644 index 000000000..3641cd7e0 --- /dev/null +++ b/pkg/cmd/testdata/testcharts/bigchart/values.yaml @@ -0,0 +1,198 @@ +# Default values for bigchart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ +replicaCount: 1 + +# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ +image: + repository: nginx + # This sets the pull policy for images. + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +# This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ +imagePullSecrets: [] +# This is to override the chart name. +nameOverride: "" +fullnameOverride: "" + +# This section builds out the service account more information can be found here: https://kubernetes.io/docs/concepts/security/service-accounts/ +serviceAccount: + # Specifies whether a service account should be created. + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: true + # Annotations to add to the service account. + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template. + name: "" + +# This is for setting Kubernetes Annotations to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +podAnnotations: {} +# This is for setting Kubernetes Labels to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +# This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ +service: + # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types + type: ClusterIP + # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports + port: 80 + +# This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +# -- Expose the service via gateway-api HTTPRoute +# Requires Gateway API resources and suitable controller installed within the cluster +# (see: https://gateway-api.sigs.k8s.io/guides/) +httpRoute: + # HTTPRoute enabled. + enabled: false + # HTTPRoute annotations. + annotations: {} + # Which Gateways this Route is attached to. + parentRefs: + - name: gateway + sectionName: http + # namespace: default + # Hostnames matching HTTP header. + hostnames: + - chart-example.local + # List of rules and filters applied. + rules: + - matches: + - path: + type: PathPrefix + value: /headers + # filters: + # - type: RequestHeaderModifier + # requestHeaderModifier: + # set: + # - name: My-Overwrite-Header + # value: this-is-the-only-value + # remove: + # - User-Agent + # - matches: + # - path: + # type: PathPrefix + # value: /echo + # headers: + # - name: version + # value: v2 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # 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 + # requests: + # cpu: 100m + # memory: 128Mi + +# This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +livenessProbe: + httpGet: + path: / + port: http +readinessProbe: + httpGet: + path: / + port: http + +# This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] + # - name: foo + # secret: + # secretName: mysecret + # optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] + # - name: foo + # mountPath: "/etc/foo" + # readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +# Large data section to make this chart exceed 1KB when compressed +# This is used for testing the --max-chart-size flag +largeData: | + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure + dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat + non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Sed ut perspiciatis unde omnis iste natus error + sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi + architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, + sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum + quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam + aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi + ut aliquid ex ea commodi consequatur. Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae + consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur. At vero eos et accusamus et iusto odio dignissimos + ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati + cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et + harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil + impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus + autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae + non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur + aut perferendis doloribus asperiores repellat. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor + incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Curabitur pretium + tincidunt lacus. Nulla gravida orci a odio. Nullam varius, turpis et commodo pharetra, est eros bibendum elit, nec luctus magna + felis sollicitudin mauris. Integer in mauris eu nibh euismod gravida. Duis ac tellus et risus vulputate vehicula. Donec lobortis + risus a elit. Etiam tempor. Ut ullamcorper, ligula eu tempor congue, eros est euismod turpis, id tincidunt sapien risus a quam. + Maecenas fermentum consequat mi. Donec fermentum. Pellentesque malesuada nulla a mi. Duis sapien sem, aliquet nec, commodo eget, + consequat quis, neque. Aliquam faucibus, elit ut dictum aliquet, felis nisl adipiscing sapien, sed malesuada diam lacus eget erat. + Cras mollis scelerisque nunc. Nullam arcu. Aliquam consequat. Curabitur augue lorem, dapibus quis, laoreet et, pretium ac, nisi. + Aenean magna nisl, mollis quis, molestie eu, feugiat in, orci. In hac habitasse platea dictumst. Fusce convallis, mauris imperdiet + gravida bibendum, nisl turpis suscipit mauris, sed placerat ipsum urna sed risus. In convallis tellus a mauris. Curabitur non elit + ut libero tristique sodales. Mauris a lacus. Donec mattis semper leo. In hac habitasse platea dictumst. Vivamus facilisis diam at + odio. Mauris dictum, nisi eget consequat elementum, lacus ligula molestie metus, non feugiat orci magna ac sem. Donec turpis ipsum, + mattis non, malesuada nec, nonummy vel, lorem. Vivamus facilisis diam at odio. Mauris dictum, nisi eget consequat elementum, lacus + ligula molestie metus, non feugiat orci magna ac sem.