Skip to content

K8s Service

udx-github edited this page Jul 3, 2026 · 3 revisions

Creates a Kubernetes Service from a native manifest definition.

Use this module when a Rabbit service needs a ClusterIP, NodePort, or LoadBalancer service to expose pods within or outside the cluster.

Supported Features

  • Service creation from a standard Kubernetes manifest.
  • ClusterIP, NodePort, and LoadBalancer service types.
  • Multiple port definitions with named ports.
  • Label-based pod selector.

Prerequisites

  • A kubeconfig secret created by the k8s-access module.
  • The target namespace and pods must exist.

Important Notes

  • The configurations key accepts an array of Kubernetes manifests. The module extracts the first manifest with kind: Service.
  • The service type defaults to ClusterIP when not specified.

Minimal Example

services:
  - name: "k8s Service"
    module: "k8s-service"
    id: "app-service"
    deployment_order: 90
    configurations:
      - kind: "Service"
        metadata:
          name: "www-example-com"
          namespace: "www-example-com"
          labels:
            app: "www-example-com"
        spec:
          type: "ClusterIP"
          selector:
            app: "www-example-com"
          ports:
            - name: "http"
              port: 80
              targetPort: 8080

Outputs

Output Description
service Created service details including name, namespace, type, cluster_ip, and ports.

Full Configuration Schema

The configurations key accepts an array containing a native Kubernetes Service manifest.

configurations:
  - kind: "Service"
    metadata:
      name: ""
      namespace: ""
      labels: {}
    spec:
      type: "ClusterIP"
      selector: {}
      ports:
        - name: ""
          port: 80
          targetPort: 8080
          protocol: "TCP"
Field Type Required Description
kind string Yes Must be Service.
metadata.name string Yes Service name.
metadata.namespace string Yes Target namespace.
metadata.labels map[string] No Kubernetes labels.
spec.type string No Service type: ClusterIP, NodePort, or LoadBalancer. Defaults to ClusterIP.
spec.selector map[string] Yes Label selector matching target pods.
spec.ports array[port] Yes Port definitions.
spec.ports[].name string No Port name.
spec.ports[].port number Yes Service port.
spec.ports[].targetPort number or string Yes Target port on the pod.
spec.ports[].protocol string No Protocol. Defaults to TCP.

Clone this wiki locally