1
0
mirror of https://github.com/rancher/rke.git synced 2025-08-16 05:53:00 +00:00

advertise address on kube-apiserver by internal_address

This commit is contained in:
Mark Lee 2019-01-08 11:14:42 +09:00 committed by Alena Prokharchyk
parent 4cbca1e90a
commit c0ee3327ba

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"crypto/md5" "crypto/md5"
"fmt" "fmt"
"net"
"path" "path"
"strconv" "strconv"
"strings" "strings"
@ -69,7 +70,7 @@ func BuildRKEConfigNodePlan(ctx context.Context, myCluster *Cluster, host *hosts
processes[services.NginxProxyContainerName] = myCluster.BuildProxyProcess() processes[services.NginxProxyContainerName] = myCluster.BuildProxyProcess()
} }
if host.IsControl { if host.IsControl {
processes[services.KubeAPIContainerName] = myCluster.BuildKubeAPIProcess(prefixPath) processes[services.KubeAPIContainerName] = myCluster.BuildKubeAPIProcess(host, prefixPath)
processes[services.KubeControllerContainerName] = myCluster.BuildKubeControllerProcess(prefixPath) processes[services.KubeControllerContainerName] = myCluster.BuildKubeControllerProcess(prefixPath)
processes[services.SchedulerContainerName] = myCluster.BuildSchedulerProcess(prefixPath) processes[services.SchedulerContainerName] = myCluster.BuildSchedulerProcess(prefixPath)
@ -97,7 +98,7 @@ func BuildRKEConfigNodePlan(ctx context.Context, myCluster *Cluster, host *hosts
} }
} }
func (c *Cluster) BuildKubeAPIProcess(prefixPath string) v3.Process { func (c *Cluster) BuildKubeAPIProcess(host *hosts.Host, prefixPath string) v3.Process {
// check if external etcd is used // check if external etcd is used
etcdConnectionString := services.GetEtcdConnString(c.EtcdHosts) etcdConnectionString := services.GetEtcdConnString(c.EtcdHosts)
etcdPathPrefix := EtcdPathPrefix etcdPathPrefix := EtcdPathPrefix
@ -193,6 +194,10 @@ func (c *Cluster) BuildKubeAPIProcess(prefixPath string) v3.Process {
CommandArgs["authorization-mode"] = "Node,RBAC" CommandArgs["authorization-mode"] = "Node,RBAC"
} }
if len(host.InternalAddress) > 0 && net.ParseIP(host.InternalAddress) != nil {
CommandArgs["advertise-address"] = host.InternalAddress
}
// PodSecurityPolicy // PodSecurityPolicy
if c.Services.KubeAPI.PodSecurityPolicy { if c.Services.KubeAPI.PodSecurityPolicy {
CommandArgs["runtime-config"] = "extensions/v1beta1/podsecuritypolicy=true" CommandArgs["runtime-config"] = "extensions/v1beta1/podsecuritypolicy=true"