Trust Domain Migration

    In Istio 1.4, we introduce an alpha feature to support trust domain migration for authorization policy. This means if an Istio mesh needs to change its trust domain, the authorization policy doesn’t need to be changed manually. In Istio, if a workload is running in namespace with the service account bar, and the trust domain of the system is my-td, the identity of said workload is spiffe://my-td/ns/foo/sa/bar. By default, the Istio mesh trust domain is cluster.local, unless you specify it during the installation.

    Before you begin this task, do the following:

    1. Read the .

    2. Install Istio with a custom trust domain and mutual TLS enabled.

    3. Deploy the httpbin sample in the default namespace and the sample in the default and sleep-allow namespaces:

      1. $ kubectl label namespace default istio-injection=enabled
      2. $ kubectl apply -f @samples/httpbin/httpbin.yaml@
      3. $ kubectl apply -f @samples/sleep/sleep.yaml@
      4. $ kubectl create namespace sleep-allow
      5. $ kubectl label namespace sleep-allow istio-injection=enabled
      6. $ kubectl apply -f @samples/sleep/sleep.yaml@ -n sleep-allow
    4. Apply the authorization policy below to deny all requests to httpbin except from sleep in the sleep-allow namespace.

      1. $ kubectl apply -f - <<EOF
      2. apiVersion: security.istio.io/v1beta1
      3. kind: AuthorizationPolicy
      4. metadata:
      5. name: service-httpbin.default.svc.cluster.local
      6. namespace: default
      7. spec:
      8. rules:
      9. - from:
      10. principals:
      11. - old-td/ns/sleep-allow/sa/sleep
      12. to:
      13. - operation:
      14. methods:
      15. - GET
      16. selector:
      17. app: httpbin
      18. ---
      19. EOF

    Notice that it may take tens of seconds for the authorization policy to be propagated to the sidecars.

    1. Verify that requests to httpbin from:

      • sleep in the default namespace are denied.
      1. $ kubectl exec "$(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name})" -c sleep -- curl http://httpbin.default:8000/ip -sS -o /dev/null -w "%{http_code}\n"
      2. 403
      • sleep in the sleep-allow namespace are allowed.
      1. $ kubectl exec "$(kubectl -n sleep-allow get pod -l app=sleep -o jsonpath={.items..metadata.name})" -c sleep -n sleep-allow -- curl http://httpbin.default:8000/ip -sS -o /dev/null -w "%{http_code}\n"
      2. 200
    1. Install Istio with a new trust domain.

    2. Redeploy istiod to pick up the trust domain changes.

      1. $ kubectl rollout restart deployment -n istio-system istiod
    3. Redeploy the httpbin and sleep applications to pick up changes from the new Istio control plane.

      1. $ kubectl delete pod --all
      1. $ kubectl delete pod --all -n sleep-allow
    1. Install Istio with a new trust domain and trust domain aliases.

      1. $ cat <<EOF > ./td-installation.yaml
      2. apiVersion: install.istio.io/v1alpha1
      3. kind: IstioOperator
      4. spec:
      5. meshConfig:
      6. trustDomain: new-td
      7. trustDomainAliases:
      8. - old-td
      9. EOF
      10. $ istioctl install --set profile=demo -f td-installation.yaml -y
    2. Without changing the authorization policy, verify that requests to httpbin from:

      • sleep in the default namespace are denied.
      1. $ kubectl exec "$(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name})" -c sleep -- curl http://httpbin.default:8000/ip -sS -o /dev/null -w "%{http_code}\n"
      2. 403
      • sleep in the sleep-allow namespace are allowed.
      1. $ kubectl exec "$(kubectl -n sleep-allow get pod -l app=sleep -o jsonpath={.items..metadata.name})" -c sleep -n sleep-allow -- curl http://httpbin.default:8000/ip -sS -o /dev/null -w "%{http_code}\n"
      2. 200
    1. $ kubectl delete authorizationpolicy service-httpbin.default.svc.cluster.local
    2. $ kubectl delete deploy httpbin; kubectl delete service httpbin; kubectl delete serviceaccount httpbin
    3. $ kubectl delete deploy sleep; kubectl delete service sleep; kubectl delete serviceaccount sleep
    4. $ istioctl x uninstall --purge
    5. $ rm ./td-installation.yaml