From 0078ccddd64bf08a29cd3fcfab4c355df57ccf5f Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Tue, 12 Dec 2023 19:30:09 +0100 Subject: [PATCH 1/6] feat: add yakd addon Add an addon for automatically setting up [YAKD (Yet Another Kubernetes Dashboard)](https://github.com/manusa/yakd) This is an alternative Kubernetes Dashboard with special support for Minikube, OpenShift, and other flavors of Kubernetes. It was originally started as an example project for [YAKC (Yet Another Kubernetes Client)](https://github.com/manusa/yakc) but it was recently spun off as a separate project. Regarding Minikube, it offers specific functionality such as cluster detection, support for opening NodePort services from the interface, and more. --- deploy/addons/assets.go | 4 ++ deploy/addons/yakd/yakd-crb.yaml | 16 +++++ deploy/addons/yakd/yakd-dp.yaml.tmpl | 69 +++++++++++++++++++ deploy/addons/yakd/yakd-ns.yaml | 7 ++ deploy/addons/yakd/yakd-sa.yaml | 9 +++ deploy/addons/yakd/yakd-svc.yaml | 17 +++++ pkg/addons/addons.go | 6 ++ pkg/addons/config.go | 5 ++ pkg/minikube/assets/addons.go | 13 ++++ .../addons/yakd-kubernetes-dashboard.md | 42 +++++++++++ test/integration/addons_test.go | 14 ++++ 11 files changed, 202 insertions(+) create mode 100644 deploy/addons/yakd/yakd-crb.yaml create mode 100644 deploy/addons/yakd/yakd-dp.yaml.tmpl create mode 100644 deploy/addons/yakd/yakd-ns.yaml create mode 100644 deploy/addons/yakd/yakd-sa.yaml create mode 100644 deploy/addons/yakd/yakd-svc.yaml create mode 100644 site/content/en/docs/handbook/addons/yakd-kubernetes-dashboard.md diff --git a/deploy/addons/assets.go b/deploy/addons/assets.go index a1c11e795feb..d7f8f7adce16 100644 --- a/deploy/addons/assets.go +++ b/deploy/addons/assets.go @@ -170,4 +170,8 @@ var ( // NvidiaDevicePlugin assets for nvidia-device-plugin addon //go:embed nvidia-device-plugin/*.tmpl NvidiaDevicePlugin embed.FS + + // YakdAssets assets for yakd addon + //go:embed yakd/*.yaml yakd/*.tmpl + YakdAssets embed.FS ) diff --git a/deploy/addons/yakd/yakd-crb.yaml b/deploy/addons/yakd/yakd-crb.yaml new file mode 100644 index 000000000000..abace7a20d56 --- /dev/null +++ b/deploy/addons/yakd/yakd-crb.yaml @@ -0,0 +1,16 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: yakd-dashboard + labels: + app.kubernetes.io/name: yakd-dashboard + kubernetes.io/minikube-addons: yakd-dashboard + addonmanager.kubernetes.io/mode: Reconcile +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cluster-admin +subjects: +- kind: ServiceAccount + name: yakd-dashboard + namespace: yakd-dashboard diff --git a/deploy/addons/yakd/yakd-dp.yaml.tmpl b/deploy/addons/yakd/yakd-dp.yaml.tmpl new file mode 100644 index 000000000000..3f00b2fa6c16 --- /dev/null +++ b/deploy/addons/yakd/yakd-dp.yaml.tmpl @@ -0,0 +1,69 @@ +kind: Deployment +apiVersion: apps/v1 +metadata: + labels: + app.kubernetes.io/name: yakd-dashboard + app.kubernetes.io/instance: yakd-dashboard + kubernetes.io/minikube-addons: yakd-dashboard + addonmanager.kubernetes.io/mode: Reconcile + name: yakd-dashboard + namespace: yakd-dashboard +spec: + replicas: 1 + revisionHistoryLimit: 10 + selector: + matchLabels: + app.kubernetes.io/name: yakd-dashboard + app.kubernetes.io/instance: yakd-dashboard + template: + metadata: + labels: + app.kubernetes.io/name: yakd-dashboard + app.kubernetes.io/instance: yakd-dashboard + gcp-auth-skip-secret: "true" + spec: + containers: + - name: yakd + image: {{.CustomRegistries.Yakd | default .ImageRepository | default .Registries.Yakd }}{{.Images.Yakd}} + imagePullPolicy: IfNotPresent + ports: + - name: http + containerPort: 8080 + protocol: TCP + env: + - name: KUBERNETES_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + - name: HOSTNAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + resources: + limits: + memory: 256Mi + requests: + memory: 128Mi + securityContext: + allowPrivilegeEscalation: false + privileged: false + runAsUser: 1001 + runAsGroup: 2001 + livenessProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: 10 + timeoutSeconds: 10 + readinessProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: 10 + timeoutSeconds: 10 + restartPolicy: Always + serviceAccountName: yakd-dashboard + nodeSelector: + "kubernetes.io/os": linux diff --git a/deploy/addons/yakd/yakd-ns.yaml b/deploy/addons/yakd/yakd-ns.yaml new file mode 100644 index 000000000000..a4bbd8e69f90 --- /dev/null +++ b/deploy/addons/yakd/yakd-ns.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: yakd-dashboard + labels: + kubernetes.io/minikube-addons: yakd-dashboard + addonmanager.kubernetes.io/mode: Reconcile diff --git a/deploy/addons/yakd/yakd-sa.yaml b/deploy/addons/yakd/yakd-sa.yaml new file mode 100644 index 000000000000..56666980fca0 --- /dev/null +++ b/deploy/addons/yakd/yakd-sa.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + app.kubernetes.io/name: yakd-dashboard + kubernetes.io/minikube-addons: yakd-dashboard + addonmanager.kubernetes.io/mode: Reconcile + name: yakd-dashboard + namespace: yakd-dashboard diff --git a/deploy/addons/yakd/yakd-svc.yaml b/deploy/addons/yakd/yakd-svc.yaml new file mode 100644 index 000000000000..6dd208173211 --- /dev/null +++ b/deploy/addons/yakd/yakd-svc.yaml @@ -0,0 +1,17 @@ +kind: Service +apiVersion: v1 +metadata: + labels: + app.kubernetes.io/name: yakd-dashboard + kubernetes.io/minikube-addons: yakd-dashboard + addonmanager.kubernetes.io/mode: Reconcile + name: yakd-dashboard + namespace: yakd-dashboard +spec: + type: NodePort + ports: + - port: 80 + targetPort: 8080 + selector: + app.kubernetes.io/name: yakd-dashboard + app.kubernetes.io/instance: yakd-dashboard diff --git a/pkg/addons/addons.go b/pkg/addons/addons.go index cba3b2f4b594..d12e9128ae54 100644 --- a/pkg/addons/addons.go +++ b/pkg/addons/addons.go @@ -150,6 +150,12 @@ kubectl get secret $SECRET --namespace headlamp --template=\{\{.data.token\}\} | minikube{{.profileArg}} addons enable metrics-server `, out.V{"profileArg": tipProfileArg}) + case "yakd": + out.Styled(style.Tip, `To access YAKD - Kubernetes Dashboard, wait for Pod to be ready and run the following command: + + minikube service yakd-dashboard -n yakd-dashboard + +`) } } diff --git a/pkg/addons/config.go b/pkg/addons/config.go index 3e5f96aeb9f2..bbfc8a9011f9 100644 --- a/pkg/addons/config.go +++ b/pkg/addons/config.go @@ -232,4 +232,9 @@ var Addons = []*Addon{ set: SetBool, callbacks: []setFn{EnableOrDisableAddon}, }, + { + name: "yakd", + set: SetBool, + callbacks: []setFn{EnableOrDisableAddon}, + }, } diff --git a/pkg/minikube/assets/addons.go b/pkg/minikube/assets/addons.go index a8c41211fcbb..d20a34900fd6 100644 --- a/pkg/minikube/assets/addons.go +++ b/pkg/minikube/assets/addons.go @@ -787,6 +787,19 @@ var Addons = map[string]*Addon{ }, map[string]string{ "NvidiaDevicePlugin": "nvcr.io", }), + "yakd": NewAddon([]*BinAsset{ + MustBinAsset(addons.YakdAssets, "yakd/yakd-ns.yaml", vmpath.GuestAddonsDir, "yakd-ns.yaml", "0640"), + MustBinAsset(addons.YakdAssets, "yakd/yakd-sa.yaml", vmpath.GuestAddonsDir, "yakd-sa.yaml", "0640"), + MustBinAsset(addons.YakdAssets, "yakd/yakd-crb.yaml", vmpath.GuestAddonsDir, "yakd-crb.yaml", "0640"), + MustBinAsset(addons.YakdAssets, "yakd/yakd-svc.yaml", vmpath.GuestAddonsDir, "yakd-svc.yaml", "0640"), + MustBinAsset(addons.YakdAssets, "yakd/yakd-dp.yaml.tmpl", vmpath.GuestAddonsDir, "yakd-dp.yaml", "0640"), + }, false, "yakd", "3rd party (marcnuri.com)", "manusa", "https://minikube.sigs.k8s.io/docs/handbook/addons/yakd/", + map[string]string{ + "Yakd": "marcnuri/yakd:0.0.3@sha256:ebb5a2378be98b0674e5fb123b37812c5f2108791bfe3a1f579bf71718eac63b", + }, + map[string]string{ + "Yakd": "docker.io", + }), } // parseMapString creates a map based on `str` which is encoded as =,=,... diff --git a/site/content/en/docs/handbook/addons/yakd-kubernetes-dashboard.md b/site/content/en/docs/handbook/addons/yakd-kubernetes-dashboard.md new file mode 100644 index 000000000000..9900ad9a19b9 --- /dev/null +++ b/site/content/en/docs/handbook/addons/yakd-kubernetes-dashboard.md @@ -0,0 +1,42 @@ +--- +title: "Using the YAKD - Kubernetes Dashboard Addon" +linkTitle: "YAKD - Kubernetes Dashboard" +weight: 1 +date: 2023-12-12 +--- + +## YAKD - Kubernetes Dashboard Addon + +[YAKD - Kubernetes Dashboard](https://github.com/manusa/yakd) is a full-featured web-based Kubernetes Dashboard with special functionality for Minikube. + +The dashboard features a real-time Search pane that allows you to search for Kubernetes resources and see them update in real-time as you type. + +### Enable YAKD - Kubernetes Dashboard on minikube + +To enable this addon, simply run: + +```shell script +minikube addons enable yakd +``` + +Once the addon is enabled, you can access the YAKD - Kubernetes Dashboard's web UI using the following command. + +```shell script +minikube service yakd-dashboard -n yakd-dashboard +``` + +There dashboard will open in a new browser window and you should be able to start using it with no further hassle. + +YAKD - Kubernetes Dashboard is also compatible with metrics-server. To install it, run: + +```shell script +minikube addons enable metrics-server +``` + +### Disable YAKD - Kubernetes Dashboard + +To disable this addon, simply run: + +```shell script +minikube addons disable yakd +``` diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index 38e219fa97ff..555bb6ddd569 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -134,6 +134,7 @@ func TestAddons(t *testing.T) { {"CloudSpanner", validateCloudSpannerAddon}, {"LocalPath", validateLocalPathAddon}, {"NvidiaDevicePlugin", validateNvidiaDevicePlugin}, + {"Yakd", validateYakdAddon}, } for _, tc := range tests { tc := tc @@ -955,3 +956,16 @@ func validateNvidiaDevicePlugin(ctx context.Context, t *testing.T, profile strin t.Errorf("failed to disable nvidia-device-plugin: args %q : %v", rr.Command(), err) } } + +func validateYakdAddon(ctx context.Context, t *testing.T, profile string) { + defer PostMortemLogs(t, profile) + + rr, err := Run(t, exec.CommandContext(ctx, Target(), "addons", "enable", "yakd", "-p", profile, "--alsologtostderr", "-v=1")) + if err != nil { + t.Fatalf("failed to enable yakd addon: args: %q: %v", rr.Command(), err) + } + + if _, err := PodWait(ctx, t, profile, "yakd-dashboard", "app.kubernetes.io/name=yakd-dashboard", Minutes(2)); err != nil { + t.Fatalf("failed waiting for YAKD - Kubernetes Dashboard pod: %v", err) + } +} From 249441d0026eab84a25497423e30ef2cad3b5a0b Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Wed, 13 Dec 2023 15:53:34 +0100 Subject: [PATCH 2/6] fix: yakd usage hint includes profile --- pkg/addons/addons.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/addons/addons.go b/pkg/addons/addons.go index d12e9128ae54..c03551d86ca1 100644 --- a/pkg/addons/addons.go +++ b/pkg/addons/addons.go @@ -153,9 +153,9 @@ minikube{{.profileArg}} addons enable metrics-server case "yakd": out.Styled(style.Tip, `To access YAKD - Kubernetes Dashboard, wait for Pod to be ready and run the following command: - minikube service yakd-dashboard -n yakd-dashboard + minikube{{.profileArg}} service yakd-dashboard -n yakd-dashboard -`) +`, out.V{"profileArg": tipProfileArg}) } } From 34072ea0e762410af5bd5553763605bdd32207d9 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Wed, 13 Dec 2023 15:54:07 +0100 Subject: [PATCH 3/6] doc: yakd minikube is lower-case --- .../en/docs/handbook/addons/yakd-kubernetes-dashboard.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/content/en/docs/handbook/addons/yakd-kubernetes-dashboard.md b/site/content/en/docs/handbook/addons/yakd-kubernetes-dashboard.md index 9900ad9a19b9..5528419c4be8 100644 --- a/site/content/en/docs/handbook/addons/yakd-kubernetes-dashboard.md +++ b/site/content/en/docs/handbook/addons/yakd-kubernetes-dashboard.md @@ -7,7 +7,7 @@ date: 2023-12-12 ## YAKD - Kubernetes Dashboard Addon -[YAKD - Kubernetes Dashboard](https://github.com/manusa/yakd) is a full-featured web-based Kubernetes Dashboard with special functionality for Minikube. +[YAKD - Kubernetes Dashboard](https://github.com/manusa/yakd) is a full-featured web-based Kubernetes Dashboard with special functionality for minikube. The dashboard features a real-time Search pane that allows you to search for Kubernetes resources and see them update in real-time as you type. From 7d68dd737b3db2577098b7e0dd1e74f80c29f686 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Wed, 13 Dec 2023 17:16:08 +0100 Subject: [PATCH 4/6] feat: yakd multi-platform image (support for arm64) --- pkg/minikube/assets/addons.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/minikube/assets/addons.go b/pkg/minikube/assets/addons.go index d20a34900fd6..1c480a5df0d7 100644 --- a/pkg/minikube/assets/addons.go +++ b/pkg/minikube/assets/addons.go @@ -795,7 +795,7 @@ var Addons = map[string]*Addon{ MustBinAsset(addons.YakdAssets, "yakd/yakd-dp.yaml.tmpl", vmpath.GuestAddonsDir, "yakd-dp.yaml", "0640"), }, false, "yakd", "3rd party (marcnuri.com)", "manusa", "https://minikube.sigs.k8s.io/docs/handbook/addons/yakd/", map[string]string{ - "Yakd": "marcnuri/yakd:0.0.3@sha256:ebb5a2378be98b0674e5fb123b37812c5f2108791bfe3a1f579bf71718eac63b", + "Yakd": "marcnuri/yakd:0.0.4@sha256:a3f540278e4c11373e15605311851dd9c64d208f4d63e727bccc0e39f9329310", }, map[string]string{ "Yakd": "docker.io", From 1ae179d9d60c8c4d6e54b7e360995c11dcacc4fa Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Wed, 13 Dec 2023 16:12:24 +0100 Subject: [PATCH 5/6] test: yakd enabled in addons IT setup phase --- test/integration/addons_test.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index 555bb6ddd569..d48b31a6441b 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -99,7 +99,7 @@ func TestAddons(t *testing.T) { // so we override that here to let minikube auto-detect appropriate cgroup driver os.Setenv(constants.MinikubeForceSystemdEnv, "") - args := append([]string{"start", "-p", profile, "--wait=true", "--memory=4000", "--alsologtostderr", "--addons=registry", "--addons=metrics-server", "--addons=volumesnapshots", "--addons=csi-hostpath-driver", "--addons=gcp-auth", "--addons=cloud-spanner", "--addons=inspektor-gadget", "--addons=storage-provisioner-rancher", "--addons=nvidia-device-plugin"}, StartArgs()...) + args := append([]string{"start", "-p", profile, "--wait=true", "--memory=4000", "--alsologtostderr", "--addons=registry", "--addons=metrics-server", "--addons=volumesnapshots", "--addons=csi-hostpath-driver", "--addons=gcp-auth", "--addons=cloud-spanner", "--addons=inspektor-gadget", "--addons=storage-provisioner-rancher", "--addons=nvidia-device-plugin", "--addons=yakd"}, StartArgs()...) if !NoneDriver() { // none driver does not support ingress args = append(args, "--addons=ingress", "--addons=ingress-dns") } @@ -960,11 +960,6 @@ func validateNvidiaDevicePlugin(ctx context.Context, t *testing.T, profile strin func validateYakdAddon(ctx context.Context, t *testing.T, profile string) { defer PostMortemLogs(t, profile) - rr, err := Run(t, exec.CommandContext(ctx, Target(), "addons", "enable", "yakd", "-p", profile, "--alsologtostderr", "-v=1")) - if err != nil { - t.Fatalf("failed to enable yakd addon: args: %q: %v", rr.Command(), err) - } - if _, err := PodWait(ctx, t, profile, "yakd-dashboard", "app.kubernetes.io/name=yakd-dashboard", Minutes(2)); err != nil { t.Fatalf("failed waiting for YAKD - Kubernetes Dashboard pod: %v", err) } From 1bdbc58cd7f29a810ebd80180308215b4b88e7ce Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Wed, 20 Dec 2023 19:55:54 +0100 Subject: [PATCH 6/6] fix: typo in yakd doc Co-authored-by: Steven Powell <44844360+spowelljr@users.noreply.github.com> --- .../en/docs/handbook/addons/yakd-kubernetes-dashboard.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/content/en/docs/handbook/addons/yakd-kubernetes-dashboard.md b/site/content/en/docs/handbook/addons/yakd-kubernetes-dashboard.md index 5528419c4be8..038b20440466 100644 --- a/site/content/en/docs/handbook/addons/yakd-kubernetes-dashboard.md +++ b/site/content/en/docs/handbook/addons/yakd-kubernetes-dashboard.md @@ -25,7 +25,7 @@ Once the addon is enabled, you can access the YAKD - Kubernetes Dashboard's web minikube service yakd-dashboard -n yakd-dashboard ``` -There dashboard will open in a new browser window and you should be able to start using it with no further hassle. +The dashboard will open in a new browser window and you should be able to start using it with no further hassle. YAKD - Kubernetes Dashboard is also compatible with metrics-server. To install it, run: