Skip to content
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

Merged
merged 1 commit into from
Apr 13, 2018

Conversation

mtaufen
Copy link
Contributor

@mtaufen mtaufen commented Apr 5, 2018

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.

cluster/kube-up.sh now provisions a Kubelet config file for GCE via the metadata server. This file is installed by the corresponding GCE init scripts.

@mtaufen mtaufen added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. area/kubelet-api sig/node Categorizes an issue or PR as relevant to SIG Node. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. kind/feature Categorizes issue or PR as related to a new feature. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Apr 5, 2018
@mtaufen mtaufen added this to the v1.11 milestone Apr 5, 2018
@mtaufen mtaufen self-assigned this Apr 5, 2018
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 5, 2018
@k8s-ci-robot k8s-ci-robot requested review from bowei and vishh April 5, 2018 23:04
@mtaufen mtaufen force-pushed the gce-kc-metadata branch 14 times, most recently from 2b2b3fd to e0423a1 Compare April 9, 2018 22:32
@mtaufen mtaufen changed the title WIP provision kubelet config file instead of deprecated flags provision kubelet config file for GCE instead of deprecated flags Apr 9, 2018
Copy link
Contributor Author

@mtaufen mtaufen left a 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.

local -r dest="$1"
echo "Downloading Kubelet config file, if it exists"
# Fetch kubelet config file from GCE metadata server.
(umask 700;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

fi
)
}

function download-kube-master-certs {
# Fetch kube-env from GCE metadata server.
(umask 700;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to 077

@@ -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. ','')
Copy link
Contributor Author

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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

done
# only output if there is a non-empty map
if [ ${#map[@]} -gt 0 ]; then
cat >>$file <<EOF
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(stage 2)

done
# only output if there is a non-empty map
if [ ${#map[@]} -gt 0 ]; then
cat >>$file <<EOF
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(stage 2)

(IFS=,
for v in ${map[$k]}; do
cat >>$file <<EOF
- $(yaml-quote ${v})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(stage 2)

local file=$2

rm -f ${file}
cat >>$file <<EOF
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(stage 2)

cat >>$file <<EOF
staticPodURL: $(yaml-quote ${MANIFEST_URL})
EOF
write-yaml-map-string-stringarray ',' ':' staticPodURLHeader ${MANIFEST_URL_HEADER} $file
Copy link
Contributor Author

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)

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 10, 2018
Copy link
Contributor

@filbranden filbranden left a 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
Copy link
Contributor

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.)

if [[ ${#map[@]} -gt 0 ]]; then
echo "${name}:"
for k in "${!map[@]}"; do
echo " ${k}"
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch, thanks

declare -a values
IFS="${item_sep}" read -ra values <<<"${map[$k]}"
for v in "${values[@]}"; do
echo " - $(yaml-quote "${v}")"
Copy link
Contributor

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... 😞

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks

Copy link
Contributor Author

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
Copy link
Contributor

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...

echo "${name}:"
for k in "${!map[@]}"; do
if [[ "${quote_val_string}" == "true" ]]; then
echo " ${k}: $(yaml-quote ${map[$k]})"
Copy link
Contributor

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...

@filbranden
Copy link
Contributor

LGTM 👍

@mtaufen mtaufen force-pushed the gce-kc-metadata branch 4 times, most recently from c70ef83 to 570f6f0 Compare April 11, 2018 00:16
@@ -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)
Copy link
Member

Choose a reason for hiding this comment

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

still need this?

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've used this in a number of debugging scenarios, I figure we might as well leave it at v=5.

@mikedanese
Copy link
Member

/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 11, 2018
@@ -2406,6 +2407,12 @@ fi

source "${KUBE_HOME}/kube-env"


if [ -f "${KUBE_HOME}/kubelet-config.yaml" ]; then
Copy link
Member

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?

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.
@mtaufen mtaufen added this to the v1.11 milestone Apr 13, 2018
@mtaufen
Copy link
Contributor Author

mtaufen commented Apr 13, 2018

/status approved-for-milestone

@k8s-github-robot
Copy link

[MILESTONENOTIFIER] Milestone Pull Request: Up-to-date for process

@maisem @mikedanese @mtaufen

Pull Request Labels
  • sig/cluster-lifecycle sig/node: Pull Request will be escalated to these SIGs if needed.
  • priority/important-soon: Escalate to the pull request owners and SIG owner; move out of milestone after several unsuccessful escalation attempts.
  • kind/feature: New functionality.
Help

@mikedanese
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 13, 2018
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-github-robot
Copy link

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.

@k8s-github-robot k8s-github-robot merged commit a5f2655 into kubernetes:master Apr 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubelet-api cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants