bug-fix: fix image-overrides usage to load locally build images into kind cluster (#751)
Webapp Test / Run webapp test suite (push) Failing after 0s
Details
Lint Checks / Run linter (push) Failing after 0s
Details
Publish / Gate: k8s deploy e2e (push) Failing after 3s
Details
Deploy Test / Run deploy test suite (push) Failing after 0s
Details
Publish / Build and publish (push) Has been skipped
Details
Smoke Test / Run basic test suite (push) Failing after 0s
Details
Webapp Test / Run webapp test suite (push) Failing after 0s
Details
Lint Checks / Run linter (push) Failing after 0s
Details
Publish / Gate: k8s deploy e2e (push) Failing after 3s
Details
Deploy Test / Run deploy test suite (push) Failing after 0s
Details
Publish / Build and publish (push) Has been skipped
Details
Smoke Test / Run basic test suite (push) Failing after 0s
Details
- Cluster setup was only considering images from containers list in `stack.yml` for kind-loading into the cluster; i.e. images from `image_overrides` in spec were not being loaded - This also resulted in laconic-so to attempt kind-loading images not present locally sometimes - Fix: union `image_overrides` values (user-specified local images) with the ones from container-list, filtered to only ones that are actually present on the docker hostpull/752/head v1.1.0-cf0e230-202605050445
parent
7c65d39bb2
commit
cf0e230b66
|
|
@ -30,6 +30,7 @@ from stack_orchestrator.deploy.k8s.helpers import (
|
||||||
create_cluster,
|
create_cluster,
|
||||||
destroy_cluster,
|
destroy_cluster,
|
||||||
get_kind_cluster,
|
get_kind_cluster,
|
||||||
|
is_image_available_locally,
|
||||||
load_images_into_kind,
|
load_images_into_kind,
|
||||||
)
|
)
|
||||||
from stack_orchestrator.deploy.k8s.helpers import (
|
from stack_orchestrator.deploy.k8s.helpers import (
|
||||||
|
|
@ -833,16 +834,17 @@ class K8sDeployer(Deployer):
|
||||||
actual_cluster = create_cluster(self.kind_cluster_name, kind_config)
|
actual_cluster = create_cluster(self.kind_cluster_name, kind_config)
|
||||||
if actual_cluster != self.kind_cluster_name:
|
if actual_cluster != self.kind_cluster_name:
|
||||||
self.kind_cluster_name = actual_cluster
|
self.kind_cluster_name = actual_cluster
|
||||||
# Only load locally-built images into kind
|
|
||||||
local_containers = self.deployment_context.stack.obj.get("containers", [])
|
local_containers = self.deployment_context.stack.obj.get("containers", [])
|
||||||
if local_containers:
|
images_to_preload = set((self.image_overrides or {}).values()) | {
|
||||||
local_images = {
|
img
|
||||||
img
|
for img in self.cluster_info.image_set
|
||||||
for img in self.cluster_info.image_set
|
if any(c in img for c in local_containers)
|
||||||
if any(c in img for c in local_containers)
|
}
|
||||||
}
|
images_to_preload = {
|
||||||
if local_images:
|
img for img in images_to_preload if is_image_available_locally(img)
|
||||||
load_images_into_kind(self.kind_cluster_name, local_images)
|
}
|
||||||
|
if images_to_preload:
|
||||||
|
load_images_into_kind(self.kind_cluster_name, images_to_preload)
|
||||||
elif self.is_kind():
|
elif self.is_kind():
|
||||||
# --skip-cluster-management (default): cluster must already exist.
|
# --skip-cluster-management (default): cluster must already exist.
|
||||||
# Without this check, connect_api() below raises a cryptic
|
# Without this check, connect_api() below raises a cryptic
|
||||||
|
|
|
||||||
|
|
@ -607,6 +607,14 @@ def update_caddy_ingress_image(caddy_image: str) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def is_image_available_locally(image: str) -> bool:
|
||||||
|
result = subprocess.run(
|
||||||
|
["docker", "image", "inspect", image],
|
||||||
|
capture_output=True,
|
||||||
|
)
|
||||||
|
return result.returncode == 0
|
||||||
|
|
||||||
|
|
||||||
def load_images_into_kind(kind_cluster_name: str, image_set: Set[str]):
|
def load_images_into_kind(kind_cluster_name: str, image_set: Set[str]):
|
||||||
for image in image_set:
|
for image in image_set:
|
||||||
result = _run_command(
|
result = _run_command(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue