-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path6_deploy_testapp_without_conjur.sh
executable file
·57 lines (41 loc) · 1.84 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
57
#!/bin/bash
set -euo pipefail
### SOLO EJECUTAR SI SE QUIERE DESPLEGAR LA APP DE PRUEBA PETS
## valida si existe el namespace de la app y si no lo crea
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 "Pushing postgres image to google registry"
pushd test-app/pg
docker build -t test-app-pg:$CONJUR_NAMESPACE .
test_app_pg_image=gcr.io/conjur-k8s-demo-230517/test-app-pg
docker tag test-app-pg:$CONJUR_NAMESPACE $test_app_pg_image
docker push $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=gcr.io/conjur-k8s-demo-230517/test-app
docker tag test-app:$CONJUR_NAMESPACE $test_app_image
docker push $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
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