I have an ISTIO on my two kubernetes clusters as a replicated control plane. In my case, some networking policies that restricting labeled deployment object access , but these are working on the only one cluster .
How I can implement domain and service restriction between two clusters on Istio ? Have you got any suggestion ?
Thanks
Sample Network Policy :
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: policy-new
namespace: point-1
spec:
ingress:
- from:
- podSelector:
matchLabels:
run: app2
podSelector:
matchLabels:
run: appKubernetes NetworkPolicy might have limited use for multicluster.
It is better to use Istio's AuthorizationPolicy. According to istio documentation:
To configure an Istio authorization policy, you create an
AuthorizationPolicyresource.An authorization policy includes a selector and a list of rules. The selector specifies the target that the policy applies to, while the rules specify who is allowed to do what under which conditions. Specifically:
- target refers to the
selectorsection in theAuthorizationPolicy.- who refers to the
fromsection in theruleof theAuthorizationPolicy.- what refers to the
tosection in theruleof theAuthorizationPolicy.- conditions refers to the
whensection in theruleof theAuthorizationPolicy.Each rule has the following standard fields:
from: A list of sources.to: A list of operations.when: A list of custom conditions.The following example shows an
AuthorizationPolicythat allows two sources (service accountcluster.local/ns/default/sa/sleepand namespacedev) to access the workloads with labelsapp: httpbinandversion: v1in namespace foo when the request is sent with a valid JWT token.
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: httpbin
namespace: foo
spec:
selector:
matchLabels:
app: httpbin
version: v1
rules:
- from:
- source:
principals: ["cluster.local/ns/default/sa/sleep"]
- source:
namespaces: ["dev"]
to:
- operation:
methods: ["GET"]
when:
- key: request.auth.claims[iss]
values: ["https://accounts.google.com"]Also I recommend reading this and this istio blog posts which cover topics of multicluster security and about Admiral an open source project under istio-ecosystem that provides automatic configuration generation, syncing and service discovery for multicluster Istio service mesh.
Ambassador can be configured to lock down communication except for the traffic which WE specify with use of ServiceEntry, Dependency and GlobalTrafficPolicy objects.
Hope this helps.