Skip to content

Commit

Permalink
feat: add yakd addon
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
manusa committed Dec 12, 2023
1 parent 3b15b42 commit 0078ccd
Show file tree
Hide file tree
Showing 11 changed files with 202 additions and 0 deletions.
4 changes: 4 additions & 0 deletions deploy/addons/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
16 changes: 16 additions & 0 deletions deploy/addons/yakd/yakd-crb.yaml
Original file line number Diff line number Diff line change
@@ -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
69 changes: 69 additions & 0 deletions deploy/addons/yakd/yakd-dp.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions deploy/addons/yakd/yakd-ns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Namespace
metadata:
name: yakd-dashboard
labels:
kubernetes.io/minikube-addons: yakd-dashboard
addonmanager.kubernetes.io/mode: Reconcile
9 changes: 9 additions & 0 deletions deploy/addons/yakd/yakd-sa.yaml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions deploy/addons/yakd/yakd-svc.yaml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions pkg/addons/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
`)
}
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/addons/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,9 @@ var Addons = []*Addon{
set: SetBool,
callbacks: []setFn{EnableOrDisableAddon},
},
{
name: "yakd",
set: SetBool,
callbacks: []setFn{EnableOrDisableAddon},
},
}
13 changes: 13 additions & 0 deletions pkg/minikube/assets/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <key1>=<value1>,<key2>=<value2>,...
Expand Down
42 changes: 42 additions & 0 deletions site/content/en/docs/handbook/addons/yakd-kubernetes-dashboard.md
Original file line number Diff line number Diff line change
@@ -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
```
14 changes: 14 additions & 0 deletions test/integration/addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func TestAddons(t *testing.T) {
{"CloudSpanner", validateCloudSpannerAddon},
{"LocalPath", validateLocalPathAddon},
{"NvidiaDevicePlugin", validateNvidiaDevicePlugin},
{"Yakd", validateYakdAddon},
}
for _, tc := range tests {
tc := tc
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 0078ccd

Please sign in to comment.