Skip to content

You are viewing documentation for Instruqt 2.0 Labs - our upcoming product releasing in September 2026. For current Tracks documentation, please visitdocs.instruqt.com.

Kubernetes Config


Defined insandboxes.hclAlso known askubernetes_config

The kubernetes_config resource applies Kubernetes configuration files to a Kubernetes cluster. It supports individual files or directories containing YAML/JSON manifests, with optional health checks to ensure successful deployment.

As a lab author, you can use kubernetes_config resources to:

  • Application Deployment: Deploy applications using Kubernetes manifests (Deployments, Services, ConfigMaps)
  • Infrastructure Setup: Apply cluster infrastructure components like RBAC, NetworkPolicies, and PersistentVolumes
  • Cluster Management: Configure cluster-wide settings, operators, and administrative resources

Kubernetes config resources enable declarative infrastructure deployment with health verification and dependency management.

resource "kubernetes_config" "name" {
cluster = resource.kubernetes_cluster.dev
paths = ["./k8s/deployment.yaml"]
wait_until_ready = true
}
resource "kubernetes_config" "name" {
cluster = resource.kubernetes_cluster.production
paths = [
"./k8s/namespace.yaml",
"./k8s/deployments/",
"./k8s/services.yaml"
]
wait_until_ready = true
health_check {
timeout = "120s"
pods = [
"app=web-server",
"app.kubernetes.io/name=api"
]
}
}

Fields

FieldTypeRequiredDescription
clusterreferencek8s_clusterReference to the Kubernetes cluster to apply configuration to
pathslist(string)Paths to Kubernetes manifest files or directories to apply
wait_until_readyboolWait for all resources to be ready before proceeding
health_checkblockHealth check configuration for applied resources

Health Check

k8s_configHealth Check

Health check configuration for applied resources

FieldTypeRequiredDescription
timeoutstringMaximum time to wait for health check (e.g. 120s)
ConstraintsMust be a valid duration (e.g. 30s, 5m)
podslist(string)Pod name patterns to check for readiness

Computed Attributes

These attributes are set by the system and are read-only.

AttributeTypeDescription
job_checksumsmap(string)Checksums of applied Kubernetes manifests for change detection
resource "kubernetes_config" "webapp" {
cluster = resource.kubernetes_cluster.dev
paths = ["./k8s/webapp-deployment.yaml"]
wait_until_ready = true
health_check {
timeout = "60s"
pods = ["app=webapp"]
}
}
resource "kubernetes_config" "microservices" {
cluster = resource.kubernetes_cluster.app
paths = [
"./k8s/namespace.yaml",
"./k8s/configmaps/",
"./k8s/deployments/",
"./k8s/services/"
]
wait_until_ready = true
health_check {
timeout = "180s"
pods = [
"app=api-service",
"app=web-frontend",
"app=worker"
]
}
}
resource "kubernetes_config" "database" {
cluster = resource.kubernetes_cluster.data
paths = [
"./k8s/postgres-secret.yaml",
"./k8s/postgres-pvc.yaml",
"./k8s/postgres-deployment.yaml",
"./k8s/postgres-service.yaml"
]
wait_until_ready = true
health_check {
timeout = "120s"
pods = ["app=postgresql"]
}
}
resource "kubernetes_config" "dev_stack" {
cluster = resource.kubernetes_cluster.development
paths = ["./k8s/dev-environment/"]
wait_until_ready = true
health_check {
timeout = "300s"
pods = [
"app=redis",
"app=postgres",
"app=rabbitmq",
"tier=development"
]
}
}
resource "kubernetes_config" "security" {
cluster = resource.kubernetes_cluster.secure
paths = [
"./k8s/rbac/service-accounts.yaml",
"./k8s/rbac/cluster-roles.yaml",
"./k8s/rbac/role-bindings.yaml",
"./k8s/network-policies/"
]
wait_until_ready = true
}
resource "kubernetes_config" "monitoring" {
cluster = resource.kubernetes_cluster.production
paths = [
"./k8s/monitoring/namespace.yaml",
"./k8s/monitoring/prometheus/",
"./k8s/monitoring/grafana/",
"./k8s/monitoring/alertmanager/"
]
wait_until_ready = true
health_check {
timeout = "240s"
pods = [
"app.kubernetes.io/name=prometheus",
"app.kubernetes.io/name=grafana",
"app.kubernetes.io/name=alertmanager"
]
}
}
./k8s/webapp-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: webapp
labels:
app: webapp
spec:
replicas: 2
selector:
matchLabels:
app: webapp
template:
metadata:
labels:
app: webapp
spec:
containers:
- name: webapp
image: nginx:1.21
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: webapp
spec:
selector:
app: webapp
ports:
- port: 80
targetPort: 80
type: ClusterIP
# Deploy infrastructure first
resource "kubernetes_config" "infrastructure" {
cluster = resource.kubernetes_cluster.app
paths = [
"./k8s/namespaces.yaml",
"./k8s/rbac/",
"./k8s/secrets/"
]
wait_until_ready = true
}
# Deploy databases after infrastructure
resource "kubernetes_config" "databases" {
depends_on = [resource.kubernetes_config.infrastructure]
cluster = resource.kubernetes_cluster.app
paths = ["./k8s/databases/"]
wait_until_ready = true
health_check {
timeout = "120s"
pods = ["tier=database"]
}
}
# Deploy applications after databases
resource "kubernetes_config" "applications" {
depends_on = [resource.kubernetes_config.databases]
cluster = resource.kubernetes_cluster.app
paths = ["./k8s/apps/"]
wait_until_ready = true
health_check {
timeout = "180s"
pods = ["tier=application"]
}
}
  1. Organized Structure: Organize configuration files in logical directories (namespaces, apps, infrastructure)
  2. Health Checks: Always configure health checks for critical application components
  3. Dependency Management: Use depends_on to ensure proper deployment order
  4. Wait Strategy: Set wait_until_ready = true for resources that other components depend on
  5. Realistic Timeouts: Set appropriate health check timeouts based on application startup time
  6. Label Consistency: Use consistent labeling across resources for effective health checking
  7. Path Organization: Use directories for related configurations and individual files for standalone resources