From 0cbd37a776ac768c391b19035ed65c83e6b8c93a Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 17 May 2021 18:30:18 -0700 Subject: [PATCH] add port to addons templates --- deploy/addons/auto-pause/haproxy.cfg.tmpl | 2 +- pkg/addons/addons.go | 3 +++ pkg/minikube/assets/addons.go | 8 +++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/deploy/addons/auto-pause/haproxy.cfg.tmpl b/deploy/addons/auto-pause/haproxy.cfg.tmpl index 11f7be5d3293..6120aea85b80 100644 --- a/deploy/addons/auto-pause/haproxy.cfg.tmpl +++ b/deploy/addons/auto-pause/haproxy.cfg.tmpl @@ -33,5 +33,5 @@ backend k8s-api-https option tcplog option tcp-check default-server inter 10s downinter 5s rise 2 fall 2 slowstart 60s maxconn 250 maxqueue 256 weight 100 - server k8s-api-1 {{.NetworkInfo.ControlPlaneNodeIP}}:8443 check + server k8s-api-1 {{.NetworkInfo.ControlPlaneNodeIP}}:{{.NetworkInfo.ControlPlaneNodePort}} check diff --git a/pkg/addons/addons.go b/pkg/addons/addons.go index b1ce70bd3199..02c67af88cf3 100644 --- a/pkg/addons/addons.go +++ b/pkg/addons/addons.go @@ -219,6 +219,9 @@ https://github.com/kubernetes/minikube/issues/7332`, out.V{"driver_name": cc.Dri var networkInfo assets.NetworkInfo if len(cc.Nodes) >= 1 { networkInfo.ControlPlaneNodeIP = cc.Nodes[0].IP + networkInfo.ControlPlaneNodePort = cc.Nodes[0].Port + fmt.Printf("+%v", networkInfo) + fmt.Println(cc.Nodes[0].Port) } else { out.WarningT("At least needs control plane nodes to enable addon") } diff --git a/pkg/minikube/assets/addons.go b/pkg/minikube/assets/addons.go index 863afc71feda..9602cd2cf8af 100644 --- a/pkg/minikube/assets/addons.go +++ b/pkg/minikube/assets/addons.go @@ -42,7 +42,8 @@ type Addon struct { // NetworkInfo contains control plane node IP address used for add on template type NetworkInfo struct { - ControlPlaneNodeIP string + ControlPlaneNodeIP string + ControlPlaneNodePort int } // NewAddon creates a new Addon @@ -660,7 +661,7 @@ var Addons = map[string]*Addon{ } // GenerateTemplateData generates template data for template assets -func GenerateTemplateData(addon *Addon, cfg config.KubernetesConfig, networkInfo NetworkInfo) interface{} { +func GenerateTemplateData(addon *Addon, cfg config.KubernetesConfig, netInfo NetworkInfo) interface{} { a := runtime.GOARCH // Some legacy docker images still need the -arch suffix @@ -697,7 +698,8 @@ func GenerateTemplateData(addon *Addon, cfg config.KubernetesConfig, networkInfo } // Network info for generating template - opts.NetworkInfo["ControlPlaneNodeIP"] = networkInfo.ControlPlaneNodeIP + opts.NetworkInfo["ControlPlaneNodeIP"] = netInfo.ControlPlaneNodeIP + opts.NetworkInfo["ControlPlaneNodePort"] = fmt.Sprint(netInfo.ControlPlaneNodePort) if opts.Images == nil { opts.Images = make(map[string]string) // Avoid nil access when rendering