Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
431 views
in Technique[技术] by (71.8m points)

google cloud platform - How to avoid recreating ingress when recreate service on GKE?

When I delete a service and recreate, I've noticed that status of the ingress indicates Some backend services are in UNKNOWN state.
After some trials and errors, it seems to be related to name of network endpoint group(NEG). NEG tied with a new service has different name, but the ingress gets an old NEG as backend services. Then, I found that they works again after I recreate an Ingress.
I'd like to avoid downtime to recreate an ingress as much as possible.
Is there a way to avoid recreating ingress when recreating services?

My Service

apiVersion: v1
kind: Service
metadata:
  name: client-service
  labels:
    app: client
spec:
  type: ClusterIP
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  selector:
    app: client

My Ingress

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: static-ip-name
    networking.gke.io/managed-certificates: managed-certificate
spec:
  rules:
    - http:
        paths:
          - path: /*
            backend:
              serviceName: client-service
              servicePort: 80


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you want to re-use the ingress when the service disappears, you can edit its configuration instead of deleting and recreating it.

To reconfigure the Ingress you will have to update it by editing the configuration, as specified in the official Kubernetes documentation. To do this, you can perform the following steps:

  1. Issue the command kubectl edit ingress test
  2. Perform the necessary changes, like updating the service configuration
  3. Save the changes
  4. kubectl will update the resource, and trigger an update on the load balancer.
  5. Verify the changes by executing the command kubectl describe ingress test

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

62 comments

56.5k users

...