Kubernetes Service TLS

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up kubernetes service tls by mounting certificate secrets into your target pods. Your app or sidecar then uses those keys to encrypt traffic in transit. Teams often pair this network setup with broad role permissions for daily work. When roles are too wide, users can read secret keys across the cluster. Broad access also lets engineers run unchecked commands inside active containers. How kubernetes service tls works in a cluster A standard service only routes network packets to pods u

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up kubernetes service tls by mounting certificate secrets into your target pods. Your app or sidecar then uses those keys to encrypt traffic in transit. Teams often pair this network setup with broad role permissions for daily work. When roles are too wide, users can read secret keys across the cluster. Broad access also lets engineers run unchecked commands inside active containers.

How kubernetes service tls works in a cluster

A standard service only routes network packets to pods using plain text by default. To encrypt this traffic, teams store public certs and private keys as cluster secrets. Pods mount these secrets as files and handle the encryption directly inside the app. Some teams also use a service mesh to manage cert rotation between pods.

Securing the network path is only half of the security job. You must also lock down who can read those secret keys through the API. Native access control uses roles and bindings to manage these rules. A Role sets permissions inside one single namespace. A ClusterRole sets rules across the entire cluster and covers all namespaces. Permissions in this system are additive, so there are no deny rules.

A RoleBinding links a user or group to a Role in one namespace. A ClusterRoleBinding grants those permissions across the whole cluster at once. If a binding allows secret reads, that user can pull your private TLS keys. You should scope secret read rules only to the specific service accounts that need them.

What native TLS and roles solve and what they miss

Network encryption stops outsiders from reading data as it moves between your pods. Native roles stop unauthorized users from reading cert secrets or starting pod sessions. Together, they verify who can connect and protect bytes on the wire.

Still, this setup leaves a major operational gap during daily debugging work. Engineers often need to run commands inside pods or query backend databases directly. In the native permission model, pod execution and log access work as subresources. Once a role grants access to the exec subresource, the API server steps back.

Kubernetes RBAC + TLS 1.3 Configuration: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Native roles decide who can log in to a pod or service. They do not check what individual commands or queries do in flight. An engineer with exec rights can view raw private keys on the pod disk. They can also query backend data and pull customer emails or card numbers. Standard TLS encrypts the session, so network monitors cannot inspect the traffic either.

How to tighten role rules around encrypted services

Start by separating human user roles from workload service account roles. Apps need to read TLS secrets at startup, while human engineers rarely do. Remove secret read permissions from standard developer roles in production namespaces. Use a RoleBinding in a single namespace instead of a wide ClusterRoleBinding.

Next, audit which groups hold permissions for the pod exec subresource. Treat exec access like full root access to the app and its local keys. Even with strict roles, someone will eventually need live access to fix a bug. At that point, static roles and wire encryption cannot filter unsafe commands or sensitive data.

Check Kubernetes API requests and responses on the wire

Kubernetes RBAC decides who may call the API server. RBAC does not check response payloads or split listing Secret names from reading Secret values when a role grants get access. With hoop.dev, you run an open-source proxy, a sidecar for your Kubernetes API, inline on the API connection. On every kubectl or API call an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

On each call, hoop.dev guardrails read the method, normalized path, and headers to refuse bad deletes or full Secret reads with a 403 error, or hold risky calls for approval. On the way back, hoop.dev data masking walks JSON responses by key and masks matched values in Secrets, ConfigMaps, and pod logs in memory. View the project on GitHub.

Frequently asked questions

Does a Kubernetes Service encrypt traffic by default?

No, a standard service only routes network packets between pods without encryption. You must set up TLS in your app pods or use a service mesh.

How do I stop users from reading TLS private keys?

Use a Role and RoleBinding to limit secret read access to specific service accounts. Since rules are additive, remove broad ClusterRoleBinding grants from human users.

Can RBAC filter commands inside an encrypted pod session?

No, native roles only check if a user can start the exec subresource session. They do not inspect or block individual commands after the session starts.

The query runs. The emails stay hidden.