@@ -44,20 +44,27 @@ func testDefaultInstallationImpl(t *testing.T) {
44
44
openebsOpts := hcli .Calls [0 ].Arguments [1 ].(helm.InstallOptions )
45
45
assert .Equal (t , "openebs" , openebsOpts .ReleaseName )
46
46
assertHelmValues (t , openebsOpts .Values , map [string ]interface {}{
47
- "['localpv-provisioner'].localpv.basePath" : "/var/lib/embedded-cluster/openebs-local" ,
47
+ "['localpv-provisioner'].localpv.basePath" : "/var/lib/embedded-cluster/openebs-local" ,
48
+ "['localpv-provisioner'].helperPod.image.registry" : "fake-replicated-proxy.test.net/anonymous/" ,
49
+ "['localpv-provisioner'].localpv.image.registry" : "fake-replicated-proxy.test.net/anonymous/" ,
50
+ "['preUpgradeHook'].image.registry" : "fake-replicated-proxy.test.net/anonymous" ,
48
51
})
49
52
50
53
// embedded cluster operator
51
54
assert .Equal (t , "Install" , hcli .Calls [1 ].Method )
52
55
operatorOpts := hcli .Calls [1 ].Arguments [1 ].(helm.InstallOptions )
53
56
assert .Equal (t , "embedded-cluster-operator" , operatorOpts .ReleaseName )
57
+ assertHelmValues (t , operatorOpts .Values , map [string ]interface {}{
58
+ "image.repository" : "fake-replicated-proxy.test.net/anonymous/replicated/embedded-cluster-operator-image" ,
59
+ })
54
60
55
61
// velero
56
62
assert .Equal (t , "Install" , hcli .Calls [2 ].Method )
57
63
veleroOpts := hcli .Calls [2 ].Arguments [1 ].(helm.InstallOptions )
58
64
assert .Equal (t , "velero" , veleroOpts .ReleaseName )
59
65
assertHelmValues (t , veleroOpts .Values , map [string ]interface {}{
60
66
"nodeAgent.podVolumePath" : "/var/lib/embedded-cluster/k0s/kubelet/pods" ,
67
+ "image.repository" : "fake-replicated-proxy.test.net/anonymous/replicated/ec-velero" ,
61
68
})
62
69
63
70
// admin console
@@ -67,6 +74,12 @@ func testDefaultInstallationImpl(t *testing.T) {
67
74
assertHelmValues (t , adminConsoleOpts .Values , map [string ]interface {}{
68
75
"kurlProxy.nodePort" : float64 (30000 ),
69
76
})
77
+ assertHelmValuePrefixes (t , adminConsoleOpts .Values , map [string ]string {
78
+ "images.kotsadm" : "fake-replicated-proxy.test.net/anonymous" ,
79
+ "images.kurlProxy" : "fake-replicated-proxy.test.net/anonymous" ,
80
+ "images.migrations" : "fake-replicated-proxy.test.net/anonymous" ,
81
+ "images.rqlite" : "fake-replicated-proxy.test.net/anonymous" ,
82
+ })
70
83
71
84
// --- validate os env --- //
72
85
assertEnv (t , dr .OSEnv , map [string ]string {
@@ -159,6 +172,14 @@ func testDefaultInstallationImpl(t *testing.T) {
159
172
assert .Equal (t , "10.244.0.0/17" , k0sConfig .Spec .Network .PodCIDR )
160
173
assert .Equal (t , "10.244.128.0/17" , k0sConfig .Spec .Network .ServiceCIDR )
161
174
assert .Contains (t , k0sConfig .Spec .API .SANs , "kubernetes.default.svc.cluster.local" )
175
+
176
+ assert .Contains (t , k0sConfig .Spec .Images .MetricsServer .Image , "fake-replicated-proxy.test.net/anonymous" )
177
+ assert .Contains (t , k0sConfig .Spec .Images .KubeProxy .Image , "fake-replicated-proxy.test.net/anonymous" )
178
+ assert .Contains (t , k0sConfig .Spec .Images .CoreDNS .Image , "fake-replicated-proxy.test.net/anonymous" )
179
+ assert .Contains (t , k0sConfig .Spec .Images .Pause .Image , "fake-replicated-proxy.test.net/anonymous" )
180
+ assert .Contains (t , k0sConfig .Spec .Images .Calico .CNI .Image , "fake-replicated-proxy.test.net/anonymous" )
181
+ assert .Contains (t , k0sConfig .Spec .Images .Calico .Node .Image , "fake-replicated-proxy.test.net/anonymous" )
182
+ assert .Contains (t , k0sConfig .Spec .Images .Calico .KubeControllers .Image , "fake-replicated-proxy.test.net/anonymous" )
162
183
}
163
184
164
185
func TestCustomDataDir (t * testing.T ) {
@@ -463,3 +484,90 @@ func TestCustomCidrInstallation(t *testing.T) {
463
484
464
485
t .Logf ("%s: test complete" , time .Now ().Format (time .RFC3339 ))
465
486
}
487
+
488
+ // this test is to ensure that when no domains are provided in the cluster config that the domains from the embedded release file are used
489
+ func TestNoDomains (t * testing.T ) {
490
+ hcli := & helm.MockClient {}
491
+
492
+ mock .InOrder (
493
+ // 4 addons
494
+ hcli .On ("Install" , mock .Anything , mock .Anything ).Times (4 ).Return (nil , nil ),
495
+ hcli .On ("Close" ).Once ().Return (nil ),
496
+ )
497
+
498
+ dr := dryrunInstallWithClusterConfig (t ,
499
+ & dryrun.Client {HelmClient : hcli },
500
+ clusterConfigNoDomainsData ,
501
+ )
502
+
503
+ // --- validate addons --- //
504
+
505
+ // openebs
506
+ assert .Equal (t , "Install" , hcli .Calls [0 ].Method )
507
+ openebsOpts := hcli .Calls [0 ].Arguments [1 ].(helm.InstallOptions )
508
+ assert .Equal (t , "openebs" , openebsOpts .ReleaseName )
509
+ assertHelmValues (t , openebsOpts .Values , map [string ]interface {}{
510
+ "['localpv-provisioner'].localpv.basePath" : "/var/lib/embedded-cluster/openebs-local" ,
511
+ "['localpv-provisioner'].helperPod.image.registry" : "proxy.staging.replicated.com/anonymous/" ,
512
+ "['localpv-provisioner'].localpv.image.registry" : "proxy.staging.replicated.com/anonymous/" ,
513
+ "['preUpgradeHook'].image.registry" : "proxy.staging.replicated.com/anonymous" ,
514
+ })
515
+
516
+ // embedded cluster operator
517
+ assert .Equal (t , "Install" , hcli .Calls [1 ].Method )
518
+ operatorOpts := hcli .Calls [1 ].Arguments [1 ].(helm.InstallOptions )
519
+ assert .Equal (t , "embedded-cluster-operator" , operatorOpts .ReleaseName )
520
+ assertHelmValues (t , operatorOpts .Values , map [string ]interface {}{
521
+ "image.repository" : "proxy.staging.replicated.com/anonymous/replicated/embedded-cluster-operator-image" ,
522
+ })
523
+
524
+ // velero
525
+ assert .Equal (t , "Install" , hcli .Calls [2 ].Method )
526
+ veleroOpts := hcli .Calls [2 ].Arguments [1 ].(helm.InstallOptions )
527
+ assert .Equal (t , "velero" , veleroOpts .ReleaseName )
528
+ assertHelmValues (t , veleroOpts .Values , map [string ]interface {}{
529
+ "nodeAgent.podVolumePath" : "/var/lib/embedded-cluster/k0s/kubelet/pods" ,
530
+ "image.repository" : "proxy.staging.replicated.com/anonymous/replicated/ec-velero" ,
531
+ })
532
+
533
+ // admin console
534
+ assert .Equal (t , "Install" , hcli .Calls [3 ].Method )
535
+ adminConsoleOpts := hcli .Calls [3 ].Arguments [1 ].(helm.InstallOptions )
536
+ assert .Equal (t , "admin-console" , adminConsoleOpts .ReleaseName )
537
+ assertHelmValues (t , adminConsoleOpts .Values , map [string ]interface {}{
538
+ "kurlProxy.nodePort" : float64 (30000 ),
539
+ })
540
+ assertHelmValuePrefixes (t , adminConsoleOpts .Values , map [string ]string {
541
+ "images.kotsadm" : "proxy.staging.replicated.com/anonymous" ,
542
+ "images.kurlProxy" : "proxy.staging.replicated.com/anonymous" ,
543
+ "images.migrations" : "proxy.staging.replicated.com/anonymous" ,
544
+ "images.rqlite" : "proxy.staging.replicated.com/anonymous" ,
545
+ })
546
+
547
+ // --- validate installation object --- //
548
+ kcli , err := dr .KubeClient ()
549
+ if err != nil {
550
+ t .Fatalf ("failed to create kube client: %v" , err )
551
+ }
552
+ in , err := kubeutils .GetLatestInstallation (context .TODO (), kcli )
553
+ if err != nil {
554
+ t .Fatalf ("failed to get latest installation: %v" , err )
555
+ }
556
+ // expected to be empty
557
+ assert .Equal (t , "" , in .Spec .Config .Domains .ProxyRegistryDomain )
558
+ assert .Equal (t , "" , in .Spec .Config .Domains .ReplicatedAppDomain )
559
+ assert .Equal (t , "" , in .Spec .Config .Domains .ReplicatedRegistryDomain )
560
+
561
+ // --- validate k0s cluster config --- //
562
+ k0sConfig := readK0sConfig (t )
563
+
564
+ assert .Contains (t , k0sConfig .Spec .Images .MetricsServer .Image , "proxy.staging.replicated.com/anonymous" )
565
+ assert .Contains (t , k0sConfig .Spec .Images .KubeProxy .Image , "proxy.staging.replicated.com/anonymous" )
566
+ assert .Contains (t , k0sConfig .Spec .Images .CoreDNS .Image , "proxy.staging.replicated.com/anonymous" )
567
+ assert .Contains (t , k0sConfig .Spec .Images .Pause .Image , "proxy.staging.replicated.com/anonymous" )
568
+ assert .Contains (t , k0sConfig .Spec .Images .Calico .CNI .Image , "proxy.staging.replicated.com/anonymous" )
569
+ assert .Contains (t , k0sConfig .Spec .Images .Calico .Node .Image , "proxy.staging.replicated.com/anonymous" )
570
+ assert .Contains (t , k0sConfig .Spec .Images .Calico .KubeControllers .Image , "proxy.staging.replicated.com/anonymous" )
571
+
572
+ t .Logf ("%s: test complete" , time .Now ().Format (time .RFC3339 ))
573
+ }
0 commit comments