From e833905678047bd432388e00785ed5100be55d3b Mon Sep 17 00:00:00 2001 From: balasu Date: Thu, 8 Jul 2021 13:22:01 +0000 Subject: [PATCH] for portainer add-on --- deploy/addons/assets.go | 4 + deploy/addons/portainer/portainer.yaml.tmpl | 143 ++++++++++++++++++++ pkg/addons/config.go | 5 + pkg/minikube/assets/addons.go | 7 + 4 files changed, 159 insertions(+) create mode 100755 deploy/addons/portainer/portainer.yaml.tmpl mode change 100644 => 100755 pkg/minikube/assets/addons.go diff --git a/deploy/addons/assets.go b/deploy/addons/assets.go index 9031cb4a99..3fa5c6ced3 100644 --- a/deploy/addons/assets.go +++ b/deploy/addons/assets.go @@ -131,4 +131,8 @@ var ( // CsiHostpathDriverAssets assets for csi-hostpath-driver addon //go:embed csi-hostpath-driver/deploy/*.tmpl csi-hostpath-driver/rbac/*.tmpl CsiHostpathDriverAssets embed.FS + + // PortainerAssets assets for portainer addon + //go:embed portainer/portainer.yaml.tmpl + PortainerAssets embed.FS ) diff --git a/deploy/addons/portainer/portainer.yaml.tmpl b/deploy/addons/portainer/portainer.yaml.tmpl new file mode 100755 index 0000000000..32d6a3dca1 --- /dev/null +++ b/deploy/addons/portainer/portainer.yaml.tmpl @@ -0,0 +1,143 @@ +--- +# Source: portainer/templates/namespace.yaml +apiVersion: v1 +kind: Namespace +metadata: + name: portainer +--- +# Source: portainer/templates/serviceaccount.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: portainer-sa-clusteradmin + namespace: portainer + labels: + app.kubernetes.io/name: portainer + app.kubernetes.io/instance: portainer + app.kubernetes.io/version: "ce-latest-ee-2.4.0" +--- +# Source: portainer/templates/pvc.yaml +kind: "PersistentVolumeClaim" +apiVersion: "v1" +metadata: + name: portainer + namespace: portainer + annotations: + volume.alpha.kubernetes.io/storage-class: "generic" + labels: + io.portainer.kubernetes.application.stack: portainer + app.kubernetes.io/name: portainer + app.kubernetes.io/instance: portainer + app.kubernetes.io/version: "ce-latest-ee-2.4.0" +spec: + accessModes: + - "ReadWriteOnce" + resources: + requests: + storage: "10Gi" +--- +# Source: portainer/templates/rbac.yaml +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: portainer + labels: + app.kubernetes.io/name: portainer + app.kubernetes.io/instance: portainer + app.kubernetes.io/version: "ce-latest-ee-2.4.0" +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cluster-admin +subjects: +- kind: ServiceAccount + namespace: portainer + name: portainer-sa-clusteradmin +--- +# Source: portainer/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: portainer + namespace: portainer + labels: + io.portainer.kubernetes.application.stack: portainer + app.kubernetes.io/name: portainer + app.kubernetes.io/instance: portainer + app.kubernetes.io/version: "ce-latest-ee-2.4.0" + kubernetes.io/minikube-addons-endpoint: portainer +spec: + type: NodePort + ports: + - port: 9000 + targetPort: 9000 + protocol: TCP + name: http + nodePort: 30777 + - port: 30776 + targetPort: 30776 + protocol: TCP + name: edge + nodePort: 30776 + selector: + app.kubernetes.io/name: portainer + app.kubernetes.io/instance: portainer +--- +# Source: portainer/templates/deployment.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: portainer + namespace: portainer + labels: + io.portainer.kubernetes.application.stack: portainer + app.kubernetes.io/name: portainer + app.kubernetes.io/instance: portainer + app.kubernetes.io/version: "ce-latest-ee-2.4.0" +spec: + replicas: 1 + strategy: + type: "Recreate" + selector: + matchLabels: + app.kubernetes.io/name: portainer + app.kubernetes.io/instance: portainer + template: + metadata: + labels: + app.kubernetes.io/name: portainer + app.kubernetes.io/instance: portainer + spec: + nodeSelector: + {} + serviceAccountName: portainer-sa-clusteradmin + volumes: + - name: "data" + persistentVolumeClaim: + claimName: portainer + containers: + - name: portainer + image: "portainer/portainer-ce:latest" + imagePullPolicy: Always + args: [ '--tunnel-port','30776' ] + volumeMounts: + - name: data + mountPath: /data + ports: + - name: http + containerPort: 9000 + protocol: TCP + - name: tcp-edge + containerPort: 8000 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: 9000 + readinessProbe: + httpGet: + path: / + port: 9000 + resources: + {} + diff --git a/pkg/addons/config.go b/pkg/addons/config.go index a6c060d1d7..7562156cbd 100644 --- a/pkg/addons/config.go +++ b/pkg/addons/config.go @@ -187,4 +187,9 @@ var Addons = []*Addon{ validations: []setFn{IsVolumesnapshotsEnabled}, callbacks: []setFn{EnableOrDisableAddon, verifyAddonStatus}, }, + { + name: "portainer", + set: SetBool, + callbacks: []setFn{EnableOrDisableAddon}, + }, } diff --git a/pkg/minikube/assets/addons.go b/pkg/minikube/assets/addons.go old mode 100644 new mode 100755 index d249636acc..334946cb20 --- a/pkg/minikube/assets/addons.go +++ b/pkg/minikube/assets/addons.go @@ -666,6 +666,13 @@ var Addons = map[string]*Addon{ "Snapshotter": "k8s.gcr.io", "Provisioner": "k8s.gcr.io", }), + "portainer": NewAddon([]*BinAsset{ + MustBinAsset(addons.PortainerAssets, + "portainer/portainer.yaml.tmpl", + vmpath.GuestAddonsDir, + "portainer.yaml", + "0640"), + }, false, "portainer", "", nil, nil), } // parseMapString creates a map based on `str` which is encoded as =,=,...