Created
January 14, 2022 13:23
-
-
Save rinormaloku/879095053126d8230fd29560eef6d491 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl --context=cluster1 create ns echo | |
kubectl --context=cluster1 label ns echo istio-injection=enabled | |
kubectl --context=cluster1 -n echo apply -f https://git.io/JyIRn | |
kubectl --context=cluster1 -n echo apply -f https://git.io/JyqPy | |
kubectl kubectl --context=mgmt apply -f - <<EOF | |
--- | |
apiVersion: networking.enterprise.mesh.gloo.solo.io/v1beta1 | |
kind: RateLimitServerConfig | |
metadata: | |
labels: | |
app: echo-policies | |
app.kubernetes.io/name: echo-policies | |
name: per-destination-counter | |
namespace: echo | |
spec: | |
raw: | |
setDescriptors: | |
- simpleDescriptors: | |
- key: destination_cluster | |
- key: user-identity | |
rateLimit: | |
requestsPerUnit: 4 | |
unit: MINUTE | |
--- | |
apiVersion: networking.enterprise.mesh.gloo.solo.io/v1beta1 | |
kind: VirtualGateway | |
metadata: | |
labels: | |
app: echo-policies | |
app.kubernetes.io/name: echo-policies | |
name: my-gateway | |
namespace: echo | |
spec: | |
connectionHandlers: | |
- http: | |
routeConfig: | |
- virtualHost: | |
domains: | |
- www.example.com | |
options: | |
trafficPolicy: | |
rateLimit: | |
raw: | |
rateLimits: | |
- setActions: | |
- destinationCluster: {} | |
- requestHeaders: | |
headerName: Authorization | |
descriptorKey: user-identity | |
ratelimitServerConfigSelector: | |
namespaces: | |
- echo | |
routes: | |
- matchers: | |
- uri: | |
prefix: / | |
name: ratings | |
routeAction: | |
destinations: | |
- kubeService: | |
clusterName: cluster1 | |
name: echo-v1 | |
namespace: echo | |
# - matchers: | |
# - uri: | |
# prefix: /reviews | |
# name: reviews | |
# routeAction: | |
# destinations: | |
# - kubeService: | |
# clusterName: cluster1 | |
# name: reviews | |
# namespace: echo | |
routeOptions: | |
rateLimit: | |
denyOnFail: true | |
ingressGatewaySelectors: | |
- portName: http2 | |
destinationSelectors: | |
- kubeServiceMatcher: | |
clusters: | |
- cluster1 | |
labels: | |
istio: ingressgateway | |
namespaces: | |
- istio-system | |
EOF | |
export INGRESS_GATEWAY_ENDPOINT=172.18.255.225 | |
array=("foo" "bar") | |
for AUTHZ in "${array[@]}" | |
do | |
echo "Executing with identity '$AUTHZ'" | |
for i in {1..5} | |
do | |
curl -s -o /dev/null -w "%{http_code}\n" -H "Host: www.example.com" -H "Authorization: Bearer $AUTHZ" $INGRESS_GATEWAY_ENDPOINT/ | |
done | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment