Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Use kubectl describe foo name #196

Merged
merged 1 commit into from
Oct 19, 2018
Merged
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
40 changes: 23 additions & 17 deletions examples/hellogrpc/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,49 @@ if [[ -z "${1:-}" ]]; then
fi

get_lb_ip() {
kubectl --namespace=${USER} get service hello-grpc-staging \
-o jsonpath='{.status.loadBalancer.ingress[0].ip}'
kubectl --namespace=${USER} get service hello-grpc-staging \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put quotes around all variables

-o jsonpath='{.status.loadBalancer.ingress[0].ip}'
}

# Ensure there is an ip address for hell-grpc-staging:50051
apply-lb() {
echo Applying service...
bazel build examples/hellogrpc:staging-service.apply
bazel-bin/examples/hellogrpc/staging-service.apply
}

create() {
bazel build examples/hellogrpc/${LANGUAGE}/server:staging.create
bazel-bin/examples/hellogrpc/${LANGUAGE}/server/staging.create
echo Creating $LANGUAGE...
bazel build examples/hellogrpc/${LANGUAGE}/server:staging.create
bazel-bin/examples/hellogrpc/${LANGUAGE}/server/staging.create
}

check_msg() {
bazel build examples/hellogrpc/${LANGUAGE}/client
bazel build examples/hellogrpc/${LANGUAGE}/client

OUTPUT=$(./bazel-bin/examples/hellogrpc/${LANGUAGE}/client/client $(get_lb_ip))
echo Checking response from service: "${OUTPUT}" matches: "DEMO$1<space>"
echo "${OUTPUT}" | grep "DEMO$1[ ]"
OUTPUT=$(./bazel-bin/examples/hellogrpc/${LANGUAGE}/client/client $(get_lb_ip))
echo Checking response from service: "${OUTPUT}" matches: "DEMO$1<space>"
echo "${OUTPUT}" | grep "DEMO$1[ ]"
}

edit() {
./examples/hellogrpc/${LANGUAGE}/server/edit.sh "$1"
echo Setting $LANGUAGE to "$1"
./examples/hellogrpc/${LANGUAGE}/server/edit.sh "$1"
}

update() {
bazel build examples/hellogrpc/${LANGUAGE}/server:staging.replace
bazel-bin/examples/hellogrpc/${LANGUAGE}/server/staging.replace
echo Updating $LANGUAGE...
bazel build examples/hellogrpc/${LANGUAGE}/server:staging.replace
bazel-bin/examples/hellogrpc/${LANGUAGE}/server/staging.replace
}

delete() {
kubectl get all --namespace="${USER}" --selector=app=hello-grpc-staging
bazel build examples/hellogrpc/${LANGUAGE}/server:staging.describe
bazel-bin/examples/hellogrpc/${LANGUAGE}/server/staging.describe
bazel build examples/hellogrpc/${LANGUAGE}/server:staging.delete
bazel-bin/examples/hellogrpc/${LANGUAGE}/server/staging.delete
echo Deleting $LANGUAGE...
kubectl get all --namespace="${USER}" --selector=app=hello-grpc-staging
bazel build examples/hellogrpc/${LANGUAGE}/server:staging.describe
bazel-bin/examples/hellogrpc/${LANGUAGE}/server/staging.describe
bazel build examples/hellogrpc/${LANGUAGE}/server:staging.delete
bazel-bin/examples/hellogrpc/${LANGUAGE}/server/staging.delete
}


Expand All @@ -71,8 +76,9 @@ while [[ -n "${1:-}" ]]; do
LANGUAGE="$1"
shift

delete || true
create
trap "delete" EXIT
trap "echo FAILED, cleaning up...; delete" EXIT
sleep 25
check_msg ""

Expand Down
41 changes: 22 additions & 19 deletions examples/hellohttp/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ fi

get_lb_ip() {
kubectl --namespace=${USER} get service hello-http-staging \
-o jsonpath='{.status.loadBalancer.ingress[0].ip}'
-o jsonpath='{.status.loadBalancer.ingress[0].ip}'
}

# Ensure there is an ip address for hello-http-staging:8080
apply-lb() {
bazel run examples/hellohttp:staging-service.apply
echo Applying service...
bazel run examples/hellohttp:staging-service.apply
}

