iac.htora.dev · security templates

Home/Templates/Encrypt and authorise every call between services

Encrypt and authorise every call between services

Mutual TLS between every service, and a deny-by-default rule for which service may call which.

Argo CD

Why bother

Inside a cluster, any pod can usually call any other. A compromised pod is then one request away from every internal API. A service mesh gives each workload an identity, encrypts traffic between them, and lets you write which callers each service accepts. Its logs also show a responder exactly who talked to whom.

How you know it worked

From a pod with no permission, call a protected service. The call is refused with 403. At Standard, the refusal is logged with the caller's identity.

How it works

1Service A calls service Binside the cluster2The mesh checks both identitiesmutual TLS3An authorisation rule decidesdeny unless allowed4Refusals are loggedwith the caller's identity, at Standard
Step by step, from the thing that happens to the result you want.

Set it up

Pick your platform, then open the level you want. Each level is complete on its own. Read the comments in the files as you go. Anything with a real consequence is explained on the line where it happens.

Argo CD. Istio in strict mutual TLS mode with deny-by-default authorisation, deployed by Argo CD

What you need first

  • For the quick start, a cluster already running Istio, with sidecar injection on for the application namespace.
  • For Standard, Argo CD with a project named platform, as the bootstrap template creates, and this folder committed to your repository.
  • A service account per workload, since a workload's service account is its identity in the mesh.

What it creates

  • Mutual TLS required across the mesh, so plain connections are refused
  • A namespace that refuses every call until a policy allows it, and one allow rule naming the caller by service account
  • Istio 1.31.1 from pinned charts, with two control plane replicas (Standard)
  • A deny on callers with no mesh identity, an allow for the ingress gateway, and access logs for refused and failed requests (Standard)

The code

Quick startReadyone file, 57 lines
One file. Strict mutual TLS, one namespace denied by default, and one allowed caller.
Run it
  1. kubectl config current-context
    Shows which cluster kubectl is pointed at. Check it first.
  2. kubectl apply -f policies.yaml
    Hands the Application to Argo CD.
  3. kubectl -n argocd get applications
    Lists applications with their sync and health status.
Download policies.yaml
Checks

Kubernetes schema passed

Last run 2026-10-02.

outcomes/service-mesh-policy/kubernetes/t0
policies.yaml
Open policies.yaml as plain text
StandardReadyfour files, 192 lines
Adds Istio installed by Argo CD from pinned charts, a deny on anonymous callers, an allow for the ingress gateway, and access logs for refusals.
Change these first
  • repoURL: https://github.com/your-org/your-cluster-config.git istio.yaml, line 86
Run it
  1. kubectl config current-context
    Shows which cluster kubectl is pointed at. Check it first.
  2. kubectl apply -k .
    Applies everything the kustomization lists, in order.
  3. kubectl -n argocd get applications
    Lists applications with their sync and health status.
Download all four files as a zip
Checks

Kubernetes schema passedBuilds passed

Last run 2026-10-02.

outcomes/service-mesh-policy/kubernetes/t1
istio.yaml
Open istio.yaml as plain text
kustomization.yaml
Open kustomization.yaml as plain text
policies/mesh.yaml
Open mesh.yaml as plain text
policies/namespace-shop.yaml
Open namespace-shop.yaml as plain text
HardenedReadyone file, 15 lines
Standard's manifests, unchanged. Rules refuse a missing mesh object, unpinned or mismatched charts, sync without prune or self-heal, mTLS other than STRICT, a weakened deny-all or deny-anonymous policy, and allow rules without named callers. A daily diff against the cluster reports drift.
Run it
  1. kubectl config current-context
    Shows which cluster kubectl is pointed at. Check it first.
  2. kubectl apply -k .
    Applies everything the kustomization lists, in order.
  3. kubectl -n argocd get applications
    Lists applications with their sync and health status.
Download kustomization.yaml
Checks

Builds passed

Last run 2026-10-02.

outcomes/service-mesh-policy/kubernetes/t2
kustomization.yaml
Open kustomization.yaml as plain text

How to check it worked

From a pod running as any service account other than the allowed caller, call the backend. It answers 403 with RBAC: access denied. From the allowed caller, it answers 200.

What catches people

Istio applies policies in its root namespace to every workload, including the ingress gateway, which outside users reach with no mesh identity. Standard keeps authorisation policies in each application namespace.

An allow-nothing policy refuses the ingress gateway too, and health checks that do not go through the sidecar. Each needs its own allow rule.

Strict mutual TLS refuses callers with no sidecar. Onboard a namespace only once every workload that calls into it has one.

istiod rewrites its own webhook's failure policy after it starts. Standard tells Argo CD to ignore that field, or the application never shows as in sync.

How to undo it

Delete the Applications, or run kubectl delete -f policies.yaml. Removing the policies opens every call again at once.

What it costs

Each sidecar uses CPU and memory beside its workload, and adds a small delay to each call. The control plane runs as pods in the cluster.

Good to know

  • Mutual TLS gives every workload an identity from its service account. Authorisation rules name those identities, so a stolen pod address is useless without the service account behind it.
  • Roll out one namespace at a time: sidecars first, then strict mutual TLS, then deny by default with the allow rules you need.

Registry 0.23.0. Built 2026-11-17.

Made by Habibullah Tora. Source on GitHub. Code under the MIT licence, writing under CC BY 4.0.