Polyaxon v3 is coming →

Encrypt container traffic in Kubernetes

Design encryption for Kubernetes data at rest and in transit, with workload identity, certificate rotation, key ownership, and verifiable coverage.

May 16, 2023by Polyaxon
Encrypt container traffic in Kubernetes

Encryption in Kubernetes is not one switch. Data moves through API requests, service-to-service connections, ingress and egress paths, storage volumes, object stores, backups, logs, and artifacts. Each path has a different endpoint, identity, key owner, and failure mode.

A useful design starts with a data-flow map, applies encryption at the right layers, and includes evidence that every required path is covered.

Classify data and flows

List the sensitive material handled by the platform: Kubernetes Secrets, source credentials, datasets, model artifacts, checkpoints, prompts, customer inputs, telemetry, and backups. Map where each item is created, transmitted, stored, copied, and deleted.

For every flow, record:

  • the client and server identities;
  • the protocol and encryption boundary;
  • who issues and rotates the key or certificate;
  • whether an intermediary terminates and re-encrypts traffic;
  • where plaintext can exist in memory or on disk;
  • the logs or tests that prove protection is active.

This prevents a common gap: declaring traffic encrypted because the public endpoint uses HTTPS while internal hops or storage copies remain unprotected.

Protect control-plane and secret data

Kubernetes API clients should validate the API server certificate and use authenticated TLS. Limit direct API access and protect kubeconfig files because they may contain credentials or references to credential helpers.

Kubernetes Secrets are base64-encoded, not inherently encrypted. Configure API data encryption at rest and protect the encryption keys separately from etcd. The Kubernetes encryption at rest guide explains provider configuration and the need to rewrite existing resources after enabling a new key.

Encrypt etcd backups and restrict access to them. A protected live database with an unencrypted, broadly accessible backup is not an effective boundary.

Encrypt service traffic with identity

TLS protects a connection only when the client verifies the intended server. Mutual TLS adds client identity so the server can authorize the calling workload. This is valuable for multi-tenant services, internal APIs, artifact systems, and paths that cross weakly trusted networks.

A service mesh can automate certificate issuance and mTLS for supported traffic, but it adds proxies, policy, upgrades, and another failure domain. Application-native TLS may be simpler for a small number of stable services. Node-to-node encryption from the networking layer can protect packets on the wire without providing application-level identity.

Choose the layer according to the threat model. Mesh mTLS, network encryption, and application TLS can complement one another, but overlapping encryption without clear ownership makes incidents and certificate failures harder to diagnose.

Secure ingress and egress

Terminate public TLS at an approved load balancer, Gateway, or Ingress controller. Use modern protocol settings, automated certificate renewal, and strict handling of forwarded identity headers. If traffic remains sensitive after termination, re-encrypt the connection to the workload and authenticate the internal destination.

For egress, verify remote certificates and avoid disabling validation to work around development issues. Private artifact stores, registries, databases, and telemetry collectors still need authenticated encryption. Use network policy and egress controls to limit which destinations a workload can contact; encryption does not make an unauthorized destination safe.

Encrypt volumes, objects, and artifacts

Use the cloud or storage provider's encryption controls for persistent volumes, snapshots, object storage, and backups. Decide whether provider-managed keys are sufficient or whether customer-managed keys are required for separation, revocation, and audit.

Server-side encryption protects stored media, while client-side encryption can protect data from the storage service and intermediaries. Client-side encryption also transfers key availability, rotation, and recovery responsibilities to the application team. Choose it only with an operational plan.

Track encryption context across ML lineage. A copied dataset, downloaded checkpoint, exported model, or cached artifact can cross into a new storage system with different controls.

Manage certificates and keys as production dependencies

Assign owners for issuing, rotating, revoking, backing up, and recovering keys. Separate key administration from data access where practical. Use short-lived workload certificates and automated renewal, but alert before expiry and when renewal fails.

Plan rotation for long-running training jobs and serving processes. Replacing a Secret or certificate file does not guarantee that an application reloads it. Test whether the process rereads the file, opens new connections, or requires a controlled restart.

Never place private keys in container images, Git history, experiment parameters, logs, or command-line arguments. Deliver them only to the container and process that needs them.

Verify coverage and failure behavior

Continuously test protocol versions, certificate validation, expiry, hostname and workload identity, storage encryption settings, backup protection, and key permissions. Inspect traffic at approved test points to confirm that supposedly encrypted paths contain no plaintext.

Test failures too: an expired certificate, unavailable key service, rejected identity, and attempted downgrade should fail closed where the security requirement demands it. Monitor handshake errors and renewal failures without logging sensitive key material.

Polyaxon connections can provide approved access to artifact stores, registries, datasets, and external services without copying credentials into components. Pair those connections with Kubernetes workload identity, encrypted transport, storage encryption, and explicit rotation so each operation receives a complete, testable data-protection path.