Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addon: add headlamp #7

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/config/addons_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestAddonsList(t *testing.T) {
Ambassador *interface{} `json:"ambassador"`
}

b := make([]byte, 557)
b := make([]byte, 571)
r, w, err := os.Pipe()
if err != nil {
t.Fatalf("failed to create pipe: %v", err)
Expand Down
23 changes: 23 additions & 0 deletions cmd/minikube/cmd/config/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,29 @@ var addonsEnableCmd = &cobra.Command{

minikube{{.profileArg}} addons enable metrics-server

`, out.V{"profileArg": tipProfileArg})

}
if addon == "headlamp" {
out.Styled(style.Tip, `To access Headlamp, use the following command:
minikube service headlamp -n headlamp

`)
yolossn marked this conversation as resolved.
Show resolved Hide resolved
out.Styled(style.Tip, `To authenticate in Headlamp, fetch the Authentication Token using the following command:

export SECRET=$(kubectl get secrets --namespace headlamp -o custom-columns=":metadata.name" | grep "headlamp-token")
kubectl get secret $SECRET --namespace headlamp --template=\{\{.data.token\}\} | base64 --decode
Comment on lines +80 to +81
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slightly different from what we have as instructions in https://kinvolk.github.io/headlamp/docs/latest/installation/#create-a-service-account-token .
Should be make more similar? (the current way looks good, just wonder if there's a way to approximate either case)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to update the documentation as it involves the user to copy the headlamp-token name, whereas this solution can be run directly.


`)

tipProfileArg := ""
if ClusterFlagValue() != constants.DefaultClusterName {
tipProfileArg = fmt.Sprintf(" -p %s", ClusterFlagValue())
}
out.Styled(style.Tip, `Headlamp can display more detailed information when metrics-server is installed. To install it, run:

minikube{{.profileArg}} addons enable metrics-server

`, out.V{"profileArg": tipProfileArg})

}
Expand Down
4 changes: 4 additions & 0 deletions deploy/addons/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,8 @@ var (
// InAccelAssets assets for inaccel addon
//go:embed inaccel/fpga-operator.yaml.tmpl
InAccelAssets embed.FS

// HeadlampAssets assets for headlamp addon
//go:embed headlamp/*.yaml headlamp/*.tmpl
HeadlampAssets embed.FS
)
18 changes: 18 additions & 0 deletions deploy/addons/headlamp/headlamp-clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
# ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: headlamp-admin
namespace: headlamp
labels:
app.kubernetes.io/name: headlamp
app.kubernetes.io/instance: headlamp
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: headlamp
namespace: headlamp
42 changes: 42 additions & 0 deletions deploy/addons/headlamp/headlamp-deployment.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: headlamp
namespace: headlamp
labels:
app.kubernetes.io/name: headlamp
app.kubernetes.io/instance: headlamp
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: headlamp
app.kubernetes.io/instance: headlamp
template:
metadata:
labels:
app.kubernetes.io/name: headlamp
app.kubernetes.io/instance: headlamp
spec:
serviceAccountName: headlamp
containers:
- name: headlamp
image: {{.CustomRegistries.Headlamp | default .ImageRepository | default .Registries.Headlamp }}{{.Images.Headlamp}}
imagePullPolicy: IfNotPresent
args:
- "-in-cluster"
- "-plugins-dir=/headlamp/plugins"
ports:
- name: http
containerPort: 4466
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
6 changes: 6 additions & 0 deletions deploy/addons/headlamp/headlamp-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
# Namespace
apiVersion: v1
kind: Namespace
metadata:
name: headlamp
21 changes: 21 additions & 0 deletions deploy/addons/headlamp/headlamp-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# Service
apiVersion: v1
kind: Service
metadata:
name: headlamp
namespace: headlamp
labels:
app.kubernetes.io/name: headlamp
app.kubernetes.io/instance: headlamp
kubernetes.io/minikube-addons-endpoint: headlamp
spec:
type: NodePort
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: headlamp
app.kubernetes.io/instance: headlamp
10 changes: 10 additions & 0 deletions deploy/addons/headlamp/headlamp-serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# ServiceAccount
apiVersion: v1
kind: ServiceAccount
metadata:
name: headlamp
namespace: headlamp
labels:
app.kubernetes.io/name: headlamp
app.kubernetes.io/instance: headlamp
5 changes: 5 additions & 0 deletions pkg/addons/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,9 @@ var Addons = []*Addon{
set: SetBool,
callbacks: []setFn{EnableOrDisableAddon},
},
{
name: "headlamp",
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 @@ -701,6 +701,19 @@ var Addons = map[string]*Addon{
}, map[string]string{
"Helm3": "docker.io",
}),
"headlamp": NewAddon([]*BinAsset{
MustBinAsset(addons.HeadlampAssets, "headlamp/headlamp-namespace.yaml", vmpath.GuestAddonsDir, "headlamp-namespace.yaml", "6040"),
MustBinAsset(addons.HeadlampAssets, "headlamp/headlamp-service.yaml", vmpath.GuestAddonsDir, "headlamp-service.yaml", "6040"),
MustBinAsset(addons.HeadlampAssets, "headlamp/headlamp-deployment.yaml.tmpl", vmpath.GuestAddonsDir, "headlamp-deployment.yaml", "6040"),
MustBinAsset(addons.HeadlampAssets, "headlamp/headlamp-serviceaccount.yaml", vmpath.GuestAddonsDir, "headlamp-serviceaccount.yaml", "6040"),
MustBinAsset(addons.HeadlampAssets, "headlamp/headlamp-clusterrolebinding.yaml", vmpath.GuestAddonsDir, "headlamp-clusterrolebinding.yaml", "6040"),
}, false, "headlamp", "kinvolk.io", "https://minikube.sigs.k8s.io/docs/handbook/addons/headlamp/",
map[string]string{
"Headlamp": "kinvolk/headlamp:v0.9.0@sha256:465aaee6518f3fdd032965eccd6a8f49e924d144b1c86115bad613872672ec02",
},
map[string]string{
"Headlamp": "ghcr.io",
}),
}

// parseMapString creates a map based on `str` which is encoded as <key1>=<value1>,<key2>=<value2>,...
Expand Down
51 changes: 51 additions & 0 deletions site/content/en/docs/handbook/addons/headlamp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: "Using Headlamp Addon"
linkTitle: "Headlamp"
weight: 1
date: 2022-06-08
---

## Headlamp Addon

[Headlamp](https://kinvolk.github.io/headlamp) is an easy-to-use and extensible Kubernetes web UI.

### Enable Headlamp on minikube

To enable this addon, simply run:
```shell script
minikube addons enable headlamp
```

Once the addon is enabled, you can access the Headlamp's web UI using the following command.
```shell script
minikube service headlamp -n headlamp
```

To authenticate in Headlamp, fetch the Authentication Token using the following command:

```shell script
export SECRET=$(kubectl get secrets --namespace headlamp -o custom-columns=":metadata.name" | grep "headlamp-token")
kubectl get secret $SECRET --namespace headlamp --template=\{\{.data.token\}\} | base64 --decode
```

Headlamp can display more detailed information when metrics-server is installed. To install it, run:

```shell script
minikube addons enable metrics-server
```

### Testing installation

```shell script
kubectl get pods -n headlamp
```

If everything went well, there should be no errors about Headlamp's installation in your Minikube cluster.

### Disable headlamp

To disable this addon, simply run:

```shell script
minikube addons disable headlamp
```