提交 aa32282e 编写于 作者: C Chen Li 提交者: dlorenc

Use IPSliceVar for apiServerIPs

上级 a3f3286f
......@@ -20,6 +20,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"net"
"os"
"os/exec"
"path/filepath"
......@@ -77,7 +78,7 @@ var (
dockerOpt []string
insecureRegistry []string
apiServerNames []string
apiServerIPs []string
apiServerIPs []net.IP
extraOptions pkgutil.ExtraOptionSlice
)
......@@ -385,7 +386,7 @@ func init() {
startCmd.Flags().StringArrayVar(&dockerOpt, "docker-opt", nil, "Specify arbitrary flags to pass to the Docker daemon. (format: key=value)")
startCmd.Flags().String(apiServerName, constants.APIServerName, "The apiserver name which is used in the generated certificate for localkube/kubernetes. This can be used if you want to make the apiserver available from outside the machine")
startCmd.Flags().StringArrayVar(&apiServerNames, "apiserver-names", nil, "A set of apiserver names which are used in the generated certificate for localkube/kubernetes. This can be used if you want to make the apiserver available from outside the machine")
startCmd.Flags().StringArrayVar(&apiServerIPs, "apiserver-ips", nil, "A set of apiserver IP Addresses which are used in the generated certificate for localkube/kubernetes. This can be used if you want to make the apiserver available from outside the machine")
startCmd.Flags().IPSliceVar(&apiServerIPs, "apiserver-ips", nil, "A set of apiserver IP Addresses which are used in the generated certificate for localkube/kubernetes. This can be used if you want to make the apiserver available from outside the machine")
startCmd.Flags().String(dnsDomain, constants.ClusterDNSDomain, "The cluster dns domain name used in the kubernetes cluster")
startCmd.Flags().StringSliceVar(&insecureRegistry, "insecure-registry", nil, "Insecure Docker registries to pass to the Docker daemon. The default service CIDR range will automatically be added.")
startCmd.Flags().StringSliceVar(&registryMirror, "registry-mirror", nil, "Registry mirrors to pass to the Docker daemon")
......
......@@ -17,6 +17,8 @@ limitations under the License.
package bootstrapper
import (
"net"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/util"
)
......@@ -38,7 +40,7 @@ type KubernetesConfig struct {
NodeName string
APIServerName string
APIServerNames []string
APIServerIPs []string
APIServerIPs []net.IP
DNSDomain string
ContainerRuntime string
NetworkPlugin string
......
......@@ -124,7 +124,7 @@ func generateCerts(k8s KubernetesConfig) error {
}
apiServerIPs := append(
util.GetAPIServerIPs(k8s.APIServerIPs),
k8s.APIServerIPs,
[]net.IP{net.ParseIP(k8s.NodeIP), serviceIP, net.ParseIP("10.0.0.1")}...)
apiServerNames := append(k8s.APIServerNames, k8s.APIServerName)
apiServerAlternateNames := append(
......@@ -152,7 +152,7 @@ func generateCerts(k8s KubernetesConfig) error {
{ // apiserver serving cert
certPath: filepath.Join(localPath, "apiserver.crt"),
keyPath: filepath.Join(localPath, "apiserver.key"),
subject: k8s.APIServerName,
subject: "minikube",
ips: apiServerIPs,
alternateNames: apiServerAlternateNames,
caCertPath: caCertPath,
......
......@@ -57,16 +57,3 @@ func GetDNSIP(serviceCIDR string) (net.IP, error) {
func GetAlternateDNS(domain string) []string {
return []string{"kubernetes.default.svc." + domain, "kubernetes.default.svc", "kubernetes.default", "kubernetes", "localhost"}
}
func GetAPIServerIPs(APIServerIPs []string) []net.IP {
var ips []net.IP
var ip net.IP
for _, ipString := range APIServerIPs {
ip = net.ParseIP(ipString)
if ip != nil {
ips = append(ips, ip)
}
}
return ips
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册