This repository has been archived by the owner on Apr 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
deploy-traffic-target.sh
executable file
·99 lines (84 loc) · 2.21 KB
/
deploy-traffic-target.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
set -aueo pipefail
# shellcheck disable=SC1091
source .env
kubectl apply -f - <<EOF
kind: TrafficTarget
apiVersion: access.smi-spec.io/v1alpha3
metadata:
name: bookbuyer-access-bookstore-v1
namespace: "$BOOKSTORE_NAMESPACE"
spec:
destination:
kind: ServiceAccount
name: bookstore-v1
namespace: "$BOOKSTORE_NAMESPACE"
rules:
- kind: HTTPRouteGroup
name: bookstore-service-routes
matches:
- buy-a-book
- books-bought
sources:
- kind: ServiceAccount
name: bookbuyer
namespace: "$BOOKBUYER_NAMESPACE"
# TrafficTarget is deny-by-default policy: if traffic from source to destination is not
# explicitly declared in this policy - it will be blocked.
# Should we ever want to allow traffic from bookthief to bookstore the block below needs
# uncommented.
# - kind: ServiceAccount
# name: bookthief
# namespace: "$BOOKTHIEF_NAMESPACE"
---
kind: TrafficTarget
apiVersion: access.smi-spec.io/v1alpha3
metadata:
name: bookbuyer-access-bookstore-v2
namespace: "$BOOKSTORE_NAMESPACE"
spec:
destination:
kind: ServiceAccount
name: bookstore-v2
namespace: "$BOOKSTORE_NAMESPACE"
rules:
- kind: HTTPRouteGroup
name: bookstore-service-routes
matches:
- buy-a-book
- books-bought
sources:
- kind: ServiceAccount
name: bookbuyer
namespace: "$BOOKBUYER_NAMESPACE"
# TrafficTarget is deny-by-default policy: if traffic from source to destination is not
# explicitly declared in this policy - it will be blocked.
# Should we ever want to allow traffic from bookthief to bookstore the block below needs
# uncommented.
# - kind: ServiceAccount
# name: bookthief
# namespace: "$BOOKTHIEF_NAMESPACE"
---
kind: TrafficTarget
apiVersion: access.smi-spec.io/v1alpha3
metadata:
name: bookstore-access-bookwarehouse
namespace: "$BOOKWAREHOUSE_NAMESPACE"
spec:
destination:
kind: ServiceAccount
name: bookwarehouse
namespace: "$BOOKWAREHOUSE_NAMESPACE"
rules:
- kind: HTTPRouteGroup
name: bookwarehouse-service-routes
matches:
- restock-books
sources:
- kind: ServiceAccount
name: bookstore-v1
namespace: "$BOOKSTORE_NAMESPACE"
- kind: ServiceAccount
name: bookstore-v2
namespace: "$BOOKSTORE_NAMESPACE"
EOF