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.

Ingress


Defined insandbox.hcl

The ingress resource creates network traffic routing between local machine and cluster services. It enables exposing Kubernetes/Nomad cluster services to users or exposing local services to clusters for testing and development.

As a lab author, you can use ingress resources to provide access to cluster services:

  • Cluster Service Access: Expose web applications running in Kubernetes/Nomad clusters for users to interact with
  • Development Workflows: Enable local-to-cluster connectivity for development and debugging scenarios
  • Service Discovery Labs: Demonstrate how external traffic reaches cluster services through ingress controllers

Ingress resources bridge the gap between isolated cluster environments and user access, enabling realistic scenarios without complex networking setup.

resource "ingress" "name" {
port = 8080
target {
resource = resource.kubernetes_cluster.k8s
port = 80
config = {
service = "my-service"
namespace = "default"
}
}
}
resource "ingress" "name" {
port = 8080
expose_local = false
target {
resource = resource.kubernetes_cluster.k8s
port = 80
named_port = "http"
config = {
service = "kubernetes-dashboard"
namespace = "kubernetes-dashboard"
}
}
}

Fields

FieldTypeRequiredDescription
portnumberLocal port to expose the service on
Constraintsport %v is reserved for internal use
expose_localboolExpose a local service to the target
targetblockTarget traffic destination
open_in_browserstringPath to open in the browser

Target

ingressTarget

Target traffic destination

FieldTypeRequiredDescription
resourcereferencecontainer, vm, k8s_cluster, nomad_clusterTarget resource to route traffic to
portnumberTarget port
named_portstringNamed port on the target
configmap(string)Driver-specific configuration

Computed Attributes

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

AttributeTypeDescription
ingress_idstringID of the created connector service
local_addressstringFully qualified URI for accessing from the local machine
remote_addressstringFully qualified URI for accessing in the remote machine

expose_local = false - Expose cluster services to users:

resource "ingress" "app_access" {
port = 8080
target {
resource = resource.kubernetes_cluster.k8s
port = 80
config = {
service = "my-web-app"
namespace = "default"
}
}
}

expose_local = true - Expose local services to cluster:

resource "ingress" "local_api" {
port = 3000
expose_local = true
target {
resource = resource.kubernetes_cluster.k8s
config = {
service = "local-dev-api"
namespace = "default"
}
}
}
resource "ingress" "k8s_dashboard" {
port = 8080
target {
resource = resource.kubernetes_cluster.training
port = 443
config = {
service = "kubernetes-dashboard"
namespace = "kubernetes-dashboard"
}
}
}
resource "ingress" "webapp" {
port = 8080
target {
resource = resource.kubernetes_cluster.cluster
port = 80
config = {
service = "nginx-service"
namespace = "web"
}
}
}
resource "ingress" "pgadmin" {
port = 5050
target {
resource = resource.kubernetes_cluster.database
port = 80
config = {
service = "pgadmin"
namespace = "database"
}
}
}
resource "ingress" "api_server" {
port = 8000
target {
resource = resource.kubernetes_cluster.api
named_port = "api"
config = {
service = "api-service"
namespace = "api"
}
}
}
resource "ingress" "frontend" {
port = 3000
target {
resource = resource.kubernetes_cluster.app
port = 80
config = {
service = "frontend-service"
namespace = "web"
}
}
}
resource "ingress" "backend" {
port = 3001
target {
resource = resource.kubernetes_cluster.app
port = 8080
config = {
service = "backend-service"
namespace = "api"
}
}
}
resource "ingress" "database" {
port = 5432
target {
resource = resource.kubernetes_cluster.app
port = 5432
config = {
service = "postgres"
namespace = "database"
}
}
}

Ingress resources are commonly referenced by service resources:

resource "service" "webapp" {
target = resource.ingress.webapp
}
resource "layout" "app_layout" {
column {
instructions {}
}
column {
tab "app" {
target = resource.service.webapp
title = "Web Application"
active = true
}
}
}
  1. Port Organization: Use consistent port ranges for different service types
  2. Service Discovery: Use meaningful service names that match Kubernetes deployments
  3. Namespace Management: Organize services by namespace for clarity
  4. Security: Be cautious when exposing database or admin interfaces
  5. Documentation: Clearly document exposed services and their purposes
  6. Testing: Verify ingress connectivity before lab deployment
Terminal window
## Verify service exists in cluster
kubectl get svc -n namespace-name
# Check ingress configuration
resource "ingress" "app" {
target {
config = {
service = "correct-service-name" # Must match kubectl output
namespace = "correct-namespace" # Must match kubectl output
}
}
}
# Ensure unique local ports
resource "ingress" "app1" { port = 8080 }
resource "ingress" "app2" { port = 8081 } # Different port
Terminal window
# Check cluster connectivity
kubectl port-forward svc/service-name port:port -n namespace
# Verify ingress target matches
resource "ingress" "app" {
port = 8080 # This is the local port users access
target {
port = 80 # This must match the service port in Kubernetes
}
}