User xxx isn’t an existing user and therefore I expect that service can’t access the database. As I understand it should be - user: "cluster.local/ns/ns1/sa/myservice". But if try it with telnet from the service instance, I get response:
Escape character is '^]'.
Y
5.5.5-10.2.21-MariaDB�K'!m&q*z�����LJme5upU5GFgmysql_native_password
Connection closed by foreign host.
instead of an error. What I’m missing? How debug it? How I can ensure that only wanted services can access the database? Can I control it exclusively from database namespace ns2?
It might be that you don’t have things configured properly for istio_proxy to intercept the traffic to the database.
You’ll want to verify that the istio_proxy is successfully injected into the database pod, and that the database pod has the containerPort defined for the MariaDB port (Istio will only intercept on ports that are defined in the podspec).
$ docker history bitnami/mariadb:10.2.21
IMAGE CREATED CREATED BY SIZE COMMENT
78d69dae35ab 5 days ago /bin/sh -c #(nop) CMD ["/run.sh"] 0 B
<missing> 5 days ago /bin/sh -c #(nop) ENTRYPOINT ["/entrypoin... 0 B
<missing> 5 days ago /bin/sh -c #(nop) USER 1001 0 B
<missing> 5 days ago /bin/sh -c #(nop) EXPOSE 3306 0 B
[...]
You might want to check the logs of the proxy_init container, to see if it is successfully setting up the IPtables rules.
If that looks correct, check the istio_proxy logs after you make your test connection to see if the istio_proxy is logging that it is processing the connection.
If all that looks correct, then we know that the proxy is intercepting the connection, and the question will be why mTLS isn’t being used.
If you can point me to a small, dedicated example to just “create a service, which isn’t accessible from other services” and then “add access to particular service from other namespace”, may be I can gather some more info. And I’m not sure I don’t mess some configurations with bookinfo example.
Istio authorization is deny by default. If you enable authorization for your service, no other service can access your service unless you define specific policies (ServiceRole/ServiceRoleBinding) to allow it.
Anton, I think your database service is running TCP protocol, correct? We supported HTTP/gRPC protocol for Istio authorization in Istio 1.0 release. TCP support was added later. From Istio 1.05 doc, it looks that we haven’t added TCP support for Istio authorization at that point. If you are running a TCP service, you need to upgrade to Istio 1.1 for Istio authorization TCP support (see https://preliminary.istio.io/docs/tasks/security/authz-tcp/).
Yes, it does. I will test it for HTTP-Communication between other services soon. Is there any ETA for more or less stable istio 1.1 release/build? How painful would be the update process from 1.0.5 to 1.1 later?
Is there any documentation about that subject for user is related to the name of serviceAccountName? I’ve spend a lot of time to debug why * and cluster.local/ns/ns2/sa/default works, but not cluster.local/ns/ns2/sa/myservice.
Anton, you need to associate a service account name with when you deploy a service. We have some examples in user guides (e.g., https://preliminary.istio.io/docs/tasks/security/authz-http/#before-you-begin). And here is the example configuration, which creates the service account “bookinfo-productpage”, and deploys it with productpage service.
Yes yes, my problem was, that it was not very clear in documentation, that I need a ServiceAccount for authorization and its name is used for service authorization. Therefore I asked about that. I think the docs can be improved.
All the services use the “default” service account if not specified. But if you want to assign specific service account to a service, you have to create the service account and then deploy. @Anton I agree with you that the doc can be improved to clarify this point.