Skip to content

Commit 127c4f2

Browse files
authored
Update Istio/SPIRE demo to use SPIRE Controller Manager (#12680)
* Update Istio/SPIRE integration demo to use SPIRE Controller Manager instead of k8s workload registration. Signed-off-by: jaellio <[email protected]> * Adds test for automatic workload registration via the SPIRE controller manager. During cleanup, removes generated istio.yaml and chaim.pem files. Updates label to spiffe.io/spire-managed-identity. Signed-off-by: jaellio <[email protected]> * Adds missing newline Signed-off-by: jaellio <[email protected]> * Fix spelling error Signed-off-by: jaellio <[email protected]> * Add missing ns flag on role and rolebinding resource commands Signed-off-by: jaellio <[email protected]> * Delete sleep resources and uninstall before SPIRE Signed-off-by: jaellio <[email protected]> * Reconfigures demo so istio install is not expected to fail. Created ClusterSPIFFEID before install istio. Previously install would fail because the ingress gateway wasn't registered/ Signed-off-by: jaellio <[email protected]> * Remove references to v1.14 and update required version to 1.14+ Signed-off-by: jaellio <[email protected]> * Fix lint errors Signed-off-by: jaellio <[email protected]> --------- Signed-off-by: jaellio <[email protected]>
1 parent 78bd08e commit 127c4f2

File tree

4 files changed

+663
-74
lines changed

4 files changed

+663
-74
lines changed

.spelling

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ CloudNativeCon
209209
CloudWatch
210210
cluster1
211211
cluster2
212+
ClusterSPIFFEID
212213
CNCF-hosted
213214
CNI
214215
cnn.com
@@ -488,6 +489,7 @@ Idit
488489
ILBs
489490
incentivized
490491
Incrementality
492+
initContainer
491493
initializer
492494
initializers
493495
injector
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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

Comments
 (0)