diff --git a/deploy/addons/assets.go b/deploy/addons/assets.go index 19b3221b8bed..c4dfc661726f 100644 --- a/deploy/addons/assets.go +++ b/deploy/addons/assets.go @@ -44,6 +44,10 @@ var ( //go:embed storage-provisioner-gluster/*.tmpl StorageProvisionerGlusterAssets embed.FS + // StorageProvisionerRancherAssets assets for storage-provisioner-rancher addon + //go:embed storage-provisioner-rancher/*.tmpl + StorageProvisionerRancherAssets embed.FS + // EfkAssets assets for efk addon //go:embed efk/*.tmpl EfkAssets embed.FS diff --git a/deploy/addons/storage-provisioner-rancher/storage-provisioner-rancher.yaml.tmpl b/deploy/addons/storage-provisioner-rancher/storage-provisioner-rancher.yaml.tmpl new file mode 100644 index 000000000000..e19a18092043 --- /dev/null +++ b/deploy/addons/storage-provisioner-rancher/storage-provisioner-rancher.yaml.tmpl @@ -0,0 +1,131 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: local-path-storage + +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: local-path-provisioner-service-account + namespace: local-path-storage + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: local-path-provisioner-role +rules: + - apiGroups: [ "" ] + resources: [ "nodes", "persistentvolumeclaims", "configmaps" ] + verbs: [ "get", "list", "watch" ] + - apiGroups: [ "" ] + resources: [ "endpoints", "persistentvolumes", "pods" ] + verbs: [ "*" ] + - apiGroups: [ "" ] + resources: [ "events" ] + verbs: [ "create", "patch" ] + - apiGroups: [ "storage.k8s.io" ] + resources: [ "storageclasses" ] + verbs: [ "get", "list", "watch" ] + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: local-path-provisioner-bind +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: local-path-provisioner-role +subjects: + - kind: ServiceAccount + name: local-path-provisioner-service-account + namespace: local-path-storage + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: local-path-provisioner + namespace: local-path-storage +spec: + replicas: 1 + selector: + matchLabels: + app: local-path-provisioner + template: + metadata: + labels: + app: local-path-provisioner + spec: + serviceAccountName: local-path-provisioner-service-account + containers: + - name: local-path-provisioner + image: {{.CustomRegistries.LocalPathProvisioner | default .ImageRepository | default .Registries.LocalPathProvisioner }}{{ .Images.LocalPathProvisioner }} + imagePullPolicy: IfNotPresent + command: + - local-path-provisioner + - --debug + - start + - --config + - /etc/config/config.json + volumeMounts: + - name: config-volume + mountPath: /etc/config/ + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + volumes: + - name: config-volume + configMap: + name: local-path-config + +--- +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: local-path +provisioner: rancher.io/local-path +volumeBindingMode: WaitForFirstConsumer +reclaimPolicy: Delete + +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: local-path-config + namespace: local-path-storage +data: + config.json: |- + { + "nodePathMap":[ + { + "node":"DEFAULT_PATH_FOR_NON_LISTED_NODES", + "paths":["/opt/local-path-provisioner"] + } + ] + } + setup: |- + #!/bin/sh + set -eu + mkdir -m 0777 -p "$VOL_DIR" + teardown: |- + #!/bin/sh + set -eu + rm -rf "$VOL_DIR" + helperPod.yaml: |- + apiVersion: v1 + kind: Pod + metadata: + name: helper-pod + spec: + containers: + - name: helper-pod + image: {{.CustomRegistries.Helper | default .ImageRepository | default .Registries.Helper }}{{ .Images.Helper }} + imagePullPolicy: IfNotPresent + + + diff --git a/pkg/addons/addons_storage_classes.go b/pkg/addons/addons_storage_classes.go index cd8b67272900..cc3aac77f71c 100644 --- a/pkg/addons/addons_storage_classes.go +++ b/pkg/addons/addons_storage_classes.go @@ -39,6 +39,8 @@ func enableOrDisableStorageClasses(cc *config.ClusterConfig, name string, val st class := defaultStorageClassProvisioner if name == "storage-provisioner-gluster" { class = "glusterfile" + } else if name == "storage-provisioner-rancher" { + class = "local-path" } api, err := machine.NewAPIClient() diff --git a/pkg/addons/config.go b/pkg/addons/config.go index 351ca0c2c880..84beac1aac6f 100644 --- a/pkg/addons/config.go +++ b/pkg/addons/config.go @@ -166,6 +166,11 @@ var Addons = []*Addon{ set: SetBool, callbacks: []setFn{enableOrDisableStorageClasses}, }, + { + name: "storage-provisioner-rancher", + set: SetBool, + callbacks: []setFn{enableOrDisableStorageClasses}, + }, { name: "metallb", set: SetBool, diff --git a/pkg/minikube/assets/addons.go b/pkg/minikube/assets/addons.go index 86f35e8c99de..da8e648b37d8 100644 --- a/pkg/minikube/assets/addons.go +++ b/pkg/minikube/assets/addons.go @@ -208,6 +208,19 @@ var Addons = map[string]*Addon{ "GlusterfsServer": "docker.io", "GlusterfileProvisioner": "docker.io", }), + "storage-provisioner-rancher": NewAddon([]*BinAsset{ + MustBinAsset(addons.StorageProvisionerRancherAssets, + "storage-provisioner-rancher/storage-provisioner-rancher.yaml.tmpl", + vmpath.GuestAddonsDir, + "storage-provisioner-rancher.yaml", + "0640"), + }, false, "storage-provisioner-rancher", "3rd party (Rancher)", "", "", map[string]string{ + "LocalPathProvisioner": "rancher/local-path-provisioner:v0.0.22@sha256:e34c88ae0affb1cdefbb874140d6339d4a27ec4ee420ae8199cd839997b05246", + "Helper": "busybox:stable@sha256:3fbc632167424a6d997e74f52b878d7cc478225cffac6bc977eedfe51c7f4e79", + }, map[string]string{ + "LocalPathProvisioner": "docker.io", + "Helper": "docker.io", + }), "efk": NewAddon([]*BinAsset{ MustBinAsset(addons.EfkAssets, "efk/elasticsearch-rc.yaml.tmpl",