mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2025-12-15 22:34:21 +03:00
[calico] call calico checks early on to prevent altering the cluster with bad configuration (#8707)
This commit is contained in:
@@ -36,44 +36,6 @@
|
||||
- kube_network_plugin is defined
|
||||
- not ignore_assert_errors
|
||||
|
||||
- name: Stop if legacy encapsulation variables are detected (ipip)
|
||||
assert:
|
||||
that:
|
||||
- ipip is not defined
|
||||
msg: "'ipip' configuration variable is deprecated, please configure your inventory with 'calico_ipip_mode' set to 'Always' or 'CrossSubnet' according to your specific needs"
|
||||
when:
|
||||
- kube_network_plugin == 'calico'
|
||||
- not ignore_assert_errors
|
||||
|
||||
- name: Stop if legacy encapsulation variables are detected (ipip_mode)
|
||||
assert:
|
||||
that:
|
||||
- ipip_mode is not defined
|
||||
msg: "'ipip_mode' configuration variable is deprecated, please configure your inventory with 'calico_ipip_mode' set to 'Always' or 'CrossSubnet' according to your specific needs"
|
||||
when:
|
||||
- kube_network_plugin == 'calico'
|
||||
- not ignore_assert_errors
|
||||
|
||||
- name: Stop if incompatible network plugin and cloudprovider
|
||||
assert:
|
||||
that:
|
||||
- calico_ipip_mode == 'Never'
|
||||
- calico_vxlan_mode in ['Always', 'CrossSubnet']
|
||||
msg: "When using cloud_provider azure and network_plugin calico calico_ipip_mode must be 'Never' and calico_vxlan_mode 'Always' or 'CrossSubnet'"
|
||||
when:
|
||||
- cloud_provider is defined and cloud_provider == 'azure'
|
||||
- kube_network_plugin == 'calico'
|
||||
- not ignore_assert_errors
|
||||
|
||||
- name: Stop if supported Calico versions
|
||||
assert:
|
||||
that:
|
||||
- "calico_version in calico_crds_archive_checksums.keys()"
|
||||
msg: "Calico version not supported {{ calico_version }} not in {{ calico_crds_archive_checksums.keys() }}"
|
||||
when:
|
||||
- kube_network_plugin == 'calico'
|
||||
- not ignore_assert_errors
|
||||
|
||||
- name: Stop if unsupported version of Kubernetes
|
||||
assert:
|
||||
that: kube_version is version(kube_version_min_required, '>=')
|
||||
@@ -200,53 +162,6 @@
|
||||
- cloud-provider
|
||||
- facts
|
||||
|
||||
- name: Get current calico cluster version
|
||||
shell: "set -o pipefail && {{ bin_dir }}/calicoctl.sh version | grep 'Cluster Version:' | awk '{ print $3}'"
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: calico_version_on_server
|
||||
async: 10
|
||||
poll: 3
|
||||
run_once: yes
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when:
|
||||
- kube_network_plugin == 'calico'
|
||||
|
||||
- name: Check that current calico version is enough for upgrade
|
||||
assert:
|
||||
that:
|
||||
- calico_version_on_server.stdout is version(calico_min_version_required, '>=')
|
||||
msg: >
|
||||
Your version of calico is not fresh enough for upgrade.
|
||||
Minimum version is {{ calico_min_version_required }} supported by the previous kubespray release.
|
||||
when:
|
||||
- kube_network_plugin == 'calico'
|
||||
- 'calico_version_on_server.stdout is defined'
|
||||
- calico_version_on_server.stdout
|
||||
- inventory_hostname == groups['kube_control_plane'][0]
|
||||
run_once: yes
|
||||
|
||||
- name: "Check that cluster_id is set if calico_rr enabled"
|
||||
assert:
|
||||
that:
|
||||
- cluster_id is defined
|
||||
msg: "A unique cluster_id is required if using calico_rr"
|
||||
when:
|
||||
- kube_network_plugin == 'calico'
|
||||
- peer_with_calico_rr
|
||||
- inventory_hostname == groups['kube_control_plane'][0]
|
||||
run_once: yes
|
||||
|
||||
- name: "Check that calico_rr nodes are in k8s_cluster group"
|
||||
assert:
|
||||
that:
|
||||
- '"k8s_cluster" in group_names'
|
||||
msg: "calico_rr must be a child group of k8s_cluster group"
|
||||
when:
|
||||
- kube_network_plugin == 'calico'
|
||||
- '"calico_rr" in group_names'
|
||||
|
||||
- name: "Check that kube_service_addresses is a network range"
|
||||
assert:
|
||||
that:
|
||||
|
||||
@@ -117,3 +117,11 @@
|
||||
- ansible_os_family == "RedHat"
|
||||
tags:
|
||||
- bootstrap-os
|
||||
|
||||
- name: Run calico checks
|
||||
include_role:
|
||||
name: network_plugin/calico
|
||||
tasks_from: check
|
||||
when:
|
||||
- kube_network_plugin == 'calico'
|
||||
- not ignore_assert_errors
|
||||
|
||||
Reference in New Issue
Block a user