mirror of https://github.com/kubernetes/kops.git
Merge pull request #16342 from rifelpet/dns-topology
Move DNS topology setup earlier in cluster creation
This commit is contained in:
commit
e43e583d00
|
|
@ -122,8 +122,6 @@ spec:
|
||||||
type: Utility
|
type: Utility
|
||||||
zone: us-test-1a
|
zone: us-test-1a
|
||||||
topology:
|
topology:
|
||||||
bastion:
|
|
||||||
bastionPublicName: bastion.complex.example.com
|
|
||||||
dns:
|
dns:
|
||||||
type: None
|
type: None
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,6 @@ spec:
|
||||||
type: Utility
|
type: Utility
|
||||||
zone: us-test-1a
|
zone: us-test-1a
|
||||||
topology:
|
topology:
|
||||||
bastion:
|
|
||||||
bastionPublicName: bastion.private.example.com
|
|
||||||
dns:
|
dns:
|
||||||
type: None
|
type: None
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,6 @@ spec:
|
||||||
type: Utility
|
type: Utility
|
||||||
zone: us-test-1a
|
zone: us-test-1a
|
||||||
topology:
|
topology:
|
||||||
bastion:
|
|
||||||
bastionPublicName: bastion.private.example.com
|
|
||||||
dns:
|
dns:
|
||||||
type: None
|
type: None
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,6 @@ spec:
|
||||||
type: Utility
|
type: Utility
|
||||||
zone: us-test-1a
|
zone: us-test-1a
|
||||||
topology:
|
topology:
|
||||||
bastion:
|
|
||||||
bastionPublicName: bastion.private.example.com
|
|
||||||
dns:
|
dns:
|
||||||
type: None
|
type: None
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,6 @@ spec:
|
||||||
region: us-test1
|
region: us-test1
|
||||||
type: Private
|
type: Private
|
||||||
topology:
|
topology:
|
||||||
bastion:
|
|
||||||
bastionPublicName: bastion.private.example.com
|
|
||||||
dns:
|
dns:
|
||||||
type: None
|
type: None
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1267,6 +1267,12 @@ func setupTopology(opt *NewClusterOptions, cluster *api.Cluster, allZones sets.S
|
||||||
}
|
}
|
||||||
|
|
||||||
cluster.Spec.Networking.Topology = &api.TopologySpec{}
|
cluster.Spec.Networking.Topology = &api.TopologySpec{}
|
||||||
|
|
||||||
|
err := setupDNSTopology(opt, cluster)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
switch opt.Topology {
|
switch opt.Topology {
|
||||||
case api.TopologyPublic:
|
case api.TopologyPublic:
|
||||||
|
|
||||||
|
|
@ -1405,10 +1411,6 @@ func setupTopology(opt *NewClusterOptions, cluster *api.Cluster, allZones sets.S
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := setupDNSTopology(opt, cluster)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return bastions, nil
|
return bastions, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,6 @@ func TestCreateEtcdCluster(t *testing.T) {
|
||||||
func TestSetupNetworking(t *testing.T) {
|
func TestSetupNetworking(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
options NewClusterOptions
|
options NewClusterOptions
|
||||||
actual api.Cluster
|
|
||||||
expected api.Cluster
|
expected api.Cluster
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
@ -337,6 +336,102 @@ func TestSetupNetworking(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSetupTopology(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
options NewClusterOptions
|
||||||
|
skeleton api.Cluster
|
||||||
|
expected api.Cluster
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
options: NewClusterOptions{
|
||||||
|
Topology: api.TopologyPrivate,
|
||||||
|
Bastion: true,
|
||||||
|
},
|
||||||
|
skeleton: api.Cluster{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "test",
|
||||||
|
},
|
||||||
|
Spec: api.ClusterSpec{
|
||||||
|
KubernetesVersion: "v1.29.0",
|
||||||
|
Networking: api.NetworkingSpec{
|
||||||
|
Topology: &api.TopologySpec{
|
||||||
|
DNS: api.DNSTypeNone,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expected: api.Cluster{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "test",
|
||||||
|
},
|
||||||
|
Spec: api.ClusterSpec{
|
||||||
|
KubernetesVersion: "v1.29.0",
|
||||||
|
Networking: api.NetworkingSpec{
|
||||||
|
Topology: &api.TopologySpec{
|
||||||
|
DNS: api.DNSTypeNone,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
options: NewClusterOptions{
|
||||||
|
Topology: api.TopologyPrivate,
|
||||||
|
DNSType: string(api.DNSTypePublic),
|
||||||
|
Bastion: true,
|
||||||
|
},
|
||||||
|
skeleton: api.Cluster{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "test",
|
||||||
|
},
|
||||||
|
Spec: api.ClusterSpec{
|
||||||
|
KubernetesVersion: "v1.29.0",
|
||||||
|
Networking: api.NetworkingSpec{
|
||||||
|
Topology: &api.TopologySpec{
|
||||||
|
DNS: api.DNSTypePublic,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expected: api.Cluster{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "test",
|
||||||
|
},
|
||||||
|
Spec: api.ClusterSpec{
|
||||||
|
KubernetesVersion: "v1.29.0",
|
||||||
|
Networking: api.NetworkingSpec{
|
||||||
|
Topology: &api.TopologySpec{
|
||||||
|
DNS: api.DNSTypePublic,
|
||||||
|
Bastion: &api.BastionSpec{
|
||||||
|
PublicName: "bastion.test",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
_, err := setupTopology(&test.options, &test.skeleton, nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("error during topology setup: %v", err)
|
||||||
|
}
|
||||||
|
expectedYaml, err := yaml.Marshal(test.expected)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("error converting expected cluster spec to yaml: %v", err)
|
||||||
|
}
|
||||||
|
actualYaml, err := yaml.Marshal(&test.skeleton)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("error converting actual cluster spec to yaml: %v", err)
|
||||||
|
}
|
||||||
|
if string(expectedYaml) != string(actualYaml) {
|
||||||
|
diffString := diff.FormatDiff(string(expectedYaml), string(actualYaml))
|
||||||
|
t.Errorf("unexpected cluster topology setup:\n%s", diffString)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestDefaultImage(t *testing.T) {
|
func TestDefaultImage(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
cluster *api.Cluster
|
cluster *api.Cluster
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue