Skip to content

Commit

Permalink
add port to addons templates
Browse files Browse the repository at this point in the history
  • Loading branch information
medyagh committed May 18, 2021
1 parent 45fca19 commit 0068f92
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deploy/addons/auto-pause/haproxy.cfg.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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

3 changes: 3 additions & 0 deletions pkg/addons/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/minikube/assets/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0068f92

Please sign in to comment.