Authorization Policy 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.
Read the authorization concept guide.
Install Istio with a custom trust domain and mutual TLS enabled.
Deploy the sample in the
default
namespace and the sleep sample in thedefault
andsleep-allow
namespaces:$ kubectl label namespace default istio-injection=enabled
$ kubectl apply -f @samples/httpbin/httpbin.yaml@
$ kubectl apply -f @samples/sleep/sleep.yaml@
$ kubectl create namespace sleep-allow
$ kubectl label namespace sleep-allow istio-injection=enabled
$ kubectl apply -f @samples/sleep/sleep.yaml@ -n sleep-allow
Apply the authorization policy below to deny all requests to
httpbin
except fromsleep
in thesleep-allow
namespace.$ kubectl apply -f - <<EOF
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: service-httpbin.default.svc.cluster.local
namespace: default
spec:
- from:
- source:
principals:
- old-td/ns/sleep-allow/sa/sleep
to:
- operation:
methods:
- GET
matchLabels:
app: httpbin
---
EOF
Notice that it may take tens of seconds for the authorization policy to be propagated to the sidecars.
Verify that requests to
httpbin
from:sleep
in thedefault
namespace are denied.
$ kubectl exec $(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name}) -c sleep -- curl http://httpbin.default:8000/ip -s -o /dev/null -w "%{http_code}\n"
403
sleep
in thesleep-allow
namespace are allowed.
Migrate trust domain without trust domain aliases
-
$ istioctl manifest apply --set profile=demo --set values.global.trustDomain=new-td
Istio mesh is now running with a new trust domain,
new-td
. Redeploy the
httpbin
andsleep
applications to pick up changes from the new Istio control plane.$ kubectl delete pod --all
$ kubectl delete pod --all -n sleep-allow
Install Istio with a new trust domain and trust domain aliases.
$ cat <<EOF > ./td-installation.yaml
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
values:
global:
trustDomain: new-td
trustDomainAliases:
- old-td
EOF
$ istioctl manifest apply --set profile=demo -f td-installation.yaml
Without changing the authorization policy, verify that requests to
httpbin
from:sleep
in thedefault
namespace are denied.
$ kubectl exec $(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name}) -c sleep -- curl http://httpbin.default:8000/ip -s -o /dev/null -w "%{http_code}\n"
403
sleep
in thesleep-allow
namespace are allowed.
Best practices
Starting from Istio 1.4, when writing authorization policy, you should consider using the value cluster.local
as the trust domain part in the policy. For example, instead of old-td/ns/sleep-allow/sa/sleep
, it should be cluster.local/ns/sleep-allow/sa/sleep
. Notice that in this case, cluster.local
is not the Istio mesh trust domain (the trust domain is still old-td
). However, in authorization policy, cluster.local
is a pointer that points to the current trust domain, i.e. old-td
(and later new-td
), as well as its aliases. By using cluster.local
in the authorization policy, when you migrate to a new trust domain, Istio will detect this and treat the new trust domain as the old trust domain without you having to include the aliases.
$ kubectl delete authorizationpolicy service-httpbin.default.svc.cluster.local
$ kubectl delete deploy httpbin; kubectl delete service httpbin; kubectl delete serviceaccount httpbin
$ kubectl delete deploy sleep; kubectl delete service sleep; kubectl delete serviceaccount sleep
$ kubectl delete namespace sleep-allow
See also
How to set up access control for TCP traffic.
How to set up access control on an ingress gateway.
Authorization policies with a deny action
Shows how to set up access control to deny traffic explicitly.
Describes Istio’s authorization and authentication functionality.
Describe Istio’s authorization feature and how to use it in various use cases.