mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-02-14 18:09:57 +00:00
23 lines
663 B
Go
23 lines
663 B
Go
package framework
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/client-go/kubernetes"
|
|
)
|
|
|
|
func CheckDeploymentReady(ctx context.Context, kubeClient kubernetes.Interface, namespace, name string) error {
|
|
deployment, err := kubeClient.AppsV1().Deployments(namespace).Get(ctx, name, metav1.GetOptions{})
|
|
if err != nil {
|
|
return fmt.Errorf("failed to get deployment %s: %w", name, err)
|
|
}
|
|
|
|
if deployment.Status.ReadyReplicas != deployment.Status.Replicas {
|
|
return fmt.Errorf("deployment %s is not ready, ready replicas: %d, replicas: %d", name, deployment.Status.ReadyReplicas, deployment.Status.Replicas)
|
|
}
|
|
|
|
return nil
|
|
}
|