Skip to content

Commit 6ad9fb1

Browse files
committed
Add demo scripts
1 parent 26ff381 commit 6ad9fb1

14 files changed

+270
-30
lines changed

hack/demo/curl.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#! /bin/bash
2+
3+
ADDR=`kubectl -n foo-infra get gateway foo-gateway -o jsonpath='{.status.addresses[0].value}'`
4+
IP=`dig "$ADDR" +short | head -n1`
5+
DOMAIN=foo.kubecon23.tv2dev.dk
6+
7+
echo "-------------------------------------------------------------------"
8+
echo "Skipping DNS, using $DOMAIN = $IP"
9+
echo "-------------------------------------------------------------------"
10+
read -p "Press enter to run CURL commands"
11+
12+
echo "-------------------------------------------------------------------"
13+
echo ""
14+
echo "1x curl --resolve $DOMAIN:443:$IP https://$DOMAIN/site"
15+
curl --resolve $DOMAIN:443:$IP https://$DOMAIN/site
16+
17+
echo "-------------------------------------------------------------------"
18+
echo ""
19+
echo "20x curl --resolve $DOMAIN:443:$IP https://$DOMAIN/store"
20+
for i in {1..20}
21+
do
22+
curl --resolve $DOMAIN:443:$IP https://$DOMAIN/store
23+
done
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#! /bin/bash
2+
3+
NS=$1
4+
GWNAME=$2
5+
6+
NAME=gw-${NS}-${GWNAME}
7+
8+
kubectl delete securitygrouprule.ec2.aws.upbound.io/${NAME}-upstream15021
9+
kubectl delete securitygrouprule.ec2.aws.upbound.io/${NAME}-upstream80
10+
kubectl delete securitygrouprule.ec2.aws.upbound.io/${NAME}-egress15021
11+
kubectl delete securitygrouprule.ec2.aws.upbound.io/${NAME}-egress80
12+
kubectl delete securitygrouprule.ec2.aws.upbound.io/${NAME}-ingress
13+
kubectl delete lblistener.elbv2.aws.upbound.io/${NAME}
14+
kubectl delete lbtargetgroup.elbv2.aws.upbound.io/${NAME}
15+
kubectl delete lb.elbv2.aws.upbound.io/${NAME}
16+
kubectl delete securitygroup.ec2.aws.upbound.io/${NAME}

hack/demo/delete.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#! /bin/bash
2+
3+
set -x
4+
5+
SCOPE=${1:-""}
6+
7+
if [ -z "$SCOPE" ] || [ "$SCOPE" == "bifrost" ]; then
8+
helm uninstall -n bifrost-gateway-controller-system bifrost-gateway-controller
9+
fi
10+
11+
if [ -z "$SCOPE" ] || [ "$SCOPE" == "app" ]; then
12+
#kubectl delete -n foo-infra gateway foo-gateway
13+
#kubectl delete -n foo-site httproute foo-site
14+
#kubectl delete -n foo-store httproute foo-store
15+
kubectl delete -f test-data/getting-started/foo-namespaces.yaml
16+
fi
17+
18+
if [ -z "$SCOPE" ] || [ "$SCOPE" == "tenantconfig" ]; then
19+
kubectl delete -f hack/demo/namespace-gatewayclassconfig.yaml
20+
fi
21+
22+
if [ -z "$SCOPE" ] || [ "$SCOPE" == "acl" ]; then
23+
kubectl delete -n foo-infra GatewayConfig foo-gateway-custom-acl
24+
fi
25+
26+
if [ -z "$SCOPE" ] || [ "$SCOPE" == "clusterresources" ]; then
27+
hack/demo/delete-gw-cluster-resources.sh foo-infra foo-gateway
28+
fi
29+
30+
if [ -z "$SCOPE" ] || [ "$SCOPE" == "configs" ]; then
31+
kubectl delete -f hack/demo/gatewayclassconfig-public.yaml
32+
kubectl delete -f hack/demo/gatewayclassconfig-internal.yaml
33+
fi
34+
35+
if [ -z "$SCOPE" ] || [ "$SCOPE" == "blueprints" ]; then
36+
kubectl delete -f blueprints/gatewayclassblueprint-aws-alb-crossplane.yaml
37+
kubectl delete -f blueprints/gatewayclass-aws-alb-crossplane.yaml
38+
fi

