github.com/GoogleContainerTools/skaffold/v2@v2.13.2/docs-v1/content/en/docs/environment/local-cluster.md (about) 1 --- 2 title: "Local Cluster" 3 linkTitle: "Local Cluster" 4 weight: 60 5 aliases: [/docs/concepts/local_development] 6 --- 7 8 Skaffold supports fast deployments to supported locally-hosted clusters, 9 such as [`minikube`] and [`Docker Desktop`], by loading images directly 10 into the cluster. Loading images is typically much faster than the 11 roundtrip required to push an image to a remote registry and then 12 for the cluster to pull that image again. 13 14 ### Auto detection 15 16 Skaffold's heuristic to detect local clusters is based on the Kubernetes context name 17 set on kubectl. You can find your the current context name by running: 18 19 ```bash 20 kubectl config current-context 21 ``` 22 23 Skaffold checks for the following context names: 24 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 34 For any other name, Skaffold assumes that the cluster is remote and that images 35 have to be pushed. 36 37 <sup>1</sup> Additionally, a Kubernetes context may be considered as `minikube` 38 even if it's not named `minikube` but it's cluster certificate is stored at 39 `$HOME/.minikube` or the `minikube profile list` command returns the Kubernetes 40 context name. 41 42 [`minikube`]: https://github.com/kubernetes/minikube/ 43 [`Docker Desktop`]: https://www.docker.com/products/docker-desktop 44 [`kind`]: https://github.com/kubernetes-sigs/kind 45 [`k3d`]: https://github.com/rancher/k3d 46 47 ### Manual override 48 49 For non-standard local setups, such as a custom `minikube` profile, 50 some extra configuration is necessary. The essential steps are: 51 52 1. Ensure that Skaffold builds the images with the same docker daemon that runs the pods' containers. 53 1. Tell Skaffold to skip pushing images either by configuring 54 55 ```yaml 56 build: 57 local: 58 push: false 59 ``` 60 61 or by marking a Kubernetes context as local (see the following example). 62 63 For example, when running `minikube` with a custom profile (e.g. `minikube start -p my-profile`): 64 65 1. Set up the docker environment for Skaffold with `source <(minikube docker-env -p my-profile)`. 66 This should set some environment variables for docker (check with `env | grep DOCKER`). 67 **It is important to do this in the same shell where Skaffold is executed.** 68 69 2. Tell Skaffold that the Kubernetes context `my-profile` refers to a local cluster with 70 71 ```bash 72 skaffold config set --kube-context my-profile local-cluster true 73 ``` 74 75 ## Caveats 76 77 There are some caveats to note with local clusters. 78 79 ### Minikube has a separate Docker Daemon 80 81 Minikube has a separate Docker daemon that runs inside the minikube 82 virtual machine, which is independent of the Docker installation 83 that may be running on the host. Skaffold automatically uses 84 `minikube docker-env` to configure image builders to use this internal 85 Docker daemon as it [results in a dramatic speed-up as compared to 86 other approaches](https://minikube.sigs.k8s.io/docs/benchmarks/imagebuild/minikubevsothers/). 87 88 The use of minikube's internal daemon does means that images are 89 not available from the host's daemon: 90 ```shell 91 # build the image `skaffold-example` 92 $ skaffold build 93 ... 94 Starting build... 95 Found [minikube] context, using local docker daemon. 96 ... 97 Successfully tagged skaffold-example:v1.35.0-37-g7ccebe58e 98 Build [skaffold-example] succeeded 99 100 # but the image is not found in the host docker! 101 $ docker images skaffold-example 102 REPOSITORY TAG IMAGE ID CREATED SIZE 103 ``` 104 105 You must instead configure the Docker CLI to use the Minikube daemon: 106 ```shell 107 $ minikube docker-env 108 export DOCKER_HOST="tcp://127.0.0.1:54168" 109 ... 110 $ eval $(minikube docker-env) && docker images skaffold-example 111 REPOSITORY TAG IMAGE ID CREATED SIZE 112 skaffold-example 160fe3a3c1358ef7b3fbfd1ae19fc8c5ac096635c39171e22ad1e5242b6ad8fd 160fe3a3c135 3 weeks ago 7.43MB 113 skaffold-example v1.35.0-37-g7ccebe58e 160fe3a3c135 3 weeks ago 7.43MB 114 ``` 115 116 Minikube also offers a set of helper commands to manage images through [`minikube image`](https://minikube.sigs.k8s.io/docs/commands/image/). 117 118 ### Impacts of `imagePullPolicy` 119 120 Skaffold's direct loading of images into a local cluster does mean that resources specifying 121 an [`imagePullPolicy: Always`](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) 122 may fail as the images are not be pushed to the remote registry.