10 Commits

Author SHA1 Message Date
97639cb6a4 ci: init 2023-03-01 16:51:10 +03:00
weian
2b878f03e0 feat: add pod priorityClassName 2023-02-15 18:35:45 +08:00
weian
f5e2b9dd67 feat: servicemonitor port must be string 2022-10-18 16:18:38 +08:00
weian
574efd8df0 feat: add podLabels value 2022-10-08 02:46:17 +08:00
weian
e62d31f8b9 feat(cronjob): add cronjob activeDeadlineSeconds options 2022-09-30 14:38:16 +08:00
weian
4383dfb7a5 feat(cronjobs): cronjob add suspend parameter 2022-09-27 20:55:27 +08:00
Wei-An Yen
2e064e65da feat: ingress.path now is an object intead string (#10) 2022-06-10 16:54:05 +08:00
Wei-An Yen
54b4a74b85 fix: wrong removing space (#9) 2022-06-10 15:57:40 +08:00
Wei-An Yen
7284144b77 fix: wrong variable calling (#8) 2022-06-10 15:19:50 +08:00
Wei-An Yen
5d28270192 feat: bump resource api version (#7) 2022-06-10 14:56:01 +08:00
9 changed files with 218 additions and 199 deletions

21
.drone.yml Normal file
View File

@@ -0,0 +1,21 @@
---
kind: pipeline
type: docker
name: default
trigger:
event:
- push
steps:
- name: release
image: cr.grachevko.ru/drone/helm:RELEASE.2023-03-01T13-46-55Z
settings:
username:
from_secret: HELM_REPO_USERNAME
password:
from_secret: HELM_REPO_PASSWORD
when:
branch:
- master
- rc

View File

@@ -14,4 +14,4 @@ type: library
# This is the chart version. This version number should be incremented each time you make changes # 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. # to the chart and its templates, including the app version.
version: 0.4.1 version: 1.4.0

350
README.md
View File

@@ -4,38 +4,34 @@ This chart was originally forked from [`incubator/common`](https://github.com/he
It provides utilities that reflect best practices of Kubernetes chart development, making it faster for you to write charts. It provides utilities that reflect best practices of Kubernetes chart development, making it faster for you to write charts.
## Contents ## Contents
- [Getting Started](#getting-started) - [Getting Started](#getting-started)
* [Adding Repository](#adding-repository) - [Adding Repository](#adding-repository)
* [Adding Dependency](#adding-dependency) - [Adding Dependency](#adding-dependency)
* [Using Starter](#using-starter) - [Using Starter](#using-starter)
- [Resource Kinds](#resource-kinds) - [Resource Kinds](#resource-kinds)
* [`common.configMap`](#commonconfigmap) - [`common.configMap`](#commonconfigmap)
* [`common.cronJob`](#commoncronjob) - [`common.cronJob`](#commoncronjob)
* [`common.deployment`](#commondeployment) - [`common.deployment`](#commondeployment)
* [`common.hpa`](#commonhpa) - [`common.hpa`](#commonhpa)
* [`common.ingress`](#commoningress) - [`common.ingress`](#commoningress)
* [`common.pdb`](#commonpdb) - [`common.pdb`](#commonpdb)
* [`common.secret`](#commonsecret) - [`common.secret`](#commonsecret)
* [`common.service`](#commonservice) - [`common.service`](#commonservice)
* [`common.serviceAccount`](#commonserviceaccount) - [`common.serviceAccount`](#commonserviceaccount)
* [`common.serviceMonitor`](#commonservicemonitor) - [`common.serviceMonitor`](#commonservicemonitor)
* [`common.serviceMonitor.secret`](#commonservicemonitorsecret) - [`common.serviceMonitor.secret`](#commonservicemonitorsecret)
- [Partial Objects](#partial-objects) - [Partial Objects](#partial-objects)
* [`common.chart`](#commonchart) - [`common.chart`](#commonchart)
* [`common.container`](#commoncontainer) - [`common.container`](#commoncontainer)
* [`common.fullname`](#commonfullname) - [`common.fullname`](#commonfullname)
* [`common.labels`](#commonlabels) - [`common.labels`](#commonlabels)
* [`common.metadata`](#commonmetadata) - [`common.metadata`](#commonmetadata)
* [`common.name`](#commonname) - [`common.name`](#commonname)
* [`common.pod.template`](#commonpodtemplate) - [`common.pod.template`](#commonpodtemplate)
* [`common.selectorLabels`](#commonselectorlabels) - [`common.selectorLabels`](#commonselectorlabels)
* [`common.serviceAccountName`](#commonserviceaccountname) - [`common.serviceAccountName`](#commonserviceaccountname)
## Getting Started ## Getting Started
@@ -84,8 +80,6 @@ $ curl https://raw.githubusercontent.com/hahow/common-chart/master/create.sh | b
Now, there is a chart in `./mychart`. You can edit it and create your own templates. Now, there is a chart in `./mychart`. You can edit it and create your own templates.
## Resource Kinds ## Resource Kinds
Kubernetes defines a variety of resource kinds, from `Secret` to `StatefulSet`. We define some of the most common kinds in a way that lets you easily work with them. Kubernetes defines a variety of resource kinds, from `Secret` to `StatefulSet`. We define some of the most common kinds in a way that lets you easily work with them.
@@ -122,8 +116,6 @@ The [`common.service`](#commonservice) template is responsible for rendering the
Each implemented base resource is described in greater detail below. Each implemented base resource is described in greater detail below.
### `common.configMap` ### `common.configMap`
The `common.configMap` template accepts a list of two values: The `common.configMap` template accepts a list of two values:
@@ -167,8 +159,6 @@ metadata:
name: release-name-mychart name: release-name-mychart
``` ```
### `common.cronJob` ### `common.cronJob`
The `common.cronJob` template accepts a list of five values: The `common.cronJob` template accepts a list of five values:
@@ -186,29 +176,31 @@ It defines a basic `CronJob` with the following defaults:
In addition, it uses the following configuration from the `$cronJob`: In addition, it uses the following configuration from the `$cronJob`:
| Value | Description | | Value | Description |
| ----- | ----------- | | ------------------------------------- | ------------------------------------------------------- |
| `$cronJob.schedule` | Schedule for the cronjob | | `$cronJob.schedule` | Schedule for the cronjob |
| `$cronJob.concurrencyPolicy` | [optional] `Allow\|Forbid\|Replace` concurrent jobs | | `$cronJob.concurrencyPolicy` | [optional] `Allow\|Forbid\|Replace` concurrent jobs |
| `$cronJob.failedJobsHistoryLimit` | [optional] Specify the number of failed jobs to keep | | `$cronJob.failedJobsHistoryLimit` | [optional] Specify the number of failed jobs to keep |
| `$cronJob.successfulJobsHistoryLimit` | [optional] Specify the number of completed jobs to keep | | `$cronJob.successfulJobsHistoryLimit` | [optional] Specify the number of completed jobs to keep |
| `$cronJob.suspend` | [optional] Specify cronjob is suspend, default false |
| `$cronJob.activeDeadlineSeconds` | [optional] Specify cronjob activeDeadlineSeconds |
Underneath the hood, it invokes [`common.pod.template`](#commonpodtemplate) template with `$pod` to populate the `PodTemplate`. Underneath the hood, it invokes [`common.pod.template`](#commonpodtemplate) template with `$pod` to populate the `PodTemplate`.
Example use: Example use:
```yaml ```yaml
{{- include "common.cronJob" (list . .Values.cronJob .Values .Values.serviceAccount) }} {
{
- include "common.cronJob" (list . .Values.cronJob .Values .Values.serviceAccount),
},
}
## The following is the same as above: ## The following is the same as above:
# {{- include "common.cronJob" (list . .Values.cronJob .Values .Values.serviceAccount "mychart.cronJob") }} # {{- include "common.cronJob" (list . .Values.cronJob .Values .Values.serviceAccount "mychart.cronJob") }}
# {{- define "mychart.cronJob" -}} # {{- define "mychart.cronJob" -}}
# {{- end }} # {{- end }}
``` ```
### `common.deployment` ### `common.deployment`
The `common.deployment` template accepts a list of five values: The `common.deployment` template accepts a list of five values:
@@ -221,31 +213,32 @@ The `common.deployment` template accepts a list of five values:
It defines a basic `Deployment` with the following settings: It defines a basic `Deployment` with the following settings:
| Value | Description | | Value | Description |
| ----- | ----------- | | -------------------------------- | -------------------------------------------------------------------------- |
| `$deployment.replicaCount` | Number of replica. If autoscaling enabled, this field will be ignored | | `$deployment.replicaCount` | Number of replica. If autoscaling enabled, this field will be ignored |
| `$deployment.imagePullSecrets` | [optional] Name of Secret resource containing private registry credentials | | `$deployment.imagePullSecrets` | [optional] Name of Secret resource containing private registry credentials |
| `$deployment.podSecurityContext` | [optional] Security options for pod | | `$deployment.podSecurityContext` | [optional] Security options for pod |
| `$deployment.nodeSelector` | [optional] Node labels for pod assignment | | `$deployment.nodeSelector` | [optional] Node labels for pod assignment |
| `$deployment.affinity` | [optional] Expressions for affinity | | `$deployment.affinity` | [optional] Expressions for affinity |
| `$deployment.tolerations` | [optional] Toleration labels for pod assignment | | `$deployment.tolerations` | [optional] Toleration labels for pod assignment |
| `$autoscaling.enabled` | [optional] Set this to `true` to enable autoscaling | | `$autoscaling.enabled` | [optional] Set this to `true` to enable autoscaling |
Underneath the hood, it invokes [`common.pod.template`](#commonpodtemplate) template with `$deployment` to populate the `PodTemplate`. Underneath the hood, it invokes [`common.pod.template`](#commonpodtemplate) template with `$deployment` to populate the `PodTemplate`.
Example use: Example use:
```yaml ```yaml
{{- include "common.deployment" (list . .Values .Values.autoscaling .Values.serviceAccount) }} {
{
- include "common.deployment" (list . .Values .Values.autoscaling .Values.serviceAccount),
},
}
## The following is the same as above: ## The following is the same as above:
# {{- include "common.deployment" (list . .Values .Values.autoscaling .Values.serviceAccount "mychart.deployment") }} # {{- include "common.deployment" (list . .Values .Values.autoscaling .Values.serviceAccount "mychart.deployment") }}
# {{- define "mychart.deployment" -}} # {{- define "mychart.deployment" -}}
# {{- end }} # {{- end }}
``` ```
### `common.hpa` ### `common.hpa`
The `common.hpa` template accepts a list of three values: The `common.hpa` template accepts a list of three values:
@@ -272,8 +265,7 @@ autoscaling:
Example use: Example use:
```yaml ```yaml
{{- include "common.hpa" (list . .Values.autoscaling) }} { { - include "common.hpa" (list . .Values.autoscaling) } }
## The following is the same as above: ## The following is the same as above:
# {{- include "common.hpa" (list . .Values.autoscaling "mychart.hpa") }} # {{- include "common.hpa" (list . .Values.autoscaling "mychart.hpa") }}
# {{- define "mychart.hpa" -}} # {{- define "mychart.hpa" -}}
@@ -296,18 +288,18 @@ metadata:
spec: spec:
maxReplicas: 5 maxReplicas: 5
metrics: metrics:
- resource: - resource:
name: cpu name: cpu
target: target:
averageUtilization: 50 averageUtilization: 50
type: Utilization type: Utilization
type: Resource type: Resource
- resource: - resource:
name: memory name: memory
target: target:
averageUtilization: 90 averageUtilization: 90
type: Utilization type: Utilization
type: Resource type: Resource
minReplicas: 3 minReplicas: 3
scaleTargetRef: scaleTargetRef:
apiVersion: apps/v1 apiVersion: apps/v1
@@ -315,8 +307,6 @@ spec:
name: release-name-mychart name: release-name-mychart
``` ```
### `common.ingress` ### `common.ingress`
The `common.ingress` template accepts a list of four values: The `common.ingress` template accepts a list of four values:
@@ -335,13 +325,14 @@ ingress:
kubernetes.io/ingress.class: nginx kubernetes.io/ingress.class: nginx
kubernetes.io/tls-acme: "true" kubernetes.io/tls-acme: "true"
hosts: hosts:
- host: chart-example.local - host: chart-example.local
paths: paths:
- /path/to/somewhere - path: /path/to/somewhere
pathType: ImplementationSpecific
tls: tls:
- secretName: chart-example-tls - secretName: chart-example-tls
hosts: hosts:
- chart-example.local - chart-example.local
service: service:
type: ClusterIP type: ClusterIP
port: 80 port: 80
@@ -350,8 +341,7 @@ service:
Example use: Example use:
```yaml ```yaml
{{- include "common.ingress" (list . .Values.ingress .Values.service) }} { { - include "common.ingress" (list . .Values.ingress .Values.service) } }
## The following is the same as above: ## The following is the same as above:
# {{- include "common.ingress" (list . .Values.ingress .Values.service "mychart.ingress") }} # {{- include "common.ingress" (list . .Values.ingress .Values.service "mychart.ingress") }}
# {{- define "mychart.ingress" -}} # {{- define "mychart.ingress" -}}
@@ -376,21 +366,22 @@ metadata:
name: release-name-mychart name: release-name-mychart
spec: spec:
rules: rules:
- host: "chart-example.local" - host: "chart-example.local"
http: http:
paths: paths:
- backend: - backend:
serviceName: release-name-mychart service:
servicePort: 80 name: release-name-mychart
path: /path/to/somewhere port:
number: 80
path: /path/to/somewhere
pathType: ImplementationSpecific
tls: tls:
- hosts: - hosts:
- "chart-example.local" - "chart-example.local"
secretName: chart-example-tls secretName: chart-example-tls
``` ```
### `common.pdb` ### `common.pdb`
The `common.pdb` template accepts a list of five values: The `common.pdb` template accepts a list of five values:
@@ -417,8 +408,11 @@ podDisruptionBudget:
Example use: Example use:
```yaml ```yaml
{{- include "common.pdb" (list . .Values.podDisruptionBudget .Values .Values.autoscaling) }} {
{
- include "common.pdb" (list . .Values.podDisruptionBudget .Values .Values.autoscaling),
},
}
## The following is the same as above: ## The following is the same as above:
# {{- include "common.pdb" (list . .Values.podDisruptionBudget .Values .Values.autoscaling "mychart.pdb") }} # {{- include "common.pdb" (list . .Values.podDisruptionBudget .Values .Values.autoscaling "mychart.pdb") }}
# {{- define "mychart.pdb" -}} # {{- define "mychart.pdb" -}}
@@ -446,8 +440,6 @@ spec:
app.kubernetes.io/name: mychart app.kubernetes.io/name: mychart
``` ```
### `common.secret` ### `common.secret`
The `common.secret` template accepts a list of two values: The `common.secret` template accepts a list of two values:
@@ -492,8 +484,6 @@ metadata:
type: Opaque type: Opaque
``` ```
### `common.service` ### `common.service`
The `common.service` template accepts a list of three values: The `common.service` template accepts a list of three values:
@@ -565,9 +555,9 @@ metadata:
name: release-name-mychart-www name: release-name-mychart-www
spec: spec:
ports: ports:
- name: www - name: www
port: 80 port: 80
targetPort: 8080 targetPort: 8080
selector: selector:
app.kubernetes.io/instance: release-name app.kubernetes.io/instance: release-name
app.kubernetes.io/name: mychart app.kubernetes.io/name: mychart
@@ -586,12 +576,12 @@ metadata:
name: release-name-mychart-mail name: release-name-mychart-mail
spec: spec:
ports: ports:
- name: smtp - name: smtp
port: 25 port: 25
targetPort: 25 targetPort: 25
- name: imaps - name: imaps
port: 993 port: 993
targetPort: 993 targetPort: 993
selector: selector:
app.kubernetes.io/instance: release-name app.kubernetes.io/instance: release-name
app.kubernetes.io/name: mychart app.kubernetes.io/name: mychart
@@ -599,8 +589,6 @@ spec:
type: ClusterIP type: ClusterIP
``` ```
### `common.serviceAccount` ### `common.serviceAccount`
The `common.serviceAccount` template accepts a list of three values: The `common.serviceAccount` template accepts a list of three values:
@@ -626,8 +614,7 @@ serviceAccount:
Example use: Example use:
```yaml ```yaml
{{- include "common.serviceAccount" (list . .Values.serviceAccount) }} { { - include "common.serviceAccount" (list . .Values.serviceAccount) } }
## The following is the same as above: ## The following is the same as above:
# {{- include "common.serviceAccount" (list . .Values.serviceAccount "mychart.serviceAccount") }} # {{- include "common.serviceAccount" (list . .Values.serviceAccount "mychart.serviceAccount") }}
# {{- define "mychart.serviceAccount" -}} # {{- define "mychart.serviceAccount" -}}
@@ -649,8 +636,6 @@ metadata:
name: release-name-mychart name: release-name-mychart
``` ```
### `common.serviceMonitor` ### `common.serviceMonitor`
The `common.serviceMonitor` template accepts a list of three values: The `common.serviceMonitor` template accepts a list of three values:
@@ -683,8 +668,7 @@ serviceMonitor:
Example use: Example use:
```yaml ```yaml
{{- include "common.serviceMonitor" (list . .Values.serviceMonitor) }} { { - include "common.serviceMonitor" (list . .Values.serviceMonitor) } }
## The following is the same as above: ## The following is the same as above:
# {{- include "common.serviceMonitor" (list . .Values.serviceMonitor "mychart.serviceMonitor") }} # {{- include "common.serviceMonitor" (list . .Values.serviceMonitor "mychart.serviceMonitor") }}
# {{- define "mychart.serviceMonitor" -}} # {{- define "mychart.serviceMonitor" -}}
@@ -707,28 +691,26 @@ metadata:
namespace: monitoring namespace: monitoring
spec: spec:
endpoints: endpoints:
- basicAuth: - basicAuth:
password: password:
key: password key: password
name: release-name-mychart name: release-name-mychart
username: username:
key: username key: username
name: release-name-mychart name: release-name-mychart
interval: 30s interval: 30s
path: /path/to/metrics path: /path/to/metrics
port: 80 port: 80
scrapeTimeout: 30s scrapeTimeout: 30s
namespaceSelector: namespaceSelector:
matchNames: matchNames:
- default - default
selector: selector:
matchLabels: matchLabels:
app.kubernetes.io/instance: release-name app.kubernetes.io/instance: release-name
app.kubernetes.io/name: mychart app.kubernetes.io/name: mychart
``` ```
### `common.serviceMonitor.secret` ### `common.serviceMonitor.secret`
The `common.serviceMonitor.secret` template accepts a list of three values: The `common.serviceMonitor.secret` template accepts a list of three values:
@@ -752,8 +734,7 @@ serviceMonitor:
Example use: Example use:
```yaml ```yaml
{{- include "common.serviceMonitor.secret" (list . .Values.serviceMonitor) }} { { - include "common.serviceMonitor.secret" (list . .Values.serviceMonitor) } }
## The following is the same as above: ## The following is the same as above:
# {{- include "common.serviceMonitor.secret" (list . .Values.serviceMonitor "mychart.serviceMonitor.secret") }} # {{- include "common.serviceMonitor.secret" (list . .Values.serviceMonitor "mychart.serviceMonitor.secret") }}
# {{- define "mychart.serviceMonitor.secret" -}} # {{- define "mychart.serviceMonitor.secret" -}}
@@ -780,14 +761,10 @@ metadata:
type: Opaque type: Opaque
``` ```
## Partial Objects ## Partial Objects
When writing Kubernetes resources, you may find the following helpers useful to construct parts of the spec. When writing Kubernetes resources, you may find the following helpers useful to construct parts of the spec.
### `common.chart` ### `common.chart`
The `common.chart` helper prints the chart name and version, escaped to be legal in a Kubernetes label field. The `common.chart` helper prints the chart name and version, escaped to be legal in a Kubernetes label field.
@@ -795,7 +772,7 @@ The `common.chart` helper prints the chart name and version, escaped to be legal
Example template: Example template:
```yaml ```yaml
helm.sh/chart: {{ include "common.chart" . }} helm.sh/chart: { { include "common.chart" . } }
``` ```
For the chart `foo` with version `1.2.3-beta.55+1234`, this will render: For the chart `foo` with version `1.2.3-beta.55+1234`, this will render:
@@ -806,8 +783,6 @@ helm.sh/chart: foo-1.2.3-beta.55_1234
(Note that `+` is an illegal character in label values) (Note that `+` is an illegal character in label values)
### `common.container` ### `common.container`
The `common.container` template accepts a list of three values: The `common.container` template accepts a list of three values:
@@ -873,7 +848,7 @@ image:
securityContext: securityContext:
capabilities: capabilities:
drop: drop:
- ALL - ALL
readOnlyRootFilesystem: true readOnlyRootFilesystem: true
runAsNonRoot: true runAsNonRoot: true
runAsUser: 1000 runAsUser: 1000
@@ -912,46 +887,44 @@ spec:
app.kubernetes.io/name: mychart app.kubernetes.io/name: mychart
spec: spec:
containers: containers:
- image: nginx:stable - image: nginx:stable
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
livenessProbe: livenessProbe:
httpGet: httpGet:
path: / path: /
port: http port: http
name: mychart name: mychart
ports: ports:
- containerPort: 80 - containerPort: 80
name: http name: http
protocol: TCP protocol: TCP
readinessProbe: readinessProbe:
httpGet: httpGet:
path: / path: /
port: http port: http
resources: resources:
limits: limits:
cpu: 100m cpu: 100m
memory: 128Mi memory: 128Mi
requests: requests:
cpu: 100m cpu: 100m
memory: 128Mi memory: 128Mi
securityContext: securityContext:
capabilities: capabilities:
drop: drop:
- ALL - ALL
readOnlyRootFilesystem: true readOnlyRootFilesystem: true
runAsNonRoot: true runAsNonRoot: true
runAsUser: 1000 runAsUser: 1000
serviceAccountName: release-name-mychart serviceAccountName: release-name-mychart
``` ```
### `common.fullname` ### `common.fullname`
The `common.fullname` template generates a name suitable for the `name:` field in Kubernetes metadata. It is used like this: The `common.fullname` template generates a name suitable for the `name:` field in Kubernetes metadata. It is used like this:
```yaml ```yaml
name: {{ include "common.fullname" . }} name: { { include "common.fullname" . } }
``` ```
This prints the value of `{{ .Release.Name }}-{{ .Chart.Name }}` by default, but can be overridden with `.Values. fullnameOverride`: This prints the value of `{{ .Release.Name }}-{{ .Chart.Name }}` by default, but can be overridden with `.Values. fullnameOverride`:
@@ -974,8 +947,6 @@ name: release-name-mychart
Output of this function is truncated at 63 characters, which is the maximum length of name. Output of this function is truncated at 63 characters, which is the maximum length of name.
### `common.labels` ### `common.labels`
`common.selectorLabels` prints the standard set of labels. `common.selectorLabels` prints the standard set of labels.
@@ -996,8 +967,6 @@ app.kubernetes.io/version: 1.16.0
helm.sh/chart: mychart-0.1.0 helm.sh/chart: mychart-0.1.0
``` ```
### `common.metadata` ### `common.metadata`
The `common.metadata` helper generates value for the `metadata:` section of a Kubernetes resource. The `common.metadata` helper generates value for the `metadata:` section of a Kubernetes resource.
@@ -1012,9 +981,7 @@ It generates standard labels and a name field.
Example template: Example template:
```yaml ```yaml
metadata: metadata: { { - include "common.metadata" (list .) | nindent 2 } }
{{- include "common.metadata" (list .) | nindent 2 }}
## The following is the same as above: ## The following is the same as above:
# metadata: # metadata:
# {{- include "common.metadata" (list . "mychart.metadata") | nindent 2 }} # {{- include "common.metadata" (list . "mychart.metadata") | nindent 2 }}
@@ -1037,14 +1004,12 @@ metadata:
Most of the common templates that define a resource type (e.g. `common.configMap` or `common.cronJob`) use this to generate the metadata, which means they inherit the same `labels` and `name` fields. Most of the common templates that define a resource type (e.g. `common.configMap` or `common.cronJob`) use this to generate the metadata, which means they inherit the same `labels` and `name` fields.
### `common.name` ### `common.name`
The `common.name` template generates a name suitable for the `app.kubernetes.io/name` label. It is used like this: The `common.name` template generates a name suitable for the `app.kubernetes.io/name` label. It is used like this:
```yaml ```yaml
app.kubernetes.io/name: {{ include "common.name" . }} app.kubernetes.io/name: { { include "common.name" . } }
``` ```
This prints the value of `{{ .Chart.Name }}` by default, but can be overridden with `.Values.nameOverride`: This prints the value of `{{ .Chart.Name }}` by default, but can be overridden with `.Values.nameOverride`:
@@ -1067,7 +1032,6 @@ app.kubernetes.io/name: mychart
Output of this function is truncated at 63 characters, which is the maximum length of name. Output of this function is truncated at 63 characters, which is the maximum length of name.
### `common.pod.template` ### `common.pod.template`
The `common.pod.template` template accepts a list of four values: The `common.pod.template` template accepts a list of four values:
@@ -1084,19 +1048,19 @@ It creates a basic `PodTemplate` spec to be used within a `Deployment` or `CronJ
It also uses the following configuration from the `$pod`: It also uses the following configuration from the `$pod`:
| Value | Description | | Value | Description |
| ----- | ----------- | | ------------------------- | -------------------------------------------------------- |
| `$pod.imagePullSecrets` | Names of secrets containing private registry credentials | | `$pod.imagePullSecrets` | Names of secrets containing private registry credentials |
| `$pod.podAnnotations` | Pod annotations | | `$pod.podAnnotations` | Pod annotations |
| `$pod.podSecurityContext` | Security options | | `$pod.podSecurityContext` | Security options |
| `$pod.nodeSelector ` | Node labels for pod assignment | | `$pod.nodeSelector ` | Node labels for pod assignment |
| `$pod.affinity ` | Expressions for affinity | | `$pod.affinity ` | Expressions for affinity |
| `$pod.tolerations ` | Toleration labels for pod assignment | | `$pod.tolerations ` | Toleration labels for pod assignment |
| `$pod.podLabels` | Pod extra labels |
| `$pod.priorityClassName` | Pod priorityClassName |
Underneath the hood, it invokes [`common.container`](#commoncontainer) template with `$pod` to populate the `PodSpec`'s container list. Underneath the hood, it invokes [`common.container`](#commoncontainer) template with `$pod` to populate the `PodSpec`'s container list.
### `common.selectorLabels` ### `common.selectorLabels`
`common.selectorLabels` prints the standard set of selector labels. `common.selectorLabels` prints the standard set of selector labels.
@@ -1114,8 +1078,6 @@ app.kubernetes.io/instance: release-name
app.kubernetes.io/name: mychart app.kubernetes.io/name: mychart
``` ```
### `common.serviceAccountName` ### `common.serviceAccountName`
The `common.serviceAccountName` template accepts a list of two values: The `common.serviceAccountName` template accepts a list of two values:

View File

@@ -10,7 +10,11 @@ spec:
{{- $cronJob := index . 1 }} {{- $cronJob := index . 1 }}
{{- $pod := index . 2 }} {{- $pod := index . 2 }}
{{- $serviceAccount := index . 3 }} {{- $serviceAccount := index . 3 }}
{{- if semverCompare ">=1.21-0" $top.Capabilities.KubeVersion.GitVersion -}}
apiVersion: batch/v1
{{- else -}}
apiVersion: batch/v1beta1 apiVersion: batch/v1beta1
{{- end }}
kind: CronJob kind: CronJob
metadata: metadata:
{{- include "common.metadata" (list $top) | nindent 2 }} {{- include "common.metadata" (list $top) | nindent 2 }}
@@ -25,11 +29,17 @@ spec:
{{- with $cronJob.successfulJobsHistoryLimit }} {{- with $cronJob.successfulJobsHistoryLimit }}
successfulJobsHistoryLimit: {{ . }} successfulJobsHistoryLimit: {{ . }}
{{- end }} {{- end }}
{{- with $cronJob.suspend }}
suspend: {{ . }}
{{- end }}
jobTemplate: jobTemplate:
metadata: metadata:
labels: labels:
{{- include "common.selectorLabels" $top | nindent 8 }} {{- include "common.selectorLabels" $top | nindent 8 }}
spec: spec:
{{- with $cronJob.activeDeadlineSeconds }}
activeDeadlineSeconds: {{ . }}
{{- end }}
template: template:
{{- include "common.pod.template" (list $top $pod $serviceAccount "common.cronJob.pod") | nindent 8 }} {{- include "common.pod.template" (list $top $pod $serviceAccount "common.cronJob.pod") | nindent 8 }}
{{- end }} {{- end }}

View File

@@ -3,7 +3,11 @@
{{- define "common.hpa.tpl" -}} {{- define "common.hpa.tpl" -}}
{{- $top := first . }} {{- $top := first . }}
{{- $autoscaling := index . 1 }} {{- $autoscaling := index . 1 }}
{{- if semverCompare ">=1.23-0" $top.Capabilities.KubeVersion.GitVersion -}}
apiVersion: autoscaling/v2
{{- else -}}
apiVersion: autoscaling/v2beta2 apiVersion: autoscaling/v2beta2
{{- end }}
kind: HorizontalPodAutoscaler kind: HorizontalPodAutoscaler
metadata: metadata:
{{- include "common.metadata" (list $top) | nindent 2 }} {{- include "common.metadata" (list $top) | nindent 2 }}

View File

@@ -14,9 +14,11 @@ annotations:
{{- $service := index . 2 }} {{- $service := index . 2 }}
{{- $fullName := include "common.fullname" $top }} {{- $fullName := include "common.fullname" $top }}
{{- $svcPort := $service.port }} {{- $svcPort := $service.port }}
{{- if semverCompare ">=1.14-0" $top.Capabilities.KubeVersion.GitVersion }} {{- if semverCompare ">=1.19-0" $top.Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" $top.Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1 apiVersion: networking.k8s.io/v1beta1
{{- else }} {{- else -}}
apiVersion: extensions/v1beta1 apiVersion: extensions/v1beta1
{{- end }} {{- end }}
kind: Ingress kind: Ingress
@@ -39,10 +41,20 @@ spec:
http: http:
paths: paths:
{{- range .paths }} {{- range .paths }}
- path: {{ . }} - path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $top.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend: backend:
{{- if semverCompare ">=1.19-0" $top.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }} serviceName: {{ $fullName }}
servicePort: {{ $svcPort }} servicePort: {{ $svcPort }}
{{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}

View File

@@ -3,7 +3,11 @@
{{- define "common.pdb.tpl" -}} {{- define "common.pdb.tpl" -}}
{{- $top := first . }} {{- $top := first . }}
{{- $pdb := index . 1 }} {{- $pdb := index . 1 }}
{{- if semverCompare ">=1.21-0" $top.Capabilities.KubeVersion.GitVersion -}}
apiVersion: policy/v1
{{- else -}}
apiVersion: policy/v1beta1 apiVersion: policy/v1beta1
{{- end }}
kind: PodDisruptionBudget kind: PodDisruptionBudget
metadata: metadata:
{{- include "common.metadata" (list $top) | nindent 2 }} {{- include "common.metadata" (list $top) | nindent 2 }}

View File

@@ -11,6 +11,9 @@ metadata:
{{- end }} {{- end }}
labels: labels:
{{- include "common.selectorLabels" $top | nindent 4 }} {{- include "common.selectorLabels" $top | nindent 4 }}
{{- with $pod.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec: spec:
{{- with $pod.imagePullSecrets }} {{- with $pod.imagePullSecrets }}
imagePullSecrets: imagePullSecrets:
@@ -33,6 +36,9 @@ spec:
tolerations: tolerations:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with $pod.priorityClassName }}
priorityClassName: {{ . }}
{{- end }}
{{- end }} {{- end }}
{{- define "common.pod.template" -}} {{- define "common.pod.template" -}}

View File

@@ -22,7 +22,7 @@ spec:
matchNames: matchNames:
- {{ $top.Release.Namespace | quote }} - {{ $top.Release.Namespace | quote }}
endpoints: endpoints:
- port: {{ $serviceMonitor.port }} - port: "{{ $serviceMonitor.port }}"
{{- with $serviceMonitor.path }} {{- with $serviceMonitor.path }}
path: {{ . }} path: {{ . }}
{{- end }} {{- end }}