Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Inject stack name into userdata for nodepool workers #735

Merged

Conversation

redbaron
Copy link
Contributor

@redbaron redbaron commented Jul 5, 2017

Fixes #727

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 5, 2017
@codecov-io
Copy link

codecov-io commented Jul 5, 2017

Codecov Report

Merging #735 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #735   +/-   ##
=======================================
  Coverage   34.33%   34.33%           
=======================================
  Files          55       55           
  Lines        3073     3073           
=======================================
  Hits         1055     1055           
  Misses       1859     1859           
  Partials      159      159

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1af89af...08e5eed. Read the comment docs.

@mumoshu
Copy link
Contributor

mumoshu commented Jul 5, 2017

@redbaron Thanks!
This looks nice, too 👍
Perhaps this method can also be enhanced to use ignition in the future? Then, I prefer this over #732.

@redbaron
Copy link
Contributor Author

redbaron commented Jul 5, 2017

Whole UserData refactor was done as a preparation for Ingition

@mumoshu
Copy link
Contributor

mumoshu commented Jul 5, 2017

@redbaron Oh, I had not realized that! Thank you very much 👍
Just confirming but have you verified this to work with ASG-based node pools? (SpotFleet-based ones are ok as they were verified by @camilb)

@@ -21,9 +22,27 @@ func Parse(filename string, funcs template.FuncMap) (*template.Template, error)
}
return content, nil
},
"toJSON": func(v interface{}) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toJson is already available through Masterminds/sprig according to https://github.com/Masterminds/sprig/blob/dba49a8d3a46ae8522f79e2c0241842d6ab613ca/defaults.go#L66
Could we use the one from sprig instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't check if it exists in a code, because it is undocumented on their godoc page: https://godoc.org/github.com/Masterminds/sprig

so I am not sure we can rely on it being available all the time

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@redbaron I believe we can expect it to remain to be existing because it is used widely in many helm charts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the good catch 👍 Let me also add that both sprig's and helm's implementations of toJson seems to swallow errors, which sounds problematic to me. I'm now convinced to have our own implementation!

data, err := json.Marshal(v)
return string(data), err
},
"execTemplate": func(name string, ctx interface{}) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use the template func bundled in text/template instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is a workaround for template not being a real function :) You can not pipe or capture its result

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good to know! Thanks 😄

@redbaron
Copy link
Contributor Author

redbaron commented Jul 5, 2017

Just confirming but have you verified this to work with ASG-based node pools?

No I didn't verify it. Your question made me check for UserData calls and I found that I forgot to update normal ASG worker userdata calls. It should be in sync now and givent that template they are calling is identical it should work, but I'd like to ask for e2e test or apply it to a test cluster if you have it running locally.

@mumoshu
Copy link
Contributor

mumoshu commented Jul 5, 2017

@redbaron Thanks for the fix. Sure, I'll kick the E2E script before I go to sleep 🛌

@mumoshu mumoshu modified the milestone: v0.9.7 Jul 5, 2017
@mumoshu mumoshu merged commit 01a4efd into kubernetes-retired:master Jul 5, 2017
@mumoshu
Copy link
Contributor

mumoshu commented Jul 5, 2017

E2E passed. Thanks for your contribution as always, @redbaron 👍

camilb added a commit to camilb/kube-aws that referenced this pull request Aug 1, 2017
* kubernetes-incubator/master:
  Update heapster k8s manifests accordingly to the upstream
  Add cluster kube-aws version to outputs
  Refactor code to reside in WithDefaultsFrom()
  Update go used to build the E2E container image to 1.8.3 to fix a build error
  Update Kubernetes to v1.7.0 Closes kubernetes-retired#744
  Update CA to 0.6.0 Closes kubernetes-retired#725
  Install Tiller by default Closes kubernetes-retired#656
  Update golang to v1.8.3 Closes kubernetes-retired#720
  Update the default etcd version to 3.2.1 Closes kubernetes-retired#726
  Update OWNERS
  Inject stack name  into userdata for nodepool workers (kubernetes-retired#735)
  Add CA a CriticalAddonsOnly toleration Ref kubernetes-retired#724
  Update comment in cluster.yaml
  Drain node on spot instance termination notice as well
  Additional propagation of etcd version for etcdadm#722)
  Bugfix: CloudWatchLogging always disabled for Worker nodes
  Update ROADMAP.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants