mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #48005 from danehans/kubeadm_tests
Automatic merge from submit-queue (batch tested with PRs 47869, 48013, 48016, 48005) Adds IPv6 unit test cases to kubeadm **What this PR does / why we need it**: Adds IPv6 test cases to kubeadm. It's needed to ensure test cases cover IPv6 related networking scenarios for kubeadm-based k8s deployments. **Which issue this PR fixes** This PR is in support of Issue #1443. **Special notes for your reviewer**: Additional PR's may follow as e2e testing is being developed by Issue #47666. **Release note**: ```NONE ```
This commit is contained in:
commit
a81c659250
@ -32,6 +32,9 @@ func TestValidateTokenDiscovery(t *testing.T) {
|
||||
{&kubeadm.NodeConfiguration{Token: "772ef5.6b6baab1d4a0a171", DiscoveryTokenAPIServers: []string{"192.168.122.100:9898"}}, nil, true},
|
||||
{&kubeadm.NodeConfiguration{Token: ".6b6baab1d4a0a171", DiscoveryTokenAPIServers: []string{"192.168.122.100:9898"}}, nil, false},
|
||||
{&kubeadm.NodeConfiguration{Token: "772ef5.", DiscoveryTokenAPIServers: []string{"192.168.122.100:9898"}}, nil, false},
|
||||
{&kubeadm.NodeConfiguration{Token: "772ef5.6b6baab1d4a0a171", DiscoveryTokenAPIServers: []string{"2001:db8::100:9898"}}, nil, true},
|
||||
{&kubeadm.NodeConfiguration{Token: ".6b6baab1d4a0a171", DiscoveryTokenAPIServers: []string{"2001:db8::100:9898"}}, nil, false},
|
||||
{&kubeadm.NodeConfiguration{Token: "772ef5.", DiscoveryTokenAPIServers: []string{"2001:db8::100:9898"}}, nil, false},
|
||||
}
|
||||
for _, rt := range tests {
|
||||
err := ValidateToken(rt.c.Token, rt.f).ToAggregate()
|
||||
@ -101,11 +104,13 @@ func TestValidateAPIServerCertSANs(t *testing.T) {
|
||||
sans []string
|
||||
expected bool
|
||||
}{
|
||||
{[]string{}, true}, // ok if not provided
|
||||
{[]string{"1,2,,3"}, false}, // not a DNS label or IP
|
||||
{[]string{"my-hostname", "???&?.garbage"}, false}, // not valid
|
||||
{[]string{"my-hostname", "my.subdomain", "1.2.3.4"}, true}, // supported
|
||||
{[]string{"my-hostname2", "my.other.subdomain", "10.0.0.10"}, true}, // supported
|
||||
{[]string{}, true}, // ok if not provided
|
||||
{[]string{"1,2,,3"}, false}, // not a DNS label or IP
|
||||
{[]string{"my-hostname", "???&?.garbage"}, false}, // not valid
|
||||
{[]string{"my-hostname", "my.subdomain", "1.2.3.4"}, true}, // supported
|
||||
{[]string{"my-hostname2", "my.other.subdomain", "10.0.0.10"}, true}, // supported
|
||||
{[]string{"my-hostname", "my.subdomain", "2001:db8::4"}, true}, // supported
|
||||
{[]string{"my-hostname2", "my.other.subdomain", "2001:db8::10"}, true}, // supported
|
||||
}
|
||||
for _, rt := range tests {
|
||||
actual := ValidateAPIServerCertSANs(rt.sans, nil)
|
||||
@ -191,6 +196,23 @@ func TestValidateMasterConfiguration(t *testing.T) {
|
||||
CertificatesDir: "/some/other/cert/dir",
|
||||
Token: "abcdef.0123456789abcdef",
|
||||
}, true},
|
||||
{&kubeadm.MasterConfiguration{
|
||||
AuthorizationModes: []string{"RBAC"},
|
||||
Networking: kubeadm.Networking{
|
||||
ServiceSubnet: "2001:db8::/98",
|
||||
DNSDomain: "cluster.local",
|
||||
},
|
||||
CertificatesDir: "/some/cert/dir",
|
||||
}, false},
|
||||
{&kubeadm.MasterConfiguration{
|
||||
AuthorizationModes: []string{"RBAC"},
|
||||
Networking: kubeadm.Networking{
|
||||
ServiceSubnet: "2001:db8::/98",
|
||||
DNSDomain: "cluster.local",
|
||||
},
|
||||
CertificatesDir: "/some/other/cert/dir",
|
||||
Token: "abcdef.0123456789abcdef",
|
||||
}, true},
|
||||
}
|
||||
for _, rt := range tests {
|
||||
actual := ValidateMasterConfiguration(rt.s)
|
||||
|
@ -648,6 +648,43 @@ func TestGetAPIServerCommand(t *testing.T) {
|
||||
"--etcd-keyfile=faz",
|
||||
},
|
||||
},
|
||||
{
|
||||
cfg: &kubeadmapi.MasterConfiguration{
|
||||
API: kubeadm.API{BindPort: 123, AdvertiseAddress: "2001:db8::1"},
|
||||
Networking: kubeadm.Networking{ServiceSubnet: "bar"},
|
||||
Etcd: kubeadm.Etcd{CertFile: "fiz", KeyFile: "faz"},
|
||||
CertificatesDir: testCertsDir,
|
||||
KubernetesVersion: "v1.7.0",
|
||||
},
|
||||
expected: []string{
|
||||
"kube-apiserver",
|
||||
"--insecure-port=0",
|
||||
"--admission-control=Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,ResourceQuota",
|
||||
"--service-cluster-ip-range=bar",
|
||||
"--service-account-key-file=" + testCertsDir + "/sa.pub",
|
||||
"--client-ca-file=" + testCertsDir + "/ca.crt",
|
||||
"--tls-cert-file=" + testCertsDir + "/apiserver.crt",
|
||||
"--tls-private-key-file=" + testCertsDir + "/apiserver.key",
|
||||
"--kubelet-client-certificate=" + testCertsDir + "/apiserver-kubelet-client.crt",
|
||||
"--kubelet-client-key=" + testCertsDir + "/apiserver-kubelet-client.key",
|
||||
fmt.Sprintf("--secure-port=%d", 123),
|
||||
"--allow-privileged=true",
|
||||
"--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname",
|
||||
"--experimental-bootstrap-token-auth=true",
|
||||
"--proxy-client-cert-file=/var/lib/certs/front-proxy-client.crt",
|
||||
"--proxy-client-key-file=/var/lib/certs/front-proxy-client.key",
|
||||
"--requestheader-username-headers=X-Remote-User",
|
||||
"--requestheader-group-headers=X-Remote-Group",
|
||||
"--requestheader-extra-headers-prefix=X-Remote-Extra-",
|
||||
"--requestheader-client-ca-file=" + testCertsDir + "/front-proxy-ca.crt",
|
||||
"--requestheader-allowed-names=front-proxy-client",
|
||||
"--authorization-mode=RBAC",
|
||||
"--advertise-address=2001:db8::1",
|
||||
"--etcd-servers=http://127.0.0.1:2379",
|
||||
"--etcd-certfile=fiz",
|
||||
"--etcd-keyfile=faz",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, rt := range tests {
|
||||
|
@ -32,6 +32,11 @@ func TestGetClusterCIDR(t *testing.T) {
|
||||
if clusterCIDR != "- --cluster-cidr=10.244.0.0/16" {
|
||||
t.Errorf("Invalid format: %s", clusterCIDR)
|
||||
}
|
||||
|
||||
clusterIPv6CIDR := getClusterCIDR("2001:db8::/64")
|
||||
if clusterIPv6CIDR != "- --cluster-cidr=2001:db8::/64" {
|
||||
t.Errorf("Invalid format: %s", clusterIPv6CIDR)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompileManifests(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user