mirror of https://github.com/istio/istio.io.git
215 lines
6.2 KiB
Plaintext
215 lines
6.2 KiB
Plaintext
# Created by TestMirror. DO NOT EDIT THIS FILE MANUALLY!
|
|
|
|
$snippet httpbin_deployment_v1.sh syntax="bash"
|
|
$ cat <<EOF | istioctl kube-inject -f - | kubectl -n istio-io-mirror create -f -
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: httpbin-v1
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: httpbin
|
|
version: v1
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: httpbin
|
|
version: v1
|
|
spec:
|
|
containers:
|
|
- image: docker.io/kennethreitz/httpbin
|
|
imagePullPolicy: IfNotPresent
|
|
name: httpbin
|
|
command: ["gunicorn", "--access-logfile", "-", "-b", "0.0.0.0:80", "httpbin:app"]
|
|
ports:
|
|
- containerPort: 80
|
|
EOF
|
|
$endsnippet
|
|
|
|
$snippet httpbin_deployment_v2.sh syntax="bash"
|
|
$ cat <<EOF | istioctl kube-inject -f - | kubectl -n istio-io-mirror create -f -
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: httpbin-v2
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: httpbin
|
|
version: v2
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: httpbin
|
|
version: v2
|
|
spec:
|
|
containers:
|
|
- image: docker.io/kennethreitz/httpbin
|
|
imagePullPolicy: IfNotPresent
|
|
name: httpbin
|
|
command: ["gunicorn", "--access-logfile", "-", "-b", "0.0.0.0:80", "httpbin:app"]
|
|
ports:
|
|
- containerPort: 80
|
|
EOF
|
|
$endsnippet
|
|
|
|
$snippet httpbin_service.sh syntax="bash"
|
|
$ kubectl -n istio-io-mirror create -f - <<EOF
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: httpbin
|
|
labels:
|
|
app: httpbin
|
|
spec:
|
|
ports:
|
|
- name: http
|
|
port: 8000
|
|
targetPort: 80
|
|
selector:
|
|
app: httpbin
|
|
EOF
|
|
$endsnippet
|
|
|
|
$snippet sleep_deployment.sh syntax="bash"
|
|
$ cat <<EOF | istioctl kube-inject -f - | kubectl -n istio-io-mirror create -f -
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: sleep
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: sleep
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: sleep
|
|
spec:
|
|
containers:
|
|
- name: sleep
|
|
image: tutum/curl
|
|
command: ["/bin/sleep","infinity"]
|
|
imagePullPolicy: IfNotPresent
|
|
EOF
|
|
$endsnippet
|
|
|
|
$snippet httpbin_policy.sh syntax="bash"
|
|
$ kubectl -n istio-io-mirror apply -f - <<EOF
|
|
apiVersion: networking.istio.io/v1alpha3
|
|
kind: VirtualService
|
|
metadata:
|
|
name: httpbin
|
|
spec:
|
|
hosts:
|
|
- httpbin
|
|
http:
|
|
- route:
|
|
- destination:
|
|
host: httpbin
|
|
subset: v1
|
|
weight: 100
|
|
---
|
|
apiVersion: networking.istio.io/v1alpha3
|
|
kind: DestinationRule
|
|
metadata:
|
|
name: httpbin
|
|
spec:
|
|
host: httpbin
|
|
subsets:
|
|
- name: v1
|
|
labels:
|
|
version: v1
|
|
- name: v2
|
|
labels:
|
|
version: v2
|
|
EOF
|
|
$endsnippet
|
|
|
|
$snippet generate_traffic_1.sh syntax="bash"
|
|
$ export SLEEP_POD=$(kubectl -n istio-io-mirror get pod -l app=sleep -o jsonpath={.items..metadata.name})
|
|
$ kubectl -n istio-io-mirror exec ${SLEEP_POD} -c sleep -- curl -o /dev/null -s -w "%{http_code}\n" http://httpbin:8000/ISTIO_IO_MIRROR_TEST_1
|
|
$endsnippet
|
|
|
|
$snippet check_logs_v1_1.sh syntax="bash" outputis="text"
|
|
$ export V1_POD=$(kubectl -n istio-io-mirror get pod -l app=httpbin,version=v1 -o jsonpath={.items..metadata.name})
|
|
$ kubectl -n istio-io-mirror logs ${V1_POD} -c httpbin
|
|
[2019-11-14 14:32:22 +0000] [1] [INFO] Starting gunicorn 19.9.0
|
|
[2019-11-14 14:32:22 +0000] [1] [INFO] Listening at: http://0.0.0.0:80 (1)
|
|
[2019-11-14 14:32:22 +0000] [1] [INFO] Using worker: sync
|
|
[2019-11-14 14:32:22 +0000] [9] [INFO] Booting worker with pid: 9
|
|
127.0.0.1 - - [14/Nov/2019:14:32:49 +0000] "GET /ISTIO_IO_MIRROR_TEST_1 HTTP/1.1" 404 233 "-" "curl/7.35.0"
|
|
$endsnippet
|
|
|
|
$snippet check_logs_v2_1.sh syntax="bash" outputis="text"
|
|
$ export V2_POD=$(kubectl -n istio-io-mirror get pod -l app=httpbin,version=v2 -o jsonpath={.items..metadata.name})
|
|
$ kubectl -n istio-io-mirror logs ${V2_POD} -c httpbin
|
|
[2019-11-14 14:32:22 +0000] [1] [INFO] Starting gunicorn 19.9.0
|
|
[2019-11-14 14:32:22 +0000] [1] [INFO] Listening at: http://0.0.0.0:80 (1)
|
|
[2019-11-14 14:32:22 +0000] [1] [INFO] Using worker: sync
|
|
[2019-11-14 14:32:22 +0000] [8] [INFO] Booting worker with pid: 8
|
|
$endsnippet
|
|
|
|
$snippet mirror_vs.sh syntax="bash"
|
|
$ kubectl -n istio-io-mirror apply -f - <<EOF
|
|
apiVersion: networking.istio.io/v1alpha3
|
|
kind: VirtualService
|
|
metadata:
|
|
name: httpbin
|
|
spec:
|
|
hosts:
|
|
- httpbin
|
|
http:
|
|
- route:
|
|
- destination:
|
|
host: httpbin
|
|
subset: v1
|
|
weight: 100
|
|
mirror:
|
|
host: httpbin
|
|
subset: v2
|
|
mirror_percent: 100
|
|
EOF
|
|
$endsnippet
|
|
|
|
$snippet generate_traffic_2.sh syntax="bash"
|
|
$ export SLEEP_POD=$(kubectl -n istio-io-mirror get pod -l app=sleep -o jsonpath={.items..metadata.name})
|
|
$ kubectl -n istio-io-mirror exec ${SLEEP_POD} -c sleep -- curl --retry 3 -o /dev/null -s -w "%{http_code}\n" http://httpbin:8000/ISTIO_IO_MIRROR_TEST_2
|
|
$endsnippet
|
|
|
|
$snippet check_logs_v1_2.sh syntax="bash" outputis="text"
|
|
$ export V1_POD=$(kubectl -n istio-io-mirror get pod -l app=httpbin,version=v1 -o jsonpath={.items..metadata.name})
|
|
$ kubectl -n istio-io-mirror logs ${V1_POD} -c httpbin
|
|
[2019-11-14 14:32:22 +0000] [1] [INFO] Starting gunicorn 19.9.0
|
|
[2019-11-14 14:32:22 +0000] [1] [INFO] Listening at: http://0.0.0.0:80 (1)
|
|
[2019-11-14 14:32:22 +0000] [1] [INFO] Using worker: sync
|
|
[2019-11-14 14:32:22 +0000] [9] [INFO] Booting worker with pid: 9
|
|
127.0.0.1 - - [14/Nov/2019:14:32:49 +0000] "GET /ISTIO_IO_MIRROR_TEST_1 HTTP/1.1" 404 233 "-" "curl/7.35.0"
|
|
127.0.0.1 - - [14/Nov/2019:14:33:00 +0000] "GET /ISTIO_IO_MIRROR_TEST_2 HTTP/1.1" 404 233 "-" "curl/7.35.0"
|
|
$endsnippet
|
|
|
|
$snippet check_logs_v2_2.sh syntax="bash" outputis="text"
|
|
$ export V2_POD=$(kubectl -n istio-io-mirror get pod -l app=httpbin,version=v2 -o jsonpath={.items..metadata.name})
|
|
$ kubectl -n istio-io-mirror logs ${V2_POD} -c httpbin
|
|
[2019-11-14 14:32:22 +0000] [1] [INFO] Starting gunicorn 19.9.0
|
|
[2019-11-14 14:32:22 +0000] [1] [INFO] Listening at: http://0.0.0.0:80 (1)
|
|
[2019-11-14 14:32:22 +0000] [1] [INFO] Using worker: sync
|
|
[2019-11-14 14:32:22 +0000] [8] [INFO] Booting worker with pid: 8
|
|
127.0.0.1 - - [14/Nov/2019:14:33:00 +0000] "GET /ISTIO_IO_MIRROR_TEST_2 HTTP/1.1" 404 233 "-" "curl/7.35.0"
|
|
$endsnippet
|
|
|
|
$snippet remove_rules.sh syntax="bash"
|
|
$ kubectl delete virtualservice httpbin
|
|
$ kubectl delete destinationrule httpbin
|
|
$endsnippet
|
|
|
|
$snippet remove_httpbin.sh syntax="bash"
|
|
$ kubectl delete deploy httpbin-v1 httpbin-v2 sleep
|
|
$ kubectl delete svc httpbin
|
|
$endsnippet
|
|
|