From 6e8d84f73d61dc3990a56c0450540ef444230344 Mon Sep 17 00:00:00 2001 From: buxiaomo <95112082@qq.com> Date: Wed, 13 Nov 2024 13:21:04 +0800 Subject: [PATCH] fix filter "ansible.netcommon.next_nth_usable" has been deprecated --- roles/add-on/templates/coredns.yaml.j2 | 16 ++++++++-------- roles/kube-apiserver/tasks/main.yml | 4 ++-- roles/kubelet/templates/kubelet.yaml.j2 | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/roles/add-on/templates/coredns.yaml.j2 b/roles/add-on/templates/coredns.yaml.j2 index 88ed7fd2b..466e89741 100644 --- a/roles/add-on/templates/coredns.yaml.j2 +++ b/roles/add-on/templates/coredns.yaml.j2 @@ -177,25 +177,25 @@ spec: k8s-app: kube-dns {% if (networking.podSubnet.split(',') | length == 2) and (networking.serviceSubnet.split(',') | length == 2) %} ipFamilyPolicy: PreferDualStack -{% if networking.serviceSubnet.split(',')[0] | default('10.96.0.0/12') | ansible.netcommon.next_nth_usable(2) | ip == 4 %} +{% if networking.serviceSubnet.split(',')[0] | default('10.96.0.0/12') | ansible.utils.next_nth_usable(2) | ip == 4 %} ipFamilies: - IPv4 - IPv6 - clusterIP: {{ networking.serviceSubnet.split(',')[0] | ansible.netcommon.next_nth_usable(2) }} + clusterIP: {{ networking.serviceSubnet.split(',')[0] | ansible.utils.next_nth_usable(2) }} clusterIPs: - - {{ networking.serviceSubnet.split(',')[0] | ansible.netcommon.next_nth_usable(2) }} - - {{ networking.serviceSubnet.split(',')[1] | ansible.netcommon.next_nth_usable(2) }} + - {{ networking.serviceSubnet.split(',')[0] | ansible.utils.next_nth_usable(2) }} + - {{ networking.serviceSubnet.split(',')[1] | ansible.utils.next_nth_usable(2) }} {% else %} ipFamilies: - IPv6 - IPv4 - clusterIP: {{ networking.serviceSubnet.split(',')[1] | ansible.netcommon.next_nth_usable(2) }} + clusterIP: {{ networking.serviceSubnet.split(',')[1] | ansible.utils.next_nth_usable(2) }} clusterIPs: - - {{ networking.serviceSubnet.split(',')[1] | ansible.netcommon.next_nth_usable(2) }} - - {{ networking.serviceSubnet.split(',')[0] | ansible.netcommon.next_nth_usable(2) }} + - {{ networking.serviceSubnet.split(',')[1] | ansible.utils.next_nth_usable(2) }} + - {{ networking.serviceSubnet.split(',')[0] | ansible.utils.next_nth_usable(2) }} {% endif %} {% else %} - clusterIP: {{ networking.serviceSubnet | default('10.96.0.0/12') | ansible.netcommon.next_nth_usable(2) }} + clusterIP: {{ networking.serviceSubnet | default('10.96.0.0/12') | ansible.utils.next_nth_usable(2) }} {% endif %} ports: - name: dns diff --git a/roles/kube-apiserver/tasks/main.yml b/roles/kube-apiserver/tasks/main.yml index 0f5c3f488..458207786 100644 --- a/roles/kube-apiserver/tasks/main.yml +++ b/roles/kube-apiserver/tasks/main.yml @@ -96,8 +96,8 @@ - "IP:127.0.0.1" - "IP:0:0:0:0:0:0:0:1" - "IP:::1" - - "IP:{{ networking.serviceSubnet.split(',')[0] | default('10.96.0.0/12') | ansible.netcommon.next_nth_usable(1) }}" - - "IP:{{ networking.serviceSubnet.split(',')[1] | default('fd74:ca9b:0172:0019::/110') | ansible.netcommon.next_nth_usable(1) }}" + - "IP:{{ networking.serviceSubnet.split(',')[0] | default('10.96.0.0/12') | ansible.utils.next_nth_usable(1) }}" + - "IP:{{ networking.serviceSubnet.split(',')[1] | default('fd74:ca9b:0172:0019::/110') | ansible.utils.next_nth_usable(1) }}" - "IP:{{ inventory_hostname }}" - "{% if ansible_default_ipv6.address is defined %}IP:{{ ansible_default_ipv6.address }}{% else %}IP:::1{% endif %}" - "{% if ipv6 is defined %}IP:{{ ipv6 }}{% else %}IP:::1{% endif %}" diff --git a/roles/kubelet/templates/kubelet.yaml.j2 b/roles/kubelet/templates/kubelet.yaml.j2 index b41d62a4e..381cd9bf9 100644 --- a/roles/kubelet/templates/kubelet.yaml.j2 +++ b/roles/kubelet/templates/kubelet.yaml.j2 @@ -18,10 +18,10 @@ cgroupDriver: systemd cgroupsPerQOS: true clusterDNS: {% if networking.serviceSubnet.split(',') | length == 2 %} -- {{ networking.serviceSubnet.split(',')[0] | default('10.96.0.0/12') | ansible.netcommon.next_nth_usable(2) }} -- {{ networking.serviceSubnet.split(',')[1] | default('fd74:ca9b:0172:0019::/110') | ansible.netcommon.next_nth_usable(2) }} +- {{ networking.serviceSubnet.split(',')[0] | default('10.96.0.0/12') | ansible.utils.next_nth_usable(2) }} +- {{ networking.serviceSubnet.split(',')[1] | default('fd74:ca9b:0172:0019::/110') | ansible.utils.next_nth_usable(2) }} {% else %} -- {{ networking.serviceSubnet | default('10.96.0.0/12') | ansible.netcommon.next_nth_usable(2) }} +- {{ networking.serviceSubnet | default('10.96.0.0/12') | ansible.utils.next_nth_usable(2) }} {% endif %} clusterDomain: {{ networking.dnsDomain | default('cluster.local') }} configMapAndSecretChangeDetectionStrategy: Watch