Merge pull request #14522 from kinvolk/fix_headlamp_tip
Fix Post installation tip for headlamp addonpull/14599/head
commit
8fd532dd3a
|
@ -20,6 +20,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/blang/semver/v4"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"k8s.io/minikube/pkg/addons"
|
"k8s.io/minikube/pkg/addons"
|
||||||
|
@ -29,6 +30,7 @@ import (
|
||||||
"k8s.io/minikube/pkg/minikube/out"
|
"k8s.io/minikube/pkg/minikube/out"
|
||||||
"k8s.io/minikube/pkg/minikube/reason"
|
"k8s.io/minikube/pkg/minikube/reason"
|
||||||
"k8s.io/minikube/pkg/minikube/style"
|
"k8s.io/minikube/pkg/minikube/style"
|
||||||
|
"k8s.io/minikube/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
var addonsEnableCmd = &cobra.Command{
|
var addonsEnableCmd = &cobra.Command{
|
||||||
|
@ -75,16 +77,28 @@ var addonsEnableCmd = &cobra.Command{
|
||||||
minikube service headlamp -n headlamp
|
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")
|
clusterName := ClusterFlagValue()
|
||||||
kubectl get secret $SECRET --namespace headlamp --template=\{\{.data.token\}\} | base64 --decode
|
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 := ""
|
tipProfileArg := ""
|
||||||
if ClusterFlagValue() != constants.DefaultClusterName {
|
if clusterName != constants.DefaultClusterName {
|
||||||
tipProfileArg = fmt.Sprintf(" -p %s", ClusterFlagValue())
|
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:
|
out.Styled(style.Tip, `Headlamp can display more detailed information when metrics-server is installed. To install it, run:
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,16 @@ package config
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"k8s.io/minikube/pkg/minikube/config"
|
"k8s.io/minikube/pkg/minikube/config"
|
||||||
|
"k8s.io/minikube/pkg/minikube/mustload"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ClusterFlagValue returns the current cluster name based on flags
|
// ClusterFlagValue returns the current cluster name based on flags
|
||||||
func ClusterFlagValue() string {
|
func ClusterFlagValue() string {
|
||||||
return viper.GetString(config.ProfileName)
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -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}}": "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",
|
"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 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: --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}}": "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}}",
|
"To connect to this cluster, use: kubectl --context={{.name}}__1": "Verwenden Sie zum Herstellen einer Verbindung zu diesem Cluster: kubectl --context = {{.name}}",
|
||||||
|
|
|
@ -750,7 +750,6 @@
|
||||||
"Tip: To remove this root owned cluster, run: sudo {{.cmd}}": "",
|
"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",
|
"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 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: --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}}": "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}}",
|
"To connect to this cluster, use: kubectl --context={{.name}}__1": "Para conectarte a este clúster, usa: kubectl --context={{.name}}",
|
||||||
|
|
|
@ -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}}": "ヒント: この root 所有クラスターの削除コマンド: sudo {{.cmd}}",
|
||||||
"Tip: To remove this root owned cluster, run: sudo {{.cmd}} delete": "ヒント: この root 所有クラスターの削除コマンド: sudo {{.cmd}} delete",
|
"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 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: --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}}": "このクラスターに接続するためには、kubectl --context={{.name}} を使用します",
|
||||||
"To connect to this cluster, use: kubectl --context={{.name}}__1": "このクラスターに接続するためには、kubectl --context={{.name}} を使用します",
|
"To connect to this cluster, use: kubectl --context={{.name}}__1": "このクラスターに接続するためには、kubectl --context={{.name}} を使用します",
|
||||||
|
|
|
@ -751,7 +751,6 @@
|
||||||
"This {{.type}} is having trouble accessing https://{{.repository}}": "",
|
"This {{.type}} is having trouble accessing https://{{.repository}}": "",
|
||||||
"Tip: To remove this root owned cluster, run: sudo {{.cmd}}": "",
|
"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 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: --context={{.name}}": "",
|
||||||
"To connect to this cluster, use: kubectl --context={{.profile_name}}": "",
|
"To connect to this cluster, use: kubectl --context={{.profile_name}}": "",
|
||||||
"To disable beta notices, run: 'minikube config set WantBetaUpdateNotification false'": "",
|
"To disable beta notices, run: 'minikube config set WantBetaUpdateNotification false'": "",
|
||||||
|
|
|
@ -762,7 +762,6 @@
|
||||||
"This {{.type}} is having trouble accessing https://{{.repository}}": "",
|
"This {{.type}} is having trouble accessing https://{{.repository}}": "",
|
||||||
"Tip: To remove this root owned cluster, run: sudo {{.cmd}}": "",
|
"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 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: --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={{.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}}",
|
"To connect to this cluster, use: kubectl --context={{.profile_name}}": "Aby połaczyć się z klastrem użyj: kubectl --context={{.profile_name}}",
|
||||||
|
|
|
@ -693,7 +693,6 @@
|
||||||
"This {{.type}} is having trouble accessing https://{{.repository}}": "",
|
"This {{.type}} is having trouble accessing https://{{.repository}}": "",
|
||||||
"Tip: To remove this root owned cluster, run: sudo {{.cmd}}": "",
|
"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 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: --context={{.name}}": "",
|
||||||
"To connect to this cluster, use: kubectl --context={{.profile_name}}": "",
|
"To connect to this cluster, use: kubectl --context={{.profile_name}}": "",
|
||||||
"To disable beta notices, run: 'minikube config set WantBetaUpdateNotification false'": "",
|
"To disable beta notices, run: 'minikube config set WantBetaUpdateNotification false'": "",
|
||||||
|
|
|
@ -693,7 +693,6 @@
|
||||||
"This {{.type}} is having trouble accessing https://{{.repository}}": "",
|
"This {{.type}} is having trouble accessing https://{{.repository}}": "",
|
||||||
"Tip: To remove this root owned cluster, run: sudo {{.cmd}}": "",
|
"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 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: --context={{.name}}": "",
|
||||||
"To connect to this cluster, use: kubectl --context={{.profile_name}}": "",
|
"To connect to this cluster, use: kubectl --context={{.profile_name}}": "",
|
||||||
"To disable beta notices, run: 'minikube config set WantBetaUpdateNotification false'": "",
|
"To disable beta notices, run: 'minikube config set WantBetaUpdateNotification false'": "",
|
||||||
|
|
|
@ -852,7 +852,6 @@
|
||||||
"Tip: To remove this root owned cluster, run: sudo {{.cmd}}": "",
|
"Tip: To remove this root owned cluster, run: sudo {{.cmd}}": "",
|
||||||
"Tip: To remove this root owned cluster, run: sudo {{.cmd}} delete": "提示:要移除这个由根用户拥有的集群,请运行 sudo {{.cmd}} delete",
|
"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 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: --context={{.name}}": "",
|
||||||
"To connect to this cluster, use: kubectl --context={{.name}}": "如需连接到此集群,请使用 kubectl --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}}",
|
"To connect to this cluster, use: kubectl --context={{.name}}__1": "如需连接到此集群,请使用 kubectl --context={{.name}}",
|
||||||
|
|
Loading…
Reference in New Issue