-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doc request: Describe how to protect the knative broker to be accessed from selected namespaces #4823
Comments
Below is a suggested content. But I am not sure where exactly to place this? Admin vs Dev ? or mix? Namespace authorization for the Knative Broker with IstioThis guide shows how to authorize workloads from selected namespaces for accessing the Knative Kafka Broker. Before you beginYou need:
Prepare the brokerIn order have Istio being able to handle JWT-based user authentication the kubectl label namespace knative-eventing istio-injection=enabled And the pod for the kubectl delete pod mt-broker-ingress-57db965447-jkl2k -n knative-eventing We now see that the pod has two containers: knative-eventing mt-broker-ingress-57db965447-jxzfk 2/2 Running 1 175m Create a BrokerCreate a broker, like: apiVersion: eventing.knative.dev/v1
kind: Broker
metadata:
namespace: default
name: my-broker get the URL from the broker: kubectl get broker -A
NAMESPACE NAME URL AGE READY REASON
default my-broker http://broker-ingress.knative-eventing.svc.cluster.local/default/my-broker 6s True Start a
Send a CloudEvent with an HTTP Post against the broker URL curl -X POST -v \
-H "content-type: application/json" \
-H "ce-specversion: 1.0" \
-H "ce-source: my/curl/command" \
-H "ce-type: my.demo.event" \
-H "ce-id: 0815" \
-d '{"value":"Hello Knative"}' \
http://broker-ingress.knative-eventing.svc.cluster.local/default/my-broker The curl is exectued in the ...
* Mark bundle as not supporting multiuse
< HTTP/1.1 202 Accepted
< allow: POST, OPTIONS
< date: Tue, 15 Mar 2022 13:37:57 GMT
< content-length: 0
< x-envoy-upstream-service-time: 79
< server: istio-envoy
< x-envoy-decorator-operation: broker-ingress.knative-eventing.svc.cluster.local:80/* Restrict the access to the brokerNow we apply a apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: require-jwt
namespace: knative-eventing
spec:
action: ALLOW
rules:
- from:
- source:
namespaces: ["bar"]
to:
- operation:
methods: ["POST"]
paths: ["/default/my-broker"] Now retrying the * Mark bundle as not supporting multiuse
< HTTP/1.1 403 Forbidden
< content-length: 19
< content-type: text/plain
< date: Tue, 15 Mar 2022 14:53:46 GMT
< server: istio-envoy
< connection: close
< x-envoy-decorator-operation: broker-ingress.knative-eventing.svc.cluster.local:80/*
<
* Closing connection 0
RBAC: access denied Prepare the application namespaceIn order get the kubectl create ns bar
kubectl label namespace bar istio-injection=enabled Start a kubectl -n bar run curl --image=radial/busyboxplus:curl -i --tty You will see there are two pods, one for the kubectl get pods -nbar
NAME READY STATUS RESTARTS AGE
curl 2/2 Running 0 39s Now apply the same < HTTP/1.1 202 Accepted
< allow: POST, OPTIONS
< date: Tue, 15 Mar 2022 15:08:57 GMT
< content-length: 0
< x-envoy-upstream-service-time: 84
< server: envoy |
This issue is stale because it has been open for 90 days with no |
Looks like a duplicate of #4824 |
/reopen this is not a duplicate of 4824 - I created both, since they cover different use-cases |
@matzew: Reopened this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
With Istio we could restrict the access to the Knative Broker, using the
AuthorizationPolicy
so that we can allow a number of workloads/namespaces to access different Broker URLs.The text was updated successfully, but these errors were encountered: