Merge pull request #1915 from yashsinghcodes/new-nightly
check worker deployments in k8s before deploying
This commit is contained in:
@@ -1448,6 +1448,18 @@ func deployK8sWorker(image string, identifier string, env []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
existing, err := clientset.AppsV1().Deployments(kubernetesNamespace).List(ctx, metav1.ListOptions{
|
||||||
|
LabelSelector: "app.kubernetes.io/name=shuffle-worker",
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[ERROR] Failed listing existing deployments: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(existing.Items) > 0 {
|
||||||
|
log.Printf("[INFO] Found existing deployments, skipping creation")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
replicaNumberInt32 := int32(replicaNumber)
|
replicaNumberInt32 := int32(replicaNumber)
|
||||||
// worker makes authenticated requests to the k8s api to create app deployments.
|
// worker makes authenticated requests to the k8s api to create app deployments.
|
||||||
// Therefore, it needs to have access to the service account token.
|
// Therefore, it needs to have access to the service account token.
|
||||||
|
|||||||
@@ -413,6 +413,8 @@ func deployk8sApp(image string, identifier string, env []string) error {
|
|||||||
kubernetesNamespace = "default"
|
kubernetesNamespace = "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
log.Printf("[DEBUG] Deploying k8s app with identifier %s to namespace %s", identifier, kubernetesNamespace)
|
log.Printf("[DEBUG] Deploying k8s app with identifier %s to namespace %s", identifier, kubernetesNamespace)
|
||||||
deployport, err := strconv.Atoi(os.Getenv("SHUFFLE_APP_EXPOSED_PORT"))
|
deployport, err := strconv.Atoi(os.Getenv("SHUFFLE_APP_EXPOSED_PORT"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -624,6 +626,21 @@ func deployk8sApp(image string, identifier string, env []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
existing, err := clientset.AppsV1().Deployments(kubernetesNamespace).List(
|
||||||
|
ctx,
|
||||||
|
metav1.ListOptions{
|
||||||
|
LabelSelector: fmt.Sprintf("app: %s", name),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[ERROR] Failed listing existing deployments: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(existing.Items) > 0 {
|
||||||
|
log.Printf("[INFO] Found existing deployments, skipping creation")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
replicaNumberInt32 := int32(replicaNumber)
|
replicaNumberInt32 := int32(replicaNumber)
|
||||||
// apps do not need access the k8s api.
|
// apps do not need access the k8s api.
|
||||||
automountServiceAccountToken := false
|
automountServiceAccountToken := false
|
||||||
|
|||||||
Reference in New Issue
Block a user