hack/demo/foo-gateway.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: gateway.networking.k8s.io/v1beta1
2+
kind: Gateway
3+
metadata:
4+
name: foo-gateway
5+
namespace: foo-infra
6+
spec:
7+
gatewayClassName: aws-alb-crossplane-public
8+
listeners:
9+
- name: web
10+
port: 80
11+
protocol: HTTP
12+
hostname: "foo.kubecon23.tv2dev.dk"
13+
allowedRoutes:
14+
namespaces:
15+
from: Selector
16+
selector:
17+
matchLabels:
18+
allowGateway: foo

hack/demo/foo-namespaces.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: foo-infra
5+
labels:
6+
istio.io/rev: 1-16-1
7+
---
8+
apiVersion: v1
9+
kind: Namespace
10+
metadata:
11+
name: foo-site
12+
labels:
13+
allowGateway: foo
14+
---
15+
apiVersion: v1
16+
kind: Namespace
17+
metadata:
18+
name: foo-store
19+
labels:
20+
allowGateway: foo
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: gateway.tv2.dk/v1alpha1
2+
kind: GatewayClassConfig
3+
metadata:
4+
name: aws-alb-crossplane-internal
5+
namespace: bifrost-gateway-controller-system
6+
annotations:
7+
krm-apply-setters: "true"
8+
spec:
9+
override:
10+
region: eu-central-1
11+
vpcId: "vpc-0f0a7248b68315eb0" # kpt-set: ${vpcId}
12+
subnets: # kpt-set: ${privateSubnetIds}
13+
- subnet-0908fcb4afac15c67
14+
- subnet-067f253633e60287f
15+
- subnet-0f1a74a3ac6bba47e
16+
upstreamSecurityGroup: "sg-0a4c4eb536ac8bb09" # kpt-set: ${clusterNodeSecurityGroupId}
17+
internal: true
18+
tags:
19+
bifrost-gateway-controller/gatewayclass: aws-alb-crossplane-internal
20+
targetRef:
21+
group: gateway.networking.k8s.io
22+
kind: GatewayClass
23+
name: aws-alb-crossplane-internal
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: gateway.tv2.dk/v1alpha1
2+
kind: GatewayClassConfig
3+
metadata:
4+
name: aws-alb-crossplane-public
5+
namespace: bifrost-gateway-controller-system
6+
annotations:
7+
krm-apply-setters: "true"
8+
spec:
9+
override:
10+
region: eu-central-1
11+
vpcId: "vpc-0f0a7248b68315eb0" # kpt-set: ${vpcId}
12+
subnets: # kpt-set: ${publicSubnetIds}
13+
- subnet-02d99e9a066281659
14+
- subnet-06f748b0455d254af
15+
- subnet-0598d5f99b6958758
16+
upstreamSecurityGroup: "sg-0a4c4eb536ac8bb09" # kpt-set: ${clusterNodeSecurityGroupId}
17+
internal: false
18+
tags:
19+
bifrost-gateway-controller/gatewayclass: aws-alb-crossplane-public
20+
targetRef:
21+
group: gateway.networking.k8s.io
22+
kind: GatewayClass
23+
name: aws-alb-crossplane-public
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: gateway.tv2.dk/v1alpha1
2+
kind: GatewayClassConfig
3+
metadata:
4+
name: foo-infra-tenant-defaults
5+
namespace: foo-infra
6+
spec:
7+
override:
8+
certificateArn: arn:aws:acm:eu-central-1:123456789012:certificate/33ce4a38-aff0-4ad7-bc7c-275fe99556e1
9+
tags:
10+
tenant: foo-tenant
11+
targetRef:
12+
group: ""
13+
kind: Namespace
14+
name: foo-infra

