LogoLogo
Bonsai (0.13) DocsGitHubDiscord CommunityGarden Enterprise
Docs Edge
Docs Edge
  • Welcome to Garden!
  • Overview
    • What is Garden
    • Use Cases
      • Isolated On-Demand Preview Environments
      • Fast, Portable CI Pipelines that Run Anywhere
      • Shift Testing Left
      • Local Development With Remote Clusters
      • Jumpstart your Internal Developer Platform
    • Garden vs Other Tools
  • Getting Started
    • Quickstart
    • Garden Basics
    • Next Steps
  • Tutorials
    • Your First Project
      • 1. Create a Garden Project
      • 2. Pick a Kubernetes Plugin
      • 3. Add Actions
      • 4. Add Tests
      • 5. Code Syncing (Hot Reload)
      • 6. Next Steps
    • Setting up a Kubernetes cluster
      • 1. Create a Cluster
        • AWS
        • GCP
        • Azure
      • 2. Configure Container Registry
        • AWS
        • GCP
        • Azure
        • Docker Hub
      • 3. Set Up Ingress, TLS and DNS
      • 4. Configure the Provider
  • Using Garden With
    • Containers
      • Using Remote Container Builder
      • Building Containers
    • Kubernetes
      • Using Remote Kubernetes
      • Using Local Kubernetes
      • Deploying K8s Resources
      • Installing Helm charts
      • Running Tests and Tasks
    • Terraform
      • Using Terraform
      • Applying Terrform Stacks
    • Pulumi
      • Using Pulumi
      • Applying Pulumi Stacks
    • Local Scripts
  • Features
    • Remote Container Builder
    • Team Caching
    • Variables and Templating
    • Config Templates
    • Workflows
    • Code Synchronization
    • Custom Commands
    • Remote Sources
  • Guides
    • Connecting a Project
    • Environments and Namespaces
    • Installing Garden
    • Including/Excluding files
    • Installing Local Kubernetes
    • Migrating from Docker Compose to Garden
    • Using the CLI
    • Using Garden in CircleCI
    • Minimal RBAC Configuration for Development Clusters
    • Deploying to Production
    • Using a Registry Mirror
    • Local mode
  • Reference
    • Providers
      • container
      • ephemeral-kubernetes
      • exec
      • jib
      • kubernetes
      • local-kubernetes
      • otel-collector
      • pulumi
      • terraform
    • Action Types
      • Build
        • container Build
        • exec Build
        • jib-container Build
      • Deploy
        • configmap Deploy
        • container Deploy
        • exec Deploy
        • helm Deploy
        • kubernetes Deploy
        • persistentvolumeclaim Deploy
        • pulumi Deploy
        • terraform Deploy
      • Run
        • container Run
        • exec Run
        • helm-pod Run
        • kubernetes-exec Run
        • kubernetes-pod Run
      • Test
        • container Test
        • exec Test
        • helm-pod Test
        • kubernetes-exec Test
        • kubernetes-pod Test
    • Template Strings
      • Project template context
      • Environment template context
      • Provider template context
      • Action (all fields) template context
      • Action spec template context
      • Module template context
      • Remote Source template context
      • Project Output template context
      • Custom Command template context
      • Workflow template context
      • Template Helper Functions
    • Commands
    • Project Configuration
    • ConfigTemplate Reference
    • RenderTemplate Reference
    • Workflow Configuration
    • Garden Containers on Docker Hub
    • Glossary
    • Module Template Configuration
    • Module Types
      • configmap
      • container
      • exec
      • helm
      • jib-container
      • kubernetes
      • persistentvolumeclaim
      • pulumi
      • templated
      • terraform
  • Misc
    • FAQ
    • Troubleshooting
    • Telemetry
    • How Organizations Adopt Garden
    • New Garden Cloud Version
    • Migrating to Bonsai
  • Contributing to Garden
    • Contributor Covenant Code of Conduct
    • Contributing to the Docs
    • Setting up Your Developer Environment
    • Developing Garden
    • Config Resolution
    • Graph Execution
