Skip to content

Commit

Permalink
Update k8gb curl demo to be usable for real deployments (#506)
Browse files Browse the repository at this point in the history
* Update k8gb curl demo to be usable for real deployments

* Make demo script https ready with optional verbose mode
* Simple docker build targets
* Paramterize hosts under test in main Makefile
* Simplify demo targets and make them single parametrized `demo`

Useful to survive end-to-end presentations when your local dns
got slammed just before the demo

Signed-off-by: Yury Tsarev <yury.tsarev@absa.africa>

* Implement PR suggestions

Signed-off-by: Yury Tsarev <yury.tsarev@absa.africa>
  • Loading branch information
ytsarev authored May 31, 2021
1 parent 1ba9dc6 commit 59aab19
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 11 deletions.
37 changes: 37 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,42 @@ These instructions will help you to set up and use local website authoring and t
- Open the `http://localhost:4000/` page in your browser.
- Website will automatically rebuild and refresh in the browser to accommodate the related code changes.

## End-to-end demo helper

The demo helper is designed to work with `podinfo` that was deployed by

```sh
make deploy-test-apps
```

It will configure `podinfo` to expose geotag as part of an HTTP response.

To test and/or demonstrate continuous query to GSLB enabled endpoint execute

```sh
make demo DEMO_URL=https://failover.test.exampledns.tk
```

The happy path will look like:

```sh
[Thu May 27 15:35:26 UTC 2021] ...

200 "message": "eu-west-1",

[Thu May 27 15:35:31 UTC 2021] ...

200
"message": "eu-west-1",
[Thu May 27 15:35:36 UTC 2021] ...
```

The sources for demo helper images can be found [here](deploy/test-apps/curldemo/)

To enable verbose debug output declare `DEMO_DEBUG=1` like
```sh
make demo DEMO_URL=https://failover.test.exampledns.tk DEMO_DEBUG=1
```

---
Thanks for contributing!
15 changes: 6 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ EXT_GSLB_CLUSTERS_GEO_TAGS ?= us
EDGE_DNS_SERVER ?= 1.1.1.1
EDGE_DNS_ZONE ?= example.com
DNS_ZONE ?= cloud.example.com
DEMO_URL ?= http://failover.cloud.example.com
DEMO_DEBUG ?=0

ifndef NO_COLOR
YELLOW=\033[0;33m
Expand Down Expand Up @@ -102,14 +104,9 @@ debug-idea: export WATCH_NAMESPACE=test-gslb
debug-idea:
$(call debug,debug --headless --listen=:2345 --api-version=2)

.PHONY: demo-roundrobin
demo-roundrobin: ## Execute round-robin demo
@$(call demo-host, "roundrobin.cloud.example.com")

.PHONY: demo-failover
demo-failover: ## Execute failover demo
@$(call demo-host, "failover.cloud.example.com")

.PHONY: demo
demo: ## Execute end-to-end demo
@$(call demo-host, $(DEMO_URL))

# spin-up local environment
.PHONY: deploy-full-local-setup
Expand Down Expand Up @@ -436,7 +433,7 @@ define testapp-set-replicas
endef

define demo-host
kubectl run -it --rm k8gbdemo --restart=Never --image=absaoss/k8gbdemocurl \
kubectl run -it --rm k8gb-demo --restart=Never --image=absaoss/k8gb-demo-curl --env="DEBUG=$(DEMO_DEBUG)" \
"`$(K8GB_COREDNS_IP)`" $1
endef

Expand Down
22 changes: 22 additions & 0 deletions deploy/test-apps/curldemo/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2021 The k8gb Contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Generated by GoLic, for more details see: https://github.com/AbsaOSS/golic
.PHONY: docker-build
docker-build:
docker build . -t absaoss/k8gb-demo-curl

.PHONY: docker-push
docker-push:
docker push absaoss/k8gb-demo-curl
9 changes: 7 additions & 2 deletions deploy/test-apps/curldemo/k8gbcurl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@
# $1 - nameserver to use usually k8gb-coredns service ip
# $2 - test fqdn to resolve in demo loops

if [ "$DEBUG" == 1 ]
then
set -x
fi

if [ "$1" != '--local' ]
then
echo "nameserver $1" > /etc/resolv.conf
fi

fqdn="$2"
url="$2"

while true
do
curl -k -s -w "%{stderr}\n%{http_code}\n" --location --request GET "${fqdn}" |grep message
curl -k -s -w "%{stderr}\n%{http_code}\n" --location --request GET "${url}" |grep message
sleep 5
echo "[`date`] ..."
done

0 comments on commit 59aab19

Please sign in to comment.