MCPcopy
hub / github.com/kubernetes/kops / ResourceNodeUp

Method ResourceNodeUp

pkg/model/bootstrapscript.go:215–262  ·  view source on GitHub ↗

ResourceNodeUp generates and returns a nodeup (bootstrap) script from a template file, substituting in specific env vars & cluster spec configuration

(c *fi.CloudupModelBuilderContext, ig *kops.InstanceGroup)

Source from the content-addressed store, hash-verified

213// ResourceNodeUp generates and returns a nodeup (bootstrap) script from a
214// template file, substituting in specific env vars & cluster spec configuration
215func (b *BootstrapScriptBuilder) ResourceNodeUp(c *fi.CloudupModelBuilderContext, ig *kops.InstanceGroup) (fi.Resource, error) {
216 keypairNames := KeypairNamesForInstanceGroup(b.Cluster, ig)
217
218 if ig.IsBastion() {
219 // Bastions can have AdditionalUserData, but if there isn't any skip this part
220 if len(ig.Spec.AdditionalUserData) == 0 {
221 return nil, nil
222 }
223 }
224
225 keypairTasks := map[string]*fitasks.Keypair{}
226 for _, keypair := range keypairNames {
227 caTaskObject, found := c.Tasks["Keypair/"+keypair]
228 if !found {
229 return nil, fmt.Errorf("keypair/%s task not found", keypair)
230 }
231 keypairTasks[keypair] = caTaskObject.(*fitasks.Keypair)
232 }
233
234 task := &BootstrapScript{
235 Name: ig.Name,
236 Lifecycle: b.Lifecycle,
237 cluster: b.Cluster,
238 ig: ig,
239 builder: b,
240 caTasks: keypairTasks,
241 }
242 task.resource.Task = task
243 task.nodeupConfig.Task = task
244 task.nodeupScript.Task = task
245 c.AddTask(task)
246
247 c.AddTask(&fitasks.ManagedFile{
248 Name: fi.PtrTo("nodeupconfig-" + ig.Name),
249 Lifecycle: b.Lifecycle,
250 Location: fi.PtrTo("igconfig/" + ig.Spec.Role.ToLowerString() + "/" + ig.Name + "/nodeupconfig.yaml"),
251 Contents: &task.nodeupConfig,
252 })
253 if ig.Spec.Manager == kops.InstanceManagerKarpenter {
254 c.AddTask(&fitasks.ManagedFile{
255 Name: fi.PtrTo("nodeupscript-" + ig.Name),
256 Lifecycle: b.Lifecycle,
257 Location: fi.PtrTo("igconfig/" + ig.Spec.Role.ToLowerString() + "/" + ig.Name + "/nodeupscript.sh"),
258 Contents: &task.nodeupScript,
259 })
260 }
261 return &task.resource, nil
262}
263
264func (b *BootstrapScript) GetName() *string {
265 return &b.Name

Callers 11

TestBootstrapUserDataFunction · 0.95
buildInstanceTemplateMethod · 0.80
buildInstancesMethod · 0.80
buildVMScaleSetTaskMethod · 0.80
BuildMethod · 0.80
BuildMethod · 0.80
buildElastigroupMethod · 0.80
buildOceanMethod · 0.80
buildLaunchSpecMethod · 0.80
BuildMethod · 0.80
BuildMethod · 0.80

Calls 5

PtrToFunction · 0.92
IsBastionMethod · 0.80
AddTaskMethod · 0.80
ToLowerStringMethod · 0.80

Tested by 1

TestBootstrapUserDataFunction · 0.76