Powered by GitBook
On this page
  • Docker Desktop
  • MicroK8s
  • minikube
  • kind
  • k3s
  • Rancher Desktop
  • k3d
  • OrbStack
  • A note on networking for k3s, k3d and Rancher Desktop
  • Updating or removing the Garden installed Nginx ingress controller
  • Moving between Rancher Desktop and Docker Desktop

Was this helpful?

  1. Guides

Installing Local Kubernetes

PreviousIncluding/Excluding filesNextMigrating from Docker Compose to Garden

Last updated 1 month ago

Was this helpful?

Docker Desktop

is our recommended option for local Kubernetes on Mac and Windows.

Please refer to their for how to download and install it (which is a pretty simple process).

Note: If you have an older version installed, you may need to update it in order to enable Kubernetes support.

Once installed, open Docker Desktop's preferences, go to the Kubernetes section, tick Enable Kubernetes and save.

MicroK8s

Garden can be used with on supported Linux platforms.

To install it, please follow .

Once installed, you need to add the microk8s configuration to your ~/.kube/config so that Garden knows how to access your cluster. We recommend exporting the config like this:

microk8s config > $HOME/.kube/microk8s.config

And then adding this to your .bashrc/.zshrc:

export KUBECONFIG=$HOME/.kube/microk8s.config:${KUBECONFIG:-$HOME/.kube/config}

You also need to ensure microk8s commands can be run by the user that's running Garden, so that Garden can get its status and enable required extensions if necessary. To do this, add your user to the microk8s group:

sudo usermod -a -G microk8s $USER   # or replace $USER with the desired user, if it's not the current user

Note that in-cluster building is currently not supported with microk8s clusters.

minikube

minikube is a tool that makes it easy to run Kubernetes locally for local development. Garden supports running minikube on macOS, Linux, and Windows via the Windows Subsystem for Linux.

If you wish to use minikube with Garden's image building capabilities, be sure to configure Garden appropriately before running garden deploy or garden build. See the following sections for more information.

Expose minikube's Docker daemon for local image building

minikube runs its own Docker daemon. Practically speaking, this has the effect of isolating images from garden when using garden deploy or garden build. If you receive an error like Error deploying deploy.backend2: ImagePullBackOff - Back-off pulling image "backend2:v-aa19766a21", you'll need to expose minikube's Docker daemon, run the following command:

eval $(minikube docker-env)
eval $(minikube docker-env)
& minikube -p minikube docker-env --shell powershell | Invoke-Expression

If you're using an external image registry, see the following section.

minikube and external registries

1.Make sure minikube is running by typing minikube start

2.Then run minikube addons configure registry-creds

3.Select applicable container registry

4.Enter credentials

5.Make sure you run minikube addons enable registry-creds

minikube should now be able to authenticate with your chosen cloud provider.

kind

cat <<EOF | kind create cluster --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  kubeadmConfigPatches:
  - |
    kind: InitConfiguration
    nodeRegistration:
      kubeletExtraArgs:
        node-labels: "ingress-ready=true"
  extraPortMappings:
  - containerPort: 80
    hostPort: 80
    protocol: TCP
  - containerPort: 443
    hostPort: 443
    protocol: TCP
EOF

Alternatively, if you don't need an ingress controller, you can set setupIngressController: null in your local-kubernetes provider configuration and start the cluster without the above customization.

Note that in-cluster building is currently not supported with kind clusters.

k3s

Use this command to install k3s so it is compatible with Garden. This command configures k3s to use docker as the container runtime and disables the traefik ingress controller. It also makes the kubeconfig user-accessible and sets the kubernetes context as the current one via the KUBECONFIG variable.

curl -sfL https://get.k3s.io | sh -s - --docker --disable=traefik --write-kubeconfig-mode=644
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml

Rancher Desktop

k3d

k3d registry create myregistry.localhost --port 12345

k3d cluster create \
  --agents 1 \
  --k3s-arg "--disable=traefik@server:0" \
  --registry-use k3d-myregistry.localhost:12345 \
  --wait

