kubernetes_service

A Service is an abstraction which defines a logical set of pods and a policy by which to access them - sometimes called a micro-service. This data source allows you to pull data about such service.

Example Usage

data "kubernetes_service" "example" {
  metadata {
    name = "terraform-example"
  }
}

resource "aws_route53_record" "example" {
  zone_id = "${data.aws_route53_zone.k8.zone_id}"
  name    = "example"
  type    = "CNAME"
  ttl     = "300"
  records = ["${data.kubernetes_service.example.load_balancer_ingress.0.hostname}"]
}

Argument Reference

The following arguments are supported:

Attributes

Nested Blocks

metadata

Arguments

Attributes

port

Attributes

  • name - The name of this port within the service. All ports within the service must have unique names. Optional if only one ServicePort is defined on this service.
  • node_port - The port on each node on which this service is exposed when type is NodePort or LoadBalancer. Usually assigned by the system. If specified, it will be allocated to the service if unused or else creation of the service will fail. Default is to auto-allocate a port if the type of this service requires one. More info: http://kubernetes.io/docs/user-guide/services#type--nodeport
  • port - The port that will be exposed by this service.
  • protocol - The IP protocol for this port. Supports TCP and UDP. Default is TCP.
  • target_port - Number or name of the port to access on the pods targeted by the service. Number must be in the range 1 to 65535. This field is ignored for services with cluster_ip = "None". More info: http://kubernetes.io/docs/user-guide/services#defining-a-service

spec

Attributes

load_balancer_ingress

Attributes

  • hostname - Hostname which is set for load-balancer ingress points that are DNS based (typically AWS load-balancers)
  • ip - IP which is set for load-balancer ingress points that are IP based (typically GCE or OpenStack load-balancers)

© 2018 HashiCorp
Licensed under the MPL 2.0 License.
https://www.terraform.io/docs/providers/kubernetes/d/service.html