Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
5fa11322
Commit
5fa11322
authored
Apr 28, 2015
by
Dawn Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factory out debian e.g. ContainerVM image specific support to its own
helper utility library.
parent
8963347b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
82 deletions
+107
-82
configure-vm.sh
cluster/gce/configure-vm.sh
+1
-1
helper.sh
cluster/gce/debian/helper.sh
+100
-0
util.sh
cluster/gce/util.sh
+6
-81
No files found.
cluster/gce/configure-vm.sh
View file @
5fa11322
#!/bin/bash
#!/bin/bash
set
-x
# Copyright 2015 Google Inc. All rights reserved.
# Copyright 2015 Google Inc. All rights reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
cluster/gce/debian/helper.sh
0 → 100644
View file @
5fa11322
#!/bin/bash
# Copyright 2015 Google Inc. All rights reserved.
#
# 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.
# A library of helper functions and constant for debian os distro
# $1: if 'true', we're building a master yaml, else a node
function
build-kube-env
{
local
master
=
$1
local
file
=
$2
rm
-f
${
file
}
cat
>
$file
<<
EOF
ENV_TIMESTAMP:
$(
yaml-quote
$(
date
-u
+%Y-%m-%dT%T%z
))
INSTANCE_PREFIX:
$(
yaml-quote
${
INSTANCE_PREFIX
})
NODE_INSTANCE_PREFIX:
$(
yaml-quote
${
NODE_INSTANCE_PREFIX
})
SERVER_BINARY_TAR_URL:
$(
yaml-quote
${
SERVER_BINARY_TAR_URL
})
SALT_TAR_URL:
$(
yaml-quote
${
SALT_TAR_URL
})
PORTAL_NET:
$(
yaml-quote
${
PORTAL_NET
})
ENABLE_CLUSTER_MONITORING:
$(
yaml-quote
${
ENABLE_CLUSTER_MONITORING
:-
false
})
ENABLE_NODE_MONITORING:
$(
yaml-quote
${
ENABLE_NODE_MONITORING
:-
false
})
ENABLE_CLUSTER_LOGGING:
$(
yaml-quote
${
ENABLE_CLUSTER_LOGGING
:-
false
})
ENABLE_NODE_LOGGING:
$(
yaml-quote
${
ENABLE_NODE_LOGGING
:-
false
})
LOGGING_DESTINATION:
$(
yaml-quote
${
LOGGING_DESTINATION
:-})
ELASTICSEARCH_LOGGING_REPLICAS:
$(
yaml-quote
${
ELASTICSEARCH_LOGGING_REPLICAS
:-})
ENABLE_CLUSTER_DNS:
$(
yaml-quote
${
ENABLE_CLUSTER_DNS
:-
false
})
DNS_REPLICAS:
$(
yaml-quote
${
DNS_REPLICAS
:-})
DNS_SERVER_IP:
$(
yaml-quote
${
DNS_SERVER_IP
:-})
DNS_DOMAIN:
$(
yaml-quote
${
DNS_DOMAIN
:-})
KUBE_USER:
$(
yaml-quote
${
KUBE_USER
})
KUBE_PASSWORD:
$(
yaml-quote
${
KUBE_PASSWORD
})
KUBE_BEARER_TOKEN:
$(
yaml-quote
${
KUBE_BEARER_TOKEN
})
KUBELET_TOKEN:
$(
yaml-quote
${
KUBELET_TOKEN
:-})
KUBE_PROXY_TOKEN:
$(
yaml-quote
${
KUBE_PROXY_TOKEN
:-})
ADMISSION_CONTROL:
$(
yaml-quote
${
ADMISSION_CONTROL
:-})
MASTER_IP_RANGE:
$(
yaml-quote
${
MASTER_IP_RANGE
})
EOF
if
[[
"
${
master
}
"
!=
"true"
]]
;
then
cat
>>
$file
<<
EOF
KUBERNETES_MASTER_NAME:
$(
yaml-quote
${
MASTER_NAME
})
ZONE:
$(
yaml-quote
${
ZONE
})
EXTRA_DOCKER_OPTS:
$(
yaml-quote
${
EXTRA_DOCKER_OPTS
})
ENABLE_DOCKER_REGISTRY_CACHE:
$(
yaml-quote
${
ENABLE_DOCKER_REGISTRY_CACHE
:-
false
})
EOF
fi
}
# create-master-instance creates the master instance. If called with
# an argument, the argument is used as the name to a reserved IP
# address for the master. (In the case of upgrade/repair, we re-use
# the same IP.)
#
# It requires a whole slew of assumed variables, partially due to to
# the call to write-master-env. Listing them would be rather
# futile. Instead, we list the required calls to ensure any additional
# variables are set:
# ensure-temp-dir
# detect-project
# get-bearer-token
#
function
create-master-instance
{
local
address_opt
=
""
[[
-n
${
1
:-}
]]
&&
address_opt
=
"--address
${
1
}
"
write-master-env
gcloud compute instances create
"
${
MASTER_NAME
}
"
\
${
address_opt
}
\
--project
"
${
PROJECT
}
"
\
--zone
"
${
ZONE
}
"
\
--machine-type
"
${
MASTER_SIZE
}
"
\
--image-project
=
"
${
MASTER_IMAGE_PROJECT
}
"
\
--image
"
${
MASTER_IMAGE
}
"
\
--tags
"
${
MASTER_TAG
}
"
\
--network
"
${
NETWORK
}
"
\
--scopes
"storage-ro"
"compute-rw"
\
--can-ip-forward
\
--metadata-from-file
\
"startup-script=
${
KUBE_ROOT
}
/cluster/gce/debian/configure-vm.sh"
\
"kube-env=
${
KUBE_TEMP
}
/master-kube-env.yaml"
\
--disk
name
=
"
${
MASTER_NAME
}
-pd"
device-name
=
master-pd
mode
=
rw
boot
=
no auto-delete
=
no
}
function
create-node-instance-template
{
create-node-template
"
${
NODE_INSTANCE_PREFIX
}
-template"
"
${
scope_flags
[*]
}
"
\
"startup-script=
${
KUBE_ROOT
}
/cluster/gce/configure-vm.sh"
\
"kube-env=
${
KUBE_TEMP
}
/node-kube-env.yaml"
}
cluster/gce/util.sh
View file @
5fa11322
...
@@ -22,6 +22,11 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
...
@@ -22,6 +22,11 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source
"
${
KUBE_ROOT
}
/cluster/gce/
${
KUBE_CONFIG_FILE
-
"config-default.sh"
}
"
source
"
${
KUBE_ROOT
}
/cluster/gce/
${
KUBE_CONFIG_FILE
-
"config-default.sh"
}
"
source
"
${
KUBE_ROOT
}
/cluster/common.sh"
source
"
${
KUBE_ROOT
}
/cluster/common.sh"
if
[[
"
${
OS_DISTRIBUTION
}
"
=
~ ^
"debian"
]]
;
then
echo
"Starting cluster using os distro :
${
OS_DISTRIBUTION
}
"
>
&2
source
"
${
KUBE_ROOT
}
/cluster/gce/
${
OS_DISTRIBUTION
}
/helper.sh"
fi
NODE_INSTANCE_PREFIX
=
"
${
INSTANCE_PREFIX
}
-minion"
NODE_INSTANCE_PREFIX
=
"
${
INSTANCE_PREFIX
}
-minion"
KUBE_PROMPT_FOR_UPDATE
=
y
KUBE_PROMPT_FOR_UPDATE
=
y
...
@@ -448,48 +453,6 @@ function yaml-quote {
...
@@ -448,48 +453,6 @@ function yaml-quote {
echo
"'
$(
echo
"
${
@
}
"
|
sed
-e
"s/'/''/g"
)
'"
echo
"'
$(
echo
"
${
@
}
"
|
sed
-e
"s/'/''/g"
)
'"
}
}
# $1: if 'true', we're building a master yaml, else a node
function
build-kube-env
{
local
master
=
$1
local
file
=
$2
rm
-f
${
file
}
cat
>
$file
<<
EOF
ENV_TIMESTAMP:
$(
yaml-quote
$(
date
-u
+%Y-%m-%dT%T%z
))
INSTANCE_PREFIX:
$(
yaml-quote
${
INSTANCE_PREFIX
})
NODE_INSTANCE_PREFIX:
$(
yaml-quote
${
NODE_INSTANCE_PREFIX
})
SERVER_BINARY_TAR_URL:
$(
yaml-quote
${
SERVER_BINARY_TAR_URL
})
SALT_TAR_URL:
$(
yaml-quote
${
SALT_TAR_URL
})
PORTAL_NET:
$(
yaml-quote
${
PORTAL_NET
})
ENABLE_CLUSTER_MONITORING:
$(
yaml-quote
${
ENABLE_CLUSTER_MONITORING
:-
false
})
ENABLE_NODE_MONITORING:
$(
yaml-quote
${
ENABLE_NODE_MONITORING
:-
false
})
ENABLE_CLUSTER_LOGGING:
$(
yaml-quote
${
ENABLE_CLUSTER_LOGGING
:-
false
})
ENABLE_NODE_LOGGING:
$(
yaml-quote
${
ENABLE_NODE_LOGGING
:-
false
})
LOGGING_DESTINATION:
$(
yaml-quote
${
LOGGING_DESTINATION
:-})
ELASTICSEARCH_LOGGING_REPLICAS:
$(
yaml-quote
${
ELASTICSEARCH_LOGGING_REPLICAS
:-})
ENABLE_CLUSTER_DNS:
$(
yaml-quote
${
ENABLE_CLUSTER_DNS
:-
false
})
DNS_REPLICAS:
$(
yaml-quote
${
DNS_REPLICAS
:-})
DNS_SERVER_IP:
$(
yaml-quote
${
DNS_SERVER_IP
:-})
DNS_DOMAIN:
$(
yaml-quote
${
DNS_DOMAIN
:-})
KUBE_USER:
$(
yaml-quote
${
KUBE_USER
})
KUBE_PASSWORD:
$(
yaml-quote
${
KUBE_PASSWORD
})
KUBE_BEARER_TOKEN:
$(
yaml-quote
${
KUBE_BEARER_TOKEN
})
KUBELET_TOKEN:
$(
yaml-quote
${
KUBELET_TOKEN
:-})
KUBE_PROXY_TOKEN:
$(
yaml-quote
${
KUBE_PROXY_TOKEN
:-})
ADMISSION_CONTROL:
$(
yaml-quote
${
ADMISSION_CONTROL
:-})
MASTER_IP_RANGE:
$(
yaml-quote
${
MASTER_IP_RANGE
})
EOF
if
[[
"
${
master
}
"
!=
"true"
]]
;
then
cat
>>
$file
<<
EOF
KUBERNETES_MASTER_NAME:
$(
yaml-quote
${
MASTER_NAME
})
ZONE:
$(
yaml-quote
${
ZONE
})
EXTRA_DOCKER_OPTS:
$(
yaml-quote
${
EXTRA_DOCKER_OPTS
})
ENABLE_DOCKER_REGISTRY_CACHE:
$(
yaml-quote
${
ENABLE_DOCKER_REGISTRY_CACHE
:-
false
})
EOF
fi
}
function
write-master-env
{
function
write-master-env
{
build-kube-env
true
"
${
KUBE_TEMP
}
/master-kube-env.yaml"
build-kube-env
true
"
${
KUBE_TEMP
}
/master-kube-env.yaml"
}
}
...
@@ -498,42 +461,6 @@ function write-node-env {
...
@@ -498,42 +461,6 @@ function write-node-env {
build-kube-env
false
"
${
KUBE_TEMP
}
/node-kube-env.yaml"
build-kube-env
false
"
${
KUBE_TEMP
}
/node-kube-env.yaml"
}
}
# create-master-instance creates the master instance. If called with
# an argument, the argument is used as the name to a reserved IP
# address for the master. (In the case of upgrade/repair, we re-use
# the same IP.)
#
# It requires a whole slew of assumed variables, partially due to to
# the call to write-master-env. Listing them would be rather
# futile. Instead, we list the required calls to ensure any additional
# variables are set:
# ensure-temp-dir
# detect-project
# get-password
# get-bearer-token
#
function
create-master-instance
{
local
address_opt
=
""
[[
-n
${
1
:-}
]]
&&
address_opt
=
"--address
${
1
}
"
write-master-env
gcloud compute instances create
"
${
MASTER_NAME
}
"
\
${
address_opt
}
\
--project
"
${
PROJECT
}
"
\
--zone
"
${
ZONE
}
"
\
--machine-type
"
${
MASTER_SIZE
}
"
\
--image-project
=
"
${
MASTER_IMAGE_PROJECT
}
"
\
--image
"
${
MASTER_IMAGE
}
"
\
--tags
"
${
MASTER_TAG
}
"
\
--network
"
${
NETWORK
}
"
\
--scopes
"storage-ro"
"compute-rw"
\
--can-ip-forward
\
--metadata-from-file
\
"startup-script=
${
KUBE_ROOT
}
/cluster/gce/configure-vm.sh"
\
"kube-env=
${
KUBE_TEMP
}
/master-kube-env.yaml"
\
--disk
name
=
"
${
MASTER_NAME
}
-pd"
device-name
=
master-pd
mode
=
rw
boot
=
no auto-delete
=
no
}
# Instantiate a kubernetes cluster
# Instantiate a kubernetes cluster
#
#
# Assumed vars
# Assumed vars
...
@@ -626,9 +553,7 @@ function kube-up {
...
@@ -626,9 +553,7 @@ function kube-up {
fi
fi
write-node-env
write-node-env
create-node-template
"
${
NODE_INSTANCE_PREFIX
}
-template"
"
${
scope_flags
[*]
}
"
\
create-node-instance-template
"startup-script=
${
KUBE_ROOT
}
/cluster/gce/configure-vm.sh"
\
"kube-env=
${
KUBE_TEMP
}
/node-kube-env.yaml"
gcloud preview managed-instance-groups
--zone
"
${
ZONE
}
"
\
gcloud preview managed-instance-groups
--zone
"
${
ZONE
}
"
\
create
"
${
NODE_INSTANCE_PREFIX
}
-group"
\
create
"
${
NODE_INSTANCE_PREFIX
}
-group"
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment