@@ -57,6 +57,11 @@ func Deploy(
5757 }
5858 }
5959
60+ // wait for the controller (webhook) to be ready before applying AKS resources
61+ if err := kubectlRolloutWait (ctx , kubeconfigFile , "unbounded-cni" , "deployment/unbounded-cni-controller" ); err != nil {
62+ return fmt .Errorf ("failed waiting for unbounded CNI controller to be ready: %w" , err )
63+ }
64+
6065 // deploy the AKS site and gateway pool resources
6166 aksDir := filepath .Join (tempDir , "aks" )
6267 if err := kubectlApply (ctx , kubeconfigFile , aksDir ); err != nil {
@@ -66,6 +71,18 @@ func Deploy(
6671 return nil
6772}
6873
74+ // kubectlRolloutWait runs kubectl rollout status for the given resource in the
75+ // given namespace, blocking until the rollout is complete.
76+ func kubectlRolloutWait (ctx context.Context , kubeconfigFile , namespace , resource string ) error {
77+ cmd := exec .CommandContext (ctx , "kubectl" , "rollout" , "status" , resource , "-n" , namespace )
78+ cmd .Stdout = os .Stdout
79+ cmd .Stderr = os .Stderr
80+ cmd .Env = append (cmd .Environ (),
81+ "KUBECONFIG=" + kubeconfigFile ,
82+ )
83+ return cmd .Run ()
84+ }
85+
6986// kubectlApply runs kubectl apply -f against the given path (file or directory)
7087// using the provided kubeconfig.
7188func kubectlApply (ctx context.Context , kubeconfigFile , path string ) error {
0 commit comments