Skip to content

Commit 9399024

Browse files
committed
Identify Rancher Desktop context as local cluster type
This way, Skaffold will automatically understand that it does not need to push images to remote registry when deploying to Rancher Desktop. Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
1 parent e770efb commit 9399024

5 files changed

Lines changed: 20 additions & 9 deletions

File tree

docs-v2/content/en/docs/design/global-config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The options are:
1818
| `insecure-registries` | list of strings | A list of image registries that may be accessed without TLS. |
1919
| `k3d-disable-load` | boolean | If true, do not use `k3d import image` to load images locally. |
2020
| `kind-disable-load` | boolean | If true, do not use `kind load` to load images locally. |
21-
| `local-cluster` | boolean | If true, do not try to push images after building. By default, contexts with names `docker-for-desktop`, `docker-desktop`, or `minikube` are treated as local. |
21+
| `local-cluster` | boolean | If true, do not try to push images after building. By default, contexts with names `docker-for-desktop`, `docker-desktop`, `minikube`, or `rancher-desktop` are treated as local. |
2222
| `update-check` | boolean | Check for a more recent version of Skaffold. |
2323
| `collect-metrics` | boolean | Collect anonymized usage data. |
2424

docs-v2/content/en/docs/environment/local-cluster.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ kubectl config current-context
2222

2323
Skaffold checks for the following context names:
2424

25-
| Kubernetes context | Local cluster type | Notes |
26-
| ------------------ | ------------------ | ----- |
27-
| docker-desktop | [`Docker Desktop`] | |
28-
| docker-for-desktop | [`Docker Desktop`] | This context name is deprecated |
29-
| minikube <sup>1</sup> | [`minikube`] | See <sup>1</sup> | |
30-
| kind-(.*) | [`kind`] | This pattern is used by kind >= v0.6.0 |
31-
| (.*)@kind | [`kind`] | This pattern was used by kind < v0.6.0 |
32-
| k3d-(.*) | [`k3d`] | This pattern is used by k3d >= v3.0.0 |
25+
| Kubernetes context | Local cluster type | Notes |
26+
|-----------------------|---------------------|----------------------------------------|
27+
| docker-desktop | [`Docker Desktop`] | |
28+
| docker-for-desktop | [`Docker Desktop`] | This context name is deprecated |
29+
| minikube <sup>1</sup> | [`minikube`] | See <sup>1</sup> |
30+
| kind-(.*) | [`kind`] | This pattern is used by kind >= v0.6.0 |
31+
| (.*)@kind | [`kind`] | This pattern was used by kind < v0.6.0 |
32+
| k3d-(.*) | [`k3d`] | This pattern is used by k3d >= v3.0.0 |
33+
| rancher-desktop | [`Rancher Desktop`] | |
3334

3435
For any other name, Skaffold assumes that the cluster is remote and that images
3536
have to be pushed.
@@ -43,6 +44,7 @@ context name.
4344
[`Docker Desktop`]: https://www.docker.com/products/docker-desktop
4445
[`kind`]: https://github.com/kubernetes-sigs/kind
4546
[`k3d`]: https://github.com/rancher/k3d
47+
[`Rancher Desktop`]: https://rancherdesktop.io
4648

4749
### Manual override
4850

pkg/skaffold/config/util.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ func GetCluster(ctx context.Context, opts GetClusterOpts) (Cluster, error) {
246246
case kubeContext == constants.DefaultMinikubeContext ||
247247
kubeContext == constants.DefaultDockerForDesktopContext ||
248248
kubeContext == constants.DefaultDockerDesktopContext ||
249+
kubeContext == constants.DefaultRancherDesktopContext ||
249250
isKindCluster || isK3dCluster:
250251
local = true
251252

pkg/skaffold/config/util_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,11 @@ func TestGetCluster(t *testing.T) {
351351
cfg: &ContextConfig{Kubecontext: "docker-for-desktop"},
352352
expected: Cluster{Local: true, LoadImages: false, PushImages: false},
353353
},
354+
{
355+
description: "rancher-desktop",
356+
cfg: &ContextConfig{Kubecontext: "rancher-desktop"},
357+
expected: Cluster{Local: true, LoadImages: false, PushImages: false},
358+
},
354359
{
355360
description: "minikube",
356361
cfg: &ContextConfig{Kubecontext: "minikube"},
@@ -436,6 +441,7 @@ func TestIsKindCluster(t *testing.T) {
436441
{context: "kind@kind", expectedIsKind: true},
437442
{context: "other@kind", expectedIsKind: true},
438443
{context: "docker-for-desktop", expectedIsKind: false},
444+
{context: "rancher-desktop", expectedIsKind: false},
439445
{context: "not-kind", expectedIsKind: false},
440446
}
441447
for _, test := range tests {
@@ -526,6 +532,7 @@ func TestIsK3dCluster(t *testing.T) {
526532
{context: "k3d-other", expectedIsK3d: true},
527533
{context: "kind-kind", expectedIsK3d: false},
528534
{context: "docker-for-desktop", expectedIsK3d: false},
535+
{context: "rancher-desktop", expectedIsK3d: false},
529536
{context: "not-k3d", expectedIsK3d: false},
530537
}
531538
for _, test := range tests {

pkg/skaffold/constants/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const (
4343
DefaultMinikubeContext = "minikube"
4444
DefaultDockerForDesktopContext = "docker-for-desktop"
4545
DefaultDockerDesktopContext = "docker-desktop"
46+
DefaultRancherDesktopContext = "rancher-desktop"
4647
GCSBucketSuffix = "_cloudbuild"
4748

4849
HelmOverridesFilename = "skaffold-overrides.yaml"

0 commit comments

Comments
 (0)