@@ -25,6 +25,7 @@ import (
25
25
"github.com/alessio/shellescape"
26
26
"k8s.io/klog/v2"
27
27
"k8s.io/utils/ptr"
28
+
28
29
eksbootstrapv1 "sigs.k8s.io/cluster-api-provider-aws/v2/bootstrap/eks/api/v1beta2"
29
30
"sigs.k8s.io/cluster-api-provider-aws/v2/exp/api/v1beta2"
30
31
)
@@ -49,12 +50,6 @@ runcmd:
49
50
{{- template "disk_setup" .DiskSetup}}
50
51
{{- template "fs_setup" .DiskSetup}}
51
52
{{- template "mounts" .Mounts}}
52
- `
53
-
54
- // Common MIME header and boundary template.
55
- mimeHeaderTemplate = `MIME-Version: 1.0
56
- Content-Type: multipart/mixed; boundary="{{.Boundary}}"
57
-
58
53
`
59
54
60
55
// Shell script part template for AL2023.
@@ -98,111 +93,8 @@ spec:
98
93
- "--node-labels={{if and .KubeletExtraArgs (index .KubeletExtraArgs "node-labels")}}{{index .KubeletExtraArgs "node-labels"}}{{else}}eks.amazonaws.com/nodegroup-image={{if .AMIImageID}}{{.AMIImageID}}{{end}},eks.amazonaws.com/capacityType={{if .CapacityType}}{{.CapacityType}}{{else}}ON_DEMAND{{end}},eks.amazonaws.com/nodegroup={{.NodeGroupName}}{{end}}"
99
94
100
95
--{{.Boundary}}--`
101
-
102
- // AL2023-specific templates.
103
- al2023KubeletExtraArgsTemplate = `{{- define "al2023KubeletExtraArgs" -}}
104
- {{- if . }}
105
- - "--node-labels={{range $k, $v := .}}{{$k}}={{$v}}{{end}}"
106
- {{- end -}}
107
- {{- end -}}`
108
-
109
- al2023ContainerRuntimeTemplate = `{{- define "al2023ContainerRuntime" -}}
110
- {{- if . -}}
111
- containerRuntime: {{.}}
112
- {{- end -}}
113
- {{- end -}}`
114
-
115
- al2023DockerConfigTemplate = `{{- define "al2023DockerConfig" -}}
116
- {{- if and . (ne . "''") -}}
117
- dockerConfig: {{.}}
118
- {{- end -}}
119
- {{- end -}}`
120
-
121
- al2023APIRetryAttemptsTemplate = `{{- define "al2023APIRetryAttempts" -}}
122
- {{- if . -}}
123
- apiRetryAttempts: {{.}}
124
- {{- end -}}
125
- {{- end -}}`
126
-
127
- al2023PauseContainerTemplate = `{{- define "al2023PauseContainer" -}}
128
- {{- if and .AccountNumber .Version -}}
129
- pauseContainer:
130
- accountNumber: {{.AccountNumber}}
131
- version: {{.Version}}
132
- {{- end -}}
133
- {{- end -}}`
134
-
135
- al2023FilesTemplate = `{{- define "al2023Files" -}}
136
- {{- if . -}}
137
- files:{{ range . }}
138
- - path: {{.Path}}
139
- content: |
140
- {{.Content | Indent 8}}{{ if ne .Owner "" }}
141
- owner: {{.Owner}}{{ end }}{{ if ne .Permissions "" }}
142
- permissions: '{{.Permissions}}'{{ end }}{{ end }}
143
- {{- end -}}
144
- {{- end -}}`
145
-
146
- al2023DiskSetupTemplate = `{{- define "al2023DiskSetup" -}}
147
- {{- if . -}}
148
- diskSetup:{{ if .Partitions }}
149
- partitions:{{ range .Partitions }}
150
- - device: {{.Device}}
151
- layout: {{.Layout}}{{ if .Overwrite }}
152
- overwrite: {{.Overwrite}}{{ end }}{{ if .TableType }}
153
- tableType: {{.TableType}}{{ end }}{{ end }}{{ end }}{{ if .Filesystems }}
154
- filesystems:{{ range .Filesystems }}
155
- - device: {{.Device}}
156
- filesystem: {{.Filesystem}}
157
- label: {{.Label}}{{ if .Partition }}
158
- partition: {{.Partition}}{{ end }}{{ if .Overwrite }}
159
- overwrite: {{.Overwrite}}{{ end }}{{ if .ExtraOpts }}
160
- extraOpts:{{ range .ExtraOpts }}
161
- - {{.}}{{ end }}{{ end }}{{ end }}{{ end }}
162
- {{- end -}}
163
- {{- end -}}`
164
-
165
- al2023MountsTemplate = `{{- define "al2023Mounts" -}}
166
- {{- if . -}}
167
- mounts:{{ range . }}
168
- -{{ range . }}
169
- - {{.}}{{ end }}{{ end }}
170
- {{- end -}}
171
- {{- end -}}`
172
-
173
- al2023UsersTemplate = `{{- define "al2023Users" -}}
174
- {{- if . -}}
175
- users:{{ range . }}
176
- - name: {{.Name}}{{ if .Gecos }}
177
- gecos: {{.Gecos}}{{ end }}{{ if .Groups }}
178
- groups: {{.Groups}}{{ end }}{{ if .HomeDir }}
179
- homeDir: {{.HomeDir}}{{ end }}{{ if .Inactive }}
180
- inactive: {{.Inactive}}{{ end }}{{ if .Shell }}
181
- shell: {{.Shell}}{{ end }}{{ if .Passwd }}
182
- passwd: {{.Passwd}}{{ end }}{{ if .PrimaryGroup }}
183
- primaryGroup: {{.PrimaryGroup}}{{ end }}{{ if .LockPassword }}
184
- lockPassword: {{.LockPassword}}{{ end }}{{ if .Sudo }}
185
- sudo: {{.Sudo}}{{ end }}{{ if .SSHAuthorizedKeys }}
186
- sshAuthorizedKeys:{{ range .SSHAuthorizedKeys }}
187
- - {{.}}{{ end }}{{ end }}{{ end }}
188
- {{- end -}}
189
- {{- end -}}`
190
-
191
- al2023NTPTemplate = `{{- define "al2023NTP" -}}
192
- {{- if . -}}
193
- ntp:{{ if .Enabled }}
194
- enabled: true{{ end }}{{ if .Servers }}
195
- servers:{{ range .Servers }}
196
- - {{.}}{{ end }}{{ end }}
197
- {{- end -}}
198
- {{- end -}}`
199
96
)
200
97
201
- // NodeUserData is responsible for generating userdata for EKS nodes.
202
- type NodeUserData struct {
203
- input * NodeInput
204
- }
205
-
206
98
// NodeInput contains all the information required to generate user data for a node.
207
99
type NodeInput struct {
208
100
ClusterName string
0 commit comments