Search code examples
kubernetesservicegoogle-kubernetes-engineipv6

Not able to add ipv6 type Load Balancer IP in kubernetes service


I'm on GKE and I'm trying to expose one application using IPV6 address.

This is my service.yaml

apiVersion: v1
kind: Service
metadata:
  annotations:
    cloud.google.com/neg: '{"ingress":true}'
  labels:
    run: ubuntu
  name: ubuntu
  namespace: default
spec:
  loadBalancerIP: "<ipv6-address>"
  ipFamilies:
  - IPv6
  ipFamilyPolicy: SingleStack
  ports:
  - nodePort: 30783
    port: 5000
    protocol: TCP
    targetPort: 5001
  selector:
    run: ubuntu
  sessionAffinity: None
  type: LoadBalancer

This is my gcloud address list

deletable-pzk-reg-ip2-6           <ipv6-address>/96  EXTERNAL                    us-central1  pzksubnet1  RESERVED

I'm getting this error

  Warning  SyncLoadBalancerFailed  13s (x6 over 2m49s)  service-controller  Error syncing load balancer: failed to ensure load balancer: requested ip "<ipv6-address>" is neither static nor assigned to the LB

Please help me in debugging this.


Solution

  • Below troubleshooting steps can help you to resolve your issue:

    1. IPv6 is only for HTTP, SSL Proxy and TCP proxy and make sure you are using one of them.

    2. The following documentation describes creation of an Ingress resource.

    • Using the following reserve a regional external IPv6 address.

      - gcloud compute addresses create <your-ipv6-address-name> --global --ip-version=IPv6

    • Specify the global ip address in the YAML file using the annotation:

      kubernetes.io/ingress.global-static-ip-name: <your-ipv6-address-name>

    1. If you want to use load balancer check the Load balancer parameters, example: After reserving the static IP use it as loadBalancedIP in yaml, the load balancer will be created.
    apiVersion: v1
    kind: Servicemetadata:
      name: my-lb-service
    spec:
      type: LoadBalancer
      loadBalancerIP: <ip>
    

    Attaching a blog HTTP on Load Balancer and IPv6 authored by John Hanley for your reference.