Skip to content

Enhance the cilium-bgp-advertisement.yml.j2 template #12843

@MRjiangmb

Description

@MRjiangmb

What would you like to be added

{% for item in cilium_bgp_advertisements %}
---
apiVersion: cilium.io/v2
kind: CiliumBGPAdvertisement
metadata:
  name: "{{ cilium_bgp_advertisement.name }}"
{% if cilium_bgp_advertisement.labels %}
  labels: {{ cilium_bgp_advertisement.labels | to_yaml }}
{% endif %}
spec:
  {{ cilium_bgp_advertisement.spec | to_yaml | indent(4) }}
{% endfor %}

The template cannot correctly recognize the use of 'matchLabels:'

Why is this needed

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: 'cilium_bgp_advertisement' is undefined
failed: [master01] (item={'name': 'cilium', 'file': 'cilium-bgp-advertisement.yml', 'type': 'CiliumBGPAdvertisement'}) => {"ansible_loop_var": "item", "changed": false, "item": {"file": "cilium-bgp-advertisement.yml", "name": "cilium", "type": "CiliumBGPAdvertisement"}, "msg": "AnsibleUndefinedVariable: 'cilium_bgp_advertisement' is undefined"}

When I used this format, an error occurred. However, according to the official website, it is allowed, so the template may need to be enhanced.

cilium_bgp_advertisements:
  - name: advertise-bgp
    labels:
      advertise: bgp
    spec:
      advertisements:
        - advertisementType: "PodCIDR"
        - advertisementType: "Service"
          service:
            addresses:
              - ClusterIP
          selector:
            matchLabels:
              app: rook-ceph-mon

---
apiVersion: cilium.io/v2
kind: CiliumPodIPPool
metadata:
  name: default
  labels:
    pool: blue

---
apiVersion: cilium.io/v2
kind: CiliumBGPAdvertisement
metadata:
  name: pod-ip-pool-advert
  labels:
    advertise: bgp
spec:
  advertisements:
    - advertisementType: "CiliumPodIPPool"
      selector:
        matchLabels:
          pool: "blue"

Metadata

Metadata

Assignees

Labels

kind/featureCategorizes issue or PR as related to a new feature.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions