Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

fix broken k8s-deploy #656

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions deploy/gk-deploy
Original file line number Diff line number Diff line change
@@ -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");
Expand All @@ -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
Expand Down Expand Up @@ -574,7 +574,7 @@ if [[ ! -f ${TOPOLOGY} ]]; then
echo "Topology File not found!"
exit 1
else
NODES=$(python - <<END
NODES=$(/usr/bin/python - <<END
# coding: utf8
import sys
import json
Expand Down Expand Up @@ -604,8 +604,8 @@ if [[ "x${ADMIN_KEY}" == "x" || "x${USER_KEY}" == "x" ]]; then
fi

if [[ "x${CLI}" == "x" ]]; then
kubectl=$(type kubectl 2>/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
Expand Down Expand Up @@ -921,7 +921,7 @@ while [[ "x${heketi_service}" == "x" ]] || [[ "${heketi_service}" == "<none>" ]]
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}')
Expand All @@ -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 '<ADMIN_KEY>' 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 '<ADMIN_KEY>' 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
Expand Down
6 changes: 5 additions & 1 deletion deploy/kube-templates/deploy-heketi-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
targetPort: 8080
---
kind: Deployment
apiVersion: extensions/v1beta1
apiVersion: apps/v1
metadata:
name: deploy-heketi
labels:
Expand All @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion deploy/kube-templates/gluster-s3-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ items:
status:
loadBalancer: {}
- kind: Deployment
apiVersion: extensions/v1beta1
apiVersion: apps/v1
metadata:
name: gluster-s3-deployment
labels:
Expand All @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion deploy/kube-templates/glusterfs-daemonset.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
kind: DaemonSet
apiVersion: extensions/v1beta1
apiVersion: apps/v1
metadata:
name: glusterfs
labels:
Expand All @@ -9,6 +9,10 @@ metadata:
description: GlusterFS DaemonSet
tags: glusterfs
spec:
selector:
matchLabels:
glusterfs: pod
glusterfs-node: pod
template:
metadata:
name: glusterfs
Expand Down
5 changes: 4 additions & 1 deletion deploy/kube-templates/heketi-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
targetPort: 8080
---
kind: Deployment
apiVersion: extensions/v1beta1
apiVersion: apps/v1
metadata:
name: heketi
labels:
Expand All @@ -26,6 +26,9 @@ metadata:
annotations:
description: Defines how to deploy Heketi
spec:
selector:
matchLabels:
glusterfs: heketi-pod
replicas: 1
template:
metadata:
Expand Down
17 changes: 9 additions & 8 deletions tests/simple/gk-deploy/test_gk_deploy_basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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}"

Expand All @@ -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}"

Expand Down Expand Up @@ -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}"

Expand Down Expand Up @@ -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}"

Expand Down