Skip to content

Commit 598a10b

Browse files
committed
hack/observability: skip preload images on non-kind clusters
Signed-off-by: Stefan Büringer [email protected]
1 parent 4920e6e commit 598a10b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

hack/tools/tilt-prepare/main.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,17 @@ func tiltResources(ctx context.Context, ts *tiltSettings) error {
283283
// NOTE: strictly speaking cert-manager is not a resource, however it is a dependency for most of the actual resources
284284
// and running this is the same task group of the kustomize/provider tasks gives the maximum benefits in terms of reducing the total elapsed time.
285285
if ts.DeployCertManager == nil || *ts.DeployCertManager {
286-
tasks["cert-manager-cainjector"] = preLoadImageTask(fmt.Sprintf("quay.io/jetstack/cert-manager-cainjector:%s", config.CertManagerDefaultVersion))
287-
tasks["cert-manager-webhook"] = preLoadImageTask(fmt.Sprintf("quay.io/jetstack/cert-manager-webhook:%s", config.CertManagerDefaultVersion))
288-
tasks["cert-manager-controller"] = preLoadImageTask(fmt.Sprintf("quay.io/jetstack/cert-manager-controller:%s", config.CertManagerDefaultVersion))
286+
cfg, err := clientcmd.NewDefaultClientConfigLoadingRules().Load()
287+
if err != nil {
288+
return errors.Wrap(err, "failed to load KubeConfig file")
289+
}
290+
// The images can only be preloaded when the cluster is a kind cluster.
291+
// Note: Not repeating the validation on the config already done in allowK8sConfig here.
292+
if strings.HasPrefix(cfg.Contexts[cfg.CurrentContext].Cluster, "kind-") {
293+
tasks["cert-manager-cainjector"] = preLoadImageTask(fmt.Sprintf("quay.io/jetstack/cert-manager-cainjector:%s", config.CertManagerDefaultVersion))
294+
tasks["cert-manager-webhook"] = preLoadImageTask(fmt.Sprintf("quay.io/jetstack/cert-manager-webhook:%s", config.CertManagerDefaultVersion))
295+
tasks["cert-manager-controller"] = preLoadImageTask(fmt.Sprintf("quay.io/jetstack/cert-manager-controller:%s", config.CertManagerDefaultVersion))
296+
}
289297
tasks["cert-manager"] = certManagerTask()
290298
}
291299

0 commit comments

Comments
 (0)