Recommended resources
The freely available resources this lesson will direct you to.
- Kubernetes Security Tutorial - RBAC, Network Policies, Kyverno, Secrets, External Secrets Operatorwww.youtube.com
- Secure Your Cluster With Network Policieswww.youtube.com
- Security in production | Deployment guides - Llamawww.llama.com
- How Can I Implement mTLS Across My Entire Infrastructure? - Tetratetetrate.io
Welcome to the final lesson in our module on LLM Security and Governance. In the previous lesson, we established a robust framework for controlling who can access what resources by designing a Role-Based Access Control (RBAC) policy. This is a critical step in managing permissions and enforcing the principle of least privilege.
Today, we move from the logical layer of permissions to the physical and network layers. We'll focus on hardening the underlying infrastructure that runs our LLM services. Your extensive experience as an SRE and Cloud Engineer will be directly applicable here, as we'll be applying standard, battle-tested security best practices to the specific context of an LLM deployment.
This lesson will cover three fundamental pillars of infrastructure security:
- Secrets Management: Securely handling API keys, database credentials, and other sensitive data.
- Mutual TLS (mTLS): Encrypting and authenticating all service-to-service communication.
- Network Policies: Isolating workloads at the network level to prevent unauthorized access and lateral movement.
By the end of this lesson, you will be able to apply these core security controls to create a defense-in-depth strategy for your LLM infrastructure.
1. Hardening the Foundation: Infrastructure and Network Security
A secure application cannot exist on a vulnerable foundation. The first layer of defense involves securing the network and compute environments. The goal is to create a hardened perimeter that prevents unauthorized network access and isolates your LLM deployment from both external and internal threats.
Security in production | Deployment guides - Llama
This guide from the Llama documentation provides an excellent overview of a multi-layered security strategy. We'll use it to frame our discussion.
Please read the introduction and the section titled "Infrastructure security: Securing the perimeter". As you read, focus on how concepts you're familiar with—like VPCs, microsegmentation, and hardened base images—are presented as a cohesive strategy. Also, take a look at the "Security checklist" at the end to see how these controls fit into a larger compliance and security posture.
As the guide emphasizes, the core principles are isolation and control. One of the most powerful tools for implementing this in a Kubernetes environment is the NetworkPolicy resource. By default, all pods in a Kubernetes cluster can communicate with each other. Network Policies act as a virtual firewall for pods, allowing you to define explicit rules for ingress (incoming) and egress (outgoing) traffic.
For an LLM system, you might implement policies such as:
- Allowing ingress to your inference pods only from your API gateway or front-end application pods.
- Denying all egress traffic from inference pods, except to necessary services like a logging endpoint or a vector database.
The following video provides a practical demonstration of creating and applying network policies.
Secure Your Cluster With Network Policies
The channel Jim's Garage offers a clear, hands-on tutorial titled "Secure Your Cluster With Network Policies."
Watch these segments to see how Network Policies are configured and what effect they have: Introduction: Get an overview of what Network Policies are and the problems they solve. Egress Policy Demo: See how to create a policy that restricts a pod's outbound traffic, for example, allowing it to reach the internet but not internal network addresses. Ingress Policy Demo: Watch how an ingress policy is used to block access to a service from an unauthorized source network.
By using Network Policies, you can enforce microsegmentation and significantly limit an attacker's ability to move laterally within your cluster if one component is compromised.
2. Securing Communication: Encryption in Transit with mTLS
Network policies control if services can talk to each other. The next step is to secure the communication itself. While standard TLS encrypts traffic and verifies the server's identity, Mutual TLS (mTLS) goes a step further by requiring both the client and the server to prove their identities to each other using certificates.
This creates a zero-trust environment where no service is trusted by default. For an LLM system, this means:
- An inference service can be certain it is only receiving requests from an authenticated API gateway.
- The API gateway can be certain it is sending sensitive user prompts only to a legitimate inference service, preventing man-in-the-middle attacks within your own network.

