Skip to content

Commit

Permalink
use label
Browse files Browse the repository at this point in the history
  • Loading branch information
avouacr committed Oct 11, 2023
1 parent 9220150 commit 6257b8c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions utils/prepull_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def prepull_deployment(namespace, images_to_prepull=None):
manifest = build_manifest(kind="Deployment",
images_to_prepull=images_to_prepull)
label_name = "prepull-deployment-" + str(randint(100000, 999999))
manifest["metadata"]["labels"]["name"] = label_name
manifest["spec"]["template"]["metadata"]["labels"]["name"] = label_name
manifest["spec"]["selector"]["matchLabels"]["name"] = label_name
kube_apps_api.create_namespaced_deployment(namespace=namespace,
Expand All @@ -91,6 +92,7 @@ def prepull_daemon(namespace, images_to_prepull=None):
manifest = build_manifest(kind="DaemonSet",
images_to_prepull=images_to_prepull)
label_name = "prepull-daemonset-" + str(randint(100000, 999999))
manifest["metadata"]["labels"]["name"] = label_name
manifest["spec"]["template"]["metadata"]["labels"]["name"] = label_name
manifest["spec"]["selector"]["matchLabels"]["name"] = label_name
kube_apps_api.create_namespaced_daemon_set(namespace=namespace,
Expand All @@ -99,15 +101,15 @@ def prepull_daemon(namespace, images_to_prepull=None):
# Get total number of daemons that will be launched
time.sleep(5) # Let the daemonset set itself up
daemon_info = kube_apps_api.list_namespaced_daemon_set(namespace=namespace,
label_selector="name=prepull")
label_selector=f"name={label_name}")
n_daemons_total = daemon_info.to_dict()["items"][0]["status"]["desired_number_scheduled"]

# Wait for all daemons to be in Running state
counter_n_daemons_ready = 0
w = kubernetes.watch.Watch()
for event in w.stream(kube_apps_api.list_namespaced_daemon_set,
namespace=namespace,
label_selector="name=prepull",
label_selector=f"name={label_name}",
timeout_seconds=0
):
n_daemons_ready = event['object'].status.number_ready
Expand Down
2 changes: 1 addition & 1 deletion utils/prepull_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ kind: ""
metadata:
name: prepull
labels:
name: prepull
name: ""
spec:
selector:
matchLabels:
Expand Down

0 comments on commit 6257b8c

Please sign in to comment.