-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96b3d73
commit 98bdfde
Showing
5 changed files
with
1,406 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,9 @@ import ( | |
"time" | ||
|
||
. "github.com/onsi/gomega" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/aws/eks-anywhere/internal/test" | ||
v1alpha1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1" | ||
"github.com/aws/eks-anywhere/pkg/cluster" | ||
"github.com/aws/eks-anywhere/pkg/providers/vsphere" | ||
"github.com/aws/eks-anywhere/pkg/utils/ptr" | ||
) | ||
|
||
func TestVsphereTemplateBuilderGenerateCAPISpecWorkersInvalidSSHKey(t *testing.T) { | ||
|
@@ -53,75 +49,32 @@ func TestVsphereTemplateBuilderGenerateCAPISpecControlPlaneInvalidEtcdSSHKey(t * | |
) | ||
} | ||
|
||
func invalidSSHKey() string { | ||
return "ssh-rsa AAAA B3NzaC1K73CeQ== [email protected]" | ||
} | ||
func TestTemplateBuilder_CertSANs(t *testing.T) { | ||
for _, tc := range []struct { | ||
Input string | ||
Output string | ||
}{ | ||
{ | ||
Input: "testdata/cluster_api_server_cert_san_domain_name.yaml", | ||
Output: "testdata/expected_cluster_api_server_cert_san_domain_name.yaml", | ||
}, | ||
{ | ||
Input: "testdata/cluster_api_server_cert_san_ip.yaml", | ||
Output: "testdata/expected_cluster_api_server_cert_san_ip.yaml", | ||
}, | ||
} { | ||
g := NewWithT(t) | ||
clusterSpec := test.NewFullClusterSpec(t, tc.Input) | ||
|
||
bldr := vsphere.NewVsphereTemplateBuilder(time.Now) | ||
|
||
func vsphereClusterSpec(opts ...test.ClusterSpecOpt) *cluster.Spec { | ||
spec := test.NewClusterSpec(func(s *cluster.Spec) { | ||
s.Cluster.Name = "test-cluster" | ||
s.Cluster.Spec.ControlPlaneConfiguration = v1alpha1.ControlPlaneConfiguration{ | ||
Count: 3, | ||
Endpoint: &v1alpha1.Endpoint{ | ||
Host: "test-ip", | ||
}, | ||
MachineGroupRef: &v1alpha1.Ref{ | ||
Kind: v1alpha1.VSphereMachineConfigKind, | ||
Name: "eksa-unit-test", | ||
}, | ||
} | ||
s.Cluster.Spec.WorkerNodeGroupConfigurations = []v1alpha1.WorkerNodeGroupConfiguration{{ | ||
Name: "md-0", | ||
Count: ptr.Int(3), | ||
MachineGroupRef: &v1alpha1.Ref{ | ||
Kind: v1alpha1.VSphereMachineConfigKind, | ||
Name: "eksa-unit-test", | ||
}, | ||
}} | ||
s.Cluster.Spec.ClusterNetwork = v1alpha1.ClusterNetwork{ | ||
CNIConfig: &v1alpha1.CNIConfig{Cilium: &v1alpha1.CiliumConfig{}}, | ||
Pods: v1alpha1.Pods{ | ||
CidrBlocks: []string{"192.168.0.0/16"}, | ||
}, | ||
Services: v1alpha1.Services{ | ||
CidrBlocks: []string{"10.96.0.0/12"}, | ||
}, | ||
} | ||
s.Cluster.Spec.DatacenterRef = v1alpha1.Ref{ | ||
Kind: v1alpha1.VSphereDatacenterKind, | ||
Name: "eksa-unit-test", | ||
} | ||
s.VSphereDatacenter = &v1alpha1.VSphereDatacenterConfig{ | ||
Spec: v1alpha1.VSphereDatacenterConfigSpec{ | ||
Datacenter: "test", | ||
Network: "test", | ||
Server: "test", | ||
}, | ||
} | ||
s.Cluster.Spec.DatacenterRef = v1alpha1.Ref{ | ||
Kind: v1alpha1.VSphereDatacenterKind, | ||
Name: "vsphere test", | ||
} | ||
s.VSphereMachineConfigs = map[string]*v1alpha1.VSphereMachineConfig{ | ||
"eksa-unit-test": { | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "eksa-unit-test", | ||
}, | ||
Spec: v1alpha1.VSphereMachineConfigSpec{ | ||
Users: []v1alpha1.UserConfiguration{ | ||
{ | ||
Name: "capv", | ||
SshAuthorizedKeys: []string{"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC1BK73XhIzjX+meUr7pIYh6RHbvI3tmHeQIXY5lv7aztN1UoX+bhPo3dwo2sfSQn5kuxgQdnxIZ/CTzy0p0GkEYVv3gwspCeurjmu0XmrdmaSGcGxCEWT/65NtvYrQtUE5ELxJ+N/aeZNlK2B7IWANnw/82913asXH4VksV1NYNduP0o1/G4XcwLLSyVFB078q/oEnmvdNIoS61j4/o36HVtENJgYr0idcBvwJdvcGxGnPaqOhx477t+kfJAa5n5dSA5wilIaoXH5i1Tf/HsTCM52L+iNCARvQzJYZhzbWI1MDQwzILtIBEQCJsl2XSqIupleY8CxqQ6jCXt2mhae+wPc3YmbO5rFvr2/EvC57kh3yDs1Nsuj8KOvD78KeeujbR8n8pScm3WDp62HFQ8lEKNdeRNj6kB8WnuaJvPnyZfvzOhwG65/9w13IBl7B1sWxbFnq2rMpm5uHVK7mAmjL0Tt8zoDhcE1YJEnp9xte3/pvmKPkST5Q/9ZtR9P5sI+02jY0fvPkPyC03j2gsPixG7rpOCwpOdbny4dcj0TDeeXJX8er+oVfJuLYz0pNWJcT2raDdFfcqvYA0B0IyNYlj5nWX4RuEcyT3qocLReWPnZojetvAG/H8XwOh7fEVGqHAKOVSnPXCSQJPl6s0H12jPJBDJMTydtYPEszl4/CeQ=="}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
}) | ||
data, err := bldr.GenerateCAPISpecControlPlane(clusterSpec) | ||
g.Expect(err).ToNot(HaveOccurred()) | ||
|
||
for _, op := range opts { | ||
op(spec) | ||
test.AssertContentToFile(t, string(data), tc.Output) | ||
} | ||
} | ||
|
||
return spec | ||
func invalidSSHKey() string { | ||
return "ssh-rsa AAAA B3NzaC1K73CeQ== [email protected]" | ||
} |
58 changes: 58 additions & 0 deletions
58
pkg/providers/vsphere/testdata/cluster_api_server_cert_san_domain_name.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
apiVersion: anywhere.eks.amazonaws.com/v1alpha1 | ||
kind: Cluster | ||
metadata: | ||
name: test | ||
namespace: test | ||
spec: | ||
controlPlaneConfiguration: | ||
count: 1 | ||
endpoint: | ||
host: 0.0.0.0 | ||
certSANs: ["foo.bar"] | ||
machineGroupRef: | ||
name: test | ||
kind: VSphereMachineConfig | ||
kubernetesVersion: "1.19" | ||
datacenterRef: | ||
kind: VSphereDatacenterConfig | ||
name: test | ||
clusterNetwork: | ||
cni: "cilium" | ||
pods: | ||
cidrBlocks: | ||
- 192.168.0.0/16 | ||
services: | ||
cidrBlocks: | ||
- 10.96.0.0/12 | ||
--- | ||
apiVersion: anywhere.eks.amazonaws.com/v1alpha1 | ||
kind: VSphereMachineConfig | ||
metadata: | ||
name: test | ||
namespace: test | ||
spec: | ||
diskGiB: 25 | ||
cloneMode: linkedClone | ||
datastore: "/SDDC-Datacenter/datastore/WorkloadDatastore" | ||
folder: "/SDDC-Datacenter/vm" | ||
memoryMiB: 8192 | ||
numCPUs: 2 | ||
osFamily: ubuntu | ||
resourcePool: "*/Resources" | ||
template: "/SDDC-Datacenter/vm/Templates/ubuntu-1804-kube-v1.19.6" | ||
users: | ||
- name: capv | ||
sshAuthorizedKeys: | ||
- "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC1BK73XhIzjX+meUr7pIYh6RHbvI3tmHeQIXY5lv7aztN1UoX+bhPo3dwo2sfSQn5kuxgQdnxIZ/CTzy0p0GkEYVv3gwspCeurjmu0XmrdmaSGcGxCEWT/65NtvYrQtUE5ELxJ+N/aeZNlK2B7IWANnw/82913asXH4VksV1NYNduP0o1/G4XcwLLSyVFB078q/oEnmvdNIoS61j4/o36HVtENJgYr0idcBvwJdvcGxGnPaqOhx477t+kfJAa5n5dSA5wilIaoXH5i1Tf/HsTCM52L+iNCARvQzJYZhzbWI1MDQwzILtIBEQCJsl2XSqIupleY8CxqQ6jCXt2mhae+wPc3YmbO5rFvr2/EvC57kh3yDs1Nsuj8KOvD78KeeujbR8n8pScm3WDp62HFQ8lEKNdeRNj6kB8WnuaJvPnyZfvzOhwG65/9w13IBl7B1sWxbFnq2rMpm5uHVK7mAmjL0Tt8zoDhcE1YJEnp9xte3/pvmKPkST5Q/9ZtR9P5sI+02jY0fvPkPyC03j2gsPixG7rpOCwpOdbny4dcj0TDeeXJX8er+oVfJuLYz0pNWJcT2raDdFfcqvYA0B0IyNYlj5nWX4RuEcyT3qocLReWPnZojetvAG/H8XwOh7fEVGqHAKOVSnPXCSQJPl6s0H12jPJBDJMTydtYPEszl4/CeQ== [email protected]" | ||
--- | ||
apiVersion: anywhere.eks.amazonaws.com/v1alpha1 | ||
kind: VSphereDatacenterConfig | ||
metadata: | ||
name: test | ||
namespace: test | ||
spec: | ||
datacenter: "SDDC-Datacenter" | ||
network: "/SDDC-Datacenter/network/sddc-cgw-network-1" | ||
server: "vsphere_server" | ||
thumbprint: "ABCDEFG" | ||
insecure: false |
58 changes: 58 additions & 0 deletions
58
pkg/providers/vsphere/testdata/cluster_api_server_cert_san_ip.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
apiVersion: anywhere.eks.amazonaws.com/v1alpha1 | ||
kind: Cluster | ||
metadata: | ||
name: test | ||
namespace: test | ||
spec: | ||
controlPlaneConfiguration: | ||
count: 1 | ||
endpoint: | ||
host: 0.0.0.0 | ||
certSANs: ["11.11.11.11"] | ||
machineGroupRef: | ||
name: test | ||
kind: VSphereMachineConfig | ||
kubernetesVersion: "1.19" | ||
datacenterRef: | ||
kind: VSphereDatacenterConfig | ||
name: test | ||
clusterNetwork: | ||
cni: "cilium" | ||
pods: | ||
cidrBlocks: | ||
- 192.168.0.0/16 | ||
services: | ||
cidrBlocks: | ||
- 10.96.0.0/12 | ||
--- | ||
apiVersion: anywhere.eks.amazonaws.com/v1alpha1 | ||
kind: VSphereMachineConfig | ||
metadata: | ||
name: test | ||
namespace: test | ||
spec: | ||
diskGiB: 25 | ||
cloneMode: linkedClone | ||
datastore: "/SDDC-Datacenter/datastore/WorkloadDatastore" | ||
folder: "/SDDC-Datacenter/vm" | ||
memoryMiB: 8192 | ||
numCPUs: 2 | ||
osFamily: ubuntu | ||
resourcePool: "*/Resources" | ||
template: "/SDDC-Datacenter/vm/Templates/ubuntu-1804-kube-v1.19.6" | ||
users: | ||
- name: capv | ||
sshAuthorizedKeys: | ||
- "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC1BK73XhIzjX+meUr7pIYh6RHbvI3tmHeQIXY5lv7aztN1UoX+bhPo3dwo2sfSQn5kuxgQdnxIZ/CTzy0p0GkEYVv3gwspCeurjmu0XmrdmaSGcGxCEWT/65NtvYrQtUE5ELxJ+N/aeZNlK2B7IWANnw/82913asXH4VksV1NYNduP0o1/G4XcwLLSyVFB078q/oEnmvdNIoS61j4/o36HVtENJgYr0idcBvwJdvcGxGnPaqOhx477t+kfJAa5n5dSA5wilIaoXH5i1Tf/HsTCM52L+iNCARvQzJYZhzbWI1MDQwzILtIBEQCJsl2XSqIupleY8CxqQ6jCXt2mhae+wPc3YmbO5rFvr2/EvC57kh3yDs1Nsuj8KOvD78KeeujbR8n8pScm3WDp62HFQ8lEKNdeRNj6kB8WnuaJvPnyZfvzOhwG65/9w13IBl7B1sWxbFnq2rMpm5uHVK7mAmjL0Tt8zoDhcE1YJEnp9xte3/pvmKPkST5Q/9ZtR9P5sI+02jY0fvPkPyC03j2gsPixG7rpOCwpOdbny4dcj0TDeeXJX8er+oVfJuLYz0pNWJcT2raDdFfcqvYA0B0IyNYlj5nWX4RuEcyT3qocLReWPnZojetvAG/H8XwOh7fEVGqHAKOVSnPXCSQJPl6s0H12jPJBDJMTydtYPEszl4/CeQ== [email protected]" | ||
--- | ||
apiVersion: anywhere.eks.amazonaws.com/v1alpha1 | ||
kind: VSphereDatacenterConfig | ||
metadata: | ||
name: test | ||
namespace: test | ||
spec: | ||
datacenter: "SDDC-Datacenter" | ||
network: "/SDDC-Datacenter/network/sddc-cgw-network-1" | ||
server: "vsphere_server" | ||
thumbprint: "ABCDEFG" | ||
insecure: false |
Oops, something went wrong.