Implementing and managing certificates for mTLS across many microservices can be complex. This is where a service mesh like Istio or Linkerd becomes invaluable. As the diagram shows, a service mesh automates certificate issuance, rotation, and injection, enabling mTLS transparently without requiring changes to your application code.
How Can I Implement mTLS Across My Entire Infrastructure? - Tetrate
This article from Tetrate provides a deep dive into implementing mTLS, focusing on the role of a service mesh.
Read the following sections to connect the concept of mTLS to the practical implementation in a cloud-native environment: "Service Mesh Approach to mTLS": Understand how Istio provides core features for mTLS. "VM Integration Strategies": See how the same security pattern can extend beyond Kubernetes to traditional workloads. "Certificate Management": Learn about the importance of SPIFFE/SPIRE for workload identity and the best practices for certificate lifecycle management. "Implementation Strategy": Review the phased approach to rolling out mTLS, which aligns with best practices for infrastructure projects.
By leveraging a service mesh, you enforce strong, cryptographically-verified identity for every service-to-service interaction, a cornerstone of modern infrastructure security.
3. Securing Credentials: Advanced Secrets Management
We've secured the network and the communication channels. The final piece of the puzzle is securing the credentials that our applications use, such as:
- API keys for third-party models (OpenAI, Anthropic).
- Database connection strings.
- Private keys for signing tokens.
As you know from your SRE work, hardcoding secrets or committing them to Git is a critical anti-pattern. While Kubernetes offers a native Secret object, it has a significant limitation: the data is only Base64 encoded, not encrypted at rest. Anyone with API access to read the secret can easily decode it.
A more robust solution involves using an external, dedicated secrets management system like HashiCorp Vault, AWS Secrets Manager, or Azure Key Vault. These systems provide encryption at rest, fine-grained access policies, audit logging, and automated secret rotation.
To bridge the gap between your secure external store and your Kubernetes applications, you can use the External Secrets Operator (ESO). This operator fetches secrets from the external store and automatically creates or updates native Kubernetes Secret objects within your cluster. Your applications can then consume these secrets as they normally would, without ever knowing about the external vault.
The following video demonstrates this entire workflow.
Kubernetes Security Tutorial - RBAC, Network Policies, Kyverno, Secrets, External Secrets Operator
This tutorial from Abhishek Veeramalla provides a clear, practical guide to secret management in Kubernetes.
Watch these two key segments: Native Secrets: This section explains what Kubernetes secrets are, how to use them, and crucially, demonstrates why they are insecure by default (Base64 encoding). External Secrets Operator: This is the core of the modern approach. Pay close attention to the three-step process: installing a provider (Vault), registering it as a SecretStore, and creating an ExternalSecret manifest that references the secret in Vault without ever exposing its value in your Git repository.
This pattern—storing secrets externally and syncing them into the cluster on-demand—is a best practice that aligns with GitOps principles and provides a high degree of security and auditability.
For cloud-native access, an even more advanced approach is to eliminate long-lived secrets entirely by using federated identity with OIDC, as illustrated below. This is particularly relevant for your background in AWS and Azure.

Conclusion
In this lesson, we've covered how to apply fundamental security best practices to harden your LLM infrastructure. By combining network policies, mTLS, and robust secrets management, you establish a secure foundation upon which all other application-level security controls can be built.
Key Takeaways:
- Defense-in-Depth: Security is about layers. We've built up from controlling network paths (
NetworkPolicy), to securing communication on those paths (mTLS), to protecting the credentials used by the applications themselves (Secrets Management). - Kubernetes Network Policies are your first line of defense for isolating workloads and preventing lateral movement within your cluster.
- mTLS, often implemented with a Service Mesh, provides strong, cryptographically-verified identity for all service-to-service communication, creating a zero-trust network.
- Advanced Secrets Management uses external stores like Vault or cloud KMS, combined with the External Secrets Operator, to keep sensitive credentials out of your code and Git repositories, providing a secure, auditable, and manageable solution.
This concludes our module on LLM Security and Governance. You now have a comprehensive understanding of the key security considerations for building and operating LLM systems, from application-level controls like RBAC and guardrails to the foundational infrastructure hardening we discussed today.
In our next lesson, we will begin a new module, Advanced Orchestration and Scaling for LLMs, where we will dive into the practicalities of making GPUs available to your containerized workloads.