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

GCI: Add two GCI specific metadata pairs #25105

Merged
merged 1 commit into from
May 5, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 40 additions & 7 deletions cluster/gce/trusty/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,45 @@

# The configuration is based on upstart, which is in Ubuntu up to 14.04 LTS (Trusty).
# Ubuntu 15.04 and above replaced upstart with systemd as the init system.
# Consequently, the configuration cannot work on these images.
# Consequently, the configuration cannot work on these images. In release-1.2 branch,
# GCI and Trusty share the configuration code. We have to keep the GCI specific code
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have to worry about keeping this code separate on the master branch? Is it just to make cherry picks easier?

Copy link
Author

Choose a reason for hiding this comment

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

I am preparing for a cluster/gce/gci dir which serves gci only. But such a big change will be in 1.3 only. For 1.2.X gci will still use the code in cluster/gce/trusty. Later if a PR breaking GCI is cherry picked to release-1.2, we will have to make 3 PR: one for fixing master branch cluster/gce/gci, one for fixing master branch cluster/gce/trusty, and another for cherry-pick into cluster/gce/trusty in release-1.2. If we only keep gci-specific code in master branch, it is hard to cherry-pick into release-1.2 as there is no dir cluster/gce/gci

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, so it's to make cherry picks easier. That's what I thought.

# here as long as the release-1.2 branch has not been deprecated.

# Creates the GCI specific metadata files if they do not exit.
# Assumed var
# KUBE_TEMP
function ensure-gci-metadata-files {
if [[ ! -f "${KUBE_TEMP}/gci-update.txt" ]]; then
cat >"${KUBE_TEMP}/gci-update.txt" << EOF
update_disabled
EOF
fi
if [[ ! -f "${KUBE_TEMP}/gci-docker.txt" ]]; then
cat >"${KUBE_TEMP}/gci-docker.txt" << EOF
true
EOF
fi
}

# $1: template name (required)
function create-node-instance-template {
local template_name="$1"
create-node-template "$template_name" "${scope_flags[*]}" \
"kube-env=${KUBE_TEMP}/node-kube-env.yaml" \
"user-data=${KUBE_ROOT}/cluster/gce/trusty/node.yaml" \
"configure-sh=${KUBE_ROOT}/cluster/gce/trusty/configure.sh" \
"cluster-name=${KUBE_TEMP}/cluster-name.txt"
if [[ "${OS_DISTRIBUTION}" == "gci" && "${NODE_IMAGE}" == gci* ]]; then
ensure-gci-metadata-files
create-node-template "$template_name" "${scope_flags[*]}" \
"kube-env=${KUBE_TEMP}/node-kube-env.yaml" \
"user-data=${KUBE_ROOT}/cluster/gce/trusty/node.yaml" \
"configure-sh=${KUBE_ROOT}/cluster/gce/trusty/configure.sh" \
"cluster-name=${KUBE_TEMP}/cluster-name.txt" \
"gci-update-strategy=${KUBE_TEMP}/gci-update.txt" \
"gci-ensure-gke-docker=${KUBE_TEMP}/gci-docker.txt"
else
create-node-template "$template_name" "${scope_flags[*]}" \
"kube-env=${KUBE_TEMP}/node-kube-env.yaml" \
"user-data=${KUBE_ROOT}/cluster/gce/trusty/node.yaml" \
"configure-sh=${KUBE_ROOT}/cluster/gce/trusty/configure.sh" \
"cluster-name=${KUBE_TEMP}/cluster-name.txt"
fi
}

# create-master-instance creates the master instance. If called with
Expand All @@ -47,6 +75,11 @@ function create-node-instance-template {
function create-master-instance {
local address_opt=""
[[ -n ${1:-} ]] && address_opt="--address ${1}"
local image_metadata=""
if [[ "${OS_DISTRIBUTION}" == "gci" && "${MASTER_IMAGE}" == gci* ]]; then
ensure-gci-metadata-files
image_metadata=",gci-update-strategy=${KUBE_TEMP}/gci-update.txt,gci-ensure-gke-docker=${KUBE_TEMP}/gci-docker.txt"
fi

write-master-env
gcloud compute instances create "${MASTER_NAME}" \
Expand All @@ -61,6 +94,6 @@ function create-master-instance {
--scopes "storage-ro,compute-rw,monitoring,logging-write" \
--can-ip-forward \
--metadata-from-file \
"kube-env=${KUBE_TEMP}/master-kube-env.yaml,user-data=${KUBE_ROOT}/cluster/gce/trusty/master.yaml,configure-sh=${KUBE_ROOT}/cluster/gce/trusty/configure.sh,cluster-name=${KUBE_TEMP}/cluster-name.txt" \
"kube-env=${KUBE_TEMP}/master-kube-env.yaml,user-data=${KUBE_ROOT}/cluster/gce/trusty/master.yaml,configure-sh=${KUBE_ROOT}/cluster/gce/trusty/configure.sh,cluster-name=${KUBE_TEMP}/cluster-name.txt${image_metadata}" \
--disk "name=${MASTER_NAME}-pd,device-name=master-pd,mode=rw,boot=no,auto-delete=no"
}