Fix Post installation tip for headlamp

Signed-off-by: Santhosh Nagaraj S <santhosh@kinvolk.io>
pull/14522/head
Santhosh Nagaraj S 2022-07-07 12:11:20 +05:30
parent 43b45b5c8d
commit d9263acf8d
10 changed files with 28 additions and 15 deletions

View File

@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"github.com/blang/semver/v4"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/addons"
@ -29,6 +30,7 @@ import (
"k8s.io/minikube/pkg/minikube/out"
"k8s.io/minikube/pkg/minikube/reason"
"k8s.io/minikube/pkg/minikube/style"
"k8s.io/minikube/pkg/util"
)
var addonsEnableCmd = &cobra.Command{
@ -75,16 +77,28 @@ var addonsEnableCmd = &cobra.Command{
minikube service headlamp -n headlamp
`)
out.Styled(style.Tip, `To authenticate in Headlamp, fetch the Authentication Token using the following command:
tokenGenerationTip := "To authenticate in Headlamp, fetch the Authentication Token using the following command:"
createSvcAccountToken := "kubectl create token headlamp --duration 24h -n headlamp"
getSvcAccountToken := `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`
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
`)
clusterName := ClusterFlagValue()
clusterVersion := ClusterKubernetesVersion(clusterName)
parsedClusterVersion, err := util.ParseKubernetesVersion(clusterVersion)
if err != nil {
tokenGenerationTip = fmt.Sprintf("%s\nIf Kubernetes Version is <1.24:\n%s\n\nIf Kubernetes Version is >=1.24:\n%s\n", tokenGenerationTip, createSvcAccountToken, getSvcAccountToken)
} else {
if parsedClusterVersion.GTE(semver.Version{Major: 1, Minor: 24}) {
tokenGenerationTip = fmt.Sprintf("%s\n%s", tokenGenerationTip, createSvcAccountToken)
} else {
tokenGenerationTip = fmt.Sprintf("%s\n%s", tokenGenerationTip, getSvcAccountToken)
}
}
out.Styled(style.Tip, fmt.Sprintf("%s\n", tokenGenerationTip))
tipProfileArg := ""
if ClusterFlagValue() != constants.DefaultClusterName {
tipProfileArg = fmt.Sprintf(" -p %s", ClusterFlagValue())
if clusterName != constants.DefaultClusterName {
tipProfileArg = fmt.Sprintf(" -p %s", clusterName)
}
out.Styled(style.Tip, `Headlamp can display more detailed information when metrics-server is installed. To install it, run:

View File

@ -19,9 +19,16 @@ package config
import (
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/mustload"
)
// ClusterFlagValue returns the current cluster name based on flags
func ClusterFlagValue() string {
return viper.GetString(config.ProfileName)
}
// ClusterKubernetesVersion returns the current Kubernetes version of the cluster
func ClusterKubernetesVersion(clusterProfile string) string {
_, cc := mustload.Partial(clusterProfile)
return cc.KubernetesConfig.KubernetesVersion
}

View File

@ -748,7 +748,6 @@
"Tip: To remove this root owned cluster, run: sudo {{.cmd}}": "Tip: Um diesen zu root gehörenden Cluster zu entfernen, führe {{.cmd}} aus",
"Tip: To remove this root owned cluster, run: sudo {{.cmd}} delete": "Tipp: Um diesen Root-Cluster zu entfernen, führen Sie Folgendes aus: sudo {{.cmd}} delete",
"To access Headlamp, use the following command:\nminikube service headlamp -n headlamp\n\n": "",
"To authenticate in Headlamp, fetch the Authentication Token using the following command:\n\nexport SECRET=$(kubectl get secrets --namespace headlamp -o custom-columns=\":metadata.name\" | grep \"headlamp-token\")\nkubectl get secret $SECRET --namespace headlamp --template=\\{\\{.data.token\\}\\} | base64 --decode\n\t\t\t\n": "",
"To connect to this cluster, use: --context={{.name}}": "Um zu diesem Cluster zu verbinden, verwende --context={{.name}}",
"To connect to this cluster, use: kubectl --context={{.name}}": "Verwenden Sie zum Herstellen einer Verbindung zu diesem Cluster: kubectl --context = {{.name}}",
"To connect to this cluster, use: kubectl --context={{.name}}__1": "Verwenden Sie zum Herstellen einer Verbindung zu diesem Cluster: kubectl --context = {{.name}}",

View File

@ -750,7 +750,6 @@
"Tip: To remove this root owned cluster, run: sudo {{.cmd}}": "",
"Tip: To remove this root owned cluster, run: sudo {{.cmd}} delete": "Para eliminar este clúster de raíz, ejecuta: sudo {{.cmd}} delete",
"To access Headlamp, use the following command:\nminikube service headlamp -n headlamp\n\n": "",
"To authenticate in Headlamp, fetch the Authentication Token using the following command:\n\nexport SECRET=$(kubectl get secrets --namespace headlamp -o custom-columns=\":metadata.name\" | grep \"headlamp-token\")\nkubectl get secret $SECRET --namespace headlamp --template=\\{\\{.data.token\\}\\} | base64 --decode\n\t\t\t\n": "",
"To connect to this cluster, use: --context={{.name}}": "",
"To connect to this cluster, use: kubectl --context={{.name}}": "Para conectarte a este clúster, usa: kubectl --context={{.name}}",
"To connect to this cluster, use: kubectl --context={{.name}}__1": "Para conectarte a este clúster, usa: kubectl --context={{.name}}",

View File

@ -750,7 +750,6 @@
"Tip: To remove this root owned cluster, run: sudo {{.cmd}}": "ヒント: この root 所有クラスターの削除コマンド: sudo {{.cmd}}",
"Tip: To remove this root owned cluster, run: sudo {{.cmd}} delete": "ヒント: この root 所有クラスターの削除コマンド: sudo {{.cmd}} delete",
"To access Headlamp, use the following command:\nminikube service headlamp -n headlamp\n\n": "",
"To authenticate in Headlamp, fetch the Authentication Token using the following command:\n\nexport SECRET=$(kubectl get secrets --namespace headlamp -o custom-columns=\":metadata.name\" | grep \"headlamp-token\")\nkubectl get secret $SECRET --namespace headlamp --template=\\{\\{.data.token\\}\\} | base64 --decode\n\t\t\t\n": "",
"To connect to this cluster, use: --context={{.name}}": "このクラスターに接続するためには、--context={{.name}} を使用します",
"To connect to this cluster, use: kubectl --context={{.name}}": "このクラスターに接続するためには、kubectl --context={{.name}} を使用します",
"To connect to this cluster, use: kubectl --context={{.name}}__1": "このクラスターに接続するためには、kubectl --context={{.name}} を使用します",

View File

@ -751,7 +751,6 @@
"This {{.type}} is having trouble accessing https://{{.repository}}": "",
"Tip: To remove this root owned cluster, run: sudo {{.cmd}}": "",
"To access Headlamp, use the following command:\nminikube service headlamp -n headlamp\n\n": "",
"To authenticate in Headlamp, fetch the Authentication Token using the following command:\n\nexport SECRET=$(kubectl get secrets --namespace headlamp -o custom-columns=\":metadata.name\" | grep \"headlamp-token\")\nkubectl get secret $SECRET --namespace headlamp --template=\\{\\{.data.token\\}\\} | base64 --decode\n\t\t\t\n": "",
"To connect to this cluster, use: --context={{.name}}": "",
"To connect to this cluster, use: kubectl --context={{.profile_name}}": "",
"To disable beta notices, run: 'minikube config set WantBetaUpdateNotification false'": "",

View File

@ -762,7 +762,6 @@
"This {{.type}} is having trouble accessing https://{{.repository}}": "",
"Tip: To remove this root owned cluster, run: sudo {{.cmd}}": "",
"To access Headlamp, use the following command:\nminikube service headlamp -n headlamp\n\n": "",
"To authenticate in Headlamp, fetch the Authentication Token using the following command:\n\nexport SECRET=$(kubectl get secrets --namespace headlamp -o custom-columns=\":metadata.name\" | grep \"headlamp-token\")\nkubectl get secret $SECRET --namespace headlamp --template=\\{\\{.data.token\\}\\} | base64 --decode\n\t\t\t\n": "",
"To connect to this cluster, use: --context={{.name}}": "",
"To connect to this cluster, use: kubectl --context={{.name}}": "Aby połączyć się z klastrem użyj: kubectl --context={{.name}}",
"To connect to this cluster, use: kubectl --context={{.profile_name}}": "Aby połaczyć się z klastrem użyj: kubectl --context={{.profile_name}}",

View File

@ -693,7 +693,6 @@
"This {{.type}} is having trouble accessing https://{{.repository}}": "",
"Tip: To remove this root owned cluster, run: sudo {{.cmd}}": "",
"To access Headlamp, use the following command:\nminikube service headlamp -n headlamp\n\n": "",
"To authenticate in Headlamp, fetch the Authentication Token using the following command:\n\nexport SECRET=$(kubectl get secrets --namespace headlamp -o custom-columns=\":metadata.name\" | grep \"headlamp-token\")\nkubectl get secret $SECRET --namespace headlamp --template=\\{\\{.data.token\\}\\} | base64 --decode\n\t\t\t\n": "",
"To connect to this cluster, use: --context={{.name}}": "",
"To connect to this cluster, use: kubectl --context={{.profile_name}}": "",
"To disable beta notices, run: 'minikube config set WantBetaUpdateNotification false'": "",

View File

@ -693,7 +693,6 @@
"This {{.type}} is having trouble accessing https://{{.repository}}": "",
"Tip: To remove this root owned cluster, run: sudo {{.cmd}}": "",
"To access Headlamp, use the following command:\nminikube service headlamp -n headlamp\n\n": "",
"To authenticate in Headlamp, fetch the Authentication Token using the following command:\n\nexport SECRET=$(kubectl get secrets --namespace headlamp -o custom-columns=\":metadata.name\" | grep \"headlamp-token\")\nkubectl get secret $SECRET --namespace headlamp --template=\\{\\{.data.token\\}\\} | base64 --decode\n\t\t\t\n": "",
"To connect to this cluster, use: --context={{.name}}": "",
"To connect to this cluster, use: kubectl --context={{.profile_name}}": "",
"To disable beta notices, run: 'minikube config set WantBetaUpdateNotification false'": "",

View File

@ -852,7 +852,6 @@
"Tip: To remove this root owned cluster, run: sudo {{.cmd}}": "",
"Tip: To remove this root owned cluster, run: sudo {{.cmd}} delete": "提示:要移除这个由根用户拥有的集群,请运行 sudo {{.cmd}} delete",
"To access Headlamp, use the following command:\nminikube service headlamp -n headlamp\n\n": "",
"To authenticate in Headlamp, fetch the Authentication Token using the following command:\n\nexport SECRET=$(kubectl get secrets --namespace headlamp -o custom-columns=\":metadata.name\" | grep \"headlamp-token\")\nkubectl get secret $SECRET --namespace headlamp --template=\\{\\{.data.token\\}\\} | base64 --decode\n\t\t\t\n": "",
"To connect to this cluster, use: --context={{.name}}": "",
"To connect to this cluster, use: kubectl --context={{.name}}": "如需连接到此集群,请使用 kubectl --context={{.name}}",
"To connect to this cluster, use: kubectl --context={{.name}}__1": "如需连接到此集群,请使用 kubectl --context={{.name}}",