-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add testscripts for persistent volume and service in k8scluster
- Loading branch information
Showing
8 changed files
with
261 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ cloud: | |
timeout: "9" | ||
threshold: "3" | ||
k8scluster: | ||
enable: "n" | ||
enable: "y" | ||
gcp: | ||
enable: "y" | ||
nlb: | ||
|
23 changes: 23 additions & 0 deletions
23
src/testclient/scripts/13.k8scluster/get-available-k8scluster-version.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
echo "####################################################################" | ||
echo "## 13. K8SCLUSTER: Get Available Version" | ||
echo "####################################################################" | ||
|
||
source ../init.sh | ||
|
||
K8SCLUSTERID_ADD=${OPTION03:-1} | ||
|
||
K8SCLUSTERID=${K8SCLUSTERID_PREFIX}${INDEX}${REGION}${K8SCLUSTERID_ADD} | ||
|
||
echo "NSID: "${NSID} | ||
echo "K8SCLUSTERID=${K8SCLUSTERID}" | ||
|
||
PROVIDERNAME="alibaba" | ||
#REGIONNAME="me-east-1" | ||
REGIONNAME="ap-south-1" | ||
|
||
resp=$( | ||
curl -H "${AUTH}" -sX GET http://$TumblebugServer/tumblebug/availableK8sClusterVersion?providerName=${PROVIDERNAME}\®ionName=${REGIONNAME} | ||
); echo ${resp} | jq '' | ||
echo "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
src/testclient/scripts/sequentialFullTest/deploy-nginx-with-pvc-to-k8scluster.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/bin/bash | ||
|
||
# From https://aweirdimagination.net/2020/06/28/kill-child-jobs-on-script-exit/ | ||
cleanup() { | ||
# kill all processes whose parent is this process | ||
pkill -P $$ | ||
} | ||
|
||
for sig in INT QUIT HUP TERM; do | ||
trap " | ||
cleanup | ||
trap - $sig EXIT | ||
kill -s $sig "'"$$"' "$sig" | ||
done | ||
trap cleanup EXIT | ||
|
||
# From https://www.grepper.com/answers/215915/regex+for+url+in+bash | ||
readonly ENDPOINT_REGEX='^[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]\.[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]$' | ||
|
||
SECONDS=0 | ||
|
||
echo "####################################################################" | ||
echo "## Command (SSH) to K8sCluster (deploy-nginx-with-pvc-to-k8scluster)" | ||
echo "####################################################################" | ||
|
||
source ../init.sh | ||
|
||
KEEP_PREV_KUBECONFIG=${OPTION02:-n} | ||
K8SCLUSTERID_ADD=${OPTION03:-1} | ||
LOCALIP=`hostname -I | cut -d' ' -f1` | ||
|
||
KUBECTL=kubectl | ||
if ! kubectl > /dev/null 2>&1; then | ||
if ! ./kubectl > /dev/null 2>&1; then | ||
# Download kubectl | ||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" | ||
chmod u+x ./kubectl | ||
fi | ||
KUBECTL=./kubectl | ||
fi | ||
|
||
if [ "${INDEX}" == "0" ]; then | ||
INDEXX=${NumCSP} | ||
for ((cspi = 1; cspi <= INDEXX; cspi++)); do | ||
INDEXY=${NumRegion[$cspi]} | ||
CSP=${CSPType[$cspi]} | ||
for ((cspj = 1; cspj <= INDEXY; cspj++)); do | ||
REGION=$cspj | ||
|
||
K8SCLUSTERID=${K8SCLUSTERID_PREFIX}${cspi}${cspj}${K8SCLUSTERID_ADD} | ||
|
||
echo "[Get K8sClusterInfo for ${K8SCLUSTERID}]" | ||
K8SCLUSTERINFO=$(curl -H "${AUTH}" -sX GET http://$TumblebugServer/tumblebug/ns/$NSID/k8scluster/${K8SCLUSTERID}) | ||
|
||
TMP_FILE_KUBECONFIG=$(mktemp ./${K8SCLUSTERID}-kubeconfig.XXXXXX || exit 1) | ||
if [ "${KEEP_PREV_KUBECONFIG}" != "y" ]; then | ||
echo "Delete Previous Kubeconfig Files" | ||
rm -f "${K8SCLUSTERID}-kubeconfig."* | ||
#trap 'echo "trapped"; rm -f -- "$TMP_FILE_KUBECONFIG"' EXIT | ||
fi | ||
|
||
ENDPOINT=$(jq -r '.AccessInfo.endpoint' <<<"$K8SCLUSTERINFO") | ||
if [[ ! $ENDPOINT =~ $ENDPOINT_REGEX ]]; then | ||
echo ".AccessInfo.endpoint ($ENDPOINT) is not valid" | ||
echo "Try again after about 5 minutes" | ||
continue | ||
fi | ||
|
||
echo "TMP_FILE_KUBECONFIG="$TMP_FILE_KUBECONFIG | ||
jq -r '.AccessInfo.kubeconfig' <<<"$K8SCLUSTERINFO" > $TMP_FILE_KUBECONFIG | ||
$KUBECTL --kubeconfig $TMP_FILE_KUBECONFIG apply -f ./nginx-with-pvc.yaml | ||
dozing 1 | ||
|
||
# max(cspi)=17, max(cspj)=40 | ||
LOCALPORT=$((4000+$cspi*64+$cspj)) | ||
echo "LOCALPORT="$LOCALPORT | ||
$KUBECTL --kubeconfig $TMP_FILE_KUBECONFIG port-forward --address=0.0.0.0 pod/nginx $LOCALPORT:80 & | ||
dozing 1 | ||
|
||
echo "[K8sCluster Nginx for PV/PVC Test: complete to create a k8scluster in $CSP[$REGION]]" | ||
echo "You can access to http://"$LOCALIP":"$LOCALPORT "until exiting by Ctrl+C" | ||
|
||
$KUBECTL --kubeconfig $TMP_FILE_KUBECONFIG get pv,pvc & | ||
done | ||
done | ||
wait | ||
|
||
fi | ||
|
||
echo "Done!" | ||
duration=$SECONDS | ||
|
||
printElapsed $@ | ||
echo "" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/testclient/scripts/sequentialFullTest/nginx-with-pvc.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: html-pvc | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 1Gi | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx | ||
spec: | ||
initContainers: | ||
- name: init-nginx | ||
image: busybox | ||
command: ['sh', '-c', 'echo "<html><body><h1>Welcome to Nginx for PV/PVC Test</h1></body></html>" > /usr/share/nginx/html/index.html'] | ||
volumeMounts: | ||
- name: html-volume | ||
mountPath: /usr/share/nginx/html | ||
containers: | ||
- name: nginx | ||
image: nginx:alpine | ||
ports: | ||
- containerPort: 80 | ||
volumeMounts: | ||
- name: html-volume | ||
mountPath: /usr/share/nginx/html | ||
volumes: | ||
- name: html-volume | ||
persistentVolumeClaim: | ||
claimName: html-pvc |
86 changes: 86 additions & 0 deletions
86
src/testclient/scripts/sequentialFullTest/undeploy-nginx-with-pvc-from-k8scluster.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/bin/bash | ||
|
||
# From https://aweirdimagination.net/2020/06/28/kill-child-jobs-on-script-exit/ | ||
cleanup() { | ||
# kill all processes whose parent is this process | ||
pkill -P $$ | ||
} | ||
|
||
for sig in INT QUIT HUP TERM; do | ||
trap " | ||
cleanup | ||
trap - $sig EXIT | ||
kill -s $sig "'"$$"' "$sig" | ||
done | ||
trap cleanup EXIT | ||
|
||
# From https://www.grepper.com/answers/215915/regex+for+url+in+bash | ||
readonly ENDPOINT_REGEX='^[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]\.[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]$' | ||
|
||
SECONDS=0 | ||
|
||
echo "####################################################################" | ||
echo "## Command (SSH) to K8sCluster (undeploy-nginx-with-pvc-from-k8scluster)" | ||
echo "####################################################################" | ||
|
||
source ../init.sh | ||
|
||
KEEP_PREV_KUBECONFIG=${OPTION02:-n} | ||
K8SCLUSTERID_ADD=${OPTION03:-1} | ||
LOCALIP=`hostname -I | cut -d' ' -f1` | ||
|
||
KUBECTL=kubectl | ||
if ! kubectl > /dev/null 2>&1; then | ||
if ! ./kubectl > /dev/null 2>&1; then | ||
# Download kubectl | ||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" | ||
chmod u+x ./kubectl | ||
fi | ||
KUBECTL=./kubectl | ||
fi | ||
|
||
if [ "${INDEX}" == "0" ]; then | ||
INDEXX=${NumCSP} | ||
for ((cspi = 1; cspi <= INDEXX; cspi++)); do | ||
INDEXY=${NumRegion[$cspi]} | ||
CSP=${CSPType[$cspi]} | ||
for ((cspj = 1; cspj <= INDEXY; cspj++)); do | ||
REGION=$cspj | ||
|
||
K8SCLUSTERID=${K8SCLUSTERID_PREFIX}${cspi}${cspj}${K8SCLUSTERID_ADD} | ||
|
||
echo "[Get K8sClusterInfo for ${K8SCLUSTERID}]" | ||
K8SCLUSTERINFO=$(curl -H "${AUTH}" -sX GET http://$TumblebugServer/tumblebug/ns/$NSID/k8scluster/${K8SCLUSTERID}) | ||
|
||
TMP_FILE_KUBECONFIG=$(mktemp ./${K8SCLUSTERID}-kubeconfig.XXXXXX || exit 1) | ||
if [ "${KEEP_PREV_KUBECONFIG}" != "y" ]; then | ||
echo "Delete Previous Kubeconfig Files" | ||
rm -f "${K8SCLUSTERID}-kubeconfig."* | ||
#trap 'echo "trapped"; rm -f -- "$TMP_FILE_KUBECONFIG"' EXIT | ||
fi | ||
|
||
ENDPOINT=$(jq -r '.AccessInfo.endpoint' <<<"$K8SCLUSTERINFO") | ||
if [[ ! $ENDPOINT =~ $ENDPOINT_REGEX ]]; then | ||
echo ".AccessInfo.endpoint ($ENDPOINT) is not valid" | ||
echo "Try again after about 5 minutes" | ||
continue | ||
fi | ||
|
||
echo "TMP_FILE_KUBECONFIG="$TMP_FILE_KUBECONFIG | ||
jq -r '.AccessInfo.kubeconfig' <<<"$K8SCLUSTERINFO" > $TMP_FILE_KUBECONFIG | ||
$KUBECTL --kubeconfig $TMP_FILE_KUBECONFIG delete -f ./nginx-with-pvc.yaml | ||
dozing 10 | ||
|
||
$KUBECTL --kubeconfig $TMP_FILE_KUBECONFIG get pv,pvc & | ||
done | ||
done | ||
wait | ||
|
||
fi | ||
|
||
echo "Done!" | ||
duration=$SECONDS | ||
|
||
printElapsed $@ | ||
echo "" | ||
|