hack/demo/setup.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#! /bin/bash
2+
3+
SCOPE=${1:-""}
4+
5+
if [ -z "$SCOPE" ] || [ "$SCOPE" == "blueprints" ]; then
6+
echo ""
7+
echo "-------------------------------------------------------------------"
8+
read -p "Press enter to deploy GatewayClassBlueprint + GatewayClass'es"
9+
kubectl apply -f blueprints/gatewayclassblueprint-aws-alb-crossplane.yaml
10+
kubectl apply -f blueprints/gatewayclass-aws-alb-crossplane.yaml
11+
fi
12+
13+
if [ -z "$SCOPE" ] || [ "$SCOPE" == "configs" ]; then
14+
echo ""
15+
echo "-------------------------------------------------------------------"
16+
read -p "Press enter to deploy GatewayClassConfig's"
17+
kubectl apply -f hack/demo/gatewayclassconfig-public.yaml
18+
kubectl apply -f hack/demo/gatewayclassconfig-internal.yaml
19+
fi
20+
21+
if [ -z "$SCOPE" ] || [ "$SCOPE" == "tenantconfig" ]; then
22+
echo ""
23+
echo "-------------------------------------------------------------------"
24+
read -p "Press enter to deploy namespace-default GatewayClassConfig's"
25+
kubectl apply -f hack/demo/foo-namespaces.yaml
26+
kubectl apply -f hack/demo/namespace-gatewayclassconfig.yaml
27+
fi
28+
29+
if [ -z "$SCOPE" ] || [ "$SCOPE" == "gateway" ]; then
30+
echo ""
31+
echo "-------------------------------------------------------------------"
32+
read -p "Press enter to deploy getting-started usecase Gateway"
33+
kubectl -n foo-infra apply -f hack/demo/foo-namespaces.yaml -f hack/demo/foo-gateway.yaml
34+
fi
35+
36+
if [ -z "$SCOPE" ] || [ "$SCOPE" == "acl" ]; then
37+
echo ""
38+
echo "-------------------------------------------------------------------"
39+
read -p "Press enter to show user GatewayConfig with ACL CIDR"
40+
hack/demo/test-add-user-acl.sh
41+
fi
42+
43+
if [ -z "$SCOPE" ] || [ "$SCOPE" == "app" ]; then
44+
echo ""
45+
echo "-------------------------------------------------------------------"
46+
read -p "Press enter to deploy getting-started usecase application"
47+
kubectl -n foo-site apply -f test-data/getting-started/app-foo-site.yaml
48+
kubectl -n foo-site apply -f test-data/getting-started/foo-site-httproute.yaml
49+
kubectl -n foo-store apply -f test-data/getting-started/app-foo-store-v1.yaml
50+
kubectl -n foo-store apply -f test-data/getting-started/app-foo-store-v2.yaml
51+
kubectl -n foo-store apply -f test-data/getting-started/foo-store-httproute.yaml
52+
fi
53+
54+
if [ -z "$SCOPE" ] || [ "$SCOPE" == "bifrost" ]; then
55+
echo ""
56+
echo "-------------------------------------------------------------------"
57+
read -p "Press enter to deploy bifrost-gateway-controller"
58+
helm repo add tv2-oss https://tv2-oss.github.io/bifrost-gateway-controller 2>/dev/null
59+
helm upgrade -i bifrost-gateway-controller tv2-oss/bifrost-gateway-controller --version 0.1.4 --values charts/bifrost-gateway-controller/ci/gatewayclassblueprint-crossplane-aws-alb-values.yaml -n bifrost-gateway-controller-system 2>/dev/null
60+
fi

hack/demo/show-resources.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#! /bin/bash
2+
3+
kubectl get gateway,lbs,lbtargetgroups -A | sed -E 's#(arn:aws:elasticloadbalancing:eu-central-1:)[0-9]+(:[-0-9a-z\/]+)#\11234567890\2#'

0 commit comments

Comments
 (0)