Note
By default, the provider ignores any annotations whose key names end with kubernetes.io. This is necessary because such annotations can be mutated by server-side components and consequently cause a perpetual diff in the Terraform plan output. If you explicitly specify any such annotations in the configuration template then Terraform will consider these as normal resource attributes and manage them as expected (while still avoiding the perpetual diff problem). For more info see Kubernetes reference
Note
By default, the provider ignores any labels whose key names end with kubernetes.io. This is necessary because such labels can be mutated by server-side components and consequently cause a perpetual diff in the Terraform plan output. If you explicitly specify any such labels in the configuration template then Terraform will consider these as normal resource attributes and manage them as expected (while still avoiding the perpetual diff problem). For more info see Kubernetes reference
resource "kubernetes_endpoints" "example" {
metadata {
name = "terraform-example"
}
subset {
address {
ip = "10.0.0.4"
}
address {
ip = "10.0.0.5"
}
port {
name = "http"
port = 80
protocol = "TCP"
}
port {
name = "https"
port = 443
protocol = "TCP"
}
}
subset {
address {
ip = "10.0.1.4"
}
address {
ip = "10.0.1.5"
}
port {
name = "http"
port = 80
protocol = "TCP"
}
port {
name = "https"
port = 443
protocol = "TCP"
}
}
}
resource "kubernetes_service" "example" {
metadata {
name = "${kubernetes_endpoints.example.metadata.0.name}"
}
spec {
port {
port = 8080
target_port = 80
}
port {
port = 8443
target_port = 443
}
}
}
apiVersion: discovery.k8s.io/v1
kind: EndpointSlice
metadata:
name: example-abc
labels:
kubernetes.io/service-name: example
addressType: IPv4
ports:
- name: http
protocol: TCP
port: 80
endpoints:
- addresses:
- "10.1.2.3"
conditions:
ready: true
hostname: pod-1
nodeName: node-1
zone: us-west2-a
Categorized by Availability, Security & Compliance and Cost