#!/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-gateway-tls-origination/index.md #################################################################################################### source "content/en/boilerplates/snips/gateway-api-support.sh" snip_before_you_begin_1() { kubectl apply -f samples/sleep/sleep.yaml } snip_before_you_begin_2() { kubectl apply -f <(istioctl kube-inject -f samples/sleep/sleep.yaml) } snip_before_you_begin_3() { export SOURCE_POD=$(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name}) } snip_before_you_begin_4() { openssl version -a | grep OpenSSL } ! IFS=$'\n' read -r -d '' snip_before_you_begin_4_out <<\ENDSNIP OpenSSL 1.1.1g 21 Apr 2020 ENDSNIP ! IFS=$'\n' read -r -d '' snip_before_you_begin_5 <<\ENDSNIP $ istioctl install --set values.pilot.env.PILOT_ENABLE_CONFIG_DISTRIBUTION_TRACKING=true --set meshConfig.accessLogFile=/dev/stdout ENDSNIP snip_perform_tls_origination_with_an_egress_gateway_1() { kubectl apply -f - < ./nginx.conf events { } http { log_format main '$remote_addr - $remote_user [$time_local] $status ' '"$request" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; error_log /var/log/nginx/error.log; server { listen 443 ssl; root /usr/share/nginx/html; index index.html; server_name my-nginx.mesh-external.svc.cluster.local; ssl_certificate /etc/nginx-server-certs/tls.crt; ssl_certificate_key /etc/nginx-server-certs/tls.key; ssl_client_certificate /etc/nginx-ca-certs/example.com.crt; ssl_verify_client on; } } EOF } snip_deploy_a_mutual_tls_server_4() { kubectl create configmap nginx-configmap -n mesh-external --from-file=nginx.conf=./nginx.conf } snip_deploy_a_mutual_tls_server_5() { kubectl apply -f - < Welcome to nginx! ... ENDSNIP snip_configure_mutual_tls_origination_for_egress_traffic_12() { kubectl logs -l istio=egressgateway -n istio-system | grep 'my-nginx.mesh-external.svc.cluster.local' | grep HTTP } snip_configure_mutual_tls_origination_for_egress_traffic_13() { kubectl logs -l gateway.networking.k8s.io/gateway-name=nginx-egressgateway | grep 'my-nginx.mesh-external.svc.cluster.local' | grep HTTP } ! IFS=$'\n' read -r -d '' snip_configure_mutual_tls_origination_for_egress_traffic_14 <<\ENDSNIP [2024-04-08T20:08:18.451Z] "GET / HTTP/1.1" 200 - via_upstream - "-" 0 615 5 5 "172.30.239.41" "curl/7.87.0-DEV" "86e54df0-6dc3-46b3-a8b8-139474c32a4d" "my-nginx.mesh-external.svc.cluster.local" "172.30.239.57:443" outbound|443||my-nginx.mesh-external.svc.cluster.local 172.30.239.53:48530 172.30.239.53:443 172.30.239.41:53694 my-nginx.mesh-external.svc.cluster.local default.forward-nginx-from-egress-gateway.0 ENDSNIP snip_cleanup_the_mutual_tls_origination_example_1() { kubectl delete secret nginx-server-certs nginx-ca-certs -n mesh-external kubectl delete configmap nginx-configmap -n mesh-external kubectl delete service my-nginx -n mesh-external kubectl delete deployment my-nginx -n mesh-external kubectl delete namespace mesh-external } snip_cleanup_the_mutual_tls_origination_example_2() { kubectl delete secret client-credential -n istio-system kubectl delete gw istio-egressgateway kubectl delete virtualservice direct-nginx-through-egress-gateway kubectl delete destinationrule -n istio-system originate-mtls-for-nginx kubectl delete destinationrule egressgateway-for-nginx } snip_cleanup_the_mutual_tls_origination_example_3() { kubectl delete secret client-credential kubectl delete gtw nginx-egressgateway kubectl delete role nginx-egressgateway-istio-sds kubectl delete rolebinding nginx-egressgateway-istio-sds kubectl delete virtualservice direct-nginx-to-egress-gateway kubectl delete httproute forward-nginx-from-egress-gateway kubectl delete destinationrule originate-mtls-for-nginx kubectl delete destinationrule egressgateway-for-nginx kubectl delete referencegrant my-nginx-reference-grant -n mesh-external } snip_cleanup_the_mutual_tls_origination_example_4() { rm example.com.crt example.com.key my-nginx.mesh-external.svc.cluster.local.crt my-nginx.mesh-external.svc.cluster.local.key my-nginx.mesh-external.svc.cluster.local.csr client.example.com.crt client.example.com.csr client.example.com.key } snip_cleanup_the_mutual_tls_origination_example_5() { rm ./nginx.conf } snip_cleanup_1() { kubectl delete -f samples/sleep/sleep.yaml }