Skip to content

Commit

Permalink
Merge pull request #6745 from sharifelgamal/cpip
Browse files Browse the repository at this point in the history
Specifying control plane IP in kubeadm config template
  • Loading branch information
medyagh committed Feb 22, 2020
2 parents 4ca33ff + fca5101 commit 9634132
Show file tree
Hide file tree
Showing 87 changed files with 244 additions and 88 deletions.
2 changes: 1 addition & 1 deletion pkg/minikube/bootstrapper/bsutil/ktmpl/v1alpha1.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ kind: MasterConfiguration
api:
advertiseAddress: {{.AdvertiseAddress}}
bindPort: {{.APIServerPort}}
controlPlaneEndpoint: localhost
controlPlaneEndpoint: {{.ControlPlaneIP}}
kubernetesVersion: {{.KubernetesVersion}}
certificatesDir: {{.CertDir}}
networking:
Expand Down
4 changes: 3 additions & 1 deletion pkg/minikube/bootstrapper/bsutil/ktmpl/v1alpha3.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ bootstrapTokens:
nodeRegistration:
criSocket: {{if .CRISocket}}{{.CRISocket}}{{else}}/var/run/dockershim.sock{{end}}
name: "{{.NodeName}}"
kubeletExtraArgs:
node-ip: {{.NodeIP}}
taints: []
---
apiVersion: kubeadm.k8s.io/v1alpha3
Expand All @@ -50,7 +52,7 @@ kind: ClusterConfiguration
certificatesDir: {{.CertDir}}
clusterName: {{.ClusterName}}
apiServerCertSANs: ["127.0.0.1", "localhost", "{{.AdvertiseAddress}}"]
controlPlaneEndpoint: localhost:{{.APIServerPort}}
controlPlaneEndpoint: {{.ControlPlaneIP}}:{{.APIServerPort}}
etcd:
local:
dataDir: {{.EtcdDataDir}}
Expand Down
4 changes: 3 additions & 1 deletion pkg/minikube/bootstrapper/bsutil/ktmpl/v1beta1.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ bootstrapTokens:
nodeRegistration:
criSocket: {{if .CRISocket}}{{.CRISocket}}{{else}}/var/run/dockershim.sock{{end}}
name: "{{.NodeName}}"
kubeletExtraArgs:
node-ip: {{.NodeIP}}
taints: []
---
apiVersion: kubeadm.k8s.io/v1beta1
Expand All @@ -55,7 +57,7 @@ kind: ClusterConfiguration
{{end -}}{{end -}}
certificatesDir: {{.CertDir}}
clusterName: {{.ClusterName}}
controlPlaneEndpoint: localhost:{{.APIServerPort}}
controlPlaneEndpoint: {{.ControlPlaneIP}}:{{.APIServerPort}}
dns:
type: CoreDNS
etcd:
Expand Down
4 changes: 3 additions & 1 deletion pkg/minikube/bootstrapper/bsutil/ktmpl/v1beta2.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ bootstrapTokens:
nodeRegistration:
criSocket: {{if .CRISocket}}{{.CRISocket}}{{else}}/var/run/dockershim.sock{{end}}
name: "{{.NodeName}}"
kubeletExtraArgs:
node-ip: {{.NodeIP}}
taints: []
---
apiVersion: kubeadm.k8s.io/v1beta2
Expand All @@ -55,7 +57,7 @@ kind: ClusterConfiguration
{{end -}}{{end -}}
certificatesDir: {{.CertDir}}
clusterName: kubernetes
controlPlaneEndpoint: localhost:{{.APIServerPort}}
controlPlaneEndpoint: {{.ControlPlaneIP}}:{{.APIServerPort}}
controllerManager: {}
dns:
type: CoreDNS
Expand Down
6 changes: 5 additions & 1 deletion pkg/minikube/bootstrapper/bsutil/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
const remoteContainerRuntime = "remote"

