From 40192a1a6928d62b4327d1d67eaa80b6e43287bf Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Fri, 22 May 2020 15:49:05 +0530 Subject: [PATCH 1/4] k8s-deploy: fix various yamls glusterfs daemonset fails to create, as the 'extensions/v1beta1' is depreciated switching to use 'apps/v1' Signed-off-by: Prasanna Kumar Kalever --- deploy/kube-templates/deploy-heketi-deployment.yaml | 6 +++++- deploy/kube-templates/gluster-s3-template.yaml | 5 ++++- deploy/kube-templates/glusterfs-daemonset.yaml | 6 +++++- deploy/kube-templates/heketi-deployment.yaml | 5 ++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/deploy/kube-templates/deploy-heketi-deployment.yaml b/deploy/kube-templates/deploy-heketi-deployment.yaml index 94f2cf7d..e8a7938b 100644 --- a/deploy/kube-templates/deploy-heketi-deployment.yaml +++ b/deploy/kube-templates/deploy-heketi-deployment.yaml @@ -17,7 +17,7 @@ spec: targetPort: 8080 --- kind: Deployment -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 metadata: name: deploy-heketi labels: @@ -26,6 +26,10 @@ metadata: annotations: description: Defines how to deploy Heketi spec: + selector: + matchLabels: + glusterfs: heketi-pod + deploy-heketi: pod replicas: 1 template: metadata: diff --git a/deploy/kube-templates/gluster-s3-template.yaml b/deploy/kube-templates/gluster-s3-template.yaml index 60045bc1..17bb941c 100644 --- a/deploy/kube-templates/gluster-s3-template.yaml +++ b/deploy/kube-templates/gluster-s3-template.yaml @@ -21,7 +21,7 @@ items: status: loadBalancer: {} - kind: Deployment - apiVersion: extensions/v1beta1 + apiVersion: apps/v1 metadata: name: gluster-s3-deployment labels: @@ -30,6 +30,9 @@ items: annotations: description: Defines how to deploy gluster s3 object storage spec: + selector: + matchLabels: + glusterfs: s3-pod replicas: 1 template: metadata: diff --git a/deploy/kube-templates/glusterfs-daemonset.yaml b/deploy/kube-templates/glusterfs-daemonset.yaml index c37a5f41..5f37d67a 100644 --- a/deploy/kube-templates/glusterfs-daemonset.yaml +++ b/deploy/kube-templates/glusterfs-daemonset.yaml @@ -1,6 +1,6 @@ --- kind: DaemonSet -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 metadata: name: glusterfs labels: @@ -9,6 +9,10 @@ metadata: description: GlusterFS DaemonSet tags: glusterfs spec: + selector: + matchLabels: + glusterfs: pod + glusterfs-node: pod template: metadata: name: glusterfs diff --git a/deploy/kube-templates/heketi-deployment.yaml b/deploy/kube-templates/heketi-deployment.yaml index ecc6cefa..9d252141 100644 --- a/deploy/kube-templates/heketi-deployment.yaml +++ b/deploy/kube-templates/heketi-deployment.yaml @@ -17,7 +17,7 @@ spec: targetPort: 8080 --- kind: Deployment -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 metadata: name: heketi labels: @@ -26,6 +26,9 @@ metadata: annotations: description: Defines how to deploy Heketi spec: + selector: + matchLabels: + glusterfs: heketi-pod replicas: 1 template: metadata: From 7623e0c9448f123c18f02a879ed9b76d12633914 Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Fri, 22 May 2020 15:55:48 +0530 Subject: [PATCH 2/4] gk-deploy: kubectl get pods --show-all option is depreciated remove deprecated flag --show-all Signed-off-by: Prasanna Kumar Kalever --- deploy/gk-deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/gk-deploy b/deploy/gk-deploy index e3735e14..4309b92d 100755 --- a/deploy/gk-deploy +++ b/deploy/gk-deploy @@ -921,7 +921,7 @@ while [[ "x${heketi_service}" == "x" ]] || [[ "${heketi_service}" == "" ]] heketi_service=$(${CLI} describe svc/heketi | grep "Endpoints:" | awk '{print $2}') done -heketi_pod=$(${CLI} get pod --no-headers --show-all --selector="heketi" | awk '{print $1}') +heketi_pod=$(${CLI} get pod --no-headers --selector="heketi" | awk '{print $1}') if [[ "${CLI}" == *oc\ * ]]; then heketi_service=$(${CLI} describe routes/heketi | grep "Requested Host:" | awk '{print $3}') From 7815b05515ecd32d86e0f1c5e6f4af788ed068ff Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Fri, 22 May 2020 16:02:11 +0530 Subject: [PATCH 3/4] summary: minor improvements at final output text Signed-off-by: Prasanna Kumar Kalever --- deploy/gk-deploy | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/deploy/gk-deploy b/deploy/gk-deploy index 4309b92d..947bdd23 100755 --- a/deploy/gk-deploy +++ b/deploy/gk-deploy @@ -938,21 +938,22 @@ if [[ "${hello}" != "Hello from Heketi" ]]; then exit 1 else debug "OK" + clear output " heketi is now running and accessible via http://${heketi_service} . To run administrative commands you can install 'heketi-cli' and use it as follows: - # heketi-cli -s http://${heketi_service} --user admin --secret '' cluster list + # heketi-cli -s http://${heketi_service} --user admin --secret '${ADMIN_KEY}' cluster list You can find it at https://github.com/heketi/heketi/releases . Alternatively, use it from within the heketi pod: - # ${CLI} exec -i ${heketi_pod} -- heketi-cli -s http://localhost:8080 --user admin --secret '' cluster list + # ${CLI} exec -i ${heketi_pod} -- heketi-cli -s http://localhost:8080 --user admin --secret '${ADMIN_KEY}' cluster list For dynamic provisioning, create a StorageClass similar to this: --- -apiVersion: storage.k8s.io/v1beta1 +apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: glusterfs-storage From 6f2b99d986151083078bcb16868901c150477fdb Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Fri, 22 May 2020 16:48:47 +0530 Subject: [PATCH 4/4] gk-deploy: fail to run without user-key and admin-key Signed-off-by: Prasanna Kumar Kalever --- deploy/gk-deploy | 12 ++++++------ tests/simple/gk-deploy/test_gk_deploy_basic.sh | 17 +++++++++-------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/deploy/gk-deploy b/deploy/gk-deploy index 947bdd23..796cb6c7 100755 --- a/deploy/gk-deploy +++ b/deploy/gk-deploy @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -x # Copyright (c) 2016 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -PROG="$(basename "${0}")" -SCRIPT_DIR="$(cd "$(dirname "${0}")" && pwd)" +PROG="$(/usr/bin/basename "${0}")" +SCRIPT_DIR="$(cd "$(/usr/bin/dirname "${0}")" && pwd)" TOPOLOGY='topology.json' LOG_FILE='' VERBOSE=0 @@ -574,7 +574,7 @@ if [[ ! -f ${TOPOLOGY} ]]; then echo "Topology File not found!" exit 1 else - NODES=$(python - </dev/null | awk '{print $3}') - oc=$(type oc 2>/dev/null | awk '{print $3}') + kubectl=$(type kubectl 2>/dev/null | /usr/bin/awk '{print $3}') + oc=$(type oc 2>/dev/null | /usr/bin/awk '{print $3}') if [[ "x${oc}" != "x" ]]; then CLI="${oc}" elif [[ "x${kubectl}" != "x" ]]; then diff --git a/tests/simple/gk-deploy/test_gk_deploy_basic.sh b/tests/simple/gk-deploy/test_gk_deploy_basic.sh index e359176b..b7a668df 100755 --- a/tests/simple/gk-deploy/test_gk_deploy_basic.sh +++ b/tests/simple/gk-deploy/test_gk_deploy_basic.sh @@ -8,6 +8,7 @@ BASE_DIR="${SCRIPT_DIR}/../../.." DEPLOY_DIR="${BASE_DIR}/deploy" GK_DEPLOY="${DEPLOY_DIR}/gk-deploy" +MANDATORY_OPTS="--admin-key 'key' --user-key 'key'" TOPOLOGY="${DEPLOY_DIR}/topology.json.sample" PATH="${STUBS_DIR}:$PATH" @@ -18,10 +19,10 @@ source "${INC_DIR}/shell_tests.sh" test_missing_topology () { local args=( -y ) - OUT=$("${GK_DEPLOY}" "${args[@]}") + OUT=$("${GK_DEPLOY}" "${MANDATORY_OPTS}" "${args[@]}") local rc=${?} - echo "cmd: '${GK_DEPLOY} ${args[*]}'" + echo "cmd: '${GK_DEPLOY} ${MANDATORY_OPTS} ${args[*]}'" echo "output:" echo "${OUT}" @@ -37,10 +38,10 @@ test_cli_not_found () { local args=( -y ) local expected_out="Container platform CLI (e.g. kubectl, oc) not found." - OUT=$(PATH='/doesnotexist' "${GK_DEPLOY}" "${args[@]}" "${TOPOLOGY}") + OUT=$(PATH='/doesnotexist' "${GK_DEPLOY}" "${MANDATORY_OPTS}" "${args[@]}" "${TOPOLOGY}") local rc=${?} - echo "cmd: 'PATH='/doesnotexist' ${GK_DEPLOY} ${args[*]} ${TOPOLOGY}'" + echo "cmd: 'PATH='/doesnotexist' ${GK_DEPLOY} ${MANDATORY_OPTS} ${args[*]} ${TOPOLOGY}'" echo "output:" echo "${OUT}" @@ -68,10 +69,10 @@ test_cli_unknown () { local args=( -y -c "${cli}" ) local expected_out="Unknown CLI '${cli}'." - OUT=$("${GK_DEPLOY}" "${args[@]}" "${TOPOLOGY}") + OUT=$("${GK_DEPLOY}" "${MANDATORY_OPTS}" "${args[@]}" "${TOPOLOGY}") local rc=${?} - echo "cmd: '${GK_DEPLOY} ${args[*]} ${TOPOLOGY}'" + echo "cmd: '${GK_DEPLOY} ${MANDATORY_OPTS} ${args[*]} ${TOPOLOGY}'" echo "output:" echo "${OUT}" @@ -99,10 +100,10 @@ test_namespace_invalid () { local expected_out="Namespace 'invalid' not found" # shellcheck disable=SC2086 - OUT=$("${GK_DEPLOY}" "${args[@]}" "${TOPOLOGY}") + OUT=$("${GK_DEPLOY}" "${MANDATORY_OPTS}" "${args[@]}" "${TOPOLOGY}") local rc=${?} - echo "cmd: '${GK_DEPLOY} ${args[*]} ${TOPOLOGY}'" + echo "cmd: '${GK_DEPLOY} ${MANDATORY_OPTS} ${args[*]} ${TOPOLOGY}'" echo "output:" echo "${OUT}"