Merge pull request #5566 from nanikjava/f-fix-4963
Use configured DNS domain in bootstrapper kubeadm templatespull/5583/head
commit
c0e51aa37b
|
@ -698,6 +698,7 @@ func generateConfig(k8s config.KubernetesConfig, r cruntime.Manager) ([]byte, er
|
|||
KubernetesVersion string
|
||||
EtcdDataDir string
|
||||
NodeName string
|
||||
DNSDomain string
|
||||
CRISocket string
|
||||
ImageRepository string
|
||||
ExtraArgs []ComponentExtraArgs
|
||||
|
@ -717,6 +718,7 @@ func generateConfig(k8s config.KubernetesConfig, r cruntime.Manager) ([]byte, er
|
|||
ExtraArgs: extraComponentConfig,
|
||||
FeatureArgs: kubeadmFeatureArgs,
|
||||
NoTaintMaster: false, // That does not work with k8s 1.12+
|
||||
DNSDomain: k8s.DNSDomain,
|
||||
}
|
||||
|
||||
if k8s.ServiceCIDR != "" {
|
||||
|
|
|
@ -235,6 +235,67 @@ func recentReleases() ([]string, error) {
|
|||
return versions, nil
|
||||
}
|
||||
|
||||
/**
|
||||
Need a separate test function to test the DNS server IP
|
||||
as v1.11 yaml file is very different compared to v1.12+.
|
||||
This test case has only 1 thing to test and that is the
|
||||
nnetworking/dnsDomain value
|
||||
*/
|
||||
func TestGenerateConfigDNS(t *testing.T) {
|
||||
versions := []string{"v1.16", "v1.15", "v1.14", "v1.13", "v1.12"}
|
||||
tests := []struct {
|
||||
name string
|
||||
runtime string
|
||||
shouldErr bool
|
||||
cfg config.KubernetesConfig
|
||||
}{
|
||||
{"dns", "docker", false, config.KubernetesConfig{DNSDomain: "1.1.1.1"}},
|
||||
}
|
||||
for _, version := range versions {
|
||||
for _, tc := range tests {
|
||||
runtime, err := cruntime.New(cruntime.Config{Type: tc.runtime})
|
||||
if err != nil {
|
||||
t.Fatalf("runtime: %v", err)
|
||||
}
|
||||
tname := tc.name + "_" + version
|
||||
t.Run(tname, func(t *testing.T) {
|
||||
cfg := tc.cfg
|
||||
cfg.NodeIP = "1.1.1.1"
|
||||
cfg.NodeName = "mk"
|
||||
cfg.KubernetesVersion = version + ".0"
|
||||
|
||||
got, err := generateConfig(cfg, runtime)
|
||||
if err != nil && !tc.shouldErr {
|
||||
t.Fatalf("got unexpected error generating config: %v", err)
|
||||
}
|
||||
if err == nil && tc.shouldErr {
|
||||
t.Fatalf("expected error but got none, config: %s", got)
|
||||
}
|
||||
if tc.shouldErr {
|
||||
return
|
||||
}
|
||||
expected, err := ioutil.ReadFile(fmt.Sprintf("testdata/%s/%s.yaml", version, tc.name))
|
||||
if err != nil {
|
||||
t.Fatalf("unable to read testdata: %v", err)
|
||||
}
|
||||
diff, err := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
|
||||
A: difflib.SplitLines(string(expected)),
|
||||
B: difflib.SplitLines(string(got)),
|
||||
FromFile: "Expected",
|
||||
ToFile: "Got",
|
||||
Context: 1,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("diff error: %v", err)
|
||||
}
|
||||
if diff != "" {
|
||||
t.Errorf("unexpected diff:\n%s\n===== [RAW OUTPUT] =====\n%s", diff, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateConfig(t *testing.T) {
|
||||
extraOpts := getExtraOpts()
|
||||
extraOptsPodCidr := getExtraOptsPodCidr()
|
||||
|
|
|
@ -84,7 +84,7 @@ etcd:
|
|||
dataDir: {{.EtcdDataDir}}
|
||||
kubernetesVersion: {{.KubernetesVersion}}
|
||||
networking:
|
||||
dnsDomain: cluster.local
|
||||
dnsDomain: {{if .DNSDomain}}{{.DNSDomain}}{{else}}cluster.local{{end}}
|
||||
podSubnet: {{if .PodSubnet}}{{.PodSubnet}}{{else}}""{{end}}
|
||||
serviceSubnet: {{.ServiceCIDR}}
|
||||
---
|
||||
|
@ -138,7 +138,7 @@ etcd:
|
|||
dataDir: {{.EtcdDataDir}}
|
||||
kubernetesVersion: {{.KubernetesVersion}}
|
||||
networking:
|
||||
dnsDomain: cluster.local
|
||||
dnsDomain: {{if .DNSDomain}}{{.DNSDomain}}{{else}}cluster.local{{end}}
|
||||
podSubnet: ""
|
||||
serviceSubnet: {{.ServiceCIDR}}
|
||||
---
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
apiVersion: kubeadm.k8s.io/v1alpha3
|
||||
kind: InitConfiguration
|
||||
apiEndpoint:
|
||||
advertiseAddress: 1.1.1.1
|
||||
bindPort: 8443
|
||||
bootstrapTokens:
|
||||
- groups:
|
||||
- system:bootstrappers:kubeadm:default-node-token
|
||||
ttl: 24h0m0s
|
||||
usages:
|
||||
- signing
|
||||
- authentication
|
||||
nodeRegistration:
|
||||
criSocket: /var/run/dockershim.sock
|
||||
name: mk
|
||||
taints: []
|
||||
---
|
||||
apiVersion: kubeadm.k8s.io/v1alpha3
|
||||
kind: ClusterConfiguration
|
||||
apiServerExtraArgs:
|
||||
enable-admission-plugins: "Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
|
||||
certificatesDir: /var/lib/minikube/certs
|
||||
clusterName: kubernetes
|
||||
controlPlaneEndpoint: localhost:8443
|
||||
etcd:
|
||||
local:
|
||||
dataDir: /var/lib/minikube/etcd
|
||||
kubernetesVersion: v1.12.0
|
||||
networking:
|
||||
dnsDomain: 1.1.1.1
|
||||
podSubnet: ""
|
||||
serviceSubnet: 10.96.0.0/12
|
||||
---
|
||||
apiVersion: kubelet.config.k8s.io/v1beta1
|
||||
kind: KubeletConfiguration
|
||||
evictionHard:
|
||||
nodefs.available: "0%"
|
||||
nodefs.inodesFree: "0%"
|
||||
imagefs.available: "0%"
|
|
@ -0,0 +1,39 @@
|
|||
apiVersion: kubeadm.k8s.io/v1alpha3
|
||||
kind: InitConfiguration
|
||||
apiEndpoint:
|
||||
advertiseAddress: 1.1.1.1
|
||||
bindPort: 8443
|
||||
bootstrapTokens:
|
||||
- groups:
|
||||
- system:bootstrappers:kubeadm:default-node-token
|
||||
ttl: 24h0m0s
|
||||
usages:
|
||||
- signing
|
||||
- authentication
|
||||
nodeRegistration:
|
||||
criSocket: /var/run/dockershim.sock
|
||||
name: mk
|
||||
taints: []
|
||||
---
|
||||
apiVersion: kubeadm.k8s.io/v1alpha3
|
||||
kind: ClusterConfiguration
|
||||
apiServerExtraArgs:
|
||||
enable-admission-plugins: "Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
|
||||
certificatesDir: /var/lib/minikube/certs
|
||||
clusterName: kubernetes
|
||||
controlPlaneEndpoint: localhost:8443
|
||||
etcd:
|
||||
local:
|
||||
dataDir: /var/lib/minikube/etcd
|
||||
kubernetesVersion: v1.13.0
|
||||
networking:
|
||||
dnsDomain: 1.1.1.1
|
||||
podSubnet: ""
|
||||
serviceSubnet: 10.96.0.0/12
|
||||
---
|
||||
apiVersion: kubelet.config.k8s.io/v1beta1
|
||||
kind: KubeletConfiguration
|
||||
evictionHard:
|
||||
nodefs.available: "0%"
|
||||
nodefs.inodesFree: "0%"
|
||||
imagefs.available: "0%"
|
|
@ -0,0 +1,43 @@
|
|||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
kind: InitConfiguration
|
||||
localAPIEndpoint:
|
||||
advertiseAddress: 1.1.1.1
|
||||
bindPort: 8443
|
||||
bootstrapTokens:
|
||||
- groups:
|
||||
- system:bootstrappers:kubeadm:default-node-token
|
||||
ttl: 24h0m0s
|
||||
usages:
|
||||
- signing
|
||||
- authentication
|
||||
nodeRegistration:
|
||||
criSocket: /var/run/dockershim.sock
|
||||
name: mk
|
||||
taints: []
|
||||
---
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
kind: ClusterConfiguration
|
||||
apiServer:
|
||||
extraArgs:
|
||||
enable-admission-plugins: "NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
|
||||
certificatesDir: /var/lib/minikube/certs
|
||||
clusterName: kubernetes
|
||||
controlPlaneEndpoint: localhost:8443
|
||||
dns:
|
||||
type: CoreDNS
|
||||
etcd:
|
||||
local:
|
||||
dataDir: /var/lib/minikube/etcd
|
||||
kubernetesVersion: v1.14.0
|
||||
networking:
|
||||
dnsDomain: 1.1.1.1
|
||||
podSubnet: ""
|
||||
serviceSubnet: 10.96.0.0/12
|
||||
---
|
||||
apiVersion: kubelet.config.k8s.io/v1beta1
|
||||
kind: KubeletConfiguration
|
||||
imageGCHighThresholdPercent: 100
|
||||
evictionHard:
|
||||
nodefs.available: "0%"
|
||||
nodefs.inodesFree: "0%"
|
||||
imagefs.available: "0%"
|
|
@ -0,0 +1,43 @@
|
|||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
kind: InitConfiguration
|
||||
localAPIEndpoint:
|
||||
advertiseAddress: 1.1.1.1
|
||||
bindPort: 8443
|
||||
bootstrapTokens:
|
||||
- groups:
|
||||
- system:bootstrappers:kubeadm:default-node-token
|
||||
ttl: 24h0m0s
|
||||
usages:
|
||||
- signing
|
||||
- authentication
|
||||
nodeRegistration:
|
||||
criSocket: /var/run/dockershim.sock
|
||||
name: mk
|
||||
taints: []
|
||||
---
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
kind: ClusterConfiguration
|
||||
apiServer:
|
||||
extraArgs:
|
||||
enable-admission-plugins: "NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
|
||||
certificatesDir: /var/lib/minikube/certs
|
||||
clusterName: kubernetes
|
||||
controlPlaneEndpoint: localhost:8443
|
||||
dns:
|
||||
type: CoreDNS
|
||||
etcd:
|
||||
local:
|
||||
dataDir: /var/lib/minikube/etcd
|
||||
kubernetesVersion: v1.15.0
|
||||
networking:
|
||||
dnsDomain: 1.1.1.1
|
||||
podSubnet: ""
|
||||
serviceSubnet: 10.96.0.0/12
|
||||
---
|
||||
apiVersion: kubelet.config.k8s.io/v1beta1
|
||||
kind: KubeletConfiguration
|
||||
imageGCHighThresholdPercent: 100
|
||||
evictionHard:
|
||||
nodefs.available: "0%"
|
||||
nodefs.inodesFree: "0%"
|
||||
imagefs.available: "0%"
|
|
@ -0,0 +1,43 @@
|
|||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
kind: InitConfiguration
|
||||
localAPIEndpoint:
|
||||
advertiseAddress: 1.1.1.1
|
||||
bindPort: 8443
|
||||
bootstrapTokens:
|
||||
- groups:
|
||||
- system:bootstrappers:kubeadm:default-node-token
|
||||
ttl: 24h0m0s
|
||||
usages:
|
||||
- signing
|
||||
- authentication
|
||||
nodeRegistration:
|
||||
criSocket: /var/run/dockershim.sock
|
||||
name: mk
|
||||
taints: []
|
||||
---
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
kind: ClusterConfiguration
|
||||
apiServer:
|
||||
extraArgs:
|
||||
enable-admission-plugins: "NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
|
||||
certificatesDir: /var/lib/minikube/certs
|
||||
clusterName: kubernetes
|
||||
controlPlaneEndpoint: localhost:8443
|
||||
dns:
|
||||
type: CoreDNS
|
||||
etcd:
|
||||
local:
|
||||
dataDir: /var/lib/minikube/etcd
|
||||
kubernetesVersion: v1.16.0
|
||||
networking:
|
||||
dnsDomain: 1.1.1.1
|
||||
podSubnet: ""
|
||||
serviceSubnet: 10.96.0.0/12
|
||||
---
|
||||
apiVersion: kubelet.config.k8s.io/v1beta1
|
||||
kind: KubeletConfiguration
|
||||
imageGCHighThresholdPercent: 100
|
||||
evictionHard:
|
||||
nodefs.available: "0%"
|
||||
nodefs.inodesFree: "0%"
|
||||
imagefs.available: "0%"
|
|
@ -0,0 +1,58 @@
|
|||
---
|
||||
title: "DNS Domain"
|
||||
linkTitle: "DNS Domain"
|
||||
weight: 6
|
||||
date: 2019-10-09
|
||||
description: >
|
||||
Use configured DNS domain in bootstrapper kubeadm
|
||||
---
|
||||
|
||||
minikube by default uses **cluster.local** if none is specified via the start flag --dns-domain. The configuration file used by kubeadm are found inside **/var/tmp/minikube/kubeadm.yaml** directory inside minikube.
|
||||
|
||||
Default DNS configuration will look like below
|
||||
|
||||
```
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
kind: InitConfiguration
|
||||
localAPIEndpoint:
|
||||
......
|
||||
......
|
||||
---
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
kind: ClusterConfiguration
|
||||
.....
|
||||
.....
|
||||
kubernetesVersion: v1.16.0
|
||||
networking:
|
||||
dnsDomain: cluster.local
|
||||
podSubnet: ""
|
||||
serviceSubnet: 10.96.0.0/12
|
||||
---
|
||||
```
|
||||
|
||||
To change the dns pass the value when starting minikube
|
||||
|
||||
```
|
||||
minikube start --dns-domain bla.blah.blah
|
||||
```
|
||||
|
||||
the dns now changed to bla.blah.blah
|
||||
|
||||
```
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
kind: InitConfiguration
|
||||
localAPIEndpoint:
|
||||
......
|
||||
......
|
||||
---
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
kind: ClusterConfiguration
|
||||
.....
|
||||
.....
|
||||
kubernetesVersion: v1.16.0
|
||||
networking:
|
||||
dnsDomain: bla.blah.blah
|
||||
podSubnet: ""
|
||||
serviceSubnet: 10.96.0.0/12
|
||||
---
|
||||
```
|
Loading…
Reference in New Issue