// GenerateKubeadmYAML generates the kubeadm.yaml file
func GenerateKubeadmYAML(mc config.ClusterConfig, r cruntime.Manager) ([]byte, error) {
func GenerateKubeadmYAML(mc config.ClusterConfig, r cruntime.Manager, n config.Node) ([]byte, error) {
k8s := mc.KubernetesConfig
version, err := ParseKubernetesVersion(k8s.KubernetesVersion)
if err != nil {
Expand Down Expand Up @@ -80,6 +80,8 @@ func GenerateKubeadmYAML(mc config.ClusterConfig, r cruntime.Manager) ([]byte, e
ComponentOptions []componentOptions
FeatureArgs map[string]bool
NoTaintMaster bool
NodeIP string
ControlPlaneIP string
}{
CertDir: vmpath.GuestKubernetesCertsDir,
ServiceCIDR: constants.DefaultServiceCIDR,
Expand All @@ -96,6 +98,8 @@ func GenerateKubeadmYAML(mc config.ClusterConfig, r cruntime.Manager) ([]byte, e
FeatureArgs: kubeadmFeatureArgs,
NoTaintMaster: false, // That does not work with k8s 1.12+
DNSDomain: k8s.DNSDomain,
NodeIP: n.IP,
ControlPlaneIP: cp.IP,
}

if k8s.ServiceCIDR != "" {
Expand Down
4 changes: 2 additions & 2 deletions pkg/minikube/bootstrapper/bsutil/kubeadm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func TestGenerateKubeadmYAMLDNS(t *testing.T) {
cfg.KubernetesConfig.KubernetesVersion = version + ".0"
cfg.KubernetesConfig.ClusterName = "kubernetes"

got, err := GenerateKubeadmYAML(cfg, runtime)
got, err := GenerateKubeadmYAML(cfg, runtime, cfg.Nodes[0])
if err != nil && !tc.shouldErr {
t.Fatalf("got unexpected error generating config: %v", err)
}
Expand Down Expand Up @@ -210,7 +210,7 @@ func TestGenerateKubeadmYAML(t *testing.T) {
cfg.KubernetesConfig.KubernetesVersion = version + ".0"
cfg.KubernetesConfig.ClusterName = "kubernetes"

got, err := GenerateKubeadmYAML(cfg, runtime)
got, err := GenerateKubeadmYAML(cfg, runtime, cfg.Nodes[0])
if err != nil && !tc.shouldErr {
t.Fatalf("got unexpected error generating config: %v", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ noTaintMaster: true
api:
advertiseAddress: 1.1.1.1
bindPort: 12345
controlPlaneEndpoint: localhost
controlPlaneEndpoint: 1.1.1.1
kubernetesVersion: v1.11.0
certificatesDir: /var/lib/minikube/certs
networking:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ noTaintMaster: true
api:
advertiseAddress: 1.1.1.1
bindPort: 8443
controlPlaneEndpoint: localhost
controlPlaneEndpoint: 1.1.1.1
kubernetesVersion: v1.11.0
certificatesDir: /var/lib/minikube/certs
networking:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ noTaintMaster: true
api:
advertiseAddress: 1.1.1.1
bindPort: 8443
controlPlaneEndpoint: localhost
controlPlaneEndpoint: 1.1.1.1
kubernetesVersion: v1.11.0
certificatesDir: /var/lib/minikube/certs
networking:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ noTaintMaster: true
api:
advertiseAddress: 1.1.1.1
bindPort: 8443
controlPlaneEndpoint: localhost
controlPlaneEndpoint: 1.1.1.1
kubernetesVersion: v1.11.0
certificatesDir: /var/lib/minikube/certs
networking:
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/bootstrapper/bsutil/testdata/v1.11/crio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ noTaintMaster: true
api:
advertiseAddress: 1.1.1.1
bindPort: 8443
controlPlaneEndpoint: localhost
controlPlaneEndpoint: 1.1.1.1
kubernetesVersion: v1.11.0
certificatesDir: /var/lib/minikube/certs
networking:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ noTaintMaster: true
api:
advertiseAddress: 1.1.1.1
bindPort: 8443
controlPlaneEndpoint: localhost
controlPlaneEndpoint: 1.1.1.1
kubernetesVersion: v1.11.0
certificatesDir: /var/lib/minikube/certs
networking:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ noTaintMaster: true
api:
advertiseAddress: 1.1.1.1
bindPort: 8443
controlPlaneEndpoint: localhost
controlPlaneEndpoint: 1.1.1.1
kubernetesVersion: v1.11.0
certificatesDir: /var/lib/minikube/certs
networking:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ noTaintMaster: true
api:
advertiseAddress: 1.1.1.1
bindPort: 8443
controlPlaneEndpoint: localhost
controlPlaneEndpoint: 1.1.1.1
kubernetesVersion: v1.11.0
certificatesDir: /var/lib/minikube/certs
networking:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ bootstrapTokens:
nodeRegistration:
criSocket: /run/containerd/containerd.sock
name: "mk"
kubeletExtraArgs:
node-ip: 1.1.1.1
taints: []
---
apiVersion: kubeadm.k8s.io/v1alpha3
Expand All @@ -22,7 +24,7 @@ apiServerExtraArgs:
certificatesDir: /var/lib/minikube/certs
clusterName: kubernetes
apiServerCertSANs: ["127.0.0.1", "localhost", "1.1.1.1"]
controlPlaneEndpoint: localhost:12345
controlPlaneEndpoint: 1.1.1.1:12345
etcd:
local:
dataDir: /var/lib/minikube/etcd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ bootstrapTokens:
nodeRegistration:
criSocket: /run/containerd/containerd.sock
name: "mk"
kubeletExtraArgs:
node-ip: 1.1.1.1
taints: []
---
apiVersion: kubeadm.k8s.io/v1alpha3
Expand All @@ -22,7 +24,7 @@ apiServerExtraArgs:
certificatesDir: /var/lib/minikube/certs
clusterName: kubernetes
apiServerCertSANs: ["127.0.0.1", "localhost", "1.1.1.1"]
controlPlaneEndpoint: localhost:8443
controlPlaneEndpoint: 1.1.1.1:8443
etcd:
local:
dataDir: /var/lib/minikube/etcd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ bootstrapTokens:
nodeRegistration:
criSocket: /run/containerd/containerd.sock
name: "mk"
kubeletExtraArgs:
node-ip: 1.1.1.1
taints: []
---
apiVersion: kubeadm.k8s.io/v1alpha3
Expand All @@ -22,7 +24,7 @@ apiServerExtraArgs:
certificatesDir: /var/lib/minikube/certs
clusterName: kubernetes
apiServerCertSANs: ["127.0.0.1", "localhost", "1.1.1.1"]
controlPlaneEndpoint: localhost:8443
controlPlaneEndpoint: 1.1.1.1:8443
etcd:
local:
dataDir: /var/lib/minikube/etcd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ bootstrapTokens:
nodeRegistration:
criSocket: /var/run/crio/crio.sock
name: "mk"
kubeletExtraArgs:
node-ip: 1.1.1.1
taints: []
---
apiVersion: kubeadm.k8s.io/v1alpha3
Expand All @@ -30,7 +32,7 @@ schedulerExtraArgs:
certificatesDir: /var/lib/minikube/certs
clusterName: kubernetes
apiServerCertSANs: ["127.0.0.1", "localhost", "1.1.1.1"]
controlPlaneEndpoint: localhost:8443
controlPlaneEndpoint: 1.1.1.1:8443
etcd:
local:
dataDir: /var/lib/minikube/etcd
Expand Down
4 changes: 3 additions & 1 deletion pkg/minikube/bootstrapper/bsutil/testdata/v1.12/crio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ bootstrapTokens:
nodeRegistration:
criSocket: /var/run/crio/crio.sock
name: "mk"
kubeletExtraArgs:
node-ip: 1.1.1.1
taints: []
---
apiVersion: kubeadm.k8s.io/v1alpha3
Expand All @@ -22,7 +24,7 @@ apiServerExtraArgs:
certificatesDir: /var/lib/minikube/certs
clusterName: kubernetes
apiServerCertSANs: ["127.0.0.1", "localhost", "1.1.1.1"]
controlPlaneEndpoint: localhost:8443
controlPlaneEndpoint: 1.1.1.1:8443
etcd:
local:
dataDir: /var/lib/minikube/etcd
Expand Down
4 changes: 3 additions & 1 deletion pkg/minikube/bootstrapper/bsutil/testdata/v1.12/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ bootstrapTokens:
nodeRegistration:
criSocket: /var/run/dockershim.sock
name: "mk"
kubeletExtraArgs:
node-ip: 1.1.1.1
taints: []
---
apiVersion: kubeadm.k8s.io/v1alpha3
Expand All @@ -22,7 +24,7 @@ apiServerExtraArgs:
certificatesDir: /var/lib/minikube/certs
clusterName: kubernetes
apiServerCertSANs: ["127.0.0.1", "localhost", "1.1.1.1"]
controlPlaneEndpoint: localhost:8443
controlPlaneEndpoint: 1.1.1.1:8443
etcd:
local:
dataDir: /var/lib/minikube/etcd
Expand Down
4 changes: 3 additions & 1 deletion pkg/minikube/bootstrapper/bsutil/testdata/v1.12/dns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ bootstrapTokens:
nodeRegistration:
criSocket: /var/run/dockershim.sock
name: "mk"
kubeletExtraArgs:
node-ip: 1.1.1.1
taints: []
---
apiVersion: kubeadm.k8s.io/v1alpha3
Expand All @@ -22,7 +24,7 @@ apiServerExtraArgs:
certificatesDir: /var/lib/minikube/certs
clusterName: kubernetes
apiServerCertSANs: ["127.0.0.1", "localhost", "1.1.1.1"]
controlPlaneEndpoint: localhost:8443
controlPlaneEndpoint: 1.1.1.1:8443
etcd:
local:
dataDir: /var/lib/minikube/etcd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ bootstrapTokens:
nodeRegistration:
criSocket: /var/run/dockershim.sock
name: "mk"
kubeletExtraArgs:
node-ip: 1.1.1.1
taints: []
---
apiVersion: kubeadm.k8s.io/v1alpha3
Expand All @@ -23,7 +25,7 @@ apiServerExtraArgs:
certificatesDir: /var/lib/minikube/certs
clusterName: kubernetes
apiServerCertSANs: ["127.0.0.1", "localhost", "1.1.1.1"]
controlPlaneEndpoint: localhost:8443
controlPlaneEndpoint: 1.1.1.1:8443
etcd:
local:
dataDir: /var/lib/minikube/etcd
Expand Down
4 changes: 3 additions & 1 deletion pkg/minikube/bootstrapper/bsutil/testdata/v1.12/options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ bootstrapTokens:
nodeRegistration:
criSocket: /var/run/dockershim.sock
name: "mk"
kubeletExtraArgs:
node-ip: 1.1.1.1
taints: []
---
apiVersion: kubeadm.k8s.io/v1alpha3
Expand All @@ -27,7 +29,7 @@ schedulerExtraArgs:
certificatesDir: /var/lib/minikube/certs
clusterName: kubernetes
apiServerCertSANs: ["127.0.0.1", "localhost", "1.1.1.1"]
controlPlaneEndpoint: localhost:8443
controlPlaneEndpoint: 1.1.1.1:8443
etcd:
local:
dataDir: /var/lib/minikube/etcd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ bootstrapTokens:
nodeRegistration:
criSocket: /run/containerd/containerd.sock
name: "mk"
kubeletExtraArgs:
node-ip: 1.1.1.1
taints: []
---
apiVersion: kubeadm.k8s.io/v1alpha3
Expand All @@ -22,7 +24,7 @@ apiServerExtraArgs:
certificatesDir: /var/lib/minikube/certs
clusterName: kubernetes
apiServerCertSANs: ["127.0.0.1", "localhost", "1.1.1.1"]
controlPlaneEndpoint: localhost:12345
controlPlaneEndpoint: 1.1.1.1:12345
etcd:
local:
dataDir: /var/lib/minikube/etcd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ bootstrapTokens:
nodeRegistration:
criSocket: /run/containerd/containerd.sock
name: "mk"
kubeletExtraArgs:
node-ip: 1.1.1.1
taints: []
---
apiVersion: kubeadm.k8s.io/v1alpha3
Expand All @@ -22,7 +24,7 @@ apiServerExtraArgs:
certificatesDir: /var/lib/minikube/certs
clusterName: kubernetes
apiServerCertSANs: ["127.0.0.1", "localhost", "1.1.1.1"]
controlPlaneEndpoint: localhost:8443
controlPlaneEndpoint: 1.1.1.1:8443
etcd:
local:
dataDir: /var/lib/minikube/etcd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ bootstrapTokens:
nodeRegistration:
criSocket: /run/containerd/containerd.sock
name: "mk"
kubeletExtraArgs:
node-ip: 1.1.1.1
taints: []
---
apiVersion: kubeadm.k8s.io/v1alpha3
Expand All @@ -22,7 +24,7 @@ apiServerExtraArgs:
certificatesDir: /var/lib/minikube/certs
clusterName: kubernetes
apiServerCertSANs: ["127.0.0.1", "localhost", "1.1.1.1"]
controlPlaneEndpoint: localhost:8443
controlPlaneEndpoint: 1.1.1.1:8443
etcd:
local:
dataDir: /var/lib/minikube/etcd
Expand Down
Loading

0 comments on commit 9634132

Please sign in to comment.