forked from QuincyChengAtWork/conjur-oss-k8s-authn-katacoda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6_deploy_testapp_without_conjur.sh
executable file
·56 lines (40 loc) · 1.68 KB
/
6_deploy_testapp_without_conjur.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
set -euo pipefail
export TEST_APP_NAMESPACE_NAME=${TEST_APP_NAMESPACE_NAME}-insecure
echo "Creating Test App namespace."
if ! kubectl get namespace $TEST_APP_NAMESPACE_NAME > /dev/null
then
kubectl create namespace $TEST_APP_NAMESPACE_NAME
fi
kubectl config set-context $(kubectl config current-context) --namespace=$TEST_APP_NAMESPACE_NAME
echo "Build test app image"
pushd test-app/pg
docker build -t test-app-pg:$CONJUR_NAMESPACE .
test_app_pg_image=test-app-pg
docker tag test-app-pg:$CONJUR_NAMESPACE $test_app_pg_image
popd
echo "Deploying test app Backend"
sed -e "s#{{ TEST_APP_PG_DOCKER_IMAGE }}#$test_app_pg_image#g" ./test-app/pg/postgres.yml |
sed -e "s#{{ TEST_APP_NAMESPACE_NAME }}#$TEST_APP_NAMESPACE_NAME#g" |
kubectl create -f -
echo "Building test app image"
pushd test-app
docker build -t test-app:$CONJUR_NAMESPACE -f Dockerfile .
test_app_image=test-app
docker tag test-app:$CONJUR_NAMESPACE $test_app_image
popd
echo "Deploying test app FrontEnd"
sed -e "s#{{ TEST_APP_DOCKER_IMAGE }}#$test_app_image#g" ./test-app/test-app.yml |
sed -e "s#{{ TEST_APP_NAMESPACE_NAME }}#$TEST_APP_NAMESPACE_NAME#g" |
kubectl create -f -
echo "Waiting for services to become available"
while [ -z "$(kubectl describe service test-app | grep 'LoadBalancer Ingress' | awk '{ print $3 }')" ]; do
printf "."
sleep 1
done
echo -e "Wait for 10 seconds\n"
sleep 10s
kubectl describe service test-app | grep 'LoadBalancer Ingress'
app_url=$(kubectl describe service test-app | grep 'LoadBalancer Ingress' | awk '{ print $3 }'):8080
echo -e "Adding entry to the app\n"
curl -d '{"name": "Insecure App"}' -H "Content-Type: application/json" $app_url/pet