In your project.garden.yml file, add the following configuration under your local-kubernetes provider` block:

    context: k3d-k3s-default
    deploymentRegistry:
      hostname: k3d-myregistry.localhost
      port: 12345
      insecure: true
      namespace: ${kebabCase(local.username)}

OrbStack

A note on networking for k3s, k3d and Rancher Desktop

For users of k3d on macOS or Linux you'll need to do some extra configuration to expose your local domains.

You can direct your ingress domain to the IP of the VM by adding an entry to the /etc/hosts file on your computer. Use the following command:

echo "$(kubectl get node/lima-rancher-desktop -o json | jq -r '.status.addresses[] | select(.type=="InternalIP").address') vote.local.demo.garden" | sudo tee -a /etc/hosts

Replace vote.local.demo.garden with the domain you want to use.

For users of Rancher Desktop users on Linux you'll need to port forward the NGINX ingress controller to access your local domains. Use the following command:

kubectl port-forward --namespace=garden-system service/garden-nginx-ingress-nginx-controller 8080:80

Then you can access your local domains on port 8080. For example, http://vote.local.demo.garden:8080.

Using an alternative ingress controller

Updating or removing the Garden installed Nginx ingress controller

Garden will not automatically try to update the nginx ingress controller. To update it you must remove it first and then run a Garden command against that cluster again. Garden will then deploy the version of the ingress controller shipped with that specific Garden version. If you want to remove it alltogether, set setupIngressController: false in your Garden project's provider configuration. To remove the ingress controller run this command:

garden plugins kubernetes uninstall-garden-services

Moving between Rancher Desktop and Docker Desktop

If you wish to move from Rancher Desktop to Docker Desktop, or vice versa, you will need to follow a few steps:

  1. Uninstall either Rancher Desktop or Docker Desktop.

  2. Delete or back up your ~/.kube directory. This is especially important for Windows users because Docker Desktop treats the ~/.kube directory as a symlink.

  3. Delete or back up your ~/.docker directory. Docker Desktop sets entries in the ~/.docker/config.json file that expect Docker Desktop to be running. If you don't delete this file, you will get errors when you try to run docker build commands.

If you are working in a team and need to use an external registry, you can such as ECR. Alternatively, you can enable minikube's registry-creds addon, by following these steps:

For kind installation instructions, see the .

To use kind with Garden you may need to start your cluster with extra port mappings to allow ingress controllers to run (see for more info):

Follow the to install Rancher Desktop for your OS. Once installed open "Preferences" in the Rancher Desktop UI. In the "Container Engine" section choose dockerd and in the "Kubernetes" section untick the box that says "Enable Traefik".

If, on deploy, you encounter error: Internal error occurred: error executing command in container: http: invalid Host header, please downgrade your Kubernetes version to v1.27.2. This is an .

Preferences in Rancher Desktop to downgrade Kubernetes version

is a lightweight wrapper to run k3s in containers. Its image registry also runs as a container. To expose it to Garden, you need to map the registry port to the host. The following commands will create a k3d cluster with the name k3d-k3s-default and with the registry exposed on port 12345.

works seamlessly with Garden. Follow OrbStack's official instructions .

K3s and its derivatives use the (ServiceLB) as a LoadBalancer controller. ServiceLB is ingress controller agnostic. By default, Garden installs an NGINX ingress controller to expose domains on common ports.

On macOS and Windows, Rancher Desktop creates a bridged network to serve local domain URLs. This means that you can access your local domains on the host machine. Note that you need to for rancher-desktop in order for this to work.

See also Rancher Desktop's for more information.

If you prefer to use the Traefik ingress controller included with k3s distributions, you must modify the installation instructions for and by removing any parts where Traefik is disabled. In your Garden project configuration file, set setupIngressController: false. Additionally, apply one of the two methods described above, specifying Traefik's service in the second approach.

Docker Desktop
installation guide
MicroK8s
their instructions
configure Garden with an external image registry
official docs
their docs
official instructions
upstream bug in Moby
K3d
OrbStack's native Kubernetes offering
to spin up its native Kubernetes cluster
Service Load Balancer
allow administrative access
Setup NGINX Ingress Controller
Rancher Desktop
k3d