-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (addon): Add local-volume-provisioner to Kubernetes addon (#928)
- Loading branch information
Showing
22 changed files
with
963 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Local volume provisioner | ||
|
||
[Local volume provisioner](https://github.com/kubernetes-sigs/sig-storage-local-static-provisioner) manages PersistentVolume lifecycle for pre-allocated disks by detecting and creating PVs for each local disk on the host, and cleaning up the disks when released | ||
|
||
|
||
## Usage | ||
|
||
Local volume provisioner can be deployed by enabling the add-on via the following. | ||
|
||
```hcl | ||
enable_local_volume_provisioner = true | ||
``` | ||
|
||
Deploy Local volume provisioner with custom `values.yaml` | ||
|
||
```hcl | ||
# Optional Map value; pass local-volume-provisioner-values.yaml from consumer module | ||
local_volume_provisioner_helm_config = { | ||
name = "local-static-provisioner" # (Required) Release name. | ||
namespace = "local-static-provisioner" # (Optional) The namespace to install the release into. | ||
values = [templatefile("${path.module}/local-volume-provisioner-values.yaml", {})] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
modules/kubernetes-addons/local-volume-provisioner/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Local volume provisioner | ||
|
||
See [docs](../../../docs/add-ons/local-volume-provisioner.md) | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 | | ||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.72 | | ||
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.10 | | ||
|
||
## Providers | ||
|
||
No providers. | ||
|
||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_helm_addon"></a> [helm\_addon](#module\_helm\_addon) | ../helm-addon | n/a | | ||
|
||
## Resources | ||
|
||
No resources. | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_addon_context"></a> [addon\_context](#input\_addon\_context) | Input configuration for the addon | <pre>object({<br> aws_caller_identity_account_id = string<br> aws_caller_identity_arn = string<br> aws_eks_cluster_endpoint = string<br> aws_partition_id = string<br> aws_region_name = string<br> eks_cluster_id = string<br> eks_oidc_issuer_url = string<br> eks_oidc_provider_arn = string<br> tags = map(string)<br> })</pre> | n/a | yes | | ||
| <a name="input_helm_config"></a> [helm\_config](#input\_helm\_config) | Helm Config for local volume provisioner | `any` | `{}` | no | | ||
|
||
## Outputs | ||
|
||
No outputs. | ||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
16 changes: 16 additions & 0 deletions
16
modules/kubernetes-addons/local-volume-provisioner/local-static-provisioner/Chart.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: v1 | ||
name: provisioner | ||
description: local provisioner chart | ||
keywords: | ||
- storage | ||
- local | ||
|
||
# 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: 2.6.0-alpha.1 | ||
|
||
# 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. | ||
appVersion: 2.4.0 |
1 change: 1 addition & 0 deletions
1
...s/kubernetes-addons/local-volume-provisioner/local-static-provisioner/templates/NOTES.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
provisioner installed |
42 changes: 42 additions & 0 deletions
42
...ubernetes-addons/local-volume-provisioner/local-static-provisioner/templates/_helpers.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "provisioner.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "provisioner.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 "provisioner.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 the name of the service account to use | ||
*/}} | ||
{{- define "provisioner.serviceAccountName" -}} | ||
{{- if .Values.common.serviceAccount.create -}} | ||
{{ default (include "provisioner.fullname" .) .Values.common.serviceAccount.name }} | ||
{{- else -}} | ||
{{ default "default" .Values.common.serviceAccount.name }} | ||
{{- end -}} | ||
{{- end -}} |
59 changes: 59 additions & 0 deletions
59
...ernetes-addons/local-volume-provisioner/local-static-provisioner/templates/configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ template "provisioner.fullname" . }}-config | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
helm.sh/chart: {{ template "provisioner.chart" . }} | ||
app.kubernetes.io/name: {{ template "provisioner.name" . }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
data: | ||
{{- if .Values.daemonset.nodeLabels }} | ||
nodeLabelsForPV: | | ||
{{- range $label := .Values.daemonset.nodeLabels }} | ||
- {{$label}} | ||
{{- end }} | ||
{{- end }} | ||
{{- if .Values.common.labelsForPV }} | ||
labelsForPV: | | ||
{{- range $label, $value := .Values.common.labelsForPV }} | ||
{{$label}} : {{$value}} | ||
{{- end }} | ||
{{- end }} | ||
{{- if .Values.common.useAlphaAPI }} | ||
useAlphaAPI: "true" | ||
{{- end }} | ||
{{- if .Values.common.setPVOwnerRef }} | ||
setPVOwnerRef: "true" | ||
{{- end }} | ||
{{- if .Values.common.useJobForCleaning }} | ||
useJobForCleaning: "yes" | ||
{{- end}} | ||
{{- if .Values.common.useNodeNameOnly }} | ||
useNodeNameOnly: "true" | ||
{{- end }} | ||
{{- if .Values.common.minResyncPeriod }} | ||
minResyncPeriod: {{ .Values.common.minResyncPeriod | quote }} | ||
{{- end}} | ||
storageClassMap: | | ||
{{- range $classConfig := .Values.classes }} | ||
{{ $classConfig.name }}: | ||
hostDir: {{ $classConfig.hostDir }} | ||
mountDir: {{ $classConfig.mountDir | default $classConfig.hostDir }} | ||
{{- if $classConfig.blockCleanerCommand }} | ||
blockCleanerCommand: | ||
{{- range $val := $classConfig.blockCleanerCommand }} | ||
- {{ $val | quote }} | ||
{{- end}} | ||
{{- end }} | ||
{{- if $classConfig.volumeMode }} | ||
volumeMode: {{ $classConfig.volumeMode }} | ||
{{- end }} | ||
{{- if $classConfig.fsType }} | ||
fsType: {{ $classConfig.fsType }} | ||
{{- end }} | ||
{{- if $classConfig.namePattern }} | ||
namePattern: {{ $classConfig.namePattern | quote }} | ||
{{- end }} | ||
{{- end }} |
113 changes: 113 additions & 0 deletions
113
...s-addons/local-volume-provisioner/local-static-provisioner/templates/daemonset_linux.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
name: {{ include "provisioner.fullname" . }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
helm.sh/chart: {{ template "provisioner.chart" . }} | ||
app.kubernetes.io/name: {{ template "provisioner.name" . }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
spec: | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: {{ template "provisioner.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: {{ template "provisioner.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- if .Values.daemonset.podLabels }} | ||
{{ .Values.daemonset.podLabels | toYaml | trim | indent 8 }} | ||
{{- end }} | ||
annotations: | ||
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} | ||
{{- if .Values.daemonset.podAnnotations }} | ||
{{ .Values.daemonset.podAnnotations | toYaml | trim | indent 8 }} | ||
{{- end }} | ||
spec: | ||
serviceAccountName: {{ template "provisioner.serviceAccountName" . }} | ||
{{- if .Values.daemonset.priorityClassName }} | ||
priorityClassName: {{.Values.daemonset.priorityClassName}} | ||
{{- end }} | ||
nodeSelector: | ||
kubernetes.io/os: linux | ||
{{- if .Values.daemonset.nodeSelector }} | ||
{{ toYaml .Values.daemonset.nodeSelector | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.daemonset.tolerations }} | ||
tolerations: | ||
{{ toYaml .Values.daemonset.tolerations | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.daemonset.affinity }} | ||
affinity: | ||
{{ toYaml .Values.daemonset.affinity | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.daemonset.initContainers }} | ||
initContainers: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
containers: | ||
- name: provisioner | ||
image: {{ .Values.daemonset.image }} | ||
{{- if .Values.daemonset.imagePullPolicy }} | ||
imagePullPolicy: {{ .Values.daemonset.imagePullPolicy }} | ||
{{- end }} | ||
securityContext: | ||
privileged: {{ .Values.daemonset.privileged }} | ||
{{- if .Values.daemonset.resources }} | ||
resources: | ||
{{ toYaml .Values.daemonset.resources | nindent 12 }} | ||
{{- end }} | ||
env: | ||
- name: MY_NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
- name: MY_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: JOB_CONTAINER_IMAGE | ||
value: {{ .Values.daemonset.image }} | ||
{{- if .Values.daemonset.kubeConfigEnv }} | ||
- name: KUBECONFIG | ||
value: {{.Values.daemonset.kubeConfigEnv}} | ||
{{- end }} | ||
ports: | ||
- name: metrics | ||
containerPort: 8080 | ||
volumeMounts: | ||
- name: provisioner-config | ||
mountPath: /etc/provisioner/config | ||
readOnly: true | ||
{{- if .Values.common.mountDevVolume }} | ||
- name: provisioner-dev | ||
mountPath: /dev | ||
{{- end }} | ||
{{- range $classConfig := .Values.classes }} | ||
- name: {{ $classConfig.name }} | ||
mountPath: {{ $classConfig.mountDir | default $classConfig.hostDir }} | ||
mountPropagation: HostToContainer | ||
{{- end }} | ||
volumes: | ||
- name: provisioner-config | ||
configMap: | ||
name: {{ template "provisioner.fullname" . }}-config | ||
{{- if .Values.common.mountDevVolume }} | ||
- name: provisioner-dev | ||
hostPath: | ||
path: /dev | ||
{{- end }} | ||
{{- range $classConfig := .Values.classes }} | ||
- name: {{ $classConfig.name }} | ||
hostPath: | ||
path: {{ $classConfig.hostDir }} | ||
{{- end }} | ||
{{- range $name, $path := .Values.daemonset.additionalHostPathVolumes }} | ||
- name: {{ quote $name }} | ||
hostPath: | ||
path: {{ quote $path }} | ||
{{- end }} |
Oops, something went wrong.