Skip to content

Commit ea8fd6c

Browse files
authored
Merge pull request #15281 from spowelljr/fixAddonEnableMessages
Prevent enabling `efk` addon due to containing Log4j CVE
2 parents 50c28d0 + 43c4e59 commit ea8fd6c

File tree

12 files changed

+114
-77
lines changed

12 files changed

+114
-77
lines changed

cmd/minikube/cmd/config/enable.go

Lines changed: 6 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,16 @@ package config
1818

1919
import (
2020
"errors"
21-
"fmt"
2221

23-
"github.com/blang/semver/v4"
2422
"github.com/spf13/cobra"
2523
"github.com/spf13/viper"
2624
"k8s.io/minikube/pkg/addons"
2725
"k8s.io/minikube/pkg/minikube/assets"
2826
"k8s.io/minikube/pkg/minikube/config"
29-
"k8s.io/minikube/pkg/minikube/constants"
3027
"k8s.io/minikube/pkg/minikube/exit"
3128
"k8s.io/minikube/pkg/minikube/out"
3229
"k8s.io/minikube/pkg/minikube/reason"
3330
"k8s.io/minikube/pkg/minikube/style"
34-
"k8s.io/minikube/pkg/util"
3531
)
3632

3733
var addonsEnableCmd = &cobra.Command{
@@ -44,16 +40,12 @@ var addonsEnableCmd = &cobra.Command{
4440
exit.Message(reason.Usage, "usage: minikube addons enable ADDON_NAME")
4541
}
4642
addon := args[0]
47-
// replace heapster as metrics-server because heapster is deprecated
48-
if addon == "heapster" {
49-
out.Styled(style.Waiting, "using metrics-server addon, heapster is deprecated")
50-
addon = "metrics-server"
51-
}
52-
if addon == "ambassador" {
53-
out.Styled(style.Warning, "The ambassador addon has stopped working as of v1.23.0, for more details visit: https://github.com/datawire/ambassador-operator/issues/73")
54-
}
55-
if addon == "olm" {
56-
out.Styled(style.Warning, "The OLM addon has stopped working, for more details visit: https://github.com/operator-framework/operator-lifecycle-manager/issues/2534")
43+
isDeprecated, replacement, msg := addons.Deprecations(addon)
44+
if isDeprecated && replacement == "" {
45+
exit.Message(reason.InternalAddonEnable, msg)
46+
} else if isDeprecated {
47+
out.Styled(style.Waiting, msg)
48+
addon = replacement
5749
}
5850
addonBundle, ok := assets.Addons[addon]
5951
if ok {
@@ -80,53 +72,6 @@ You can view the list of minikube maintainers at: https://github.com/kubernetes/
8072
if err != nil && !errors.Is(err, addons.ErrSkipThisAddon) {
8173
exit.Error(reason.InternalAddonEnable, "enable failed", err)
8274
}
83-
if addon == "dashboard" {
84-
tipProfileArg := ""
85-
if ClusterFlagValue() != constants.DefaultClusterName {
86-
tipProfileArg = fmt.Sprintf(" -p %s", ClusterFlagValue())
87-
}
88-
out.Styled(style.Tip, `Some dashboard features require the metrics-server addon. To enable all features please run:
89-
90-
minikube{{.profileArg}} addons enable metrics-server
91-
92-
`, out.V{"profileArg": tipProfileArg})
93-
94-
}
95-
if addon == "headlamp" {
96-
out.Styled(style.Tip, `To access Headlamp, use the following command:
97-
minikube service headlamp -n headlamp
98-
99-
`)
100-
tokenGenerationTip := "To authenticate in Headlamp, fetch the Authentication Token using the following command:"
101-
createSvcAccountToken := "kubectl create token headlamp --duration 24h -n headlamp"
102-
getSvcAccountToken := `export SECRET=$(kubectl get secrets --namespace headlamp -o custom-columns=":metadata.name" | grep "headlamp-token")
103-
kubectl get secret $SECRET --namespace headlamp --template=\{\{.data.token\}\} | base64 --decode`
104-
105-
clusterName := ClusterFlagValue()
106-
clusterVersion := ClusterKubernetesVersion(clusterName)
107-
parsedClusterVersion, err := util.ParseKubernetesVersion(clusterVersion)
108-
if err != nil {
109-
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)
110-
} else {
111-
if parsedClusterVersion.GTE(semver.Version{Major: 1, Minor: 24}) {
112-
tokenGenerationTip = fmt.Sprintf("%s\n%s", tokenGenerationTip, createSvcAccountToken)
113-
} else {
114-
tokenGenerationTip = fmt.Sprintf("%s\n%s", tokenGenerationTip, getSvcAccountToken)
115-
}
116-
}
117-
out.Styled(style.Tip, fmt.Sprintf("%s\n", tokenGenerationTip))
118-
119-
tipProfileArg := ""
120-
if clusterName != constants.DefaultClusterName {
121-
tipProfileArg = fmt.Sprintf(" -p %s", clusterName)
122-
}
123-
out.Styled(style.Tip, `Headlamp can display more detailed information when metrics-server is installed. To install it, run:
124-
125-
minikube{{.profileArg}} addons enable metrics-server
126-
127-
`, out.V{"profileArg": tipProfileArg})
128-
129-
}
13075
if err == nil {
13176
out.Step(style.AddonEnable, "The '{{.addonName}}' addon is enabled", out.V{"addonName": addon})
13277
}

cmd/minikube/cmd/config/flags.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,9 @@ package config
1919
import (
2020
"github.com/spf13/viper"
2121
"k8s.io/minikube/pkg/minikube/config"
22-
"k8s.io/minikube/pkg/minikube/mustload"
2322
)
2423

2524
// ClusterFlagValue returns the current cluster name based on flags
2625
func ClusterFlagValue() string {
2726
return viper.GetString(config.ProfileName)
2827
}
29-
30-
// ClusterKubernetesVersion returns the current Kubernetes version of the cluster
31-
func ClusterKubernetesVersion(clusterProfile string) string {
32-
_, cc := mustload.Partial(clusterProfile)
33-
return cc.KubernetesConfig.KubernetesVersion
34-
}

pkg/addons/addons.go

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,90 @@ func RunCallbacks(cc *config.ClusterConfig, name string, value string) error {
7676
return errors.Wrap(err, "running validations")
7777
}
7878

79+
preStartMessages(name, value)
80+
7981
// Run any callbacks for this property
8082
if err := run(cc, name, value, a.callbacks); err != nil {
8183
if errors.Is(err, ErrSkipThisAddon) {
8284
return err
8385
}
8486
return errors.Wrap(err, "running callbacks")
8587
}
88+
89+
postStartMessages(cc, name, value)
90+
8691
return nil
8792
}
8893

94+
func preStartMessages(name, value string) {
95+
if value != "true" {
96+
return
97+
}
98+
switch name {
99+
case "ambassador":
100+
out.Styled(style.Warning, "The ambassador addon has stopped working as of v1.23.0, for more details visit: https://github.com/datawire/ambassador-operator/issues/73")
101+
case "olm":
102+
out.Styled(style.Warning, "The OLM addon has stopped working, for more details visit: https://github.com/operator-framework/operator-lifecycle-manager/issues/2534")
103+
}
104+
}
105+
106+
func postStartMessages(cc *config.ClusterConfig, name, value string) {
107+
if value != "true" {
108+
return
109+
}
110+
clusterName := cc.Name
111+
tipProfileArg := ""
112+
if clusterName != constants.DefaultClusterName {
113+
tipProfileArg = fmt.Sprintf(" -p %s", clusterName)
114+
}
115+
switch name {
116+
case "dashboard":
117+
out.Styled(style.Tip, `Some dashboard features require the metrics-server addon. To enable all features please run:
118+
119+
minikube{{.profileArg}} addons enable metrics-server
120+
121+
`, out.V{"profileArg": tipProfileArg})
122+
case "headlamp":
123+
out.Styled(style.Tip, `To access Headlamp, use the following command:
124+
minikube service headlamp -n headlamp
125+
126+
`)
127+
tokenGenerationTip := "To authenticate in Headlamp, fetch the Authentication Token using the following command:"
128+
createSvcAccountToken := "kubectl create token headlamp --duration 24h -n headlamp"
129+
getSvcAccountToken := `export SECRET=$(kubectl get secrets --namespace headlamp -o custom-columns=":metadata.name" | grep "headlamp-token")
130+
kubectl get secret $SECRET --namespace headlamp --template=\{\{.data.token\}\} | base64 --decode`
131+
132+
clusterVersion := cc.KubernetesConfig.KubernetesVersion
133+
parsedClusterVersion, err := util.ParseKubernetesVersion(clusterVersion)
134+
if err != nil {
135+
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)
136+
} else {
137+
if parsedClusterVersion.GTE(semver.Version{Major: 1, Minor: 24}) {
138+
tokenGenerationTip = fmt.Sprintf("%s\n%s", tokenGenerationTip, createSvcAccountToken)
139+
} else {
140+
tokenGenerationTip = fmt.Sprintf("%s\n%s", tokenGenerationTip, getSvcAccountToken)
141+
}
142+
}
143+
out.Styled(style.Tip, fmt.Sprintf("%s\n", tokenGenerationTip))
144+
out.Styled(style.Tip, `Headlamp can display more detailed information when metrics-server is installed. To install it, run:
145+
146+
minikube{{.profileArg}} addons enable metrics-server
147+
148+
`, out.V{"profileArg": tipProfileArg})
149+
}
150+
}
151+
152+
// Deprecations if the selected addon is deprecated return the replacement addon, otherwise return the passed in addon
153+
func Deprecations(name string) (bool, string, string) {
154+
switch name {
155+
case "heapster":
156+
return true, "metrics-server", "using metrics-server addon, heapster is deprecated"
157+
case "efk":
158+
return true, "", "The current images used in the efk addon contain Log4j vulnerabilities, the addon will be disabled until images are updated, see: https://github.com/kubernetes/minikube/issues/15280"
159+
}
160+
return false, "", ""
161+
}
162+
89163
// Set sets a value in the config (not threadsafe)
90164
func Set(cc *config.ClusterConfig, name string, value string) error {
91165
a, valid := isAddonValid(name)
@@ -426,9 +500,13 @@ func Start(wg *sync.WaitGroup, cc *config.ClusterConfig, toEnable map[string]boo
426500

427501
// Apply new addons
428502
for _, name := range additional {
429-
// replace heapster as metrics-server because heapster is deprecated
430-
if name == "heapster" {
431-
name = "metrics-server"
503+
isDeprecated, replacement, msg := Deprecations(name)
504+
if isDeprecated && replacement == "" {
505+
out.FailureT(msg)
506+
continue
507+
} else if isDeprecated {
508+
out.Styled(style.Waiting, msg)
509+
name = replacement
432510
}
433511
// if the specified addon doesn't exist, skip enabling
434512
_, e := isAddonValid(name)

translations/de.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,7 @@
927927
"config modifies minikube config files using subcommands like \"minikube config set driver kvm2\"\nConfigurable fields: \n\n": "config modifiziert Minikube Konfigurations Dateien mit Unter-Befehlen wie \"minikube config set driver kvm2\"\nConfigurable fields: \n\n",
928928
"config view failed": "config view fehlgeschlagen",
929929
"containers paused status: {{.paused}}": "Container in pausiert status: {{.paused}}",
930+
"dashboard": "",
930931
"dashboard service is not running: {{.error}}": "Dashboard Service läuft nicht: {{.error}}",
931932
"delete ctx": "lösche ctx",
932933
"deleting node": "lösche Node",
@@ -953,6 +954,7 @@
953954
"failed to set cloud shell kubelet config options": "Setzen der Cloud Shell Kublet Konfigurations Opetionen fehlgeschlagen",
954955
"failed to set extra option": "",
955956
"failed to start node": "Start des Nodes fehlgeschlagen",
957+
"false": "",
956958
"fish completion failed": "fish completion fehlgeschlagen",
957959
"fish completion.": "fish fehlgeschlagen",
958960
"if true, will embed the certs in kubeconfig.": "Falls gesetzt, werden die Zeritifikate in die kubeconfig integriert.",
@@ -1012,6 +1014,7 @@
10121014
"status json failure": "Status json Fehler",
10131015
"status text failure": "Status text Fehler",
10141016
"too many arguments ({{.ArgCount}}).\nusage: minikube config set PROPERTY_NAME PROPERTY_VALUE": "Zu viele Parameter ({{.ArgCount}}).\nVerwendung: minikube config set PROPERTY_NAME PROPERTY_VALUE",
1017+
"true": "",
10151018
"tunnel creates a route to services deployed with type LoadBalancer and sets their Ingress to their ClusterIP. for a detailed example see https://minikube.sigs.k8s.io/docs/tasks/loadbalancer": "",
10161019
"unable to bind flags": "Kann Parameter nicht zuweisen",
10171020
"unable to daemonize: {{.err}}": "Kann nicht in den Hintergrund starten (daemonize): {{.err}}",

translations/es.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,7 @@
925925
"config modifies minikube config files using subcommands like \"minikube config set driver kvm2\"\nConfigurable fields: \n\n": "",
926926
"config view failed": "",
927927
"containers paused status: {{.paused}}": "",
928+
"dashboard": "",
928929
"dashboard service is not running: {{.error}}": "",
929930
"delete ctx": "",
930931
"deleting node": "",
@@ -949,6 +950,7 @@
949950
"failed to save config": "",
950951
"failed to set extra option": "",
951952
"failed to start node": "",
953+
"false": "",
952954
"fish completion failed": "",
953955
"fish completion.": "",
954956
"if true, will embed the certs in kubeconfig.": "",
@@ -1006,6 +1008,7 @@
10061008
"status json failure": "",
10071009
"status text failure": "",
10081010
"too many arguments ({{.ArgCount}}).\nusage: minikube config set PROPERTY_NAME PROPERTY_VALUE": "",
1011+
"true": "",
10091012
"tunnel creates a route to services deployed with type LoadBalancer and sets their Ingress to their ClusterIP. for a detailed example see https://minikube.sigs.k8s.io/docs/tasks/loadbalancer": "",
10101013
"unable to bind flags": "",
10111014
"unable to daemonize: {{.err}}": "",
@@ -1026,7 +1029,6 @@
10261029
"usage: minikube config unset PROPERTY_NAME": "",
10271030
"usage: minikube delete": "",
10281031
"usage: minikube profile [MINIKUBE_PROFILE_NAME]": "",
1029-
"using metrics-server addon, heapster is deprecated": "",
10301032
"version json failure": "",
10311033
"version yaml failure": "",
10321034
"yaml encoding failure": "",

translations/fr.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,7 @@
899899
"config modifies minikube config files using subcommands like \"minikube config set driver kvm2\"\nConfigurable fields: \n\n": "config modifie les fichiers de configuration de minikube à l'aide de sous-commandes telles que \"minikube config set driver kvm2\"\nChamps configurables : \n\n",
900900
"config view failed": "échec de la vue de configuration",
901901
"containers paused status: {{.paused}}": "état des conteneurs en pause : {{.paused}}",
902+
"dashboard": "",
902903
"dashboard service is not running: {{.error}}": "le service de tableau de bord ne fonctionne pas : {{.error}}",
903904
"delete ctx": "supprimer ctx",
904905
"deleting node": "suppression d'un nœud",
@@ -925,6 +926,7 @@
925926
"failed to set cloud shell kubelet config options": "échec de la définition des options de configuration cloud shell kubelet",
926927
"failed to set extra option": "impossible de définir une option supplémentaire",
927928
"failed to start node": "échec du démarrage du nœud",
929+
"false": "",
928930
"fish completion failed": "la complétion fish a échoué",
929931
"fish completion.": "complétion fish.",
930932
"if true, will embed the certs in kubeconfig.": "si vrai, intégrera les certificats dans kubeconfig.",
@@ -984,6 +986,7 @@
984986
"status json failure": "état du JSON en échec",
985987
"status text failure": "état du texte en échec",
986988
"too many arguments ({{.ArgCount}}).\nusage: minikube config set PROPERTY_NAME PROPERTY_VALUE": "trop d'arguments ({{.ArgCount}}).\nusage : jeu de configuration de minikube PROPERTY_NAME PROPERTY_VALUE",
989+
"true": "",
987990
"tunnel creates a route to services deployed with type LoadBalancer and sets their Ingress to their ClusterIP. for a detailed example see https://minikube.sigs.k8s.io/docs/tasks/loadbalancer": "le tunnel crée une route vers les services déployés avec le type LoadBalancer et définit leur Ingress sur leur ClusterIP. Pour un exemple détaillé, voir https://minikube.sigs.k8s.io/docs/tasks/loadbalancer",
988991
"unable to bind flags": "impossible de lier les configurations",
989992
"unable to daemonize: {{.err}}": "impossible de démoniser : {{.err}}",

translations/ja.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@
861861
"config modifies minikube config files using subcommands like \"minikube config set driver kvm2\"\nConfigurable fields: \n\n": "config コマンドは「minikube config set driver kvm2」のようにサブコマンドを使用して、minikube 設定ファイルを編集します。 \n設定可能なフィールド:\n\n",
862862
"config view failed": "設定表示が失敗しました",
863863
"containers paused status: {{.paused}}": "コンテナー停止状態: {{.paused}}",
864+
"dashboard": "",
864865
"dashboard service is not running: {{.error}}": "ダッシュボードサービスが実行していません: {{.error}}",
865866
"delete ctx": "ctx を削除します",
866867
"deleting node": "ノードを削除しています",
@@ -885,6 +886,7 @@
885886
"failed to save config": "設定保存に失敗しました",
886887
"failed to set extra option": "追加オプションの設定に失敗しました",
887888
"failed to start node": "ノード開始に失敗しました",
889+
"false": "",
888890
"fish completion failed": "fish のコマンド補完に失敗しました",
889891
"fish completion.": "fish のコマンド補完です。",
890892
"if true, will embed the certs in kubeconfig.": "true の場合、kubeconfig に証明書を埋め込みます。",
@@ -944,6 +946,7 @@
944946
"status json failure": "status json に失敗しました",
945947
"status text failure": "status text に失敗しました",
946948
"too many arguments ({{.ArgCount}}).\nusage: minikube config set PROPERTY_NAME PROPERTY_VALUE": "引数 ({{.ArgCount}} 個) が多すぎます。\n使用法: minikube config set PROPERTY_NAME PROPERTY_VALUE",
949+
"true": "",
947950
"tunnel creates a route to services deployed with type LoadBalancer and sets their Ingress to their ClusterIP. for a detailed example see https://minikube.sigs.k8s.io/docs/tasks/loadbalancer": "tunnel は LoadBalancer タイプで作成されたサービスへのルートを作成し、Ingress をサービスの ClusterIP に設定します。詳細例は https://minikube.sigs.k8s.io/docs/tasks/loadbalancer を参照してください",
948951
"unable to bind flags": "フラグをバインドできません",
949952
"unable to daemonize: {{.err}}": "デーモン化できません: {{.err}}",

translations/ko.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,7 @@
927927
"config view failed": "config view 가 실패하였습니다",
928928
"containers paused status: {{.paused}}": "",
929929
"creating api client": "api 클라이언트 생성 중",
930+
"dashboard": "",
930931
"dashboard service is not running: {{.error}}": "대시보드 서비스가 실행 중이지 않습니다: {{.error}}",
931932
"delete ctx": "",
932933
"deleting node": "",
@@ -952,6 +953,7 @@
952953
"failed to save config": "",
953954
"failed to set extra option": "",
954955
"failed to start node": "",
956+
"false": "",
955957
"fish completion failed": "",
956958
"fish completion.": "",
957959
"getting config": "컨피그 조회 중",
@@ -1014,6 +1016,7 @@
10141016
"status json failure": "",
10151017
"status text failure": "",
10161018
"too many arguments ({{.ArgCount}}).\nusage: minikube config set PROPERTY_NAME PROPERTY_VALUE": "",
1019+
"true": "",
10171020
"tunnel creates a route to services deployed with type LoadBalancer and sets their Ingress to their ClusterIP. for a detailed example see https://minikube.sigs.k8s.io/docs/tasks/loadbalancer": "",
10181021
"unable to bind flags": "",
10191022
"unable to daemonize: {{.err}}": "",
@@ -1035,7 +1038,6 @@
10351038
"usage: minikube config unset PROPERTY_NAME": "",
10361039
"usage: minikube delete": "",
10371040
"usage: minikube profile [MINIKUBE_PROFILE_NAME]": "",
1038-
"using metrics-server addon, heapster is deprecated": "",
10391041
"version json failure": "",
10401042
"version yaml failure": "",
10411043
"yaml encoding failure": "",

translations/pl.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,7 @@
937937
"config modifies minikube config files using subcommands like \"minikube config set driver kvm2\"\nConfigurable fields: \n\n": "",
938938
"config view failed": "",
939939
"containers paused status: {{.paused}}": "",
940+
"dashboard": "",
940941
"dashboard service is not running: {{.error}}": "",
941942
"delete ctx": "",
942943
"deleting node": "",
@@ -961,6 +962,7 @@
961962
"failed to save config": "",
962963
"failed to set extra option": "",
963964
"failed to start node": "",
965+
"false": "",
964966
"fish completion failed": "",
965967
"fish completion.": "",
966968
"if true, will embed the certs in kubeconfig.": "Jeśli ta opcja będzie miała wartoś true, zakodowane w base64 certyfikaty zostaną osadzone w pliku konfiguracyjnym kubeconfig zamiast ścieżek do plików z certyfikatami",
@@ -1019,6 +1021,7 @@
10191021
"status json failure": "",
10201022
"status text failure": "",
10211023
"too many arguments ({{.ArgCount}}).\nusage: minikube config set PROPERTY_NAME PROPERTY_VALUE": "",
1024+
"true": "",
10221025
"tunnel creates a route to services deployed with type LoadBalancer and sets their Ingress to their ClusterIP. for a detailed example see https://minikube.sigs.k8s.io/docs/tasks/loadbalancer": "",
10231026
"unable to bind flags": "",
10241027
"unable to daemonize: {{.err}}": "",
@@ -1040,7 +1043,6 @@
10401043
"usage: minikube config unset PROPERTY_NAME": "użycie: minikube config unset PROPERTY_NAME",
10411044
"usage: minikube delete": "użycie: minikube delete",
10421045
"usage: minikube profile [MINIKUBE_PROFILE_NAME]": "użycie: minikube profile [MINIKUBE_PROFILE_NAME]",
1043-
"using metrics-server addon, heapster is deprecated": "",
10441046
"version json failure": "",
10451047
"version yaml failure": "",
10461048
"yaml encoding failure": "",

0 commit comments

Comments
 (0)