docker.recipes

Kind Kubernetes Development

advanced

Kubernetes in Docker with Kind, local registry, and kubectl configured.

Overview

Kind (Kubernetes IN Docker) is a tool originally developed by the Kubernetes community for testing Kubernetes itself, transforming how developers interact with Kubernetes locally. By running Kubernetes nodes as Docker containers, Kind eliminates the complexity of setting up virtual machines or bare metal clusters while maintaining full Kubernetes API compatibility. This approach has revolutionized local development workflows since its introduction in 2019, making Kubernetes accessible to developers without requiring expensive infrastructure. This stack combines Kind's containerized Kubernetes cluster with a local Docker registry and NGINX ingress controller, creating a complete development ecosystem that mirrors production environments. The local registry eliminates the need to push images to external registries during development, while NGINX provides HTTP/HTTPS ingress capabilities with its proven performance characteristics. The registry UI component adds visual management of container images, streamlining the development workflow from build to deployment. Kubernetes application developers, DevOps engineers building CI/CD pipelines, and teams transitioning from traditional deployment models to cloud-native architectures will find this stack invaluable. Unlike managed Kubernetes services that incur costs and require internet connectivity, this configuration runs entirely on local infrastructure while providing the same APIs and behaviors as production clusters, making it perfect for rapid prototyping, integration testing, and learning Kubernetes concepts.

Key Features

  • Full Kubernetes v1.29 cluster running as Docker containers with complete API compatibility
  • Local Docker registry v2 with push/pull capabilities for rapid image iteration
  • Web-based registry UI with search and browsing capabilities for image management
  • NGINX Alpine-based ingress controller with HTTP/HTTPS traffic routing
  • NodePort service access through mapped ports 30000-30100 for external connectivity
  • Privileged container execution enabling advanced Kubernetes features like CNI plugins
  • Shared kernel modules access for container runtime compatibility
  • Bridge network isolation for secure inter-component communication

Common Use Cases

  • 1Kubernetes application development and testing without cloud provider costs
  • 2CI/CD pipeline development requiring full Kubernetes API testing capabilities
  • 3Microservices architecture prototyping with ingress traffic management
  • 4Container image build and deployment workflow optimization
  • 5Kubernetes operator development requiring real cluster interactions
  • 6Educational environments for learning Kubernetes concepts hands-on
  • 7Integration testing of Helm charts and Kubernetes manifests before production deployment

Prerequisites

  • Docker Engine with privileged container support and at least 4GB RAM available
  • Kind CLI tool installed for cluster lifecycle management operations
  • kubectl configured for Kubernetes cluster interaction and manifest deployment
  • Available ports 80, 443, 5001, 6443, 8080, and 30000-30100 on host system
  • Basic understanding of Kubernetes concepts including pods, services, and ingress
  • Familiarity with Docker registry operations for image push/pull workflows

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 kind-control-plane:
3 image: kindest/node:v1.29.0
4 privileged: true
5 volumes:
6 - /lib/modules:/lib/modules:ro
7 - kind_data:/var
8 environment:
9 KIND_EXPERIMENTAL_PROVIDER: docker
10 ports:
11 - "6443:6443"
12 - "30000-30100:30000-30100"
13 networks:
14 - kind-net
15 restart: unless-stopped
16
17 registry:
18 image: registry:2
19 ports:
20 - "5001:5000"
21 volumes:
22 - registry_data:/var/lib/registry
23 networks:
24 - kind-net
25 restart: unless-stopped
26
27 registry-ui:
28 image: joxit/docker-registry-ui:latest
29 ports:
30 - "8080:80"
31 environment:
32 REGISTRY_TITLE: Kind Registry
33 REGISTRY_URL: http://registry:5000
34 depends_on:
35 - registry
36 networks:
37 - kind-net
38 restart: unless-stopped
39
40 nginx-ingress:
41 image: nginx:alpine
42 ports:
43 - "80:80"
44 - "443:443"
45 volumes:
46 - ./nginx.conf:/etc/nginx/nginx.conf:ro
47 networks:
48 - kind-net
49 restart: unless-stopped
50
51volumes:
52 kind_data:
53 registry_data:
54
55networks:
56 kind-net:
57 driver: bridge

