mirror of https://github.com/istio/istio.io.git
Partial convert mirror test to new model (#7153)
Reverted the actual mirror test script, because mirror test seems to have some subtle failure when running with what seems to be the exact same commands via snips. Will investigate further in followup PR. Merging this one to get the generator changes.
This commit is contained in:
parent
1449b54534
commit
1fe7056ffa
|
@ -1,6 +1,5 @@
|
|||
#!/bin/bash
|
||||
# shellcheck disable=SC2153
|
||||
# shellcheck disable=SC2034
|
||||
# shellcheck disable=SC2034,SC2153,SC2155
|
||||
|
||||
# Copyright Istio Authors. All Rights Reserved.
|
||||
#
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#!/bin/bash
|
||||
# shellcheck disable=SC2153
|
||||
# shellcheck disable=SC2034
|
||||
# shellcheck disable=SC2034,SC2153,SC2155
|
||||
|
||||
# Copyright Istio Authors. All Rights Reserved.
|
||||
#
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#!/bin/bash
|
||||
# shellcheck disable=SC2153
|
||||
# shellcheck disable=SC2034
|
||||
# shellcheck disable=SC2034,SC2153,SC2155
|
||||
|
||||
# Copyright Istio Authors. All Rights Reserved.
|
||||
#
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#!/bin/bash
|
||||
# shellcheck disable=SC2153
|
||||
# shellcheck disable=SC2034
|
||||
# shellcheck disable=SC2034,SC2153,SC2155
|
||||
|
||||
# Copyright Istio Authors. All Rights Reserved.
|
||||
#
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#!/bin/bash
|
||||
# shellcheck disable=SC2153
|
||||
# shellcheck disable=SC2034
|
||||
# shellcheck disable=SC2034,SC2153,SC2155
|
||||
|
||||
# Copyright Istio Authors. All Rights Reserved.
|
||||
#
|
||||
|
|
|
@ -3,6 +3,7 @@ title: Mirroring
|
|||
description: This task demonstrates the traffic mirroring/shadowing capabilities of Istio.
|
||||
weight: 60
|
||||
keywords: [traffic-management,mirroring]
|
||||
test: true
|
||||
---
|
||||
|
||||
This task demonstrates the traffic mirroring capabilities of Istio.
|
||||
|
@ -175,7 +176,7 @@ In this step, you will change that behavior so that all traffic goes to `v1`.
|
|||
|
||||
{{< text bash json >}}
|
||||
$ export SLEEP_POD=$(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name})
|
||||
$ kubectl exec -it $SLEEP_POD -c sleep -- sh -c 'curl http://httpbin:8000/headers' | python -m json.tool
|
||||
$ kubectl exec -it "$SLEEP_POD" -c sleep -- sh -c 'curl http://httpbin:8000/headers' | python -m json.tool
|
||||
{
|
||||
"headers": {
|
||||
"Accept": "*/*",
|
||||
|
@ -195,13 +196,13 @@ log entries for `v1` and none for `v2`:
|
|||
|
||||
{{< text bash >}}
|
||||
$ export V1_POD=$(kubectl get pod -l app=httpbin,version=v1 -o jsonpath={.items..metadata.name})
|
||||
$ kubectl logs -f $V1_POD -c httpbin
|
||||
$ kubectl logs -f "$V1_POD" -c httpbin
|
||||
127.0.0.1 - - [07/Mar/2018:19:02:43 +0000] "GET /headers HTTP/1.1" 200 321 "-" "curl/7.35.0"
|
||||
{{< /text >}}
|
||||
|
||||
{{< text bash >}}
|
||||
$ export V2_POD=$(kubectl get pod -l app=httpbin,version=v2 -o jsonpath={.items..metadata.name})
|
||||
$ kubectl logs -f $V2_POD -c httpbin
|
||||
$ kubectl logs -f "$V2_POD" -c httpbin
|
||||
<none>
|
||||
{{< /text >}}
|
||||
|
||||
|
@ -245,20 +246,20 @@ log entries for `v1` and none for `v2`:
|
|||
1. Send in traffic:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl exec -it $SLEEP_POD -c sleep -- sh -c 'curl http://httpbin:8000/headers' | python -m json.tool
|
||||
$ kubectl exec -it "$SLEEP_POD" -c sleep -- sh -c 'curl http://httpbin:8000/headers' | python -m json.tool
|
||||
{{< /text >}}
|
||||
|
||||
Now, you should see access logging for both `v1` and `v2`. The access logs
|
||||
created in `v2` are the mirrored requests that are actually going to `v1`.
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl logs -f $V1_POD -c httpbin
|
||||
$ kubectl logs -f "$V1_POD" -c httpbin
|
||||
127.0.0.1 - - [07/Mar/2018:19:02:43 +0000] "GET /headers HTTP/1.1" 200 321 "-" "curl/7.35.0"
|
||||
127.0.0.1 - - [07/Mar/2018:19:26:44 +0000] "GET /headers HTTP/1.1" 200 321 "-" "curl/7.35.0"
|
||||
{{< /text >}}
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl logs -f $V2_POD -c httpbin
|
||||
$ kubectl logs -f "$V2_POD" -c httpbin
|
||||
127.0.0.1 - - [07/Mar/2018:19:26:44 +0000] "GET /headers HTTP/1.1" 200 361 "-" "curl/7.35.0"
|
||||
{{< /text >}}
|
||||
|
||||
|
|
|
@ -0,0 +1,242 @@
|
|||
#!/bin/bash
|
||||
# shellcheck disable=SC2034,SC2153,SC2155
|
||||
|
||||
# Copyright Istio Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
####################################################################################################
|
||||
# WARNING: THIS IS AN AUTO-GENERATED FILE, DO NOT EDIT. PLEASE MODIFY THE ORIGINAL MARKDOWN FILE:
|
||||
# docs/tasks/traffic-management/mirroring/index.md
|
||||
####################################################################################################
|
||||
|
||||
snip_before_you_begin_1() {
|
||||
cat <<EOF | istioctl kube-inject -f - | kubectl 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
|
||||
}
|
||||
|
||||
snip_before_you_begin_2() {
|
||||
cat <<EOF | istioctl kube-inject -f - | kubectl 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
|
||||
}
|
||||
|
||||
snip_before_you_begin_3() {
|
||||
kubectl 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
|
||||
}
|
||||
|
||||
snip_before_you_begin_4() {
|
||||
cat <<EOF | istioctl kube-inject -f - | kubectl 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
|
||||
}
|
||||
|
||||
snip_creating_a_default_routing_policy_1() {
|
||||
kubectl 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
|
||||
}
|
||||
|
||||
snip_creating_a_default_routing_policy_2() {
|
||||
export SLEEP_POD=$(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name})
|
||||
kubectl exec -it "$SLEEP_POD" -c sleep -- sh -c 'curl http://httpbin:8000/headers' | python -m json.tool
|
||||
}
|
||||
|
||||
! read -r -d '' snip_creating_a_default_routing_policy_2_out <<ENDSNIP
|
||||
{
|
||||
"headers": {
|
||||
"Accept": "*/*",
|
||||
"Content-Length": "0",
|
||||
"Host": "httpbin:8000",
|
||||
"User-Agent": "curl/7.35.0",
|
||||
"X-B3-Sampled": "1",
|
||||
"X-B3-Spanid": "eca3d7ed8f2e6a0a",
|
||||
"X-B3-Traceid": "eca3d7ed8f2e6a0a",
|
||||
"X-Ot-Span-Context": "eca3d7ed8f2e6a0a;eca3d7ed8f2e6a0a;0000000000000000"
|
||||
}
|
||||
}
|
||||
ENDSNIP
|
||||
|
||||
snip_creating_a_default_routing_policy_3() {
|
||||
export V1_POD=$(kubectl get pod -l app=httpbin,version=v1 -o jsonpath={.items..metadata.name})
|
||||
kubectl logs -f "$V1_POD" -c httpbin
|
||||
}
|
||||
|
||||
! read -r -d '' snip_creating_a_default_routing_policy_3_out <<ENDSNIP
|
||||
127.0.0.1 - - [07/Mar/2018:19:02:43 +0000] "GET /headers HTTP/1.1" 200 321 "-" "curl/7.35.0"
|
||||
ENDSNIP
|
||||
|
||||
snip_creating_a_default_routing_policy_4() {
|
||||
export V2_POD=$(kubectl get pod -l app=httpbin,version=v2 -o jsonpath={.items..metadata.name})
|
||||
kubectl logs -f "$V2_POD" -c httpbin
|
||||
}
|
||||
|
||||
! read -r -d '' snip_creating_a_default_routing_policy_4_out <<ENDSNIP
|
||||
<none>
|
||||
ENDSNIP
|
||||
|
||||
snip_mirroring_traffic_to_v2_1() {
|
||||
kubectl 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
|
||||
}
|
||||
|
||||
snip_mirroring_traffic_to_v2_2() {
|
||||
kubectl exec -it "$SLEEP_POD" -c sleep -- sh -c 'curl http://httpbin:8000/headers' | python -m json.tool
|
||||
}
|
||||
|
||||
snip_mirroring_traffic_to_v2_3() {
|
||||
kubectl logs -f "$V1_POD" -c httpbin
|
||||
}
|
||||
|
||||
! read -r -d '' snip_mirroring_traffic_to_v2_3_out <<ENDSNIP
|
||||
127.0.0.1 - - [07/Mar/2018:19:02:43 +0000] "GET /headers HTTP/1.1" 200 321 "-" "curl/7.35.0"
|
||||
127.0.0.1 - - [07/Mar/2018:19:26:44 +0000] "GET /headers HTTP/1.1" 200 321 "-" "curl/7.35.0"
|
||||
ENDSNIP
|
||||
|
||||
snip_mirroring_traffic_to_v2_4() {
|
||||
kubectl logs -f "$V2_POD" -c httpbin
|
||||
}
|
||||
|
||||
! read -r -d '' snip_mirroring_traffic_to_v2_4_out <<ENDSNIP
|
||||
127.0.0.1 - - [07/Mar/2018:19:26:44 +0000] "GET /headers HTTP/1.1" 200 361 "-" "curl/7.35.0"
|
||||
ENDSNIP
|
||||
|
||||
snip_cleaning_up_1() {
|
||||
kubectl delete virtualservice httpbin
|
||||
kubectl delete destinationrule httpbin
|
||||
}
|
||||
|
||||
snip_cleaning_up_2() {
|
||||
kubectl delete deploy httpbin-v1 httpbin-v2 sleep
|
||||
kubectl delete svc httpbin
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
#!/bin/bash
|
||||
# shellcheck disable=SC2153
|
||||
# shellcheck disable=SC2034
|
||||
# shellcheck disable=SC2034,SC2153,SC2155
|
||||
|
||||
# Copyright Istio Authors. All Rights Reserved.
|
||||
#
|
||||
|
|
|
@ -72,8 +72,7 @@ the [Ingress Gateways](/docs/tasks/traffic-management/ingress/ingress-control/#d
|
|||
`$INGRESS_PORT` value, use the following command.
|
||||
|
||||
{{< text bash >}}
|
||||
$ INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="tcp")].port}')
|
||||
$ export INGRESS_PORT
|
||||
$ export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="tcp")].port}')
|
||||
{{< /text >}}
|
||||
|
||||
Send some TCP traffic to the `tcp-echo` microservice.
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#!/bin/bash
|
||||
# shellcheck disable=SC2153
|
||||
# shellcheck disable=SC2034
|
||||
# shellcheck disable=SC2034,SC2153,SC2155
|
||||
|
||||
# Copyright Istio Authors. All Rights Reserved.
|
||||
#
|
||||
|
@ -42,8 +41,7 @@ kubectl apply -f samples/tcp-echo/tcp-echo-all-v1.yaml -n istio-io-tcp-traffic-s
|
|||
}
|
||||
|
||||
snip_apply_weightbased_tcp_routing_6() {
|
||||
INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="tcp")].port}')
|
||||
export INGRESS_PORT
|
||||
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="tcp")].port}')
|
||||
}
|
||||
|
||||
snip_apply_weightbased_tcp_routing_7() {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#!/bin/bash
|
||||
# shellcheck disable=SC2153
|
||||
# shellcheck disable=SC2034
|
||||
# shellcheck disable=SC2034,SC2153,SC2155
|
||||
|
||||
# Copyright Istio Authors. All Rights Reserved.
|
||||
#
|
||||
|
|
|
@ -28,8 +28,7 @@ output_started = False
|
|||
snippets = []
|
||||
|
||||
HEADER = """#!/bin/bash
|
||||
# shellcheck disable=SC2153
|
||||
# shellcheck disable=SC2034
|
||||
# shellcheck disable=SC2034,SC2153,SC2155
|
||||
|
||||
# Copyright Istio Authors. All Rights Reserved.
|
||||
#
|
||||
|
|
|
@ -38,17 +38,10 @@ func TestMirror(t *testing.T) {
|
|||
Input: istioio.Inline{
|
||||
FileName: "cleanup.sh",
|
||||
Value: `
|
||||
# $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
|
||||
|
||||
$ kubectl delete ns istio-io-mirror
|
||||
source ${REPO_ROOT}/content/en/docs/tasks/traffic-management/mirroring/snips.sh
|
||||
snip_cleaning_up_1
|
||||
snip_cleaning_up_2
|
||||
kubectl delete ns istio-io-mirror
|
||||
`,
|
||||
},
|
||||
}).
|
||||
|
|
Loading…
Reference in New Issue