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
f3ebe306
Commit
f3ebe306
authored
Mar 25, 2015
by
Saad Ali
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5940 from justinsb/fix_bash_style
Fix bash style issues in AWS script
parents
b815fbf2
ac12665f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
util.sh
cluster/aws/util.sh
+19
-19
No files found.
cluster/aws/util.sh
View file @
f3ebe306
...
...
@@ -90,7 +90,7 @@ function detect-minions () {
echo
"Found
${
MINION_NAMES
[
$i
]
}
at
${
minion_ip
}
"
KUBE_MINION_IP_ADDRESSES+
=(
"
${
minion_ip
}
"
)
done
if
[
-z
"
$KUBE_MINION_IP_ADDRESSES
"
]
;
then
if
[
[
-z
"
$KUBE_MINION_IP_ADDRESSES
"
]
]
;
then
echo
"Could not detect Kubernetes minion nodes. Make sure you've launched a cluster with 'kube-up.sh'"
exit
1
fi
...
...
@@ -159,7 +159,7 @@ function detect-image () {
# Verify prereqs
function
verify-prereqs
{
if
[
"
$(
which aws
)
"
==
""
]
;
then
if
[
[
"
$(
which aws
)
"
==
""
]
]
;
then
echo
"Can't find aws in PATH, please fix and retry."
exit
1
fi
...
...
@@ -344,17 +344,17 @@ function kube-up {
local
htpasswd
htpasswd
=
$(
cat
"
${
KUBE_TEMP
}
/htpasswd"
)
if
[
!
-f
$AWS_SSH_KEY
]
;
then
ssh-keygen
-f
$AWS_SSH_KEY
-N
''
if
[
[
!
-f
"
$AWS_SSH_KEY
"
]
]
;
then
ssh-keygen
-f
"
$AWS_SSH_KEY
"
-N
''
fi
detect-image
$AWS_CMD
import-key-pair
--key-name
kubernetes
--public-key-material
file://
$AWS_SSH_KEY
.pub
>
$LOG
2>&1
||
true
$AWS_CMD
import-key-pair
--key-name
kubernetes
--public-key-material
"file://
$AWS_SSH_KEY
.pub"
>
$LOG
2>&1
||
true
VPC_ID
=
$(
$AWS_CMD
describe-vpcs | get_vpc_id
)
if
[
-z
"
$VPC_ID
"
]
;
then
if
[
[
-z
"
$VPC_ID
"
]
]
;
then
echo
"Creating vpc."
VPC_ID
=
$(
$AWS_CMD
create-vpc
--cidr-block
172.20.0.0/16 | json_val
'["Vpc"]["VpcId"]'
)
$AWS_CMD
modify-vpc-attribute
--vpc-id
$VPC_ID
--enable-dns-support
'{"Value": true}'
>
$LOG
...
...
@@ -365,7 +365,7 @@ function kube-up {
echo
"Using VPC
$VPC_ID
"
SUBNET_ID
=
$(
$AWS_CMD
describe-subnets | get_subnet_id
$VPC_ID
)
if
[
-z
"
$SUBNET_ID
"
]
;
then
if
[
[
-z
"
$SUBNET_ID
"
]
]
;
then
echo
"Creating subnet."
SUBNET_ID
=
$(
$AWS_CMD
create-subnet
--cidr-block
172.20.0.0/24
--vpc-id
$VPC_ID
| json_val
'["Subnet"]["SubnetId"]'
)
fi
...
...
@@ -373,7 +373,7 @@ function kube-up {
echo
"Using subnet
$SUBNET_ID
"
IGW_ID
=
$(
$AWS_CMD
describe-internet-gateways | get_igw_id
$VPC_ID
)
if
[
-z
"
$IGW_ID
"
]
;
then
if
[
[
-z
"
$IGW_ID
"
]
]
;
then
echo
"Creating Internet Gateway."
IGW_ID
=
$(
$AWS_CMD
create-internet-gateway | json_val
'["InternetGateway"]["InternetGatewayId"]'
)
$AWS_CMD
attach-internet-gateway
--internet-gateway-id
$IGW_ID
--vpc-id
$VPC_ID
>
$LOG
...
...
@@ -397,7 +397,7 @@ function kube-up {
--query
SecurityGroups[].GroupId
\
|
tr
"
\t
"
"
\n
"
)
if
[
-z
"
$SEC_GROUP_ID
"
]
;
then
if
[
[
-z
"
$SEC_GROUP_ID
"
]
]
;
then
echo
"Creating security group."
SEC_GROUP_ID
=
$(
$AWS_CMD
create-security-group
--group-name
kubernetes-sec-group
--description
kubernetes-sec-group
--vpc-id
$VPC_ID
| json_val
'["GroupId"]'
)
$AWS_CMD
authorize-security-group-ingress
--group-id
$SEC_GROUP_ID
--protocol
-1
--port
all
--cidr
0.0.0.0/0
>
$LOG
...
...
@@ -482,7 +482,7 @@ function kube-up {
while
true
;
do
echo
-n
Attempt
"
$((
$attempt
+
1
))
"
to check
for
salt-master
local
output
output
=
$(
ssh
-oStrictHostKeyChecking
=
no
-i
${
AWS_SSH_KEY
}
ubuntu@
${
KUBE_MASTER_IP
}
pgrep salt-master 2>
$LOG
)
||
output
=
""
output
=
$(
ssh
-oStrictHostKeyChecking
=
no
-i
"
${
AWS_SSH_KEY
}
"
ubuntu@
${
KUBE_MASTER_IP
}
pgrep salt-master 2>
$LOG
)
||
output
=
""
if
[[
-z
"
${
output
}
"
]]
;
then
if
((
attempt
>
30
))
;
then
echo
...
...
@@ -569,7 +569,7 @@ function kube-up {
sleep
10
done
echo
"Re-running salt highstate"
ssh
-oStrictHostKeyChecking
=
no
-i
${
AWS_SSH_KEY
}
ubuntu@
${
KUBE_MASTER_IP
}
sudo
salt
'*'
state.highstate
>
$LOG
ssh
-oStrictHostKeyChecking
=
no
-i
"
${
AWS_SSH_KEY
}
"
ubuntu@
${
KUBE_MASTER_IP
}
sudo
salt
'*'
state.highstate
>
$LOG
echo
"Waiting for cluster initialization."
echo
...
...
@@ -602,9 +602,9 @@ function kube-up {
(
mkdir
-p
"
${
config_dir
}
"
umask
077
ssh
-oStrictHostKeyChecking
=
no
-i
${
AWS_SSH_KEY
}
ubuntu@
${
KUBE_MASTER_IP
}
sudo cat
/srv/kubernetes/kubecfg.crt
>
"
${
config_dir
}
/
${
kube_cert
}
"
2>
$LOG
ssh
-oStrictHostKeyChecking
=
no
-i
${
AWS_SSH_KEY
}
ubuntu@
${
KUBE_MASTER_IP
}
sudo cat
/srv/kubernetes/kubecfg.key
>
"
${
config_dir
}
/
${
kube_key
}
"
2>
$LOG
ssh
-oStrictHostKeyChecking
=
no
-i
${
AWS_SSH_KEY
}
ubuntu@
${
KUBE_MASTER_IP
}
sudo cat
/srv/kubernetes/ca.crt
>
"
${
config_dir
}
/
${
ca_cert
}
"
2>
$LOG
ssh
-oStrictHostKeyChecking
=
no
-i
"
${
AWS_SSH_KEY
}
"
ubuntu@
${
KUBE_MASTER_IP
}
sudo cat
/srv/kubernetes/kubecfg.crt
>
"
${
config_dir
}
/
${
kube_cert
}
"
2>
$LOG
ssh
-oStrictHostKeyChecking
=
no
-i
"
${
AWS_SSH_KEY
}
"
ubuntu@
${
KUBE_MASTER_IP
}
sudo cat
/srv/kubernetes/kubecfg.key
>
"
${
config_dir
}
/
${
kube_key
}
"
2>
$LOG
ssh
-oStrictHostKeyChecking
=
no
-i
"
${
AWS_SSH_KEY
}
"
ubuntu@
${
KUBE_MASTER_IP
}
sudo cat
/srv/kubernetes/ca.crt
>
"
${
config_dir
}
/
${
ca_cert
}
"
2>
$LOG
"
${
kubectl
}
"
config set-cluster
"
${
context
}
"
--server
=
"https://
${
KUBE_MASTER_IP
}
"
--certificate-authority
=
"
${
config_dir
}
/
${
ca_cert
}
"
--global
"
${
kubectl
}
"
config set-credentials
"
${
user
}
"
--auth-path
=
"
${
config_dir
}
/
${
kube_auth
}
"
--global
...
...
@@ -642,7 +642,7 @@ EOF
local
minion_name
=
${
MINION_NAMES
[
$i
]
}
local
minion_ip
=
${
KUBE_MINION_IP_ADDRESSES
[
$i
]
}
echo
-n
Attempt
"
$((
$attempt
+
1
))
"
to check Docker on node
"
${
minion_name
}
@
${
minion_ip
}
"
...
local
output
=
$(
ssh
-oStrictHostKeyChecking
=
no
-i
${
AWS_SSH_KEY
}
ubuntu@
$minion_ip
sudo
docker ps
-a
2>/dev/null
)
local
output
=
$(
ssh
-oStrictHostKeyChecking
=
no
-i
"
${
AWS_SSH_KEY
}
"
ubuntu@
$minion_ip
sudo
docker ps
-a
2>/dev/null
)
if
[[
-z
"
${
output
}
"
]]
;
then
if
((
attempt
>
9
))
;
then
echo
...
...
@@ -666,7 +666,7 @@ EOF
fi
echo
-e
"
${
color_yellow
}
[not working yet]
${
color_norm
}
"
# Start Docker, in case it failed to start.
ssh
-oStrictHostKeyChecking
=
no
-i
${
AWS_SSH_KEY
}
ubuntu@
$
$
minion_ip
sudo
service docker start
>
$LOG
2>&1
ssh
-oStrictHostKeyChecking
=
no
-i
"
${
AWS_SSH_KEY
}
"
ubuntu@
$minion_ip
sudo
service docker start
>
$LOG
2>&1
attempt
=
$((
$attempt
+
1
))
sleep
30
done
...
...
@@ -771,7 +771,7 @@ function kube-push {
echo
"echo Executing configuration"
echo
"sudo salt '*' mine.update"
echo
"sudo salt --force-color '*' state.highstate"
)
| ssh
-oStrictHostKeyChecking
=
no
-i
${
AWS_SSH_KEY
}
ubuntu@
${
KUBE_MASTER_IP
}
sudo
bash
)
| ssh
-oStrictHostKeyChecking
=
no
-i
"
${
AWS_SSH_KEY
}
"
ubuntu@
${
KUBE_MASTER_IP
}
sudo
bash
get-password
...
...
@@ -818,13 +818,13 @@ function ssh-to-node {
local
cmd
=
"
$2
"
local
ip
=
$(
get_instance_public_ip
${
node
})
if
[
-z
"ip"
]
;
then
if
[
[
-z
"
$ip
"
]
]
;
then
echo
"Could not detect IP for
${
node
}
."
exit
1
fi
for
try
in
$(
seq
1 5
)
;
do
if
ssh
-oLogLevel
=
quiet
-oStrictHostKeyChecking
=
no
-i
${
AWS_SSH_KEY
}
ubuntu@
${
ip
}
"
${
cmd
}
"
;
then
if
ssh
-oLogLevel
=
quiet
-oStrictHostKeyChecking
=
no
-i
"
${
AWS_SSH_KEY
}
"
ubuntu@
${
ip
}
"
${
cmd
}
"
;
then
break
fi
done
...
...
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