Skip to content

Commit 5730e77

Browse files
authored
Merge pull request #8931 from sbueringer/pr-disable-cert-manager-preload
🌱 hack/observability: skip preload images on non-kind clusters
2 parents 5ca1f6f + 598a10b commit 5730e77

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
@@ -286,9 +286,17 @@ func tiltResources(ctx context.Context, ts *tiltSettings) error {
286286
// NOTE: strictly speaking cert-manager is not a resource, however it is a dependency for most of the actual resources
287287
// 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.
288288
if ts.DeployCertManager == nil || *ts.DeployCertManager {
289-
tasks["cert-manager-cainjector"] = preLoadImageTask(fmt.Sprintf("quay.io/jetstack/cert-manager-cainjector:%s", config.CertManagerDefaultVersion))
290-
tasks["cert-manager-webhook"] = preLoadImageTask(fmt.Sprintf("quay.io/jetstack/cert-manager-webhook:%s", config.CertManagerDefaultVersion))
291-
tasks["cert-manager-controller"] = preLoadImageTask(fmt.Sprintf("quay.io/jetstack/cert-manager-controller:%s", config.CertManagerDefaultVersion))
289+
cfg, err := clientcmd.NewDefaultClientConfigLoadingRules().Load()
290+
if err != nil {
291+
return errors.Wrap(err, "failed to load KubeConfig file")
292+
}
293+
// The images can only be preloaded when the cluster is a kind cluster.
294+
// Note: Not repeating the validation on the config already done in allowK8sConfig here.
295+
if strings.HasPrefix(cfg.Contexts[cfg.CurrentContext].Cluster, "kind-") {
296+
tasks["cert-manager-cainjector"] = preLoadImageTask(fmt.Sprintf("quay.io/jetstack/cert-manager-cainjector:%s", config.CertManagerDefaultVersion))
297+
tasks["cert-manager-webhook"] = preLoadImageTask(fmt.Sprintf("quay.io/jetstack/cert-manager-webhook:%s", config.CertManagerDefaultVersion))
298+
tasks["cert-manager-controller"] = preLoadImageTask(fmt.Sprintf("quay.io/jetstack/cert-manager-controller:%s", config.CertManagerDefaultVersion))
299+
}
292300
tasks["cert-manager"] = certManagerTask()
293301
}
294302

0 commit comments

Comments
 (0)