Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: service.annotations did not find expected key #778

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bruhsb
Copy link

@bruhsb bruhsb commented Sep 4, 2024

Bugfix for a issue about setting annotations for Service Gateway, in the Apisix Helm Chart

How to reproduce:

1 - From master, in a local clone, update the block service: uncommenting the annotation block and including the following lines in the values.yaml

service:
  # -- Apache APISIX service type for user access itself
  type: NodePort
  # -- Setting how the Service route external traffic
  # If you want to keep the client source IP, you can set this to Local.

  # ref: https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip
  externalTrafficPolicy: Cluster
  # type: LoadBalancer
  annotations:
    cloud.google.com/neg: '{"exposed_ports": {"80":{"name":""}}}'
    controller.autoneg.dev/neg: |
      {"backend_services": {"80":[
        {"max_rate_per_endpoint":2000,"name":"apisix-backend-service"},
        {"max_rate_per_endpoint":2000,"name":"xlb-ng-apisix-backend-service"}
      ]}}

2 - Run helm template apisix apisix-helm-chart/charts/apisix from root folder

--- helm template apisix apisix-helm-chart/charts/apisix Output without the fix:

# Source: apisix/templates/service-gateway.yaml
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: Service
metadata:
  name: apisix-gateway
  namespace: default
  annotations:
      cloud.google.com/neg: "{\"exposed_ports\": {\"80\":{\"name\":\"\"}}}"
      controller.autoneg.dev/neg: "{\"backend_services\": {\"80\":[\n  {\"max_rate_per_endpoint\":2000,\"name\":\"apisix-backend-service\"},\n  {\"max_rate_per_endpoint\":2000,\"name\":\"xlb-ng-apisix-backend-service\"}\n]}}\n"
  labels:
    helm.sh/chart: apisix-2.8.1
    
    app.kubernetes.io/name: apisix
    app.kubernetes.io/instance: apisix
    app.kubernetes.io/version: "3.9.1"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/service: apisix-gateway
spec:
  type: NodePort
  externalTrafficPolicy: Cluster
  ports:
  - name: apisix-gateway
    port: 80
    targetPort: 9080
    protocol: TCP
  selector:
    
    app.kubernetes.io/name: apisix
    app.kubernetes.io/instance: apisix
---

--- helm template apisix apisix-helm-chart/charts/apisix Output with the fix:

# Source: apisix/templates/service-gateway.yaml
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: Service
metadata:
  name: apisix-gateway
  namespace: default
  annotations:
    cloud.google.com/neg: '{"exposed_ports": {"80":{"name":""}}}'
    controller.autoneg.dev/neg: |
      {"backend_services": {"80":[
        {"max_rate_per_endpoint":2000,"name":"apisix-backend-service"},
        {"max_rate_per_endpoint":2000,"name":"xlb-ng-apisix-backend-service"}
      ]}}
  labels:
    helm.sh/chart: apisix-2.8.1
    
    app.kubernetes.io/name: apisix
    app.kubernetes.io/instance: apisix
    app.kubernetes.io/version: "3.9.1"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/service: apisix-gateway
spec:
  type: NodePort
  externalTrafficPolicy: Cluster
  ports:
  - name: apisix-gateway
    port: 80
    targetPort: 9080
    protocol: TCP
  selector:
    
    app.kubernetes.io/name: apisix
    app.kubernetes.io/instance: apisix
---

#495 #591 cc @Gallardot @Revolyssup

@bruhsb bruhsb marked this pull request as ready for review September 4, 2024 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants