Created
December 8, 2021 04:39
-
-
Save jpeach/5b757b17cdd0ca90589bac3d511bfadf 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
#! /usr/bin/env bash | |
set -o errexit | |
readonly ENVOY=${ENVOY:-${HOME}/.getenvoy/versions/1.18.3/bin/envoy} | |
readonly DPTYPE=dataplane | |
exec kuma-dp run \ | |
--binary-path=$ENVOY \ | |
--dataplane-token=$(kumactl generate dataplane-token --proxy-type=${DPTYPE}) \ | |
--proxy-type=${DPTYPE} \ | |
--dataplane-file=<( | |
cat <<EOF | |
type: Dataplane | |
mesh: default | |
name: greenling | |
networking: | |
address: 127.0.0.1 | |
gateway: | |
type: BUILTIN | |
tags: | |
kuma.io/service: edge-gateway | |
EOF | |
) "$@" | |
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
#! /usr/bin/env bash | |
set -o errexit | |
clean::name() { | |
echo "$@" | tr --delete --complement '[0-9a-z]_-' | |
} | |
kill::tagged() { | |
kill -TERM $(ps e | grep --fixed-strings -e "KILLTAG=$KILLTAG" | awk '{print $1}') 2>/dev/null | |
} | |
readonly ENVOY=${ENVOY:-${HOME}/.getenvoy/versions/1.18.3/bin/envoy} | |
readonly KILLTAG="$(basename $0)-$RANDOM" | |
readonly NAME=$(clean::name $(basename $0)) | |
trap kill::tagged EXIT | |
kumactl apply -f <( | |
cat <<EOF | |
type: Dataplane | |
mesh: default | |
name: $NAME | |
networking: | |
address: 127.0.0.1 | |
inbound: | |
- port: 20011 | |
servicePort: 10011 | |
tags: | |
kuma.io/service: echo-service | |
EOF | |
) | |
env KILLTAG=$KILLTAG \ | |
test-server echo --instance="$(basename $0)-$$" --port=10011 & | |
env KILLTAG=$KILLTAG \ | |
kuma-dp run \ | |
--binary-path=$ENVOY \ | |
--dataplane-token=$(kumactl generate dataplane-token --proxy-type=dataplane) \ | |
--proxy-type=dataplane \ | |
--mesh=default \ | |
--name=$NAME \ | |
"$@" & | |
wait |
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
#! /usr/bin/env bash | |
set -o errexit | |
kumactl apply -f <( | |
cat <<EOF | |
type: Mesh | |
name: default | |
mtls: | |
enabledBackend: builtin | |
backends: | |
- name: builtin | |
type: builtin | |
EOF | |
) |
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
#! /usr/bin/env bash | |
set -o errexit | |
kumactl apply -f <( | |
cat <<EOF | |
type: Gateway | |
mesh: default | |
name: edge-gateway | |
selectors: | |
- match: | |
kuma.io/service: edge-gateway | |
conf: | |
listeners: | |
- port: 8080 | |
protocol: HTTP | |
hostname: foo.example.com | |
tags: | |
name: foo.example.com | |
EOF | |
) | |
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
#! /usr/bin/env bash | |
set -o errexit | |
kumactl apply -f <( | |
cat <<EOF | |
type: Gateway | |
mesh: default | |
name: edge-gateway | |
sources: | |
- match: | |
kuma.io/service: edge-gateway | |
conf: | |
listeners: | |
- port: 8080 | |
protocol: HTTP | |
hostname: foo.example.com | |
tags: | |
name: foo.example.com | |
- port: 8080 | |
protocol: HTTP | |
hostname: bar.example.com | |
tags: | |
name: bar.example.com | |
EOF | |
) | |
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
#! /usr/bin/env bash | |
set -o errexit | |
kumactl apply -f <( | |
cat <<EOF | |
type: GatewayRoute | |
mesh: default | |
name: edge-gateway | |
selectors: | |
- match: | |
kuma.io/service: edge-gateway | |
conf: | |
http: | |
rules: | |
- matches:#! /usr/bin/env bash | |
set -o errexit | |
readonly SERVICENAME=${SERVICENAME:-edge-gateway} | |
echo Creating external service | |
kumactl apply -f <( | |
cat <<EOF | |
type: ExternalService | |
mesh: default | |
name: httpbin | |
tags: | |
kuma.io/service: httpbin | |
kuma.io/protocol: http | |
networking: | |
address: httpbin.org:443 | |
tls: | |
enabled: true | |
sni: httpbin.org | |
EOF | |
) | |
echo Creating gateway | |
kumactl apply -f <( | |
cat <<EOF | |
type: Gateway | |
mesh: default | |
name: httpbin-gateway | |
selectors: | |
- match: | |
kuma.io/service: ${SERVICENAME} | |
conf: | |
listeners: | |
- port: 8080 | |
protocol: HTTP | |
hostname: 'zero.example.com' | |
tags: | |
name: example.com | |
- port: 8081 | |
protocol: HTTP | |
hostname: 'one.example.com' | |
tags: | |
name: example.com | |
EOF | |
) | |
echo Creating routes | |
kumactl apply -f <( | |
cat <<EOF | |
type: GatewayRoute | |
mesh: default | |
name: httpbin-routes | |
selectors: | |
- match: | |
kuma.io/service: ${SERVICENAME} | |
conf: | |
http: | |
rules: | |
- matches: | |
- path: | |
match: PREFIX | |
value: / | |
backends: | |
- destination: | |
kuma.io/service: httpbin | |
EOF | |
) | |
- path: | |
match: PREFIX | |
value: / | |
backends: | |
- destination: | |
kuma.io/service: echo-service | |
EOF | |
) |
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
#! /usr/bin/env bash | |
set -o errexit | |
readonly SERVICENAME=${SERVICENAME:-edge-gateway} | |
echo Creating external service | |
kumactl apply -f <( | |
cat <<EOF | |
type: ExternalService | |
mesh: default | |
name: httpbin | |
tags: | |
kuma.io/service: httpbin | |
kuma.io/protocol: http | |
networking: | |
address: httpbin.org:443 | |
tls: | |
enabled: true | |
sni: httpbin.org | |
EOF | |
) | |
echo Creating gateway | |
kumactl apply -f <( | |
cat <<EOF | |
type: Gateway | |
mesh: default | |
name: httpbin-gateway | |
selectors: | |
- match: | |
kuma.io/service: ${SERVICENAME} | |
conf: | |
listeners: | |
- port: 8080 | |
protocol: HTTP | |
hostname: 'zero.example.com' | |
tags: | |
name: example.com | |
- port: 8081 | |
protocol: HTTP | |
hostname: 'one.example.com' | |
tags: | |
name: example.com | |
EOF | |
) | |
echo Creating routes | |
kumactl apply -f <( | |
cat <<EOF | |
type: GatewayRoute | |
mesh: default | |
name: httpbin-routes | |
selectors: | |
- match: | |
kuma.io/service: ${SERVICENAME} | |
conf: | |
http: | |
rules: | |
- matches: | |
- path: | |
match: PREFIX | |
value: / | |
backends: | |
- destination: | |
kuma.io/service: httpbin | |
EOF | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Let's get this in a repo somewhere.
I think something went wrong here:
https://gist.github.com/jpeach/5b757b17cdd0ca90589bac3d511bfadf#file-06-gatewayroute-sh-L16