K8sService
K8sService creates a Kubernetes Service in the target cluster. Services provide stable network endpoints for pods, supporting internal cluster DNS, load-balanced access, and external exposure.
Service port
Section titled “Service port”| Property | Type | Required | Description |
|---|---|---|---|
port |
number |
✅ | Service port |
targetPort |
number |
❌ | Pod port to route to (defaults to port) |
protocol |
string |
❌ | Protocol (TCP, UDP, SCTP; defaults to TCP) |
name |
string |
❌ | Port name (required for multi-port services) |
nodePort |
number |
❌ | Static node port (for NodePort type) |
Config
Section titled “Config”| Property | Type | Required | Description |
|---|---|---|---|
cluster |
KubernetesCluster | string |
✅ | Target cluster |
namespace |
K8sNamespace | string |
❌ | Namespace to create the Service in |
dependsOn |
string[] |
❌ | Explicit dependency ordering |
serviceType |
'ClusterIP' | 'NodePort' | 'LoadBalancer' | 'ExternalName' |
❌ | Service type (defaults to ClusterIP) |
selector |
Record<string, string> |
❌ | Label selector for pod targeting |
selectorRef |
K8sDeployment | K8sStatefulSet |
❌ | Reference to a Deployment or StatefulSet (auto-generates selector) |
ports |
K8sServicePort[] |
✅ | Port mappings |
Example
Section titled “Example”// Using selectorRef to target a deploymentconst apiService = new K8sService({ name: 'api', cluster: myCluster, namespace: myNamespace, serviceType: 'ClusterIP', selectorRef: apiDeployment, ports: [ { port: 80, targetPort: 8080, name: 'http' }, { port: 443, targetPort: 8443, name: 'https' }, ],})
// External load balancerconst ingressGateway = new K8sService({ name: 'gateway', cluster: myCluster, serviceType: 'LoadBalancer', selector: { app: 'gateway' }, ports: [{ port: 443, protocol: 'TCP', name: 'https' }],})Provider support
Section titled “Provider support”| Provider | Supported |
|---|---|
| Kubernetes | ✅ |
| Hetzner | ❌ |
| DigitalOcean | ❌ |
| AWS | ❌ |
| GCP | ❌ |