@@ -74,4 +74,56 @@ func TestControlPlaneJoin(t *testing.T) {
7474 _ , err = cloudinit .GenerateCloudConfig (cloudConfig )
7575 g .Expect (err ).ToNot (HaveOccurred ())
7676 })
77+
78+ t .Run ("WithAddons" , func (t * testing.T ) {
79+ g := NewWithT (t )
80+
81+ authToken := "capi-auth-token"
82+ cloudConfig , err := cloudinit .NewJoinControlPlane (& cloudinit.ControlPlaneJoinInput {
83+ AuthToken : authToken ,
84+ ControlPlaneEndpoint : "k8s.my-domain.com" ,
85+ KubernetesVersion : "v1.25.2" ,
86+ ClusterAgentPort : "30000" ,
87+ DqlitePort : "2379" ,
88+ IPinIP : true ,
89+ DisableDefaultCNI : true ,
90+ Token : strings .Repeat ("a" , 32 ),
91+ TokenTTL : 10000 ,
92+ Addons : []string {"cis-hardening" },
93+ JoinNodeIPs : []string {"10.0.3.39" , "10.0.3.40" , "10.0.3.41" },
94+ })
95+ g .Expect (err ).NotTo (HaveOccurred ())
96+
97+ g .Expect (cloudConfig .RunCommands ).To (Equal ([]string {
98+ `set -x` ,
99+ `/capi-scripts/00-configure-snapstore-http-proxy.sh "" ""` ,
100+ `/capi-scripts/00-configure-snapstore-proxy.sh "http" "" ""` ,
101+ `/capi-scripts/00-disable-host-services.sh` ,
102+ `/capi-scripts/00-install-microk8s.sh "--channel 1.25 --classic" true` ,
103+ `/capi-scripts/10-configure-containerd-proxy.sh "" "" ""` ,
104+ `/capi-scripts/10-configure-kubelet.sh` ,
105+ `/capi-scripts/50-wait-apiserver.sh` ,
106+ `/capi-scripts/10-configure-calico-ipip.sh true` ,
107+ `/capi-scripts/10-configure-cluster-agent-port.sh "30000"` ,
108+ `/capi-scripts/10-configure-dqlite-port.sh "2379"` ,
109+ `/capi-scripts/50-wait-apiserver.sh` ,
110+ `/capi-scripts/10-configure-cert-for-lb.sh "DNS" "k8s.my-domain.com"` ,
111+ `/capi-scripts/20-microk8s-join.sh no "10.0.3.39:30000/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "10.0.3.40:30000/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "10.0.3.41:30000/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"` ,
112+ `/capi-scripts/10-configure-apiserver.sh` ,
113+ `microk8s add-node --token-ttl 10000 --token "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"` ,
114+ `/capi-scripts/20-microk8s-enable.sh "cis-hardening"` ,
115+ }))
116+
117+ g .Expect (cloudConfig .WriteFiles ).To (ContainElements (
118+ cloudinit.File {
119+ Content : authToken ,
120+ Path : cloudinit .CAPIAuthTokenPath ,
121+ Permissions : "0600" ,
122+ Owner : "root:root" ,
123+ },
124+ ))
125+
126+ _ , err = cloudinit .GenerateCloudConfig (cloudConfig )
127+ g .Expect (err ).ToNot (HaveOccurred ())
128+ })
77129}
0 commit comments