1
0
mirror of https://github.com/gryf/vmstrap.git synced 2025-12-18 12:00:31 +01:00
Files
vmstrap/create_client_server.sh
2020-10-07 12:55:12 +02:00

35 lines
942 B
Bash
Executable File

#!/usr/bin/env bash
function wait_for {
local command=$1
local amount=$2
while true; do
if eval "${command}"; then
break;
fi
sleep "${amount}"
done
}
kubectl create namespace foo
kubectl run --image kuryr/demo -n foo server
wait_for "kubectl get pod -A |grep server|grep -q Running" 1
kubectl expose pod/server -n foo --port 80 --target-port 8080 --name=foosrvr
sleep 6
wait_for "openstack loadbalancer list -f value -c name -c provisioning_status | grep foosrvr | grep -q ACTIVE" 4
kubectl run --image kuryr/demo -n foo client
wait_for "kubectl get pod -A |grep client|grep -q Running" 1
kubectl exec -ti -n foo client -- wget http://server.foo -q -O -
cat > policy_foo_deny_all.yaml << NIL
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all
namespace: foo
spec:
podSelector: {}
policyTypes:
- Ingress
NIL
kubectl apply -f policy_foo_deny_all.yaml