|
| 1 | +#!/bin/bash |
| 2 | +# shellcheck disable=SC2034,SC2153,SC2154,SC2155,SC2164 |
| 3 | + |
| 4 | +# Copyright Istio Authors. All Rights Reserved. |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. |
| 8 | +# You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | + |
| 18 | +set -e |
| 19 | +set -u |
| 20 | +set -o pipefail |
| 21 | + |
| 22 | +# @setup profile=none |
| 23 | + |
| 24 | +# Install SPIRE configured with k8s Controller Manager |
| 25 | +snip_install_spire_with_controller_manager |
| 26 | +_wait_for_daemonset spire spire-agent |
| 27 | +_wait_for_deployment spire spire-server |
| 28 | + |
| 29 | +# Create ClusterSPIFFEID |
| 30 | +snip_create_clusterspiffeid |
| 31 | + |
| 32 | +# Install Istio |
| 33 | +set +u # Do not exit when value is unset. CHECK_FILE in the IstioOperator might be unset |
| 34 | +snip_define_istio_operator_for_auto_registration |
| 35 | +snip_apply_istio_operator_configuration |
| 36 | +set -u # Exit on unset value |
| 37 | +_wait_for_deployment istio-system istiod |
| 38 | +_wait_for_deployment istio-system istio-ingressgateway |
| 39 | + |
| 40 | +# Deploy sleep application with registration label |
| 41 | +snip_apply_sleep |
| 42 | +_wait_for_deployment default sleep |
| 43 | + |
| 44 | +# Set spire-server pod variable |
| 45 | +snip_set_spire_server_pod_name_var |
| 46 | + |
| 47 | +# Verify registration identities were created for sleep and ingress gateway |
| 48 | +_verify_contains snip_verifying_that_identities_were_created_for_workloads_1 "spiffe://example.org/ns/default/sa/sleep" |
| 49 | +_verify_contains snip_verifying_that_identities_were_created_for_workloads_1 "spiffe://example.org/ns/istio-system/sa/istio-ingressgateway-service-account" |
| 50 | + |
| 51 | +# Set sleep pod and pod uid variables |
| 52 | +snip_set_sleep_pod_vars |
| 53 | + |
| 54 | +# Verify sleep workload identity was issued by SPIRE |
| 55 | +snip_get_sleep_svid |
| 56 | +_verify_contains snip_get_svid_subject "O = SPIRE" |
| 57 | + |
| 58 | +# @cleanup |
| 59 | +kubectl delete -f samples/security/spire/sleep-spire.yaml |
| 60 | +istioctl uninstall --purge --skip-confirmation |
| 61 | +kubectl delete ns istio-system |
| 62 | +snip_cleanup_spire_1 |
0 commit comments