.env Template

.env
1# Kind Cluster Name
2KIND_CLUSTER_NAME=local-dev
3
4# Registry Port
5REGISTRY_PORT=5001

Usage Notes

  1. 1Use kind CLI for cluster management
  2. 2Local registry at localhost:5001
  3. 3NodePorts available 30000-30100
  4. 4Configure kubectl with kind export kubeconfig

Individual Services(4 services)

Copy individual services to mix and match with your existing compose files.

kind-control-plane
kind-control-plane:
  image: kindest/node:v1.29.0
  privileged: true
  volumes:
    - /lib/modules:/lib/modules:ro
    - kind_data:/var
  environment:
    KIND_EXPERIMENTAL_PROVIDER: docker
  ports:
    - "6443:6443"
    - 30000-30100:30000-30100
  networks:
    - kind-net
  restart: unless-stopped
registry
registry:
  image: registry:2
  ports:
    - "5001:5000"
  volumes:
    - registry_data:/var/lib/registry
  networks:
    - kind-net
  restart: unless-stopped
registry-ui
registry-ui:
  image: joxit/docker-registry-ui:latest
  ports:
    - "8080:80"
  environment:
    REGISTRY_TITLE: Kind Registry
    REGISTRY_URL: http://registry:5000
  depends_on:
    - registry
  networks:
    - kind-net
  restart: unless-stopped
nginx-ingress
nginx-ingress:
  image: nginx:alpine
  ports:
    - "80:80"
    - "443:443"
  volumes:
    - ./nginx.conf:/etc/nginx/nginx.conf:ro
  networks:
    - kind-net
  restart: unless-stopped

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 kind-control-plane:
5 image: kindest/node:v1.29.0
6 privileged: true
7 volumes:
8 - /lib/modules:/lib/modules:ro
9 - kind_data:/var
10 environment:
11 KIND_EXPERIMENTAL_PROVIDER: docker
12 ports:
13 - "6443:6443"
14 - "30000-30100:30000-30100"
15 networks:
16 - kind-net
17 restart: unless-stopped
18
19 registry:
20 image: registry:2
21 ports:
22 - "5001:5000"
23 volumes:
24 - registry_data:/var/lib/registry
25 networks:
26 - kind-net
27 restart: unless-stopped
28
29 registry-ui:
30 image: joxit/docker-registry-ui:latest
31 ports:
32 - "8080:80"
33 environment:
34 REGISTRY_TITLE: Kind Registry
35 REGISTRY_URL: http://registry:5000
36 depends_on:
37 - registry
38 networks:
39 - kind-net
40 restart: unless-stopped
41
42 nginx-ingress:
43 image: nginx:alpine
44 ports:
45 - "80:80"
46 - "443:443"
47 volumes:
48 - ./nginx.conf:/etc/nginx/nginx.conf:ro
49 networks:
50 - kind-net
51 restart: unless-stopped
52
53volumes:
54 kind_data:
55 registry_data:
56
57networks:
58 kind-net:
59 driver: bridge
60EOF
61
62# 2. Create the .env file
63cat > .env << 'EOF'
64# Kind Cluster Name
65KIND_CLUSTER_NAME=local-dev
66
67# Registry Port
68REGISTRY_PORT=5001
69EOF
70
71# 3. Start the services
72docker compose up -d
73
74# 4. View logs
75docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/minikube-alternative-stack/run | bash

Troubleshooting

  • Kind cluster fails to start with 'permission denied' errors: Ensure Docker daemon is running and user has Docker group membership or sudo access
  • kubectl connection refused on port 6443: Run 'kind export kubeconfig' to update kubectl configuration with correct cluster endpoint
  • Container images not found when deploying to cluster: Tag images with 'localhost:5001/' prefix and push to local registry before applying manifests
  • NGINX ingress returns 503 Service Temporarily Unavailable: Verify ingress controller pods are running and backend services have ready endpoints
  • Registry UI shows empty repository list: Check registry container logs for permission issues and verify registry_data volume mount permissions
  • NodePort services unreachable from host: Confirm port mapping in docker-compose matches service nodePort definition and firewall allows connections

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space