#!/bin/bash # Copyright 2016 The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. set -o errexit set -o nounset set -o pipefail proc download-kube-env { # Fetch kube-env from GCE metadata server. var -r tmp_kube_env = '"/tmp/kube-env.yaml'" curl --fail --retry 5 --retry-delay 3 --silent --show-error \ -H "X-Google-Metadata-Request: True" \ -o $(tmp_kube_env) \ http://metadata.google.internal/computeMetadata/v1/instance/attributes/kube-env # Convert the yaml format file into a shell-style file. sed 's/: /=/' < $(tmp_kube_env) > "$(KUBE_HOME)/kube-env" rm -f $(tmp_kube_env) } proc validate-hash { var -r file = $1 var -r expected = $2 global actual := $[sha1sum $(file) | awk '{ print $1 }] || true if [[ "${actual}" != "${expected}" ]] { echo "== $(file) corrupted, sha1 $(actual) doesn't match expected $(expected) ==" return 1 } } # Retry a download until we get it. Takes a hash and a set of URLs. # # $1 is the sha1 of the URL. Can be "" if the sha1 is unknown. # $2+ are the URLs to download. proc download-or-bust { var -r hash = $1 shift 1 var -r urls = '( '$* ) while true { for url in [$(urls[@])] { var file = $(url##*/) rm -f $(file) if ! curl -f --ipv4 -Lo $(file) --connect-timeout 20 --max-time 300 --retry 6 --retry-delay 10 $(url) { echo "== Failed to download $(url). Retrying. ==" } elif [[ -n "${hash}" ]] && ! validate-hash $(file) $(hash) { echo "== Hash validation of $(url) failed. Retrying. ==" } else { if [[ -n "${hash}" ]] { echo "== Downloaded $(url) (SHA1 = $(hash)) ==" } else { echo "== Downloaded $(url) ==" } return } } } } proc split-commas { echo $1 | tr "," "\n" } # Downloads kubernetes binaries and kube-system manifest tarball, unpacks them, # and places them into suitable directories. Files are placed in /opt/kubernetes. proc install-kube-binary-config { cd $(KUBE_HOME) var -r server_binary_tar_urls = '( '$(split-commas "${SERVER_BINARY_TAR_URL}") ) var -r server_binary_tar = $(server_binary_tar_urls[0]##*/) if [[ -n "${SERVER_BINARY_TAR_HASH:-}" ]] { var -r server_binary_tar_hash = $(SERVER_BINARY_TAR_HASH) } else { echo "Downloading binary release sha1 (not found in env)" download-or-bust "" $(server_binary_tar_urls[@]/.tar.gz/.tar.gz.sha1) var -r server_binary_tar_hash = $[cat "$(server_binary_tar).sha1] } echo "Downloading binary release tar" download-or-bust $(server_binary_tar_hash) $(server_binary_tar_urls[@]) tar xzf "$(KUBE_HOME)/$(server_binary_tar)" -C $(KUBE_HOME) --overwrite # Copy docker_tag and image files to ${KUBE_HOME}/kube-docker-files. global src_dir := ""$(KUBE_HOME)/kubernetes/server/bin"" global dst_dir := ""$(KUBE_HOME)/kube-docker-files"" mkdir -p $(dst_dir) cp "$(src_dir)/"*.docker_tag $(dst_dir) if [[ "${KUBERNETES_MASTER:-}" == "false" ]] { cp "$(src_dir)/kube-proxy.tar" $(dst_dir) } else { cp "$(src_dir)/kube-apiserver.tar" $(dst_dir) cp "$(src_dir)/kube-controller-manager.tar" $(dst_dir) cp "$(src_dir)/kube-scheduler.tar" $(dst_dir) cp -r "$(KUBE_HOME)/kubernetes/addons" $(dst_dir) } var -r kube_bin = ""$(KUBE_HOME)/bin"" mv "$(src_dir)/kubelet" $(kube_bin) mv "$(src_dir)/kubectl" $(kube_bin) if [[ "${NETWORK_PROVIDER:-}" == "kubenet" ]] || \ [[ "${NETWORK_PROVIDER:-}" == "cni" ]] { #TODO(andyzheng0831): We should make the cni version number as a k8s env variable. var -r cni_tar = '"cni-0799f5732f2a11b329d9e3d51b9c8f2e3759f2ff.tar.gz'" var -r cni_sha1 = '"1d9788b0f5420e1a219aad2cb8681823fc515e7c'" download-or-bust $(cni_sha1) "https://storage.googleapis.com/kubernetes-release/network-plugins/$(cni_tar)" var -r cni_dir = ""$(KUBE_HOME)/cni"" mkdir -p $(cni_dir) tar xzf "$(KUBE_HOME)/$(cni_tar)" -C $(cni_dir) --overwrite mv "$(cni_dir)/bin"/* $(kube_bin) rmdir "$(cni_dir)/bin" rm -f "$(KUBE_HOME)/$(cni_tar)" } mv "$(KUBE_HOME)/kubernetes/LICENSES" $(KUBE_HOME) mv "$(KUBE_HOME)/kubernetes/kubernetes-src.tar.gz" $(KUBE_HOME) # Put kube-system pods manifests in ${KUBE_HOME}/kube-manifests/. global dst_dir := ""$(KUBE_HOME)/kube-manifests"" mkdir -p $(dst_dir) var -r manifests_tar_urls = '( '$(split-commas "${KUBE_MANIFESTS_TAR_URL}") ) var -r manifests_tar = $(manifests_tar_urls[0]##*/) if test -n $(KUBE_MANIFESTS_TAR_HASH:-) { var -r manifests_tar_hash = $(KUBE_MANIFESTS_TAR_HASH) } else { echo "Downloading k8s manifests sha1 (not found in env)" download-or-bust "" $(manifests_tar_urls[@]/.tar.gz/.tar.gz.sha1) var -r manifests_tar_hash = $[cat "$(manifests_tar).sha1] } echo "Downloading k8s manifests tar" download-or-bust $(manifests_tar_hash) $(manifests_tar_urls[@]) tar xzf "$(KUBE_HOME)/$(manifests_tar)" -C $(dst_dir) --overwrite var -r kube_addon_registry = $(KUBE_ADDON_REGISTRY:-gcr.io/google_containers) if [[ "${kube_addon_registry}" != "gcr.io/google_containers" ]] { find $(dst_dir) -name '*'.yaml -or -name '*'.yaml.in | \ xargs sed -ri "s@(image:\s.*)gcr.io/google_containers@\1$(kube_addon_registry)@" find $(dst_dir) -name '*'.manifest -or -name '*'.json | \ xargs sed -ri "s@(image\":\s+\")gcr.io/google_containers@\1$(kube_addon_registry)@" } cp "$(dst_dir)/kubernetes/gci-trusty/container-linux-configure-helper.sh" "$(KUBE_HOME)/bin/configure-helper.sh" chmod -R 755 $(kube_bin) # Clean up. rm -rf "$(KUBE_HOME)/kubernetes" rm -f "$(KUBE_HOME)/$(server_binary_tar)" rm -f "$(KUBE_HOME)/$(server_binary_tar).sha1" rm -f "$(KUBE_HOME)/$(manifests_tar)" rm -f "$(KUBE_HOME)/$(manifests_tar).sha1" } ######### Main Function ########## echo "Start to install kubernetes files" global KUBE_HOME := '"/opt/kubernetes'" mkdir -p $(KUBE_HOME) download-kube-env source "$(KUBE_HOME)/kube-env" install-kube-binary-config echo "Done for installing kubernetes files" # On Container Linux, the hosts is in /usr/share/baselayout/hosts # So we need to manually populdate the hosts file here on gce. echo "127.0.0.1 localhost" >> /etc/hosts echo "::1 localhost" >> /etc/hosts echo "Configuring hostname" hostnamectl set-hostname $[hostname | cut -f1 -d.] (CommandList children: [ (C {(set)} {(-o)} {(errexit)}) (C {(set)} {(-o)} {(nounset)}) (C {(set)} {(-o)} {(pipefail)}) (FuncDef name: download-kube-env body: (BraceGroup children: [ (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:tmp_kube_env) op: Equal rhs: {(DQ (/tmp/kube-env.yaml))} spids: [78] ) ] spids: [74] ) (C {(curl)} {(--fail)} {(--retry)} {(5)} {(--retry-delay)} {(3)} {(--silent)} {(--show-error)} {(-H)} {(DQ ("X-Google-Metadata-Request: True"))} {(-o)} {(DQ (${ VSub_Name tmp_kube_env))} {(http) (Lit_Other ":") (//metadata.google.internal/computeMetadata/v1/instance/attributes/kube-env) } ) (SimpleCommand words: [{(sed)} {(SQ <"s/: /=/">)}] redirects: [ (Redir op_id: Redir_Less fd: -1 arg_word: {(DQ (${ VSub_Name tmp_kube_env))} spids: [135] ) (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ (${ VSub_Name KUBE_HOME) (/kube-env))} spids: [143] ) ] ) (C {(rm)} {(-f)} {(DQ (${ VSub_Name tmp_kube_env))}) ] spids: [67] ) spids: [63 66] ) (FuncDef name: validate-hash body: (BraceGroup children: [ (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:file) op: Equal rhs: {(DQ ($ VSub_Number "$1"))} spids: [177] ) ] spids: [173] ) (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:expected) op: Equal rhs: {(DQ ($ VSub_Number "$2"))} spids: [187] ) ] spids: [183] ) (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:actual) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(sha1sum)} {(${ VSub_Name file)}) (C {(awk)} {(SQ <"{ print $1 }">)}) ] negated: False ) ] ) left_token: spids: [195 209] ) } spids: [194] ) ] spids: [194] ) (C {(true)}) ] op_id: Op_DPipe ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {(DQ (${ VSub_Name actual))} right: {(DQ (${ VSub_Name expected))} ) ) terminator: ) ] action: [ (C {(echo)} { (DQ ("== ") (${ VSub_Name file) (" corrupted, sha1 ") (${ VSub_Name actual) (" doesn't match expected ") (${ VSub_Name expected) (" ==") ) } ) (ControlFlow token: arg_word:{(1)}) ] spids: [-1 237] ) ] spids: [-1 264] ) ] spids: [170] ) spids: [166 169] ) (FuncDef name: download-or-bust body: (BraceGroup children: [ (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:hash) op: Equal rhs: {(DQ ($ VSub_Number "$1"))} spids: [293] ) ] spids: [289] ) (C {(shift)} {(1)}) (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:urls) op: Equal rhs: {(ArrayLiteralPart words:[{($ VSub_Star "$*")}])} spids: [309] ) ] spids: [305] ) (While cond: [(Sentence child:(C {(true)}) terminator:)] body: (DoGroup children: [ (ForEach iter_name: url iter_words: [ { (DQ (BracedVarSub token: bracket_op: (WholeArray op_id:Lit_At) spids: [332 337] ) ) } ] do_arg_iter: False body: (DoGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:file) op: Equal rhs: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id: VOp1_DPound arg_word: {("*") (Lit_Slash /)} ) spids: [348 353] ) ) } spids: [346] ) ] spids: [344] ) (C {(rm)} {(-f)} {(DQ (${ VSub_Name file))}) (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (C {(curl)} {(-f)} {(--ipv4)} {(-Lo)} {(DQ (${ VSub_Name file))} {(--connect-timeout)} {(20)} {(--max-time)} {(300)} {(--retry)} {(6)} {(--retry-delay)} {(10)} {(DQ (${ VSub_Name url))} ) ] negated: True ) terminator: ) ] action: [ (C {(echo)} { (DQ ("== Failed to download ") (${ VSub_Name url) (". Retrying. ==") ) } ) ] spids: [-1 409] ) (if_arm cond: [ (Sentence child: (AndOr children: [ (DBracket expr: (BoolUnary op_id: BoolUnary_n child: {(DQ (${ VSub_Name hash))} ) ) (Pipeline children: [ (C {(validate-hash)} {(DQ (${ VSub_Name file))} {(DQ (${ VSub_Name hash))} ) ] negated: True ) ] op_id: Op_DAmp ) terminator: ) ] action: [ (C {(echo)} { (DQ ("== Hash validation of ") (${ VSub_Name url) (" failed. Retrying. ==") ) } ) ] spids: [423 456] ) ] else_action: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolUnary op_id: BoolUnary_n child: {(DQ (${ VSub_Name hash))} ) ) terminator: ) ] action: [ (C {(echo)} { (DQ ("== Downloaded ") (${ VSub_Name url) (" (SHA1 = ") (${ VSub_Name hash) (") ==") ) } ) ] spids: [-1 488] ) ] else_action: [ (C {(echo)} {(DQ ("== Downloaded ") (${ VSub_Name url) (" =="))}) ] spids: [506 520] ) (ControlFlow token: ) ] spids: [470 526] ) ] spids: [341 529] ) spids: [330 339] ) ] spids: [322 532] ) ) ] spids: [286] ) spids: [282 285] ) (FuncDef name: split-commas body: (BraceGroup children: [ (Pipeline children: [ (C {(echo)} {($ VSub_Number "$1")}) (C {(tr)} {(DQ (","))} {(DQ (EscapedLiteralPart token:))}) ] negated: False ) ] spids: [541] ) spids: [537 540] ) (FuncDef name: install-kube-binary-config body: (BraceGroup children: [ (C {(cd)} {(DQ (${ VSub_Name KUBE_HOME))}) (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:server_binary_tar_urls) op: Equal rhs: { (ArrayLiteralPart words: [ { (CommandSubPart command_list: (CommandList children: [ (C {(split-commas)} {(DQ (${ VSub_Name SERVER_BINARY_TAR_URL))}) ] ) left_token: spids: [592 600] ) } ] ) } spids: [589] ) ] spids: [585] ) (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:server_binary_tar) op: Equal rhs: { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{(Lit_Digits 0)})) suffix_op: (StringUnary op_id:VOp1_DPound arg_word:{("*") (Lit_Slash /)}) spids: [611 619] ) ) } spids: [609] ) ] spids: [605] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolUnary op_id: BoolUnary_n child: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [630 633] ) ) } ) ) terminator: ) ] action: [ (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:server_binary_tar_hash) op: Equal rhs: {(DQ (${ VSub_Name SERVER_BINARY_TAR_HASH))} spids: [646] ) ] spids: [642] ) ] spids: [-1 639] ) ] else_action: [ (C {(echo)} {(DQ ("Downloading binary release sha1 (not found in env)"))}) (C {(download-or-bust)} {(DQ )} { (DQ (BracedVarSub token: bracket_op: (WholeArray op_id:Lit_At) suffix_op: (PatSub pat: {(.tar.gz)} replace: {(.tar.gz.sha1)} do_all: False do_prefix: False do_suffix: False ) spids: [670 679] ) ) } ) (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:server_binary_tar_hash) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(cat)} {(DQ (${ VSub_Name server_binary_tar) (.sha1))})] ) left_token: spids: [688 697] ) } spids: [687] ) ] spids: [683] ) ] spids: [654 700] ) (C {(echo)} {(DQ ("Downloading binary release tar"))}) (C {(download-or-bust)} {(DQ (${ VSub_Name server_binary_tar_hash))} { (DQ (BracedVarSub token: bracket_op: (WholeArray op_id:Lit_At) spids: [719 724] ) ) } ) (C {(tar)} {(xzf)} {(DQ (${ VSub_Name KUBE_HOME) (/) (${ VSub_Name server_binary_tar))} {(-C)} {(DQ (${ VSub_Name KUBE_HOME))} {(--overwrite)} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:src_dir) op: Equal rhs: {(DQ (${ VSub_Name KUBE_HOME) (/kubernetes/server/bin))} spids: [757] ) ] spids: [757] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:dst_dir) op: Equal rhs: {(DQ (${ VSub_Name KUBE_HOME) (/kube-docker-files))} spids: [766] ) ] spids: [766] ) (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name dst_dir))}) (C {(cp)} {(DQ (${ VSub_Name src_dir) (/)) (Lit_Other "*") (.docker_tag)} {(DQ (${ VSub_Name dst_dir))} ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [809 812] ) ) } right: {(DQ (false))} ) ) terminator: ) ] action: [ (C {(cp)} {(DQ (${ VSub_Name src_dir) (/kube-proxy.tar))} {(DQ (${ VSub_Name dst_dir))} ) ] spids: [-1 824] ) ] else_action: [ (C {(cp)} {(DQ (${ VSub_Name src_dir) (/kube-apiserver.tar))} {(DQ (${ VSub_Name dst_dir))} ) (C {(cp)} {(DQ (${ VSub_Name src_dir) (/kube-controller-manager.tar))} {(DQ (${ VSub_Name dst_dir))} ) (C {(cp)} {(DQ (${ VSub_Name src_dir) (/kube-scheduler.tar))} {(DQ (${ VSub_Name dst_dir))} ) (C {(cp)} {(-r)} {(DQ (${ VSub_Name KUBE_HOME) (/kubernetes/addons))} {(DQ (${ VSub_Name dst_dir))} ) ] spids: [843 912] ) (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:kube_bin) op: Equal rhs: {(DQ (${ VSub_Name KUBE_HOME) (/bin))} spids: [919] ) ] spids: [915] ) (C {(mv)} {(DQ (${ VSub_Name src_dir) (/kubelet))} {(DQ (${ VSub_Name kube_bin))}) (C {(mv)} {(DQ (${ VSub_Name src_dir) (/kubectl))} {(DQ (${ VSub_Name kube_bin))}) (If arms: [ (if_arm cond: [ (Sentence child: (AndOr children: [ (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [966 969] ) ) } right: {(DQ (kubenet))} ) ) (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [987 990] ) ) } right: {(DQ (cni))} ) ) ] op_id: Op_DPipe ) terminator: ) ] action: [ (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:cni_tar) op: Equal rhs: {(DQ (cni-0799f5732f2a11b329d9e3d51b9c8f2e3759f2ff.tar.gz))} spids: [1013] ) ] spids: [1009] ) (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:cni_sha1) op: Equal rhs: {(DQ (1d9788b0f5420e1a219aad2cb8681823fc515e7c))} spids: [1023] ) ] spids: [1019] ) (C {(download-or-bust)} {(DQ (${ VSub_Name cni_sha1))} { (DQ ("https://storage.googleapis.com/kubernetes-release/network-plugins/") (${ VSub_Name cni_tar) ) } ) (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:cni_dir) op: Equal rhs: {(DQ (${ VSub_Name KUBE_HOME) (/cni))} spids: [1049] ) ] spids: [1045] ) (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name cni_dir))}) (C {(tar)} {(xzf)} {(DQ (${ VSub_Name KUBE_HOME) (/) (${ VSub_Name cni_tar))} {(-C)} {(DQ (${ VSub_Name cni_dir))} {(--overwrite)} ) (C {(mv)} {(DQ (${ VSub_Name cni_dir) (/bin)) (/) (Lit_Other "*")} {(DQ (${ VSub_Name kube_bin))} ) (C {(rmdir)} {(DQ (${ VSub_Name cni_dir) (/bin))}) (C {(rm)} {(-f)} {(DQ (${ VSub_Name KUBE_HOME) (/) (${ VSub_Name cni_tar))}) ] spids: [-1 1002] ) ] spids: [-1 1137] ) (C {(mv)} {(DQ (${ VSub_Name KUBE_HOME) (/kubernetes/LICENSES))} {(DQ (${ VSub_Name KUBE_HOME))} ) (C {(mv)} {(DQ (${ VSub_Name KUBE_HOME) (/kubernetes/kubernetes-src.tar.gz))} {(DQ (${ VSub_Name KUBE_HOME))} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:dst_dir) op: Equal rhs: {(DQ (${ VSub_Name KUBE_HOME) (/kube-manifests))} spids: [1178] ) ] spids: [1178] ) (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name dst_dir))}) (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:manifests_tar_urls) op: Equal rhs: { (ArrayLiteralPart words: [ { (CommandSubPart command_list: (CommandList children: [ (C {(split-commas)} {(DQ (${ VSub_Name KUBE_MANIFESTS_TAR_URL))}) ] ) left_token: spids: [1205 1213] ) } ] ) } spids: [1202] ) ] spids: [1198] ) (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:manifests_tar) op: Equal rhs: { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{(Lit_Digits 0)})) suffix_op: (StringUnary op_id:VOp1_DPound arg_word:{("*") (Lit_Slash /)}) spids: [1224 1232] ) ) } spids: [1222] ) ] spids: [1218] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-n)} { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [1243 1246] ) ) } {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:manifests_tar_hash) op: Equal rhs: {(DQ (${ VSub_Name KUBE_MANIFESTS_TAR_HASH))} spids: [1259] ) ] spids: [1255] ) ] spids: [-1 1252] ) ] else_action: [ (C {(echo)} {(DQ ("Downloading k8s manifests sha1 (not found in env)"))}) (C {(download-or-bust)} {(DQ )} { (DQ (BracedVarSub token: bracket_op: (WholeArray op_id:Lit_At) suffix_op: (PatSub pat: {(.tar.gz)} replace: {(.tar.gz.sha1)} do_all: False do_prefix: False do_suffix: False ) spids: [1283 1292] ) ) } ) (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:manifests_tar_hash) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(cat)} {(DQ (${ VSub_Name manifests_tar) (.sha1))})] ) left_token: spids: [1301 1310] ) } spids: [1300] ) ] spids: [1296] ) ] spids: [1267 1313] ) (C {(echo)} {(DQ ("Downloading k8s manifests tar"))}) (C {(download-or-bust)} {(DQ (${ VSub_Name manifests_tar_hash))} { (DQ (BracedVarSub token: bracket_op: (WholeArray op_id:Lit_At) spids: [1332 1337] ) ) } ) (C {(tar)} {(xzf)} {(DQ (${ VSub_Name KUBE_HOME) (/) (${ VSub_Name manifests_tar))} {(-C)} {(DQ (${ VSub_Name dst_dir))} {(--overwrite)} ) (Assignment keyword: Assign_Local flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:kube_addon_registry) op: Equal rhs: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: {(gcr.io) (Lit_Slash /) (google_containers)} ) spids: [1372 1378] ) ) } spids: [1370] ) ] spids: [1366] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {(DQ (${ VSub_Name kube_addon_registry))} right: {(DQ (gcr.io/google_containers))} ) ) terminator: ) ] action: [ (Pipeline children: [ (C {(find)} {(DQ (${ VSub_Name dst_dir))} {(-name)} {(EscapedLiteralPart token:) (.yaml)} {(-or)} {(-name)} {(EscapedLiteralPart token:) (.yaml.in)} ) (C {(xargs)} {(sed)} {(-ri)} { (DQ ("s@(image:") (EscapedLiteralPart token:) (".*)gcr.io/google_containers@") (EscapedLiteralPart token:) (${ VSub_Name kube_addon_registry) ("@") ) } ) ] negated: False ) (Pipeline children: [ (C {(find)} {(DQ (${ VSub_Name dst_dir))} {(-name)} {(EscapedLiteralPart token:) (.manifest)} {(-or)} {(-name)} {(EscapedLiteralPart token:) (.json)} ) (C {(xargs)} {(sed)} {(-ri)} { (DQ ("s@(image") (EscapedLiteralPart token:) (":") (EscapedLiteralPart token: ) ("+") (EscapedLiteralPart token:) (")gcr.io/google_containers@") (EscapedLiteralPart token: ) (${ VSub_Name kube_addon_registry) ("@") ) } ) ] negated: False ) ] spids: [-1 1401] ) ] spids: [-1 1492] ) (C {(cp)} { (DQ (${ VSub_Name dst_dir) (/kubernetes/gci-trusty/container-linux-configure-helper.sh) ) } {(DQ (${ VSub_Name KUBE_HOME) (/bin/configure-helper.sh))} ) (C {(chmod)} {(-R)} {(755)} {(DQ (${ VSub_Name kube_bin))}) (C {(rm)} {(-rf)} {(DQ (${ VSub_Name KUBE_HOME) (/kubernetes))}) (C {(rm)} {(-f)} {(DQ (${ VSub_Name KUBE_HOME) (/) (${ VSub_Name server_binary_tar))}) (C {(rm)} {(-f)} {(DQ (${ VSub_Name KUBE_HOME) (/) (${ VSub_Name server_binary_tar) (.sha1))}) (C {(rm)} {(-f)} {(DQ (${ VSub_Name KUBE_HOME) (/) (${ VSub_Name manifests_tar))}) (C {(rm)} {(-f)} {(DQ (${ VSub_Name KUBE_HOME) (/) (${ VSub_Name manifests_tar) (.sha1))}) ] spids: [573] ) spids: [569 572] ) (C {(echo)} {(DQ ("Start to install kubernetes files"))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KUBE_HOME) op: Equal rhs: {(DQ (/opt/kubernetes))} spids: [1615] ) ] spids: [1615] ) (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name KUBE_HOME))}) (C {(download-kube-env)}) (C {(source)} {(DQ (${ VSub_Name KUBE_HOME) (/kube-env))}) (C {(install-kube-binary-config)}) (C {(echo)} {(DQ ("Done for installing kubernetes files"))}) (SimpleCommand words: [{(echo)} {(DQ ("127.0.0.1 localhost"))}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{(/etc/hosts)} spids:[1662])] ) (SimpleCommand words: [{(echo)} {(DQ ("::1 localhost"))}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{(/etc/hosts)} spids:[1672])] ) (C {(echo)} {(DQ ("Configuring hostname"))}) (C {(hostnamectl)} {(set-hostname)} { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [(C {(hostname)}) (C {(cut)} {(-f1)} {(-d.)})] negated: False ) ] ) left_token: spids: [1687 1697] ) } ) ] )