setconst global FOO = "bar"#!/bin/bash # Copyright 2015 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. readonly root = $[dirname $(BASH_SOURCE)] ## Contains configuration values for the CentOS cluster # The user should have sudo privilege export MASTER=$(MASTER:-"centos@172.10.0.11") export MASTER_IP=$(MASTER#*@) # Define all your master nodes, # And separated with blank space like . # The user should have sudo privilege export MASTERS="$(MASTERS:-$MASTER)" # length-of # Get the length of specific arg0, could be a space-separate string or array. proc length-of { var len = '0' for part in [$1] { let ++len } echo $len } # Number of nodes in your cluster. export NUM_MASTERS="$(NUM_MASTERS:-$(length-of "$MASTERS"))" # Get default master advertise address: first master node. proc default-advertise-address { # get the first master node var masters_array = '('${MASTERS}) var master = $(masters_array[0]) echo $(master#*@) } # Define advertise address of masters, could be a load balancer address. # If not provided, the default is ip of first master node. export MASTER_ADVERTISE_ADDRESS="$(MASTER_ADVERTISE_ADDRESS:-$(default-advertise-address))" export MASTER_ADVERTISE_IP="$(MASTER_ADVERTISE_IP:-$(getent hosts "${MASTER_ADVERTISE_ADDRESS}" | awk '{print $1; exit}'))" # Define all your minion nodes, # And separated with blank space like . # The user should have sudo privilege export NODES="$(NODES:-"centos@172.10.0.12 centos@172.10.0.13")" # Number of nodes in your cluster. export NUM_NODES="$(NUM_NODES:-$(length-of "$NODES"))" # Should be removed when NUM_NODES is deprecated in validate-cluster.sh export NUM_NODES="$(NUM_NODES)" # By default, the cluster will use the etcd installed on master. proc concat-etcd-servers { var etcd_servers = ''"" for master in [$(MASTERS)] { var master_ip = $(master#*@) var prefix = ''"" if test -n $etcd_servers { prefix := ""$(etcd_servers),"" } etcd_servers := ""$(prefix)https://$(master_ip):2379"" } echo $etcd_servers } export ETCD_SERVERS="$[concat-etcd-servers]" # By default, etcd cluster will use runtime configuration # https://coreos.com/etcd/docs/latest/v2/runtime-configuration.html # Get etc initial cluster and store in ETCD_INITIAL_CLUSTER proc concat-etcd-initial-cluster { var etcd_initial_cluster = ''"" var num_infra = '0' for master in [$(MASTERS)] { var master_ip = $(master#*@) if test -n $etcd_initial_cluster { etcd_initial_cluster := '",'" } etcd_initial_cluster := ""infra$(num_infra)=https://$(master_ip):2380"" let ++num_infra } echo $etcd_initial_cluster } export ETCD_INITIAL_CLUSTER="$[concat-etcd-initial-cluster]" global CERT_DIR := $(CERT_DIR:-${root}/ca-cert) mkdir -p $(CERT_DIR) # CERT_DIR path must be absolute. export CERT_DIR="$[cd $(CERT_DIR); pwd]" # define the IP range used for service cluster IPs. # according to rfc 1918 ref: https://tools.ietf.org/html/rfc1918 choose a private ip range here. export SERVICE_CLUSTER_IP_RANGE=$(SERVICE_CLUSTER_IP_RANGE:-"192.168.3.0/24") # Optional: Install cluster DNS. global ENABLE_CLUSTER_DNS := $(KUBE_ENABLE_CLUSTER_DNS:-true) # DNS_SERVER_IP must be a IP in SERVICE_CLUSTER_IP_RANGE global DNS_SERVER_IP := $(DNS_SERVER_IP:-"192.168.3.100") global DNS_DOMAIN := $(DNS_DOMAIN:-"cluster.local") # Optional: Install Kubernetes UI global ENABLE_CLUSTER_UI := $(KUBE_ENABLE_CLUSTER_UI:-true) # define the IP range used for flannel overlay network, should not conflict with above SERVICE_CLUSTER_IP_RANGE export FLANNEL_NET=$(FLANNEL_NET:-"172.16.0.0/16") # Admission Controllers to invoke prior to persisting objects in cluster # If we included ResourceQuota, we should keep it at the end of the list to prevent incrementing quota usage prematurely. export ADMISSION_CONTROL=$(ADMISSION_CONTROL:-"Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultTolerationSeconds,Priority,ResourceQuota") # Extra options to set on the Docker command line. # This is useful for setting --insecure-registry for local registries. export DOCKER_OPTS=$(DOCKER_OPTS:-"") # Timeouts for process checking on master and minion export PROCESS_CHECK_TIMEOUT=$(PROCESS_CHECK_TIMEOUT:-180) # seconds. unset -f default-advertise-address concat-etcd-servers length-of concat-etcd-initial-cluster (CommandList children: [ (Assignment keyword: Assign_Readonly pairs: [ (assign_pair lhs: (LhsName name:root) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(dirname)} {(DQ (${ VSub_Name BASH_SOURCE))})] ) left_token: spids: [47 55] ) } spids: [46] ) ] spids: [44] ) (C {(export)} {(Lit_VarLike "MASTER=") (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(DQ ("centos@172.10.0.11"))}) spids: [67 73] ) } ) (C {(export)} {(Lit_VarLike "MASTER_IP=") (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_Pound arg_word:{("*@")}) spids: [78 82] ) } ) (C {(export)} {(Lit_VarLike "MASTERS=") (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{($ VSub_Name "$MASTER")}) spids: [98 102] ) ) } ) (FuncDef name: length-of body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:len) op:Equal rhs:{(0)} spids:[123])] spids: [121] ) (ForEach iter_name: part iter_words: [{($ VSub_Number "$1")}] do_arg_iter: False body: (DoGroup children: [(C {(let)} {(Lit_Other "+") (Lit_Other "+") (len)})] spids: [136 146] ) spids: [132 134] ) (C {(echo)} {($ VSub_Name "$len")}) ] spids: [118] ) spids: [112 117] ) (C {(export)} {(Lit_VarLike "NUM_MASTERS=") (DQ (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: { (CommandSubPart command_list: (CommandList children: [(C {(length-of)} {(DQ ($ VSub_Name "$MASTERS"))})] ) left_token: spids: [165 171] ) } ) spids: [162 172] ) ) } ) (FuncDef name: default-advertise-address body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:masters_array) op: Equal rhs: {(ArrayLiteralPart words:[{(${ VSub_Name MASTERS)}])} spids: [194] ) ] spids: [192] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:master) op: Equal rhs: { (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{(Lit_Digits 0)})) spids: [205 210] ) } spids: [204] ) ] spids: [202] ) (C {(echo)} { (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_Pound arg_word:{("*@")}) spids: [215 219] ) } ) ] spids: [185] ) spids: [179 184] ) (C {(export)} {(Lit_VarLike "MASTER_ADVERTISE_ADDRESS=") (DQ (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: { (CommandSubPart command_list: (CommandList children:[(C {(default-advertise-address)})]) left_token: spids: [237 239] ) } ) spids: [234 240] ) ) } ) (C {(export)} {(Lit_VarLike "MASTER_ADVERTISE_IP=") (DQ (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(getent)} {(hosts)} {(DQ (${ VSub_Name MASTER_ADVERTISE_ADDRESS))}) (C {(awk)} {(SQ <"{print $1; exit}">)}) ] negated: False ) ] ) left_token: spids: [250 268] ) } ) spids: [247 269] ) ) } ) (C {(export)} {(Lit_VarLike "NODES=") (DQ (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: {(DQ ("centos@172.10.0.12 centos@172.10.0.13"))} ) spids: [286 292] ) ) } ) (C {(export)} {(Lit_VarLike "NUM_NODES=") (DQ (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: { (CommandSubPart command_list: (CommandList children: [(C {(length-of)} {(DQ ($ VSub_Name "$NODES"))})] ) left_token: spids: [306 312] ) } ) spids: [303 313] ) ) } ) (C {(export)} {(Lit_VarLike "NUM_NODES=") (DQ (${ VSub_Name NUM_NODES))}) (FuncDef name: concat-etcd-servers body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:etcd_servers) op:Equal rhs:{(DQ )} spids:[344])] spids: [342] ) (ForEach iter_name: master iter_words: [{(${ VSub_Name MASTERS)}] do_arg_iter: False body: (DoGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:master_ip) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_Pound arg_word:{("*@")}) spids: [366 370] ) } spids: [365] ) ] spids: [363] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:prefix) op: Equal rhs: {(DQ )} spids: [375] ) ] spids: [373] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-n)} {(DQ ($ VSub_Name "$etcd_servers"))} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:prefix) op: Equal rhs: {(DQ (${ VSub_Name etcd_servers) (","))} spids: [396] ) ] spids: [396] ) ] spids: [-1 393] ) ] spids: [-1 405] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:etcd_servers) op: Equal rhs: { (DQ (${ VSub_Name prefix) ("https://") (${ VSub_Name master_ip) (":2379")) } spids: [408] ) ] spids: [408] ) ] spids: [360 421] ) spids: [354 358] ) (C {(echo)} {(DQ ($ VSub_Name "$etcd_servers"))}) ] spids: [339] ) spids: [333 338] ) (C {(export)} {(Lit_VarLike "ETCD_SERVERS=") (DQ (CommandSubPart command_list: (CommandList children:[(C {(concat-etcd-servers)})]) left_token: spids: [437 439] ) ) } ) (FuncDef name: concat-etcd-initial-cluster body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:etcd_initial_cluster) op: Equal rhs: {(DQ )} spids: [463] ) ] spids: [461] ) (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:num_infra) op:Equal rhs:{(0)} spids:[470])] spids: [468] ) (ForEach iter_name: master iter_words: [{(${ VSub_Name MASTERS)}] do_arg_iter: False body: (DoGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:master_ip) op: Equal rhs: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_Pound arg_word:{("*@")}) spids: [492 496] ) ) } spids: [490] ) ] spids: [488] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-n)} {(DQ ($ VSub_Name "$etcd_initial_cluster"))} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:etcd_initial_cluster) op: PlusEqual rhs: {(DQ (","))} spids: [516] ) ] spids: [516] ) ] spids: [-1 513] ) ] spids: [-1 522] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:etcd_initial_cluster) op: PlusEqual rhs: { (DQ (infra) (${ VSub_Name num_infra) ("=https://") (${ VSub_Name master_ip) (":2380") ) } spids: [525] ) ] spids: [525] ) (C {(let)} {(Lit_Other "+") (Lit_Other "+") (num_infra)}) ] spids: [485 546] ) spids: [479 483] ) (C {(echo)} {(DQ ($ VSub_Name "$etcd_initial_cluster"))}) ] spids: [458] ) spids: [452 457] ) (C {(export)} {(Lit_VarLike "ETCD_INITIAL_CLUSTER=") (DQ (CommandSubPart command_list: (CommandList children:[(C {(concat-etcd-initial-cluster)})]) left_token: spids: [562 564] ) ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CERT_DIR) op: Equal rhs: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: {(${ VSub_Name root) (Lit_Slash /) (ca-cert)} ) spids: [570 578] ) ) } spids: [568] ) ] spids: [568] ) (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name CERT_DIR))}) (C {(export)} {(Lit_VarLike "CERT_DIR=") (DQ (CommandSubPart command_list: (CommandList children: [ (Sentence child: (C {(cd)} {(DQ (${ VSub_Name CERT_DIR))}) terminator: ) (C {(pwd)}) ] ) left_token: spids: [598 609] ) ) } ) (C {(export)} {(Lit_VarLike "SERVICE_CLUSTER_IP_RANGE=") (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(DQ (192.168.3.0/24))}) spids: [622 628] ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ENABLE_CLUSTER_DNS) op: Equal rhs: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(true)}) spids: [636 640] ) ) } spids: [634] ) ] spids: [634] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DNS_SERVER_IP) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(DQ (192.168.3.100))}) spids: [647 653] ) } spids: [646] ) ] spids: [646] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DNS_DOMAIN) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(DQ (cluster.local))}) spids: [656 662] ) } spids: [655] ) ] spids: [655] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ENABLE_CLUSTER_UI) op: Equal rhs: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(true)}) spids: [670 674] ) ) } spids: [668] ) ] spids: [668] ) (C {(export)} {(Lit_VarLike "FLANNEL_NET=") (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(DQ (172.16.0.0/16))}) spids: [684 690] ) } ) (C {(export)} {(Lit_VarLike "ADMISSION_CONTROL=") (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: { (DQ ( "Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultTolerationSeconds,Priority,ResourceQuota" ) ) } ) spids: [702 708] ) } ) (C {(export)} {(Lit_VarLike "DOCKER_OPTS=") (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(DQ )}) spids: [720 725] ) } ) (C {(export)} {(Lit_VarLike "PROCESS_CHECK_TIMEOUT=") (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(180)}) spids: [735 739] ) } ) (C {(unset)} {(-f)} {(default-advertise-address)} {(concat-etcd-servers)} {(length-of)} {(concat-etcd-initial-cluster)} ) ] )