55"strings"
66
77"github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell"
8- "github.com/aws/eks-anywhere/release/api/v1alpha1"
98)
109
1110const (
@@ -19,11 +18,16 @@ manage_etc_hosts: localhost
1918warnings:
2019 dsid_missing_source: off
2120`
21+
22+ // HookOS embeds container images from the bundle.
23+ // The container images are tagged as below.
24+ actionImage2Disk = "127.0.0.1/embedded/image2disk"
25+ actionWriteFile = "127.0.0.1/embedded/writefile"
26+ actionReboot = "127.0.0.1/embedded/reboot"
2227)
2328
24- // GetDefaultActionsFromBundle constructs a set of default actions for the given osFamily using the
25- // bundle as the source of action images.
26- func GetDefaultActionsFromBundle (clusterSpec * Cluster , b v1alpha1.VersionsBundle , osImageOverride , tinkerbellLocalIP , tinkerbellLBIP string , osFamily OSFamily ) []ActionOpt {
29+ // DefaultActions constructs a set of default actions for the given osFamily.
30+ func DefaultActions (clusterSpec * Cluster , osImageOverride , tinkerbellLocalIP , tinkerbellLBIP string , osFamily OSFamily ) []ActionOpt {
2731// The metadata string will have two URLs:
2832// 1. one that will be used initially for bootstrap and will point to hegel running on kind.
2933// 2. one that will be used when the workload cluster is up and will point to hegel running on
@@ -56,19 +60,19 @@ func GetDefaultActionsFromBundle(clusterSpec *Cluster, b v1alpha1.VersionsBundle
5660devicePath := "{{ index .Hardware.Disks 0 }}"
5761paritionPathFmt := "{{ formatPartition ( index .Hardware.Disks 0 ) %s }}"
5862
59- actions := []ActionOpt {withStreamImageAction (b , devicePath , osImageOverride , additionalEnvVar )}
63+ actions := []ActionOpt {withStreamImageAction (devicePath , osImageOverride , additionalEnvVar )}
6064
6165switch osFamily {
6266case Bottlerocket :
6367partitionPath := fmt .Sprintf (paritionPathFmt , "12" )
6468
6569actions = append (actions ,
66- withBottlerocketBootconfigAction (b , partitionPath ),
67- withBottlerocketUserDataAction (b , partitionPath , strings .Join (metadataURLs , "," )),
70+ withBottlerocketBootconfigAction (partitionPath ),
71+ withBottlerocketUserDataAction (partitionPath , strings .Join (metadataURLs , "," )),
6872// Order matters. This action needs to append to an existing user-data.toml file so
6973// must be after withBottlerocketUserDataAction().
70- withNetplanAction (b , partitionPath , osFamily ),
71- withRebootAction (b ),
74+ withNetplanAction (partitionPath , osFamily ),
75+ withRebootAction (),
7276)
7377case RedHat :
7478var mu []string
@@ -79,28 +83,28 @@ func GetDefaultActionsFromBundle(clusterSpec *Cluster, b v1alpha1.VersionsBundle
7983partitionPath := fmt .Sprintf (paritionPathFmt , "1" )
8084
8185actions = append (actions ,
82- withNetplanAction (b , partitionPath , osFamily ),
83- withDisableCloudInitNetworkCapabilities (b , partitionPath ),
84- withTinkCloudInitAction (b , partitionPath , strings .Join (mu , "," )),
85- withDsCloudInitAction (b , partitionPath ),
86- withRebootAction (b ),
86+ withNetplanAction (partitionPath , osFamily ),
87+ withDisableCloudInitNetworkCapabilities (partitionPath ),
88+ withTinkCloudInitAction (partitionPath , strings .Join (mu , "," )),
89+ withDsCloudInitAction (partitionPath ),
90+ withRebootAction (),
8791)
8892default :
8993partitionPath := fmt .Sprintf (paritionPathFmt , "2" )
9094
9195actions = append (actions ,
92- withNetplanAction (b , partitionPath , osFamily ),
93- withDisableCloudInitNetworkCapabilities (b , partitionPath ),
94- withTinkCloudInitAction (b , partitionPath , strings .Join (metadataURLs , "," )),
95- withDsCloudInitAction (b , partitionPath ),
96- withRebootAction (b ),
96+ withNetplanAction (partitionPath , osFamily ),
97+ withDisableCloudInitNetworkCapabilities (partitionPath ),
98+ withTinkCloudInitAction (partitionPath , strings .Join (metadataURLs , "," )),
99+ withDsCloudInitAction (partitionPath ),
100+ withRebootAction (),
97101)
98102}
99103
100104return actions
101105}
102106
103- func withStreamImageAction (b v1alpha1. VersionsBundle , disk , imageURL string , additionalEnvVar map [string ]string ) ActionOpt {
107+ func withStreamImageAction (disk , imageURL string , additionalEnvVar map [string ]string ) ActionOpt {
104108return func (a * []tinkerbell.Action ) {
105109env := map [string ]string {
106110"DEST_DISK" : disk ,
@@ -113,19 +117,19 @@ func withStreamImageAction(b v1alpha1.VersionsBundle, disk, imageURL string, add
113117}
114118
115119* a = append (* a , tinkerbell.Action {
116- Name : "stream- image" ,
117- Image : b . Tinkerbell . TinkerbellStack . Actions . ImageToDisk . URI ,
120+ Name : "stream image to disk " ,
121+ Image : actionImage2Disk ,
118122Timeout : 600 ,
119123Environment : env ,
120124})
121125}
122126}
123127
124- func withNetplanAction (b v1alpha1. VersionsBundle , disk string , osFamily OSFamily ) ActionOpt {
128+ func withNetplanAction (disk string , osFamily OSFamily ) ActionOpt {
125129return func (a * []tinkerbell.Action ) {
126130netplanAction := tinkerbell.Action {
127- Name : "write- netplan" ,
128- Image : b . Tinkerbell . TinkerbellStack . Actions . WriteFile . URI ,
131+ Name : "write netplan config " ,
132+ Image : actionWriteFile ,
129133Timeout : 90 ,
130134Environment : map [string ]string {
131135"DEST_DISK" : disk ,
@@ -151,11 +155,11 @@ func withNetplanAction(b v1alpha1.VersionsBundle, disk string, osFamily OSFamily
151155}
152156}
153157
154- func withDisableCloudInitNetworkCapabilities (b v1alpha1. VersionsBundle , disk string ) ActionOpt {
158+ func withDisableCloudInitNetworkCapabilities (disk string ) ActionOpt {
155159return func (a * []tinkerbell.Action ) {
156160* a = append (* a , tinkerbell.Action {
157- Name : "disable- cloud-init- network- capabilities" ,
158- Image : b . Tinkerbell . TinkerbellStack . Actions . WriteFile . URI ,
161+ Name : "disable cloud-init network capabilities" ,
162+ Image : actionWriteFile ,
159163Timeout : 90 ,
160164Environment : map [string ]string {
161165"CONTENTS" : "network: {config: disabled}" ,
@@ -171,11 +175,11 @@ func withDisableCloudInitNetworkCapabilities(b v1alpha1.VersionsBundle, disk str
171175}
172176}
173177
174- func withTinkCloudInitAction (b v1alpha1. VersionsBundle , disk string , metadataURLs string ) ActionOpt {
178+ func withTinkCloudInitAction (disk , metadataURLs string ) ActionOpt {
175179return func (a * []tinkerbell.Action ) {
176180* a = append (* a , tinkerbell.Action {
177- Name : "add-tink- cloud-init- config" ,
178- Image : b . Tinkerbell . TinkerbellStack . Actions . WriteFile . URI ,
181+ Name : "add cloud-init config" ,
182+ Image : actionWriteFile ,
179183Timeout : 90 ,
180184Environment : map [string ]string {
181185"DEST_DISK" : disk ,
@@ -191,11 +195,11 @@ func withTinkCloudInitAction(b v1alpha1.VersionsBundle, disk string, metadataURL
191195}
192196}
193197
194- func withDsCloudInitAction (b v1alpha1. VersionsBundle , disk string ) ActionOpt {
198+ func withDsCloudInitAction (disk string ) ActionOpt {
195199return func (a * []tinkerbell.Action ) {
196200* a = append (* a , tinkerbell.Action {
197- Name : "add-tink- cloud-init-ds- config" ,
198- Image : b . Tinkerbell . TinkerbellStack . Actions . WriteFile . URI ,
201+ Name : "add cloud-init ds config" ,
202+ Image : actionWriteFile ,
199203Timeout : 90 ,
200204Environment : map [string ]string {
201205"DEST_DISK" : disk ,
@@ -211,23 +215,23 @@ func withDsCloudInitAction(b v1alpha1.VersionsBundle, disk string) ActionOpt {
211215}
212216}
213217
214- func withRebootAction (b v1alpha1. VersionsBundle ) ActionOpt {
218+ func withRebootAction () ActionOpt {
215219return func (a * []tinkerbell.Action ) {
216220* a = append (* a , tinkerbell.Action {
217- Name : "reboot-image " ,
218- Image : b . Tinkerbell . TinkerbellStack . Actions . Reboot . URI ,
221+ Name : "reboot" ,
222+ Image : actionReboot ,
219223Timeout : 90 ,
220224Pid : "host" ,
221225Volumes : []string {"/worker:/worker" },
222226})
223227}
224228}
225229
226- func withBottlerocketBootconfigAction (b v1alpha1. VersionsBundle , disk string ) ActionOpt {
230+ func withBottlerocketBootconfigAction (disk string ) ActionOpt {
227231return func (a * []tinkerbell.Action ) {
228232* a = append (* a , tinkerbell.Action {
229- Name : "write- bootconfig" ,
230- Image : b . Tinkerbell . TinkerbellStack . Actions . WriteFile . URI ,
233+ Name : "write Bottlerocket bootconfig" ,
234+ Image : actionWriteFile ,
231235Timeout : 90 ,
232236Pid : "host" ,
233237Environment : map [string ]string {
@@ -244,11 +248,11 @@ func withBottlerocketBootconfigAction(b v1alpha1.VersionsBundle, disk string) Ac
244248}
245249}
246250
247- func withBottlerocketUserDataAction (b v1alpha1. VersionsBundle , disk string , metadataURLs string ) ActionOpt {
251+ func withBottlerocketUserDataAction (disk , metadataURLs string ) ActionOpt {
248252return func (a * []tinkerbell.Action ) {
249253* a = append (* a , tinkerbell.Action {
250- Name : "write- user- data" ,
251- Image : b . Tinkerbell . TinkerbellStack . Actions . WriteFile . URI ,
254+ Name : "write Bottlerocket user data" ,
255+ Image : actionWriteFile ,
252256Timeout : 90 ,
253257Pid : "host" ,
254258Environment : map [string ]string {
0 commit comments