What is a Kubernetes origin stack?
A Kubernetes origin stack consists of Kubernetes resources (Deployments, Services, ConfigMaps, etc.) defined within a Terraform or CloudFormation origin stack using the respective provider’s Kubernetes resources. Key characteristic: Kubernetes resources are always embedded within another origin stack format. The parent origin stack (Terraform or CloudFormation) serves as the container, while Kubernetes manifests define the workload orchestration.Why embed Kubernetes?
Kubernetes manifests define how your application runs (pods, deployments, services), but they don’t provision the underlying infrastructure (clusters, networks, load balancers). By embedding Kubernetes within Terraform or CloudFormation, you get:- Complete infrastructure: The parent stack provisions the cluster (EKS, GKE, AKS) and supporting infrastructure
- Unified deployment: One release process deploys both infrastructure and workloads
- Automatic artifact handling: Tensor9 automatically copies container images to customer environments
- Form factor adaptation: Kubernetes workloads adapt to different cloud environments seamlessly
How Kubernetes origin stacks work
Define Kubernetes resources in Terraform/CloudFormation
kubernetes_manifest or kubernetes_deployment resources:Terraform example:Publish and create a release
- Finds Kubernetes resources: Scans the origin stack for
kubernetes_manifest,kubernetes_deployment, and other Kubernetes provider resources - Extracts container images: Identifies all container image references in Kubernetes specs
- Prepares image copying: Configures the deployment stack to copy images to the appliance’s container registry (specific to the cloud provider)
- Rewrites image references: Updates container image fields to point to the locally-copied images
- Compiles the deployment stack: Generates a ready-to-deploy stack with all Kubernetes resources intact
Deploy to the appliance
Supported Kubernetes resources
Tensor9 automatically handles artifact copying for these Kubernetes resource types:kubernetes_manifest (Terraform)
Thekubernetes_manifest resource accepts any Kubernetes manifest as a map. Tensor9 automatically detects and processes:
- Deployments (
kind: "Deployment"): Extracts container images fromspec.template.spec.containers[].image - Other workload types: Support for additional resource types is expanding
kubernetes_deployment (Terraform)
Thekubernetes_deployment resource provides typed Kubernetes Deployment support. Tensor9 extracts container images from the deployment spec.
Example:
Other Kubernetes provider resources
Tensor9 supports other Kubernetes provider resources (Services, ConfigMaps, Secrets, etc.). These resources pass through compilation unchanged, as they typically don’t reference external artifacts.Helm charts
Helm charts can be deployed using the Terraform Helm provider. Helm is a package manager for Kubernetes that bundles multiple Kubernetes resources into a single deployable unit called a “chart.”Add the Helm provider to your Terraform configuration
required_providers block:Configure the provider to connect to your Kubernetes cluster
Deploy charts using helm_release resources
helm_release resources to deploy Helm charts:How Helm charts are compiled
Helm resources pass through
helm_release resource is included in the deployment stack unchanged.Charts deploy at runtime
tofu apply on the deployment stack, Terraform installs the Helm chart into the cluster.Container images in charts
Best practices for Helm charts
- Pin chart versions: Always specify a
versionin yourhelm_releaseto ensure consistent deployments - Use accessible registries: Ensure Helm charts reference images from registries the appliance can reach
- Test chart deployments: Validate Helm charts in test appliances before deploying to customer appliances
- Configure chart values: Use
setorvaluesblocks to customize chart behavior for each environment
Container image handling
Tensor9 automatically handles container images referenced in Kubernetes resources:Automatic image copying
When Tensor9 finds a container image in a Kubernetes resource, it:- Validates the image reference: Ensures the image has a registry (e.g.,
docker.io,ghcr.io,myregistry.io) - Configures image copying: Prepares the deployment stack to copy the image to the appliance’s container registry
- Rewrites the reference: Updates the Kubernetes manifest to point to the locally-copied image
Image registry requirements
For Tensor9 to copy a container image, it must include a registry in the image reference:- ✅ Supported:
docker.io/nginx:latest,ghcr.io/myorg/app:v1.0,myregistry.io/image:tag - ⚠️ Skipped:
nginx:latest(no registry - assumed to be publicly available in the appliance)
docker.io/nginx:latest instead of nginx:latest.Where images are stored
Copied container images are stored in the appliance’s container registry. The storage location is determined by the appliance’s form factor and is handled automatically by Tensor9:Prerequisites
Before using Kubernetes resources in your origin stack:For Terraform origin stacks
- Kubernetes provider configured: Include the Kubernetes Terraform provider in your
required_providers - Cluster access configured: The Kubernetes provider must be configured to connect to your cluster (typically via EKS, GKE, or AKS data sources)
- Valid Kubernetes manifests: Your Kubernetes resources must be valid according to the Kubernetes API
For CloudFormation origin stacks
Support for Kubernetes resources in CloudFormation origin stacks is under development. Currently, Terraform is the recommended approach for embedding Kubernetes resources.Example: Complete Terraform + Kubernetes origin stack
This example shows a complete Terraform origin stack that provisions an EKS cluster and deploys a Kubernetes application:Publishing and deploying
Publishing and deploying a Kubernetes origin stack follows the same workflow as any Terraform origin stack:1. Publish your origin stack
2. Bind the stack to your app
3. Create a release
4. Deploy the deployment stack
Best practices
Always specify image registries
Always specify image registries
docker.io/nginx:latest instead of nginx:latest). This ensures Tensor9 can copy the images to customer environments.Configure provider authentication carefully
Configure provider authentication carefully
aws_eks_cluster) rather than hardcoded values. This ensures the provider configuration adapts to each appliance’s cluster.Use environment variables for secrets
Use environment variables for secrets
Mind resource limits and requests
Mind resource limits and requests
Limitations and considerations
Standalone Kubernetes manifests not supported
Standalone Kubernetes manifests not supported
Cluster must exist before Kubernetes resources
Cluster must exist before Kubernetes resources
depends_on in Terraform) to ensure correct ordering.Kubernetes provider versions
Kubernetes provider versions
Image pull secrets
Image pull secrets
Troubleshooting
Container image not copied
Container image not copied
- Ensure your image reference includes the full registry:
docker.io/nginx:latest - Check that the image is referenced in a supported field (
spec.containers[].image) - Review compilation logs for warnings about skipped images
Kubernetes provider authentication fails
Kubernetes provider authentication fails
- Verify the cluster exists before applying Kubernetes resources
- Use data sources to dynamically configure the provider
- Check that IAM roles/permissions allow cluster access
Deployment applies but pods don't start
Deployment applies but pods don't start
ImagePullBackOff.Cause: Pods cannot pull the container image from the appliance registry.Solution:- Verify that the deployment stack shows rewritten image references
- Check that the node group has permissions to pull from ECR (for AWS)
- Ensure the image was successfully copied during compilation
Related topics
- Terraform/OpenTofu: Learn about Terraform origin stacks
- CloudFormation: Learn about CloudFormation origin stacks
- Deployments: Understand the deployment workflow
- Form Factors: How Kubernetes workloads adapt to different environments