diff --git a/manifests/function/phase-helpers/wait_cluster/kubectl_wait_cluster.sh b/manifests/function/phase-helpers/wait_cluster/kubectl_wait_cluster.sh index 8833d2f93..b9cb08b42 100644 --- a/manifests/function/phase-helpers/wait_cluster/kubectl_wait_cluster.sh +++ b/manifests/function/phase-helpers/wait_cluster/kubectl_wait_cluster.sh @@ -15,28 +15,29 @@ set -xe export TIMEOUT=${TIMEOUT:-3600} +export CONDITION=${CONDITION:-"controlPlaneReady"} end=$(($(date +%s) + $TIMEOUT)) -echo "Waiting $TIMEOUT seconds for cluster to reach controlPlaneReady condition" 1>&2 +echo "Waiting $TIMEOUT seconds for cluster to reach $CONDITION condition" 1>&2 while true; do # TODO(vkuzmin): Add ability to wait for multiple clusters if [ "$(kubectl \ --request-timeout 20s \ --context $KCTL_CONTEXT \ get -f $RENDERED_BUNDLE_PATH \ - -o jsonpath='{.status.controlPlaneReady}')" == "true" ] + -o jsonpath={.status.$CONDITION})" == "true" ] then echo "Getting information about cluster" 1>&2 kubectl \ --request-timeout 20s \ --context $KCTL_CONTEXT \ get -f $RENDERED_BUNDLE_PATH 1>&2 - echo "Cluster successfully reach controlPlaneReady condition" 1>&2 + echo "Cluster successfully reach $CONDITION condition" 1>&2 break else now=$(date +%s) if [ $now -gt $end ]; then - echo "Cluster didn't reach controlPlaneReady condition before TIMEOUT=$TIMEOUT, exiting" 1>&2 + echo "Cluster didn't reach $CONDITION condition before TIMEOUT=$TIMEOUT, exiting" 1>&2 exit 1 fi sleep 15 diff --git a/manifests/phases/executors.yaml b/manifests/phases/executors.yaml index 3c6e735b1..35797b3c1 100644 --- a/manifests/phases/executors.yaml +++ b/manifests/phases/executors.yaml @@ -433,6 +433,23 @@ configRef: --- apiVersion: airshipit.org/v1alpha1 kind: GenericContainer +metadata: + name: kubectl-wait-cluster-init +spec: + image: localhost/toolbox + hostNetwork: true + envVars: + - RESOURCE_GROUP_FILTER=cluster.x-k8s.io + - RESOURCE_VERSION_FILTER=v1alpha3 + - RESOURCE_KIND_FILTER=Cluster + - CONDITION=controlPlaneInitialized +configRef: + kind: ConfigMap + name: kubectl-wait-cluster + apiVersion: v1 +--- +apiVersion: airshipit.org/v1alpha1 +kind: GenericContainer metadata: name: virsh-eject-cdrom-images labels: diff --git a/manifests/phases/phases.yaml b/manifests/phases/phases.yaml index 693f0e046..4a3b2ee9f 100644 --- a/manifests/phases/phases.yaml +++ b/manifests/phases/phases.yaml @@ -291,6 +291,17 @@ config: --- apiVersion: airshipit.org/v1alpha1 kind: Phase +metadata: + name: kubectl-wait-node-target + clusterName: target-cluster +config: + executorRef: + apiVersion: airshipit.org/v1alpha1 + kind: GenericContainer + name: kubectl-wait-node +--- +apiVersion: airshipit.org/v1alpha1 +kind: Phase metadata: name: kubectl-get-node-target clusterName: target-cluster @@ -391,6 +402,18 @@ config: --- apiVersion: airshipit.org/v1alpha1 kind: Phase +metadata: + name: kubectl-wait-cluster-ephemeral + clusterName: ephemeral-cluster +config: + executorRef: + apiVersion: airshipit.org/v1alpha1 + kind: GenericContainer + name: kubectl-wait-cluster-init + documentEntryPoint: ephemeral/controlplane +--- +apiVersion: airshipit.org/v1alpha1 +kind: Phase metadata: name: kubectl-wait-cluster-target clusterName: target-cluster diff --git a/manifests/type/gating/plan.yaml b/manifests/type/gating/plan.yaml index 85981930f..a42f47099 100644 --- a/manifests/type/gating/plan.yaml +++ b/manifests/type/gating/plan.yaml @@ -49,6 +49,11 @@ phases: - name: virsh-eject-cdrom-images # Create target k8s cluster resources - name: controlplane-ephemeral + # Wait till the cluster is created + # Scripts for this phase placed in manifests/function/phase-helpers/wait_cluster/ + # To get ConfigMap for this phase, execute `airshipctl phase render --source config -k ConfigMap` + # and find ConfigMap with name kubectl-wait-cluster + - name: kubectl-wait-cluster-ephemeral # List all nodes in target cluster # Scripts for this phase placed in manifests/function/phase-helpers/get_node/ # To get ConfigMap for this phase, execute `airshipctl phase render --source config -k ConfigMap`