Skip to content

Commit

Permalink
Merge pull request #13 from isovalent/pr/bruno/wait-for-total-control…
Browse files Browse the repository at this point in the history
…-plane-nodes-improvements

Improve the logic around waiting for control-plane.
  • Loading branch information
bmcustodio authored Oct 16, 2023
2 parents a1331c2 + 7bbda04 commit 75b2954
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ No modules.
| <a name="input_cilium_helm_values_override_file_path"></a> [cilium\_helm\_values\_override\_file\_path](#input\_cilium\_helm\_values\_override\_file\_path) | The path to the file containing the values to use when installing Cilium. These values will override the ones in 'cilium\_helm\_values\_file\_path'. | `string` | n/a | yes |
| <a name="input_cilium_helm_version"></a> [cilium\_helm\_version](#input\_cilium\_helm\_version) | The version of the Cilium Helm chart to install. | `string` | n/a | yes |
| <a name="input_cilium_namespace"></a> [cilium\_namespace](#input\_cilium\_namespace) | The namespace in which to install Cilium. | `string` | `"kube-system"` | no |
| <a name="input_control_plane_nodes_label_selector"></a> [control\_plane\_nodes\_label\_selector](#input\_control\_plane\_nodes\_label\_selector) | The label selector used to filter control-plane nodes. | `string` | `"node-role.kubernetes.io/control-plane"` | no |
| <a name="input_deploy_etcd_cluster"></a> [deploy\_etcd\_cluster](#input\_deploy\_etcd\_cluster) | Whether to deploy an 'etcd' cluster suitable for usage as the Cilium key-value store (HIGHLY EXPERIMENTAL). | `bool` | `false` | no |
| <a name="input_extra_provisioner_environment_variables"></a> [extra\_provisioner\_environment\_variables](#input\_extra\_provisioner\_environment\_variables) | A map of extra environment variables to include when executing the provisioning script. | `map(string)` | `{}` | no |
| <a name="input_ipsec_key"></a> [ipsec\_key](#input\_ipsec\_key) | The IPsec key to use for transparent encryption. Leave empty for none to be created (in which case encryption should be disabled in Helm as well). | `string` | `""` | no |
Expand Down
7 changes: 3 additions & 4 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ locals {
CILIUM_HELM_VALUES_OVERRIDE_FILE = var.cilium_helm_values_override_file_path, // The path to the Helm values override file to use when installing Cilium.
CILIUM_HELM_VERSION = var.cilium_helm_version, // The version of the Cilium Helm chart to deploy.
CILIUM_NAMESPACE = var.cilium_namespace, // The namespace where to deploy Cilium.
CONTROL_PLANE_NODES_LABEL_SELECTOR = var.control_plane_nodes_label_selector, // The label selector used to filter control-plane nodes.
DEPLOY_ETCD_CLUSTER = var.deploy_etcd_cluster // Whether to deploy an 'etcd' cluster suitable for usage as the Cilium key-value store.
INSTALL_KUBE_PROMETHEUS_CRDS = true, // Whether to install (some of) the 'kube-prometheus' CRDs (such as 'ServiceMonitor').
IPSEC_KEY = var.ipsec_key, // The IPsec key to be used for transparent encryption.
KUBECONFIG = var.path_to_kubeconfig_file // The path to the kubeconfig file that will be created and output.
PRE_CILIUM_INSTALL_SCRIPT = var.pre_cilium_install_script != "" ? base64encode(var.pre_cilium_install_script) : "" // The script to execute before installing Cilium.
POST_CILIUM_INSTALL_SCRIPT = var.post_cilium_install_script != "" ? base64encode(var.post_cilium_install_script) : "" // The script to execute after installing Cilium.
TOTAL_CONTROL_PLANE_NODES = var.total_control_plane_nodes
WAIT_FOR_TOTAL_CONTROL_PLANE_NODES = var.wait_for_total_control_plane_nodes
TOTAL_CONTROL_PLANE_NODES = var.total_control_plane_nodes // The number of control-plane nodes expected in the cluster.
WAIT_FOR_TOTAL_CONTROL_PLANE_NODES = var.wait_for_total_control_plane_nodes // Whether to wait for the expected number of control-plane nodes to be registered before applying any changes.
}
provisioner_path = "${abspath(path.module)}/scripts/provisioner.sh"
}


12 changes: 10 additions & 2 deletions scripts/provisioner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,17 @@ set -e
set +e
if [[ "${WAIT_FOR_TOTAL_CONTROL_PLANE_NODES}" == "true" ]];
then
until [[ $(kubectl get node -l node-role.kubernetes.io/control-plane --no-headers | wc -l) == "${TOTAL_CONTROL_PLANE_NODES}" ]];
WAIT_FOR_TOTAL_CONTROL_PLANE_NODES_ATTEMPT_NUM=1
until [[ $(kubectl get node -l "${CONTROL_PLANE_NODES_LABEL_SELECTOR}" --no-headers | wc -l) == "${TOTAL_CONTROL_PLANE_NODES}" ]];
do
sleep 1
if [[ ${WAIT_FOR_TOTAL_CONTROL_PLANE_NODES_ATTEMPT_NUM} -gt 180 ]];
then
echo "Timed out while waiting for the total number of control-plane nodes."
exit 1
else
WAIT_FOR_TOTAL_CONTROL_PLANE_NODES_ATTEMPT_NUM=$((WAIT_FOR_TOTAL_CONTROL_PLANE_NODES_ATTEMPT_NUM+1))
sleep 1
fi
done
fi
set -e
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ variable "deploy_etcd_cluster" {
type = bool
}

variable "control_plane_nodes_label_selector" {
default = "node-role.kubernetes.io/control-plane"
description = "The label selector used to filter control-plane nodes."
type = string
}

variable "extra_provisioner_environment_variables" {
default = {}
description = "A map of extra environment variables to include when executing the provisioning script."
Expand Down

0 comments on commit 75b2954

Please sign in to comment.