Skip to content

Commit 18075ae

Browse files
authored
Add support for Headlamp dashboard for kubernetes; deprecate legacy kubernetes dashboard (#12776)
1 parent cf9bda2 commit 18075ae

File tree

4 files changed

+72
-19
lines changed

4 files changed

+72
-19
lines changed

plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/utils/KubernetesClusterUtil.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,20 @@ public static boolean isKubernetesClusterDashboardServiceRunning(final Kubernete
171171
// Check if dashboard service is up running.
172172
while (System.currentTimeMillis() < timeoutTime) {
173173
if (LOGGER.isDebugEnabled()) {
174-
LOGGER.debug(String.format("Checking dashboard service for the Kubernetes cluster: %s to come up", kubernetesCluster));
174+
LOGGER.debug(String.format("Checking dashboard service (Kubernetes Dashboard or Headlamp) for the Kubernetes cluster: %s to come up", kubernetesCluster));
175175
}
176+
// Check for Headlamp (new dashboard) in kube-system namespace
177+
if (isKubernetesClusterAddOnServiceRunning(kubernetesCluster, ipAddress, port, user, sshKeyFile, "kube-system", "headlamp")) {
178+
if (LOGGER.isInfoEnabled()) {
179+
LOGGER.info(String.format("Headlamp dashboard service for the Kubernetes cluster %s is in running state", kubernetesCluster));
180+
}
181+
running = true;
182+
break;
183+
}
184+
// For backward compatibility, check for Kubernetes Dashboard in kubernetes-dashboard namespace
176185
if (isKubernetesClusterAddOnServiceRunning(kubernetesCluster, ipAddress, port, user, sshKeyFile, "kubernetes-dashboard", "kubernetes-dashboard")) {
177186
if (LOGGER.isInfoEnabled()) {
178-
LOGGER.info(String.format("Dashboard service for the Kubernetes cluster %s is in running state", kubernetesCluster));
187+
LOGGER.info(String.format("Kubernetes Dashboard service for the Kubernetes cluster %s is in running state", kubernetesCluster));
179188
}
180189
running = true;
181190
break;

plugins/integrations/kubernetes-service/src/main/resources/conf/k8s-control-node.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,16 +331,29 @@ write_files:
331331
if [[ ${EXTERNAL_CNI_PLUGIN} == false ]]; then
332332
/opt/bin/kubectl apply -f ${K8S_CONFIG_SCRIPTS_COPY_DIR}/network.yaml
333333
fi
334-
/opt/bin/kubectl apply -f ${K8S_CONFIG_SCRIPTS_COPY_DIR}/dashboard.yaml
334+
if [ -f "${K8S_CONFIG_SCRIPTS_COPY_DIR}/headlamp.yaml" ]; then
335+
echo "Installing Headlamp dashboard from ISO"
336+
/opt/bin/kubectl apply -f ${K8S_CONFIG_SCRIPTS_COPY_DIR}/headlamp.yaml
337+
elif [ -f "${K8S_CONFIG_SCRIPTS_COPY_DIR}/dashboard.yaml" ]; then
338+
echo "Installing Kubernetes Dashboard from ISO"
339+
/opt/bin/kubectl apply -f ${K8S_CONFIG_SCRIPTS_COPY_DIR}/dashboard.yaml
340+
/opt/bin/kubectl create rolebinding admin-binding --role=admin --user=admin || true
341+
/opt/bin/kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin --user=admin || true
342+
/opt/bin/kubectl create clusterrolebinding kubernetes-dashboard-ui --clusterrole=cluster-admin --serviceaccount=kubernetes-dashboard:kubernetes-dashboard || true
343+
else
344+
echo "Warning: No dashboard YAML found in ISO (neither headlamp.yaml nor dashboard.yaml)"
345+
fi
335346
rm -rf "${K8S_CONFIG_SCRIPTS_COPY_DIR}"
336347
else
348+
### Online installation - use Headlamp by default ###
337349
/opt/bin/kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(/opt/bin/kubectl version | base64 | tr -d '\n')"
338-
/opt/bin/kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta6/aio/deploy/recommended.yaml
350+
/opt/bin/kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/headlamp/v0.40.1/kubernetes-headlamp.yaml
351+
/opt/bin/kubectl create serviceaccount headlamp-admin -n kube-system || true
352+
/opt/bin/kubectl create clusterrolebinding headlamp-admin --clusterrole=cluster-admin --serviceaccount=kube-system:headlamp-admin || true
339353
fi
340354
341355
/opt/bin/kubectl create rolebinding admin-binding --role=admin --user=admin || true
342356
/opt/bin/kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin --user=admin || true
343-
/opt/bin/kubectl create clusterrolebinding kubernetes-dashboard-ui --clusterrole=cluster-admin --serviceaccount=kubernetes-dashboard:kubernetes-dashboard || true
344357
345358
sudo touch /home/cloud/success
346359
echo "true" > /home/cloud/success

scripts/util/create-kubernetes-binaries-iso.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
set -e
2020

2121
if [ $# -lt 6 ]; then
22-
echo "Invalid input. Valid usage: ./create-kubernetes-binaries-iso.sh OUTPUT_PATH KUBERNETES_VERSION CNI_VERSION CRICTL_VERSION WEAVENET_NETWORK_YAML_CONFIG DASHBOARD_YAML_CONFIG BUILD_NAME [ARCH] [ETCD_VERSION]"
23-
echo "eg: ./create-kubernetes-binaries-iso.sh ./ 1.11.4 0.7.1 1.11.1 https://github.com/weaveworks/weave/releases/download/latest_release/weave-daemonset-k8s-1.11.yaml https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.0/src/deploy/recommended/kubernetes-dashboard.yaml setup-v1.11.4 amd64"
22+
echo "Invalid input. Valid usage: ./create-kubernetes-binaries-iso.sh OUTPUT_PATH KUBERNETES_VERSION CNI_VERSION CRICTL_VERSION WEAVENET_NETWORK_YAML_CONFIG HEADLAMP_DASHBOARD_VERSION BUILD_NAME [ARCH] [ETCD_VERSION]"
23+
echo "eg: ./create-kubernetes-binaries-iso.sh ./ 1.11.4 0.7.1 1.11.1 https://github.com/weaveworks/weave/releases/download/latest_release/weave-daemonset-k8s-1.11.yaml 0.40.1 setup-v1.11.4 amd64"
2424
exit 1
2525
fi
2626

@@ -96,10 +96,11 @@ echo "Downloading network config ${NETWORK_CONFIG_URL}"
9696
network_conf_file="${working_dir}/network.yaml"
9797
curl -sSL ${NETWORK_CONFIG_URL} -o ${network_conf_file}
9898

99-
DASHBORAD_CONFIG_URL="${6}"
100-
echo "Downloading dashboard config ${DASHBORAD_CONFIG_URL}"
101-
dashboard_conf_file="${working_dir}/dashboard.yaml"
102-
curl -sSL ${DASHBORAD_CONFIG_URL} -o ${dashboard_conf_file}
99+
HEADLAMP_DASHBOARD_VERSION="${6}"
100+
HEADLAMP_DASHBOARD_URL="https://raw.githubusercontent.com/kubernetes-sigs/headlamp/v${HEADLAMP_DASHBOARD_VERSION}/kubernetes-headlamp.yaml"
101+
echo "Downloading Headlamp manifest from ${HEADLAMP_DASHBOARD_URL}"
102+
headlamp_conf_file="${working_dir}/headlamp.yaml"
103+
curl -sSL ${HEADLAMP_DASHBOARD_URL} -o ${headlamp_conf_file}
103104

104105
# TODO : Change the url once merged
105106
AUTOSCALER_URL="https://raw.githubusercontent.com/kubernetes/autoscaler/master/cluster-autoscaler/cloudprovider/cloudstack/examples/cluster-autoscaler-standard.yaml"
@@ -135,7 +136,7 @@ mkdir -p "${working_dir}/docker"
135136
output=`${k8s_dir}/kubeadm config images list --kubernetes-version=${RELEASE}`
136137

137138
# Don't forget about the yaml images !
138-
for i in ${network_conf_file} ${dashboard_conf_file}
139+
for i in ${network_conf_file} ${headlamp_conf_file}
139140
do
140141
images=`grep "image:" $i | cut -d ':' -f2- | tr -d ' ' | tr -d "'"`
141142
output=`printf "%s\n" ${output} ${images}`

ui/src/views/compute/KubernetesServiceTab.vue

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,32 +66,62 @@
6666
</a-timeline>
6767
</a-card>
6868
<a-card :title="$t('label.kubernetes.dashboard')">
69+
<p><strong>Note:</strong> CloudStack Kubernetes clusters use <strong>Headlamp</strong> dashboard (deployed in <code>kube-system</code> namespace). For backward compatibility with older clusters using Kubernetes Dashboard, please check your cluster configuration.</p>
6970
<a-timeline>
7071
<a-timeline-item>
7172
<p>
72-
{{ $t('label.run.proxy.locally') }}<br><br>
73-
<code><b>kubectl --kubeconfig /custom/path/kube.conf proxy</b></code>
73+
<strong>Access Headlamp Dashboard (new clusters)</strong><br><br>
74+
<strong>Step 1:</strong> Run port-forward command:<br>
75+
<code><b>kubectl --kubeconfig /custom/path/kube.conf port-forward -n kube-system service/headlamp 8080:80</b></code><br><br>
76+
<strong>Step 2:</strong> Open in your browser:<br>
77+
<a href="http://localhost:8080"><code>http://localhost:8080</code></a>
7478
</p>
7579
</a-timeline-item>
7680
<a-timeline-item>
7781
<p>
78-
{{ $t('label.open.url') }}<br><br>
82+
<strong>Access Kubernetes Dashboard (legacy clusters)</strong><br><br>
83+
<strong>Step 1:</strong> {{ $t('label.run.proxy.locally') }}<br>
84+
<code><b>kubectl --kubeconfig /custom/path/kube.conf proxy</b></code><br><br>
85+
<strong>Step 2:</strong> {{ $t('label.open.url') }}<br>
7986
<a href="http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/"><code>http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/</code></a>
8087
</p>
8188
</a-timeline-item>
8289
<a-timeline-item>
90+
<p>
91+
<strong>Create Access Token for Headlamp (new clusters)</strong>
92+
</p>
8393
<p v-html="$t('label.kubernetes.dashboard.create.token')"></p>
8494
<p v-html="$t('label.kubernetes.dashboard.create.token.desc')"></p>
85-
<a-textarea :value="'kubectl --kubeconfig /custom/path/kube.conf apply -f - <<EOF\napiVersion: v1\nkind: ServiceAccount\nmetadata:\n name: kubernetes-dashboard-admin-user\n namespace: kubernetes-dashboard\n---\napiVersion: rbac.authorization.k8s.io/v1\nkind: ClusterRoleBinding\nmetadata:\n name: kubernetes-dashboard-admin-user\nroleRef:\n apiGroup: rbac.authorization.k8s.io\n kind: ClusterRole\n name: cluster-admin\nsubjects:\n- kind: ServiceAccount\n name: kubernetes-dashboard-admin-user\n namespace: kubernetes-dashboard\n---\napiVersion: v1\nkind: Secret\ntype: kubernetes.io/service-account-token\nmetadata:\n name: kubernetes-dashboard-token\n namespace: kubernetes-dashboard\n annotations:\n kubernetes.io/service-account.name: kubernetes-dashboard-admin-user\nEOF'" :rows="10" readonly />
95+
<a-textarea :value="'kubectl --kubeconfig /custom/path/kube.conf apply -f - <<EOF\napiVersion: v1\nkind: ServiceAccount\nmetadata:\n name: headlamp-admin\n namespace: kube-system\n---\napiVersion: rbac.authorization.k8s.io/v1\nkind: ClusterRoleBinding\nmetadata:\n name: headlamp-admin\nroleRef:\n apiGroup: rbac.authorization.k8s.io\n kind: ClusterRole\n name: cluster-admin\nsubjects:\n- kind: ServiceAccount\n name: headlamp-admin\n namespace: kube-system\n---\napiVersion: v1\nkind: Secret\ntype: kubernetes.io/service-account-token\nmetadata:\n name: headlamp-admin-token\n namespace: kube-system\n annotations:\n kubernetes.io/service-account.name: headlamp-admin\nEOF'" :rows="12" readonly />
96+
<br><br>
97+
<p>{{ $t('label.token.for.dashboard.login') }}:</p>
98+
<code><b>kubectl --kubeconfig /custom/path/kube.conf describe secret headlamp-admin-token -n kube-system</b></code>
99+
</a-timeline-item>
100+
<a-timeline-item>
101+
<p>
102+
<strong>Create Access Token for Kubernetes Dashboard (legacy clusters)</strong>
103+
</p>
104+
<p v-html="$t('label.kubernetes.dashboard.create.token.desc')"></p>
105+
<a-textarea :value="'kubectl --kubeconfig /custom/path/kube.conf apply -f - <<EOF\napiVersion: v1\nkind: ServiceAccount\nmetadata:\n name: kubernetes-dashboard-admin-user\n namespace: kubernetes-dashboard\n---\napiVersion: rbac.authorization.k8s.io/v1\nkind: ClusterRoleBinding\nmetadata:\n name: kubernetes-dashboard-admin-user\nroleRef:\n apiGroup: rbac.authorization.k8s.io\n kind: ClusterRole\n name: cluster-admin\nsubjects:\n- kind: ServiceAccount\n name: kubernetes-dashboard-admin-user\n namespace: kubernetes-dashboard\n---\napiVersion: v1\nkind: Secret\ntype: kubernetes.io/service-account-token\nmetadata:\n name: kubernetes-dashboard-token\n namespace: kubernetes-dashboard\n annotations:\n kubernetes.io/service-account.name: kubernetes-dashboard-admin-user\nEOF'" :rows="12" readonly />
106+
<br><br>
107+
<p>{{ $t('label.token.for.dashboard.login') }}:</p>
108+
<code><b>kubectl --kubeconfig /custom/path/kube.conf describe secret kubernetes-dashboard-token -n kubernetes-dashboard</b></code>
86109
</a-timeline-item>
87110
<a-timeline-item>
88111
<p>
89-
{{ $t('label.token.for.dashboard.login') }}<br><br>
90-
<code><b>kubectl --kubeconfig /custom/path/kube.conf describe secret $(kubectl --kubeconfig /custom/path/kube.conf get secrets -n kubernetes-dashboard | grep kubernetes-dashboard-token | awk '{print $1}') -n kubernetes-dashboard</b></code>
112+
<strong>Important Notes:</strong><br>
113+
• <strong>Port-forwarding is recommended for Headlamp</strong> - simpler and more reliable than kubectl proxy<br>
114+
• Token is only needed if accessing Headlamp via NodePort or LoadBalancer with external access<br>
115+
• For Kubernetes 1.24+, service account tokens are no longer auto-generated - use the Secret resource shown above or <code>kubectl create token</code> command<br>
116+
• <strong>Cluster-admin role grants full control</strong> - use with caution and only for trusted administrators<br>
117+
• Keep the port-forward command running while using the dashboard (press Ctrl+C to stop)
91118
</p>
92119
</a-timeline-item>
93120
</a-timeline>
94-
<p>{{ $t('label.more.access.dashboard.ui') }}, <a href="https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/#accessing-the-dashboard-ui">https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/#accessing-the-dashboard-ui</a></p>
121+
<p>{{ $t('label.more.access.dashboard.ui') }}:
122+
<a href="https://headlamp.dev/docs/latest/">Headlamp Documentation</a> |
123+
<a href="https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/#accessing-the-dashboard-ui">Kubernetes Dashboard (Legacy)</a>
124+
</p>
95125
</a-card>
96126
<a-card :title="$t('label.access.kubernetes.nodes')">
97127
<p v-html="$t('label.kubernetes.access.details')"></p>

0 commit comments

Comments
 (0)