Skip to content

Commit

Permalink
Use IPSliceVar for apiServerIPs
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen Li authored and dlorenc committed Jan 17, 2018
1 parent a3f3286 commit aa32282
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
5 changes: 3 additions & 2 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"net"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -77,7 +78,7 @@ var (
dockerOpt []string
insecureRegistry []string
apiServerNames []string
apiServerIPs []string
apiServerIPs []net.IP
extraOptions pkgutil.ExtraOptionSlice
)

Expand Down Expand Up @@ -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")
Expand Down
4 changes: 3 additions & 1 deletion pkg/minikube/bootstrapper/bootstrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package bootstrapper

import (
"net"

"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/util"
)
Expand All @@ -38,7 +40,7 @@ type KubernetesConfig struct {
NodeName string
APIServerName string
APIServerNames []string
APIServerIPs []string
APIServerIPs []net.IP
DNSDomain string
ContainerRuntime string
NetworkPlugin string
Expand Down
4 changes: 2 additions & 2 deletions pkg/minikube/bootstrapper/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 0 additions & 13 deletions pkg/util/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit aa32282

Please sign in to comment.