From 6a94f79d9d881d3bf3819e0f030f06082ce723be Mon Sep 17 00:00:00 2001 From: Tadas Sutkaitis Date: Mon, 26 May 2025 18:18:27 +0300 Subject: [PATCH 1/3] feat: allow set capo instance creation timeoput Signed-off-by: Tadas Sutkaitis --- roles/cluster_api/defaults/main.yml | 2 ++ roles/cluster_api/tasks/patch.yml | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/roles/cluster_api/defaults/main.yml b/roles/cluster_api/defaults/main.yml index 5b4f884a..15587711 100644 --- a/roles/cluster_api/defaults/main.yml +++ b/roles/cluster_api/defaults/main.yml @@ -35,3 +35,5 @@ cluster_api_control_plane_version: "{{ cluster_api_version }}" # cluster_api_infrastructure_version: cluster_api_node_selector: {} + +cluster_api_capo_instance_creation_timeout: 10 diff --git a/roles/cluster_api/tasks/patch.yml b/roles/cluster_api/tasks/patch.yml index 1159c3b0..d628f011 100644 --- a/roles/cluster_api/tasks/patch.yml +++ b/roles/cluster_api/tasks/patch.yml @@ -52,3 +52,26 @@ - {"crd": "kubeadmconfigtemplates.bootstrap.cluster.x-k8s.io", "path": "/spec/versions/2/schema/openAPIV3Schema/properties/spec/properties/template/properties/spec/properties/joinConfiguration/properties/nodeRegistration/properties/imagePullPolicy/default"} - {"crd": "kubeadmcontrolplanes.controlplane.cluster.x-k8s.io", "path": "/spec/versions/2/schema/openAPIV3Schema/properties/spec/properties/kubeadmConfigSpec/properties/initConfiguration/properties/nodeRegistration/properties/imagePullPolicy/default"} - {"crd": "kubeadmcontrolplanes.controlplane.cluster.x-k8s.io", "path": "/spec/versions/2/schema/openAPIV3Schema/properties/spec/properties/kubeadmConfigSpec/properties/joinConfiguration/properties/nodeRegistration/properties/imagePullPolicy/default"} + +- name: Set CAPO instance creation timeout + changed_when: false + when: cluster_api_infrastructure_provider == "openstack" + ansible.builtin.command: | + kubectl patch deployment capo-controller-manager \ + -n capo-system \ + --type=json \ + -p='[ + { + "op": "add", + "path": "/spec/template/spec/containers/0/env", + "value": [] + }, + { + "op": "add", + "path": "/spec/template/spec/containers/0/env/-", + "value": { + "name": "CLUSTER_API_OPENSTACK_INSTANCE_CREATE_TIMEOUT", + "value": "{{ cluster_api_capo_instance_creation_timeout | quote }}" + } + } + ]' From b2028f690dd36062830f13f9e5a8bb9844e9a3c0 Mon Sep 17 00:00:00 2001 From: Tadas Sutkaitis Date: Mon, 26 May 2025 18:30:58 +0300 Subject: [PATCH 2/3] fix: license and rename variable Signed-off-by: Tadas Sutkaitis --- roles/cluster_api/defaults/main.yml | 23 +++++------------------ roles/cluster_api/meta/main.yml | 15 ++------------- roles/cluster_api/tasks/init.yml | 15 ++------------- roles/cluster_api/tasks/main.yml | 15 ++------------- roles/cluster_api/tasks/patch.yml | 17 +++-------------- roles/cluster_api/tasks/upgrade.yml | 15 ++------------- roles/cluster_api/vars/main.yml | 15 ++------------- 7 files changed, 18 insertions(+), 97 deletions(-) diff --git a/roles/cluster_api/defaults/main.yml b/roles/cluster_api/defaults/main.yml index 15587711..2bc2bb29 100644 --- a/roles/cluster_api/defaults/main.yml +++ b/roles/cluster_api/defaults/main.yml @@ -1,20 +1,6 @@ -# Copyright (c) 2023 VEXXHOST, Inc. -# -# Licensed 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. - -# clusterctl depends heavily on the GitHub API and gets very quickly rate -# limited so you should set this to your own token. -# +# Copyright (c) 2025 VEXXHOST, Inc. +# SPDX-License-Identifier: Apache-2.0 + # See: https://github.com/kubernetes-sigs/cluster-api/issues/3982 cluster_api_github_token: "" @@ -36,4 +22,5 @@ cluster_api_control_plane_version: "{{ cluster_api_version }}" cluster_api_node_selector: {} -cluster_api_capo_instance_creation_timeout: 10 +# https://cluster-api-openstack.sigs.k8s.io/clusteropenstack/configuration.html#timeout-settings +cluster_api_capo_instance_create_timeout: 10 diff --git a/roles/cluster_api/meta/main.yml b/roles/cluster_api/meta/main.yml index 82874c48..80557c3d 100644 --- a/roles/cluster_api/meta/main.yml +++ b/roles/cluster_api/meta/main.yml @@ -1,16 +1,5 @@ -# Copyright (c) 2023 VEXXHOST, Inc. -# -# Licensed 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. +# Copyright (c) 2025 VEXXHOST, Inc. +# SPDX-License-Identifier: Apache-2.0 galaxy_info: author: VEXXHOST, Inc. diff --git a/roles/cluster_api/tasks/init.yml b/roles/cluster_api/tasks/init.yml index e7b2b4c1..32c014d5 100644 --- a/roles/cluster_api/tasks/init.yml +++ b/roles/cluster_api/tasks/init.yml @@ -1,16 +1,5 @@ -# Copyright (c) 2023 VEXXHOST, Inc. -# -# Licensed 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. +# Copyright (c) 2025 VEXXHOST, Inc. +# SPDX-License-Identifier: Apache-2.0 - name: Initialize the management cluster run_once: true diff --git a/roles/cluster_api/tasks/main.yml b/roles/cluster_api/tasks/main.yml index 0ba209f1..aae8291f 100644 --- a/roles/cluster_api/tasks/main.yml +++ b/roles/cluster_api/tasks/main.yml @@ -1,16 +1,5 @@ -# Copyright (c) 2023 VEXXHOST, Inc. -# -# Licensed 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. +# Copyright (c) 2025 VEXXHOST, Inc. +# SPDX-License-Identifier: Apache-2.0 - name: Create a folder for the Cluster API providers ansible.builtin.file: diff --git a/roles/cluster_api/tasks/patch.yml b/roles/cluster_api/tasks/patch.yml index d628f011..19360d84 100644 --- a/roles/cluster_api/tasks/patch.yml +++ b/roles/cluster_api/tasks/patch.yml @@ -1,16 +1,5 @@ - # Copyright (c) 2023 VEXXHOST, Inc. - # - # Licensed 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. +# Copyright (c) 2025 VEXXHOST, Inc. +# SPDX-License-Identifier: Apache-2.0 - name: Set node selector for Cluster API components kubernetes.core.k8s: @@ -71,7 +60,7 @@ "path": "/spec/template/spec/containers/0/env/-", "value": { "name": "CLUSTER_API_OPENSTACK_INSTANCE_CREATE_TIMEOUT", - "value": "{{ cluster_api_capo_instance_creation_timeout | quote }}" + "value": "{{ cluster_api_capo_instance_create_timeout | quote }}" } } ]' diff --git a/roles/cluster_api/tasks/upgrade.yml b/roles/cluster_api/tasks/upgrade.yml index b4a395d5..7935645c 100644 --- a/roles/cluster_api/tasks/upgrade.yml +++ b/roles/cluster_api/tasks/upgrade.yml @@ -1,16 +1,5 @@ -# Copyright (c) 2023 VEXXHOST, Inc. -# -# Licensed 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. +# Copyright (c) 2025 VEXXHOST, Inc. +# SPDX-License-Identifier: Apache-2.0 - name: Parse provider resources into version mapping run_once: true diff --git a/roles/cluster_api/vars/main.yml b/roles/cluster_api/vars/main.yml index 4e55a31f..e1048246 100644 --- a/roles/cluster_api/vars/main.yml +++ b/roles/cluster_api/vars/main.yml @@ -1,16 +1,5 @@ -# Copyright (c) 2023 VEXXHOST, Inc. -# -# Licensed 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. +# Copyright (c) 2025 VEXXHOST, Inc. +# SPDX-License-Identifier: Apache-2.0 _cluster_api_environment: | {% set res = {'CLUSTER_TOPOLOGY': 'true', 'EXP_CLUSTER_RESOURCE_SET': 'true'} -%} From df8b9aabd33330b6b03c6a1f5fd86942c699d23d Mon Sep 17 00:00:00 2001 From: Tadas Sutkaitis Date: Tue, 3 Jun 2025 18:56:06 +0300 Subject: [PATCH 3/3] fix: patch using native kubernetes module Signed-off-by: Tadas Sutkaitis --- roles/cluster_api/tasks/patch.yml | 45 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/roles/cluster_api/tasks/patch.yml b/roles/cluster_api/tasks/patch.yml index 19360d84..af12a9f7 100644 --- a/roles/cluster_api/tasks/patch.yml +++ b/roles/cluster_api/tasks/patch.yml @@ -28,10 +28,15 @@ # set the default value of imagePullPolicy in CRDs. # yamllint disable rule:line-length - name: Set default values for imagePullPolicy in kubeadmConfigSpec of CRDs - changed_when: false when: cluster_api_control_plane_version | float >= 1.4 - ansible.builtin.command: | - kubectl patch crd {{ item.crd }} --type=json -p='[{"op": "add", "path": "{{ item.path }}", "value": "IfNotPresent"}]' + kubernetes.core.k8s_json_patch: + kind: CustomResourceDefinition + name: "{{ item.crd }}" + patch: + - op: add + path: "{{ item.path }}" + value: "IfNotPresent" + wait: true loop: - {"crd": "kubeadmcontrolplanetemplates.controlplane.cluster.x-k8s.io", "path": "/spec/versions/1/schema/openAPIV3Schema/properties/spec/properties/template/properties/spec/properties/kubeadmConfigSpec/properties/initConfiguration/properties/nodeRegistration/properties/imagePullPolicy/default"} - {"crd": "kubeadmcontrolplanetemplates.controlplane.cluster.x-k8s.io", "path": "/spec/versions/1/schema/openAPIV3Schema/properties/spec/properties/template/properties/spec/properties/kubeadmConfigSpec/properties/joinConfiguration/properties/nodeRegistration/properties/imagePullPolicy/default"} @@ -43,24 +48,18 @@ - {"crd": "kubeadmcontrolplanes.controlplane.cluster.x-k8s.io", "path": "/spec/versions/2/schema/openAPIV3Schema/properties/spec/properties/kubeadmConfigSpec/properties/joinConfiguration/properties/nodeRegistration/properties/imagePullPolicy/default"} - name: Set CAPO instance creation timeout - changed_when: false when: cluster_api_infrastructure_provider == "openstack" - ansible.builtin.command: | - kubectl patch deployment capo-controller-manager \ - -n capo-system \ - --type=json \ - -p='[ - { - "op": "add", - "path": "/spec/template/spec/containers/0/env", - "value": [] - }, - { - "op": "add", - "path": "/spec/template/spec/containers/0/env/-", - "value": { - "name": "CLUSTER_API_OPENSTACK_INSTANCE_CREATE_TIMEOUT", - "value": "{{ cluster_api_capo_instance_create_timeout | quote }}" - } - } - ]' + kubernetes.core.k8s_json_patch: + kind: Deployment + namespace: capo-system + name: capo-controller-manager + patch: + - op: add + path: /spec/template/spec/containers/0/env + value: [] + - op: add + path: /spec/template/spec/containers/0/env/- + value: + name: CLUSTER_API_OPENSTACK_INSTANCE_CREATE_TIMEOUT + value: "{{ cluster_api_capo_instance_create_timeout | quote }}" + wait: true