1
0
mirror of https://github.com/gryf/vmstrap.git synced 2025-12-18 12:00:31 +01:00

Add simple scripts for creating client/server pods

This commit is contained in:
2020-10-06 13:53:21 +02:00
parent 6c7b7dac1b
commit 2bf6c4066d
2 changed files with 41 additions and 0 deletions

34
create_client_server.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/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

7
delete_client_server.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
kubectl -n foo delete networkpolicy deny_all
kubectl -n foo delete pod client
kubectl -n foo delete service foosrvr # remove LB
kubectl -n foo delete pod server
kubectl delete namespace foo