@muthurajr
knative/serving#10940
I am having trouble in enabling Istio Authorization for Knative service to service communication.
Steps taken:
- Installed Istio and enabled mTLS with STRICT mode
- Installed Knative and enabled mTLS PERMISSIVE [https://knative.dev/docs/serving/istio-authorization/] as requests might be forwarded by activator based on TargetBurstCapacity.
- Created two namespaces serving-test1 & serving-test2
- Enabled istio sidecar injection and deployed Hello service in both serving-test1 & serving-test2
** Ignore the IP used in the code as I have tried to use Internal Load Balancer IP.
Expectation:
- Services in serving-test1 should get RBAC access denied when accessing services in serving-test2
- vice versa of previous scenario as well
Actual Result:
Services in serving-test1 is able to communicate with services in serving-test2 & vice versa.
I have tried on adding destination rules as well with host="*.local" and tls mode=ISTIO_MUTUAL, but no luck. Something I'm missing here but unable to identify. Any help is appreciated.
Complete installation and test scripts below.
export ISTIO_VERSION="1.8.2"
curl -L https://istio.io/downloadIstio | ISTIO_VERSION=${ISTIO_VERSION} TARGET_ARCH=x86_64 sh -
export PATH="$PATH:istio-${ISTIO_VERSION}/bin"
export ISTIO_HOME=istio-${ISTIO_VERSION}/
cat <<EOF > istio-minimal-operator.yaml
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
values:
global:
proxy:
autoInject: enabled
useMCP: false
jwtPolicy: first-party-jwt
meshConfig:
enableAutoMtls: true
addonComponents:
pilot:
enabled: true
components:
ingressGateways:
- name: istio-ingressgateway
enabled: true
k8s:
service:
type: LoadBalancer
loadBalancerIP: "10.173.128.70"
EOF
istioctl install -y -f istio-minimal-operator.yaml
kubectl -n istio-system annotate service istio-ingressgateway cloud.google.com/load-balancer-type=Internal --overwrite
kubectl ${OPERATION:-apply} -f - <<EOF
apiVersion: "security.istio.io/v1beta1"
kind: "PeerAuthentication"
metadata:
name: "default"
namespace: istio-system
spec:
mtls:
mode: STRICT
EOF
kubectl create namespace serving-test1
kubectl create namespace serving-test2
kubectl create namespace knative-serving
kubectl label namespace serving-test1 istio-injection=enabled
kubectl label namespace serving-test2 istio-injection=enabled
kubectl label namespace knative-serving istio-injection=enabled
export KNATIVE_VERSION="v0.20.0"
kubectl apply -f https://github.com/knative/serving/releases/download/${KNATIVE_VERSION}/serving-crds.yaml
kubectl apply -f https://github.com/knative/serving/releases/download/${KNATIVE_VERSION}/serving-core.yaml
kubectl apply -f https://github.com/knative/net-istio/releases/download/${KNATIVE_VERSION}/release.yaml
kubectl ${OPERATION:-apply} -f - <<EOF
apiVersion: "security.istio.io/v1beta1"
kind: "PeerAuthentication"
metadata:
name: "default"
namespace: "knative-serving"
spec:
mtls:
mode: PERMISSIVE
EOF
cat <<EOF | kubectl ${OPERATION:-apply} -f -
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
labels:
app: hello
name: hello
namespace: serving-test1
spec:
template:
metadata:
annotations:
autoscaling.knative.dev/minScale: "1"
spec:
containers:
- env:
- name: TARGET
value: Go Sample v1
image: gcr.io/knative-samples/helloworld-go
name: user-container
---
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
labels:
app: hello
name: hello
namespace: serving-test2
spec:
template:
metadata:
annotations:
autoscaling.knative.dev/minScale: "1"
spec:
containers:
- env:
- name: TARGET
value: Go Sample v2
image: gcr.io/knative-samples/helloworld-go
name: user-container
EOF
kubectl -n serving-test1 exec -it $(kubectl -n serving-test1 get pod -o jsonpath='{.items[0].metadata.name}') -- bash
curl -H "Host: hello.serving-test2.example.com" http://10.173.128.70
curl -H "Host: hello.serving-test2.example.com" http://istio-ingressgateway.istio-system.svc.cluster.local
curl -H "Host: hello.serving-test2.example.com" http://knative-local-gateway.istio-system.svc.cluster.local
curl http://hello.serving-test2.svc.cluster.local
kubectl -n serving-test2 exec -it $(kubectl -n serving-test2 get pod -o jsonpath='{.items[0].metadata.name}') -- bash
curl -H "Host: hello.serving-test1.example.com" http://10.173.128.70
curl -H "Host: hello.serving-test1.example.com" http://istio-ingressgateway.istio-system.svc.cluster.local
curl -H "Host: hello.serving-test1.example.com" http://knative-local-gateway.istio-system.svc.cluster.local
curl http://hello.serving-test1.svc.cluster.local
kubectl ${OPERATION:-apply} -f - <<EOF
apiVersion: "security.istio.io/v1beta1"
kind: "PeerAuthentication"
metadata:
name: "default"
namespace: serving-test1
spec:
mtls:
mode: STRICT
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: deny-all
namespace: serving-test1
spec:
{}
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: allow-serving-tests
namespace: serving-test1
spec:
action: ALLOW
rules:
- from:
- source:
namespaces: ["serving-test1", "knative-serving"]
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: allowlist-by-paths
namespace: serving-test1
spec:
action: ALLOW
rules:
- to:
- operation:
paths:
- /metrics
- /healthz
---
apiVersion: "security.istio.io/v1beta1"
kind: "PeerAuthentication"
metadata:
name: "default"
namespace: "serving-test2"
spec:
mtls:
mode: STRICT
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: deny-all
namespace: serving-test2
spec:
{}
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: allow-serving-tests
namespace: serving-test2
spec:
action: ALLOW
rules:
- from:
- source:
namespaces: ["serving-test2", "knative-serving"]
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: allowlist-by-paths
namespace: serving-test2
spec:
action: ALLOW
rules:
- to:
- operation:
paths:
- /metrics
- /healthz
EOF
@muthurajr
knative/serving#10940
I am having trouble in enabling Istio Authorization for Knative service to service communication.
Steps taken:
** Ignore the IP used in the code as I have tried to use Internal Load Balancer IP.
Expectation:
Actual Result:
Services in serving-test1 is able to communicate with services in serving-test2 & vice versa.
I have tried on adding destination rules as well with host="*.local" and tls mode=ISTIO_MUTUAL, but no luck. Something I'm missing here but unable to identify. Any help is appreciated.
Complete installation and test scripts below.