check_msg() {
Expand All @@ -40,33 +41,35 @@ check_msg() {
}

edit() {
./examples/hellohttp/${LANGUAGE}/edit.sh "$1"
echo Setting $LANGUAGE to "$1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please quote language var. We might want to lint with shellcheck

./examples/hellohttp/${LANGUAGE}/edit.sh "$1"
}

apply() {
bazel run examples/hellohttp/${LANGUAGE}:staging.apply
echo Applying $LANGUAGE...
bazel run examples/hellohttp/${LANGUAGE}:staging.apply
}

delete() {
kubectl get all --namespace="${USER}" --selector=app=hello-http-staging
bazel run examples/hellohttp/${LANGUAGE}:staging.describe
bazel run examples/hellohttp/${LANGUAGE}:staging.delete
echo Deleting $LANGUAGE...
kubectl get all --namespace="${USER}" --selector=app=hello-http-staging
bazel run examples/hellohttp/${LANGUAGE}:staging.describe
bazel run examples/hellohttp/${LANGUAGE}:staging.delete
}

check_bad_substitution() {
echo Checking a bad substitution
if ! bazel run examples/hellohttp:error-on-run;
then
echo "Success, substitution failed."
return
else
echo "Bad substitution should fail!"
exit 1
fi
echo Checking a bad substitution...
if ! bazel run examples/hellohttp:error-on-run; then
echo "Success, substitution failed."
return 0
else
echo "Bad substitution should fail!"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am a grammar critic it could read a tad better, but a nit pick

exit 1
fi
}

check_no_images_resolution() {
echo Checking resolution with no images attribute.
echo Checking resolution with no images attribute...
bazel build examples/hellohttp:resolve-external
OUTPUT=$(bazel-bin/examples/hellohttp/resolve-external 2>&1)
echo Checking output: "${OUTPUT}" matches: "/pause@"
Expand All @@ -83,8 +86,8 @@ while [[ -n "${1:-}" ]]; do
LANGUAGE="$1"
shift

apply
trap "delete" EXIT
apply # apply will handle already created
trap "echo FAILED, cleaning up...; delete" EXIT
sleep 25
check_msg ""

Expand Down
64 changes: 35 additions & 29 deletions examples/todocontroller/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,66 +18,72 @@ set -e
LANGUAGE="$1"

function get_lb_ip() {
kubectl --namespace=${USER} get service hello-grpc-staging \
-o jsonpath='{.status.loadBalancer.ingress[0].ip}'
kubectl --namespace=${USER} get service hello-grpc-staging \
-o jsonpath='{.status.loadBalancer.ingress[0].ip}'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again missing quotes around a bash var

}

function create() {
bazel build examples/todocontroller/${LANGUAGE}:staging.create
bazel-bin/examples/todocontroller/${LANGUAGE}/staging.create
bazel build examples/todocontroller:example-todo.create
bazel-bin/examples/todocontroller/example-todo.create
echo Creating $LANGUAGE...
bazel build examples/todocontroller/${LANGUAGE}:staging.create
bazel-bin/examples/todocontroller/${LANGUAGE}/staging.create
bazel build examples/todocontroller:example-todo.create
bazel-bin/examples/todocontroller/example-todo.create
}

function check_msg() {
bazel build examples/todocontroller:example-todo.describe
bazel build examples/todocontroller:example-todo.describe

OUTPUT=$(./bazel-bin/examples/todocontroller/example-todo.describe)
echo Checking response from service: "${OUTPUT}" matches: "DEMO$1<space>"
echo "${OUTPUT}" | grep "DEMO$1[ ]"
OUTPUT=$(./bazel-bin/examples/todocontroller/example-todo.describe)
echo Checking response from service: "${OUTPUT}" matches: "DEMO$1<space>"
echo "${OUTPUT}" | grep "DEMO$1[ ]"
}

function edit() {
./examples/todocontroller/${LANGUAGE}/edit.sh "$1"
echo Editing $LANGUAGE to $1...
./examples/todocontroller/${LANGUAGE}/edit.sh "$1"
}

function update_controller() {
bazel build examples/todocontroller/${LANGUAGE}:controller-deployment.replace
bazel-bin/examples/todocontroller/${LANGUAGE}/controller-deployment.replace
echo Replacing $LANGUAGE controller...
bazel build examples/todocontroller/${LANGUAGE}:controller-deployment.replace
bazel-bin/examples/todocontroller/${LANGUAGE}/controller-deployment.replace
}

function update_todo() {
bazel build examples/todocontroller:example-todo.replace
bazel-bin/examples/todocontroller/example-todo.replace
echo Replacing example-todo...
bazel build examples/todocontroller:example-todo.replace
bazel-bin/examples/todocontroller/example-todo.replace
}

function delete() {
bazel run examples/todocontroller/example-todo.describe
bazel run examples/todocontroller/${LANGUAGE}:controller-deployment.describe

bazel build examples/todocontroller/example-todo.delete
bazel-bin/examples/todocontroller/example-todo.delete
bazel build examples/todocontroller/${LANGUAGE}:staging.delete
bazel-bin/examples/todocontroller/${LANGUAGE}/staging.delete
echo Deleting $LANGUAGE...
bazel run examples/todocontroller/example-todo.describe
bazel run examples/todocontroller/${LANGUAGE}:controller-deployment.describe

bazel build examples/todocontroller/example-todo.delete
bazel-bin/examples/todocontroller/example-todo.delete
bazel build examples/todocontroller/${LANGUAGE}:staging.delete
bazel-bin/examples/todocontroller/${LANGUAGE}/staging.delete
}

function check_reverse_delete_k8s_object() {
echo Checking deletion in reverse order via k8s_object.
bazel run examples/todocontroller:joined.apply
bazel run examples/todocontroller:joined.delete
echo Checking deletion in reverse order via k8s_object...
bazel run examples/todocontroller:joined.apply
bazel run examples/todocontroller:joined.delete
}

function check_reverse_delete_k8s_objects() {
echo Checking deletion in reverse order via k8s_objects.
bazel run examples/todocontroller:everything.apply
bazel run examples/todocontroller:everything.delete
echo Checking deletion in reverse order via k8s_objects...
bazel run examples/todocontroller:everything.apply
bazel run examples/todocontroller:everything.delete
}

check_reverse_delete_k8s_object
check_reverse_delete_k8s_objects

delete || true
create
trap "delete" EXIT
trap "echo FAILED, cleaning up...; delete" EXIT
sleep 25
check_msg

Expand Down
7 changes: 4 additions & 3 deletions k8s/describe.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function guess_runfiles() {

RUNFILES="${PYTHON_RUNFILES:-$(guess_runfiles)}"

RESOURCE_NAME=$(kubectl create --dry-run -f "%{unresolved}" | cut -d'"' -f 2)
RESOURCE_NAME=$(kubectl create --dry-run -f "%{unresolved}" -o name | cut -d'"' -f 2)

kubectl --cluster="%{cluster}" --context="%{context}" --user="%{user}" %{namespace_arg} describe %{kind} \
"${RESOURCE_NAME}"
kubectl \
--cluster="%{cluster}" --context="%{context}" --user="%{user}" \
%{namespace_arg} describe "${RESOURCE_NAME}"