-
Notifications
You must be signed in to change notification settings - Fork 40.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
provision kubelet config file for GCE instead of deprecated flags #62183
Conversation
2b2b3fd
to
e0423a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making changes in stages. Will try echo/redirect again on my second pass.
cluster/gce/gci/configure.sh
Outdated
local -r dest="$1" | ||
echo "Downloading Kubelet config file, if it exists" | ||
# Fetch kubelet config file from GCE metadata server. | ||
(umask 700; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
cluster/gce/gci/configure.sh
Outdated
http://metadata.google.internal/computeMetadata/v1/instance/attributes/kubelet-config; then | ||
# only write to the final location if curl succeeds | ||
mv "${tmp_kubelet_config}" "${dest}" | ||
elif [[ REQUIRE_METADATA_KUBELET_CONFIG_FILE == "true" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
cluster/gce/gci/configure.sh
Outdated
fi | ||
) | ||
} | ||
|
||
function download-kube-master-certs { | ||
# Fetch kube-env from GCE metadata server. | ||
(umask 700; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to 077
cluster/gce/util.sh
Outdated
@@ -531,16 +533,98 @@ function build-node-labels { | |||
echo $node_labels | |||
} | |||
|
|||
# yaml-map-string-stringarray converts the encoded structure to yaml format, and echoes the result | |||
# under the provided name. If the encoded structure is empty, echoes nothing. | |||
# 1: item separator (e.g. ','') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curse my editor's quote behavior
@@ -531,16 +533,98 @@ function build-node-labels { | |||
echo $node_labels | |||
} | |||
|
|||
# yaml-map-string-stringarray converts the encoded structure to yaml format, and echoes the result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
cluster/gce/util.sh
Outdated
done | ||
# only output if there is a non-empty map | ||
if [ ${#map[@]} -gt 0 ]; then | ||
cat >>$file <<EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(stage 2)
cluster/gce/util.sh
Outdated
done | ||
# only output if there is a non-empty map | ||
if [ ${#map[@]} -gt 0 ]; then | ||
cat >>$file <<EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(stage 2)
cluster/gce/util.sh
Outdated
(IFS=, | ||
for v in ${map[$k]}; do | ||
cat >>$file <<EOF | ||
- $(yaml-quote ${v}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(stage 2)
cluster/gce/util.sh
Outdated
local file=$2 | ||
|
||
rm -f ${file} | ||
cat >>$file <<EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(stage 2)
cluster/gce/util.sh
Outdated
cat >>$file <<EOF | ||
staticPodURL: $(yaml-quote ${MANIFEST_URL}) | ||
EOF | ||
write-yaml-map-string-stringarray ',' ':' staticPodURLHeader ${MANIFEST_URL_HEADER} $file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done w/ double quote
(stage 2)
349b11f
to
9649267
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! You need to remove the ${file}
from the list of arguments in the functions... You're not passing it when calling them, so I think just not taking them as argument is enough already...
@@ -531,16 +533,98 @@ function build-node-labels { | |||
echo $node_labels | |||
} | |||
|
|||
# yaml-map-string-stringarray converts the encoded structure to yaml format, and echoes the result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
You're taking a ${file}
argument here but you don't use it anywhere. Just remove it (and shift the other two up.)
cluster/gce/util.sh
Outdated
if [[ ${#map[@]} -gt 0 ]]; then | ||
echo "${name}:" | ||
for k in "${!map[@]}"; do | ||
echo " ${k}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo " ${k}:"
with a colon at the end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch, thanks
cluster/gce/util.sh
Outdated
declare -a values | ||
IFS="${item_sep}" read -ra values <<<"${map[$k]}" | ||
for v in "${values[@]}"; do | ||
echo " - $(yaml-quote "${v}")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: I'd use an assignment to avoid the nested quotes:
declare quoted_value
quoted_value=$(yaml-quote "${v}")
echo " - ${quoted_value}"
Note that this doesn't work!
declare quoted_value=$(yaml-quote "${v}")
Because if yaml-quote
fails (returns non-zero) then that gets ignored since neither errexit or pipefail is triggered... 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
fi | ||
} | ||
|
||
# yaml-map-string-string converts the encoded structure to yaml format, and echoes the result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, ${file}
should be gone...
cluster/gce/util.sh
Outdated
echo "${name}:" | ||
for k in "${!map[@]}"; do | ||
if [[ "${quote_val_string}" == "true" ]]; then | ||
echo " ${k}: $(yaml-quote ${map[$k]})" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment above about storing yaml-quote
result on a variable...
02b1cc0
to
0328e10
Compare
LGTM 👍 |
c70ef83
to
570f6f0
Compare
@@ -230,6 +230,7 @@ HTTP server: The kubelet can also listen for HTTP and respond to a simple API | |||
} | |||
|
|||
// run the kubelet | |||
glog.V(5).Infof("KubeletConfiguration: %#v", kubeletServer.KubeletConfiguration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've used this in a number of debugging scenarios, I figure we might as well leave it at v=5.
/approve |
cluster/gce/gci/configure-helper.sh
Outdated
@@ -2406,6 +2407,12 @@ fi | |||
|
|||
source "${KUBE_HOME}/kube-env" | |||
|
|||
|
|||
if [ -f "${KUBE_HOME}/kubelet-config.yaml" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this into start-kubelet right before you use it?
570f6f0
to
2baf00a
Compare
This PR extends the client-side startup scripts to provision a Kubelet config file instead of legacy flags. This PR also extends the master/node init scripts to install this config file from the GCE metadata server, and provide the --config argument to the Kubelet.
2baf00a
to
420edc7
Compare
/status approved-for-milestone |
[MILESTONENOTIFIER] Milestone Pull Request: Up-to-date for process Pull Request Labels
|
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mikedanese, mtaufen The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Automatic merge from submit-queue (batch tested with PRs 62486, 62471, 62183). If you want to cherry-pick this change to another branch, please follow the instructions here. |
Many Kubelet flags are now deprecated in favor of the versioned config file format. This PR adopts the versioned config file format in our cluster turn-up scripts.