#!/bin/bash # shellcheck disable=SC2034,SC2153,SC2155,SC2164 # 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/egress/egress-kubernetes-services/index.md #################################################################################################### source "content/en/boilerplates/snips/before-you-begin-egress.sh" snip__1() { kubectl create namespace without-istio } snip__2() { kubectl apply -f samples/sleep/sleep.yaml -n without-istio } snip__3() { export SOURCE_POD_WITHOUT_ISTIO="$(kubectl get pod -n without-istio -l app=sleep -o jsonpath={.items..metadata.name})" } snip__4() { kubectl get pod "$SOURCE_POD_WITHOUT_ISTIO" -n without-istio } ! read -r -d '' snip__4_out <<\ENDSNIP NAME READY STATUS RESTARTS AGE sleep-66c8d79ff5-8tqrl 1/1 Running 0 32s ENDSNIP snip_kubernetes_externalname_service_to_access_an_external_service_1() { kubectl apply -f - < httpbin.org 80/TCP 4s ENDSNIP snip_kubernetes_externalname_service_to_access_an_external_service_3() { kubectl exec "$SOURCE_POD_WITHOUT_ISTIO" -n without-istio -c sleep -- curl -sS my-httpbin.default.svc.cluster.local/headers } ! read -r -d '' snip_kubernetes_externalname_service_to_access_an_external_service_3_out <<\ENDSNIP { "headers": { "Accept": "*/*", "Host": "my-httpbin.default.svc.cluster.local", "User-Agent": "curl/7.55.0" } } ENDSNIP snip_kubernetes_externalname_service_to_access_an_external_service_4() { kubectl apply -f - < 443/TCP 21h ENDSNIP snip_use_a_kubernetes_service_with_endpoints_to_access_an_external_service_4() { kubectl exec "$SOURCE_POD_WITHOUT_ISTIO" -n without-istio -c sleep -- curl -sS --resolve en.wikipedia.org:443:"$(kubectl get service my-wikipedia -o jsonpath='{.spec.clusterIP}')" https://en.wikipedia.org/wiki/Main_Page | grep -o ".*" } ! read -r -d '' snip_use_a_kubernetes_service_with_endpoints_to_access_an_external_service_4_out <<\ENDSNIP Wikipedia, the free encyclopedia ENDSNIP snip_use_a_kubernetes_service_with_endpoints_to_access_an_external_service_5() { kubectl apply -f - <.*" } ! read -r -d '' snip_use_a_kubernetes_service_with_endpoints_to_access_an_external_service_6_out <<\ENDSNIP Wikipedia, the free encyclopedia ENDSNIP snip_use_a_kubernetes_service_with_endpoints_to_access_an_external_service_7() { kubectl exec "$SOURCE_POD" -c sleep -- curl -sS -v --resolve en.wikipedia.org:443:"$(kubectl get service my-wikipedia -o jsonpath='{.spec.clusterIP}')" https://en.wikipedia.org/wiki/Main_Page -o /dev/null } ! read -r -d '' snip_use_a_kubernetes_service_with_endpoints_to_access_an_external_service_7_out <<\ENDSNIP * Added en.wikipedia.org:443:172.21.156.230 to DNS cache * Hostname en.wikipedia.org was found in DNS cache * Trying 172.21.156.230... * TCP_NODELAY set * Connected to en.wikipedia.org (172.21.156.230) port 443 (#0) ... ENDSNIP snip_cleanup_of_kubernetes_service_with_endpoints_1() { kubectl delete destinationrule my-wikipedia kubectl delete endpoints my-wikipedia kubectl delete service my-wikipedia } snip_cleanup_1() { kubectl delete -f samples/sleep/sleep.yaml } snip_cleanup_2() { kubectl delete -f samples/sleep/sleep.yaml -n without-istio } snip_cleanup_3() { kubectl delete namespace without-istio } snip_cleanup_4() { unset SOURCE_POD SOURCE_POD_WITHOUT_ISTIO }