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
cb59cb33
Unverified
Commit
cb59cb33
authored
Feb 04, 2019
by
Bob Killen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix shellcheck lint errors in test/kubemark/iks/util.sh
parent
e3e2a965
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
31 deletions
+46
-31
.shellcheck_failures
hack/.shellcheck_failures
+0
-1
util.sh
test/kubemark/iks/util.sh
+46
-30
No files found.
hack/.shellcheck_failures
View file @
cb59cb33
...
@@ -145,7 +145,6 @@
...
@@ -145,7 +145,6 @@
./test/images/volume/rbd/create_block.sh
./test/images/volume/rbd/create_block.sh
./test/images/volume/rbd/mon.sh
./test/images/volume/rbd/mon.sh
./test/images/volume/rbd/osd.sh
./test/images/volume/rbd/osd.sh
./test/kubemark/iks/util.sh
./test/kubemark/master-log-dump.sh
./test/kubemark/master-log-dump.sh
./test/kubemark/resources/start-kubemark-master.sh
./test/kubemark/resources/start-kubemark-master.sh
./test/kubemark/run-e2e-tests.sh
./test/kubemark/run-e2e-tests.sh
...
...
test/kubemark/iks/util.sh
View file @
cb59cb33
...
@@ -14,10 +14,11 @@
...
@@ -14,10 +14,11 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
KUBE_ROOT
=
$(
dirname
"
${
BASH_SOURCE
}
"
)
/../../..
KUBE_ROOT
=
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
/../../..
# Creates a new kube-spawn cluster
# Creates a new kube-spawn cluster
function
create-clusters
{
function
create-clusters
{
# shellcheck disable=SC2154 # Color defined in sourced script
echo
-e
"
${
color_yellow
}
CHECKING CLUSTERS
${
color_norm
}
"
echo
-e
"
${
color_yellow
}
CHECKING CLUSTERS
${
color_norm
}
"
if
bx cs clusters |
grep
-Fq
'deleting'
;
then
if
bx cs clusters |
grep
-Fq
'deleting'
;
then
echo
-n
"Deleting old clusters"
echo
-n
"Deleting old clusters"
...
@@ -34,14 +35,15 @@ function create-clusters {
...
@@ -34,14 +35,15 @@ function create-clusters {
PUBVLAN
=
$(
bx cs vlans wdc06
--json
| jq
'. | .[] | select(.type == "public") | .id'
|
sed
-e
"s/
\"
//g"
)
PUBVLAN
=
$(
bx cs vlans wdc06
--json
| jq
'. | .[] | select(.type == "public") | .id'
|
sed
-e
"s/
\"
//g"
)
if
!
bx cs clusters |
grep
-Fq
'kubeSpawnTester'
;
then
if
!
bx cs clusters |
grep
-Fq
'kubeSpawnTester'
;
then
echo
"Creating spawning cluster"
echo
"Creating spawning cluster"
bx cs cluster-create
--location
${
CLUSTER_LOCATION
}
--public-vlan
${
PUBVLAN
}
--private-vlan
${
PRIVLAN
}
--workers
2
--machine-type
u2c.2x4
--name
kubeSpawnTester
bx cs cluster-create
--location
"
${
CLUSTER_LOCATION
}
"
--public-vlan
"
${
PUBVLAN
}
"
--private-vlan
"
${
PRIVLAN
}
"
--workers
2
--machine-type
u2c.2x4
--name
kubeSpawnTester
fi
fi
if
!
bx cs clusters |
grep
-Fq
'kubeMasterTester'
;
then
if
!
bx cs clusters |
grep
-Fq
'kubeMasterTester'
;
then
echo
"Creating master cluster"
echo
"Creating master cluster"
bx cs cluster-create
--location
${
CLUSTER_LOCATION
}
--public-vlan
${
PUBVLAN
}
--private-vlan
${
PRIVLAN
}
--workers
2
--machine-type
u2c.2x4
--name
kubeMasterTester
bx cs cluster-create
--location
"
${
CLUSTER_LOCATION
}
"
--public-vlan
"
${
PUBVLAN
}
"
--private-vlan
"
${
PRIVLAN
}
"
--workers
2
--machine-type
u2c.2x4
--name
kubeMasterTester
fi
fi
push-image
push-image
if
!
bx cs clusters |
grep
'kubeSpawnTester'
|
grep
-Fq
'normal'
;
then
if
!
bx cs clusters |
grep
'kubeSpawnTester'
|
grep
-Fq
'normal'
;
then
# shellcheck disable=SC2154 # Color defined in sourced script
echo
-e
"
${
color_cyan
}
Warning: new clusters may take up to 60 minutes to be ready
${
color_norm
}
"
echo
-e
"
${
color_cyan
}
Warning: new clusters may take up to 60 minutes to be ready
${
color_norm
}
"
echo
-n
"Clusters loading"
echo
-n
"Clusters loading"
fi
fi
...
@@ -61,17 +63,17 @@ function create-clusters {
...
@@ -61,17 +63,17 @@ function create-clusters {
# Builds and pushes image to registry
# Builds and pushes image to registry
function
push-image
{
function
push-image
{
if
[[
"
${
ISBUILD
}
"
=
"y"
]]
;
then
if
[[
"
${
ISBUILD
}
"
=
"y"
]]
;
then
if
!
bx cr namespaces |
grep
-Fq
${
KUBE_NAMESPACE
}
;
then
if
!
bx cr namespaces |
grep
-Fq
"
${
KUBE_NAMESPACE
}
"
;
then
echo
"Creating registry namespace"
echo
"Creating registry namespace"
bx cr namespace-add
${
KUBE_NAMESPACE
}
bx cr namespace-add
"
${
KUBE_NAMESPACE
}
"
echo
"bx cr namespace-rm
${
KUBE_NAMESPACE
}
"
>>
${
RESOURCE_DIRECTORY
}
/iks-namespacelist.sh
echo
"bx cr namespace-rm
${
KUBE_NAMESPACE
}
"
>>
"
${
RESOURCE_DIRECTORY
}
/iks-namespacelist.sh"
fi
fi
docker build
-t
${
KUBEMARK_INIT_TAG
}
${
KUBEMARK_IMAGE_LOCATION
}
docker build
-t
"
${
KUBEMARK_INIT_TAG
}
"
"
${
KUBEMARK_IMAGE_LOCATION
}
"
docker tag
${
KUBEMARK_INIT_TAG
}
${
KUBEMARK_IMAGE_REGISTRY
}${
KUBE_NAMESPACE
}
/
${
PROJECT
}
:
${
KUBEMARK_IMAGE_TAG
}
docker tag
"
${
KUBEMARK_INIT_TAG
}
"
"
${
KUBEMARK_IMAGE_REGISTRY
}${
KUBE_NAMESPACE
}
/
${
PROJECT
}
:
${
KUBEMARK_IMAGE_TAG
}
"
docker push
${
KUBEMARK_IMAGE_REGISTRY
}${
KUBE_NAMESPACE
}
/
${
PROJECT
}
:
${
KUBEMARK_IMAGE_TAG
}
docker push
"
${
KUBEMARK_IMAGE_REGISTRY
}${
KUBE_NAMESPACE
}
/
${
PROJECT
}
:
${
KUBEMARK_IMAGE_TAG
}
"
echo
"Image pushed"
echo
"Image pushed"
else
else
KUBEMARK_IMAGE_REGISTRY
=
$(
echo
"brandondr96"
)
KUBEMARK_IMAGE_REGISTRY
=
"brandondr96"
KUBE_NAMESPACE
=
""
KUBE_NAMESPACE
=
""
fi
fi
}
}
...
@@ -79,16 +81,17 @@ function push-image {
...
@@ -79,16 +81,17 @@ function push-image {
# Allow user to use existing clusters if desired
# Allow user to use existing clusters if desired
function
choose-clusters
{
function
choose-clusters
{
echo
-n
-e
"Do you want to use custom clusters? [y/N]
${
color_cyan
}
>
${
color_norm
}
"
echo
-n
-e
"Do you want to use custom clusters? [y/N]
${
color_cyan
}
>
${
color_norm
}
"
read
USE_EXISTING
read
-r
USE_EXISTING
if
[[
"
${
USE_EXISTING
}
"
=
"y"
]]
;
then
if
[[
"
${
USE_EXISTING
}
"
=
"y"
]]
;
then
echo
-e
"
${
color_yellow
}
Enter path for desired hollow-node spawning cluster kubeconfig file:
${
color_norm
}
"
echo
-e
"
${
color_yellow
}
Enter path for desired hollow-node spawning cluster kubeconfig file:
${
color_norm
}
"
read
CUSTOM_SPAWN_CONFIG
read
-r
CUSTOM_SPAWN_CONFIG
echo
-e
"
${
color_yellow
}
Enter path for desired hollow-node hosting cluster kubeconfig file:
${
color_norm
}
"
echo
-e
"
${
color_yellow
}
Enter path for desired hollow-node hosting cluster kubeconfig file:
${
color_norm
}
"
read
CUSTOM_MASTER_CONFIG
read
-r
CUSTOM_MASTER_CONFIG
push-image
push-image
elif
[[
"
${
USE_EXISTING
}
"
=
"N"
]]
;
then
elif
[[
"
${
USE_EXISTING
}
"
=
"N"
]]
;
then
create-clusters
create-clusters
else
else
# shellcheck disable=SC2154 # Color defined in sourced script
echo
-e
"
${
color_red
}
Invalid response, please try again:
${
color_norm
}
"
echo
-e
"
${
color_red
}
Invalid response, please try again:
${
color_norm
}
"
choose-clusters
choose-clusters
fi
fi
...
@@ -102,28 +105,35 @@ function set-registry-secrets {
...
@@ -102,28 +105,35 @@ function set-registry-secrets {
kubectl
-n
kubemark get serviceaccounts default
-o
json | jq
'del(.metadata.resourceVersion)'
| jq
'setpath(["imagePullSecrets"];[{"name":"bluemix-kubemark-secret-regional"}])'
| kubectl
-n
kubemark replace serviceaccount default
-f
-
kubectl
-n
kubemark get serviceaccounts default
-o
json | jq
'del(.metadata.resourceVersion)'
| jq
'setpath(["imagePullSecrets"];[{"name":"bluemix-kubemark-secret-regional"}])'
| kubectl
-n
kubemark replace serviceaccount default
-f
-
}
}
# Sets hollow nodes spawned under master
# Sets the hollow-node master
# Exported variables:
# MASTER_IP - IP Address of the Kubemark master
function
set-hollow-master
{
function
set-hollow-master
{
echo
-e
"
${
color_yellow
}
CONFIGURING MASTER
${
color_norm
}
"
echo
-e
"
${
color_yellow
}
CONFIGURING MASTER
${
color_norm
}
"
master-config
master-config
MASTER_IP
=
$(
cat
$KUBECONFIG
|
grep
server |
awk
-F
"/"
'{print $3}'
)
MASTER_IP
=
$(
grep
server
"
$KUBECONFIG
"
|
awk
-F
"/"
'{print $3}'
)
export
MASTER_IP
}
}
# Set up master cluster environment
# Set up master cluster environment
# Exported variables:
# KUBECONFIG - Overrides default kube config for the purpose of setting up the Kubemark master components.
function
master-config
{
function
master-config
{
if
[[
"
${
USE_EXISTING
}
"
=
"y"
]]
;
then
if
[[
"
${
USE_EXISTING
}
"
=
"y"
]]
;
then
export
KUBECONFIG
=
${
CUSTOM_MASTER_CONFIG
}
export
KUBECONFIG
=
${
CUSTOM_MASTER_CONFIG
}
else
else
$(
bx cs cluster-config kubeMasterTester
--admin
|
grep export
)
eval
"
$(
bx cs cluster-config kubeMasterTester
--admin
|
grep export
)
"
fi
fi
}
}
# Set up spawn cluster environment
# Set up spawn cluster environment
# Exported variables:
# KUBECONFIG - Overrides default kube config for the purpose of setting up the hollow-node cluster.
function
spawn-config
{
function
spawn-config
{
if
[[
"
${
USE_EXISTING
}
"
=
"y"
]]
;
then
if
[[
"
${
USE_EXISTING
}
"
=
"y"
]]
;
then
export
KUBECONFIG
=
${
CUSTOM_SPAWN_CONFIG
}
export
KUBECONFIG
=
${
CUSTOM_SPAWN_CONFIG
}
else
else
$(
bx cs cluster-config kubeSpawnTester
--admin
|
grep export
)
eval
"
$(
bx cs cluster-config kubeSpawnTester
--admin
|
grep export
)
"
fi
fi
}
}
...
@@ -147,11 +157,11 @@ function delete-clusters {
...
@@ -147,11 +157,11 @@ function delete-clusters {
function
complete-login
{
function
complete-login
{
echo
-e
"
${
color_yellow
}
LOGGING INTO CLOUD SERVICES
${
color_norm
}
"
echo
-e
"
${
color_yellow
}
LOGGING INTO CLOUD SERVICES
${
color_norm
}
"
echo
-n
-e
"Do you have a federated IBM cloud login? [y/N]
${
color_cyan
}
>
${
color_norm
}
"
echo
-n
-e
"Do you have a federated IBM cloud login? [y/N]
${
color_cyan
}
>
${
color_norm
}
"
read
ISFED
read
-r
ISFED
if
[[
"
${
ISFED
}
"
=
"y"
]]
;
then
if
[[
"
${
ISFED
}
"
=
"y"
]]
;
then
bx login
--sso
-a
${
REGISTRY_LOGIN_URL
}
bx login
--sso
-a
"
${
REGISTRY_LOGIN_URL
}
"
elif
[[
"
${
ISFED
}
"
=
"N"
]]
;
then
elif
[[
"
${
ISFED
}
"
=
"N"
]]
;
then
bx login
-a
${
REGISTRY_LOGIN_URL
}
bx login
-a
"
${
REGISTRY_LOGIN_URL
}
"
else
else
echo
-e
"
${
color_red
}
Invalid response, please try again:
${
color_norm
}
"
echo
-e
"
${
color_red
}
Invalid response, please try again:
${
color_norm
}
"
complete-login
complete-login
...
@@ -159,28 +169,34 @@ function complete-login {
...
@@ -159,28 +169,34 @@ function complete-login {
bx cr login
bx cr login
}
}
# Generate values to fill the hollow-node configuration
# Generate values to fill the hollow-node configuration templates.
# Exported variables:
# KUBECTL - The name or path to the kubernetes client binary.
# TEST_CLUSTER_API_CONTENT_TYPE - Defines the content-type of the requests used by the Kubemark components.
function
generate-values
{
function
generate-values
{
echo
"Generating values"
echo
"Generating values"
master-config
master-config
KUBECTL
=
kubectl
KUBECTL
=
kubectl
export
KUBECTL
KUBEMARK_DIRECTORY
=
"
${
KUBE_ROOT
}
/test/kubemark"
KUBEMARK_DIRECTORY
=
"
${
KUBE_ROOT
}
/test/kubemark"
RESOURCE_DIRECTORY
=
"
${
KUBEMARK_DIRECTORY
}
/resources"
RESOURCE_DIRECTORY
=
"
${
KUBEMARK_DIRECTORY
}
/resources"
TEST_CLUSTER_API_CONTENT_TYPE
=
"bluemix"
#Determine correct usage of this
TEST_CLUSTER_API_CONTENT_TYPE
=
"bluemix"
#Determine correct usage of this
export
TEST_CLUSTER_API_CONTENT_TYPE
CONFIGPATH
=
${
KUBECONFIG
%/*
}
CONFIGPATH
=
${
KUBECONFIG
%/*
}
KUBELET_CERT_BASE64
=
"
${
KUBELET_CERT_BASE64
:-$(
cat
${
CONFIGPATH
}
/admin.pem |
base64
|
tr
-d
'\r\n'
)}
"
KUBELET_CERT_BASE64
=
"
${
KUBELET_CERT_BASE64
:-$(
base64
"
${
CONFIGPATH
}
/admin.pem"
|
tr
-d
'\r\n'
)}
"
KUBELET_KEY_BASE64
=
"
${
KUBELET_KEY_BASE64
:-$(
cat
${
CONFIGPATH
}
/admin-key.pem |
base64
|
tr
-d
'\r\n'
)}
"
KUBELET_KEY_BASE64
=
"
${
KUBELET_KEY_BASE64
:-$(
base64
"
${
CONFIGPATH
}
/admin-key.pem"
|
tr
-d
'\r\n'
)}
"
CA_CERT_BASE64
=
"
${
CA_CERT_BASE64
:-$(
cat
`
find
${
CONFIGPATH
}
-name
*
ca
*
`
|
base64
|
tr
-d
'\r\n'
)}
"
CA_CERT_BASE64
=
"
${
CA_CERT_BASE64
:-$(
base64
"
$(
find
"
${
CONFIGPATH
}
"
-name
"*ca*"
|
head
-n
1
)
"
|
tr
-d
'\r\n'
)}
"
}
}
# Build image for kubemark
# Build image for kubemark
function
build-kubemark-image
{
function
build-kubemark-image
{
echo
-n
-e
"Do you want to build the kubemark image? [y/N]
${
color_cyan
}
>
${
color_norm
}
"
echo
-n
-e
"Do you want to build the kubemark image? [y/N]
${
color_cyan
}
>
${
color_norm
}
"
read
ISBUILD
read
-r
ISBUILD
if
[[
"
${
ISBUILD
}
"
=
"y"
]]
;
then
if
[[
"
${
ISBUILD
}
"
=
"y"
]]
;
then
echo
-e
"
${
color_yellow
}
BUILDING IMAGE
${
color_norm
}
"
echo
-e
"
${
color_yellow
}
BUILDING IMAGE
${
color_norm
}
"
${
KUBE_ROOT
}
/build/run.sh
make kubemark
"
${
KUBE_ROOT
}
/build/run.sh"
make kubemark
cp
${
KUBE_ROOT
}
/_output/dockerized/bin/linux/amd64/kubemark
${
KUBEMARK_IMAGE_LOCATION
}
cp
"
${
KUBE_ROOT
}
/_output/dockerized/bin/linux/amd64/kubemark"
"
${
KUBEMARK_IMAGE_LOCATION
}
"
elif
[[
"
${
ISBUILD
}
"
=
"N"
]]
;
then
elif
[[
"
${
ISBUILD
}
"
=
"N"
]]
;
then
echo
-n
""
echo
-n
""
else
else
...
@@ -192,11 +208,11 @@ function build-kubemark-image {
...
@@ -192,11 +208,11 @@ function build-kubemark-image {
# Clean up repository
# Clean up repository
function
clean-repo
{
function
clean-repo
{
echo
-n
-e
"Do you want to remove build output and binary? [y/N]
${
color_cyan
}
>
${
color_norm
}
"
echo
-n
-e
"Do you want to remove build output and binary? [y/N]
${
color_cyan
}
>
${
color_norm
}
"
read
ISCLEAN
read
-r
ISCLEAN
if
[[
"
${
ISCLEAN
}
"
=
"y"
]]
;
then
if
[[
"
${
ISCLEAN
}
"
=
"y"
]]
;
then
echo
-e
"
${
color_yellow
}
CLEANING REPO
${
color_norm
}
"
echo
-e
"
${
color_yellow
}
CLEANING REPO
${
color_norm
}
"
rm
-rf
${
KUBE_ROOT
}
/_output
rm
-rf
"
${
KUBE_ROOT
}
/_output"
rm
-f
${
KUBEMARK_IMAGE_LOCATION
}
/kubemark
rm
-f
"
${
KUBEMARK_IMAGE_LOCATION
}
/kubemark"
elif
[[
"
${
ISCLEAN
}
"
=
"N"
]]
;
then
elif
[[
"
${
ISCLEAN
}
"
=
"N"
]]
;
then
echo
-n
""
echo
-n
""
else
else
...
...
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