kind (Kubernetes in Docker)

repository·main·Indexed 12 days ago

https://github.com/kubernetes-sigs/kind

A tool for running local Kubernetes clusters using Docker container nodes. Includes documentation on building specialized node images, the kindnetd networking daemon for CNI configuration and IP masquerading, and programmatic usage of the kind application in Go.

Tokens
26.7K
Snippets
111
Records
146
Agent score
96%

What's inside kind

  1. What is kind (Kubernetes in Docker)

    main

    kind (kubernetes in docker) is a suite of tooling designed for running local Kubernetes clusters where each "node" is a Docker container. It is primarily targeted at testing Kubernetes.

    The project consists of:

    • Go packages (implementing core functionality, intended to be reusable by other tools like kubetest).
    • A command-line interface (CLI) for users to manage clusters.
    • A "node" base image containing necessary utilities (systemd, certificates, mount, etc.).
  2. KubeCon Talks regarding KIND

    main

    A collection of KubeCon presentations covering KIND internals, testing workflows, and load balancing:

  3. What is kindnetd

    main

    kindnetd is a simple networking daemon used to implement KIND's standard CNI (Container Network Interface) and cluster networking configuration. Its primary responsibilities include:

    • IP masquerade: Handling traffic leaving the nodes that is headed out of the cluster.
    • Route management: Ensuring netlink routes to pod CIDRs are directed via the host node IP for each node.
    • CNI Configuration: Ensuring a simple CNI configuration based on the standard ptp and host-local plugins and the node's pod CIDR.
  4. Understand the composition of the kind node image

    main

    The kind node image is a specialized container image used as the foundation for Kubernetes nodes in a kind cluster. It is built programmatically using docker run, exec, and commit to efficiently handle large artifacts.

    Conceptually, the node image is based on the base image and includes the following additions:

    • Installation of Kubernetes packages and binaries.
    • Kubernetes docker images stored in /kind/images/*.tar.
    • A /kind/version file containing the Kubernetes semantic version (semver).
  5. How kind manages clusters and nodes

    main

    kind manages clusters by using Docker containers as nodes.

    Key management concepts:

    • Identification: Each cluster is identified by a specific Docker object label. The cluster name/ID is stored as the value of this label on every node container. This allows kind to select nodes via labels rather than brittle container names.
    • State Management: Cluster state is offloaded into the containers and Docker itself, avoiding the need to manage state on the host filesystem.
    • KUBECONFIG: The KUBECONFIG is bind-mounted to a temporary directory. The kind tooling can detect this mount to provide helpers for accessing the cluster.
  6. Guidelines for creating custom kind base images

    main

    When creating custom base images for kind, you must ensure that the image can produce a working node image using the kind build node-image command at the specific kind release version it was shipped with.

    Warning: Do not depend on the internal implementation details or specific contents of the base images. kind provides conformant Kubernetes; any other behavior or structure within the image is considered an implementation detail and is subject to change without notice to improve reliability, performance, or maintainability. The project will not accept bug reports regarding breaking changes to base image internals.

  7. Configure kind using Kubernetes API conventions

    main

    kind prefers to use Kubernetes-style configuration files for its settings. When creating configurations or extending kind, follow these guidelines:

    • Respect Kubernetes API Conventions: Use standard Kubernetes patterns for configuration structures.
    • Minimize CLI Flags: Avoid using a large number of flags. Specifically, avoid using structured values in flags, as these cannot be easily versioned.
    • Stability: kind aims to follow the [Kubernetes Deprecation Policy] as it moves from alpha to beta, ensuring that CLI and configuration changes are stable and documented.
  8. Understand the Node Image contract in kind

    main

    In kind, the node image is a black box used to create a working Kubernetes node. While the source code is open, the internal implementation and contents of these images are subject to change without notice to improve reliability, performance, or maintainability.

    The Supported Contract: kind only guarantees that a node image will:

    1. Create a working Kubernetes node at the advertised version.
    2. Be compatible with the kind version it was released with (and best effort with other releases).

    Warning: Do not depend on the specific internals, file paths, or implementation details of the node images. kind provides CNCF-conformant Kubernetes; anything inside the image that is not part of the Kubernetes conformance specification is considered an implementation detail and is not supported.

  9. Understand the design principles of kind

    main

    kind is designed primarily for automated end-to-end testing. When using or extending kind, keep the following architectural principles in mind:

    • Degrade Gracefully: kind aims to remain functional even in partially degraded states. For example, if pre-loaded images in a node image fail to load, kind falls back to letting the container runtime attempt to pull them.
    • Target CRI Functionality: kind targets the Kubernetes Container Runtime Interface (CRI) to minimize coupling with specific runtimes. It currently supports containerd and has experimental support for podman.
    • Be Hermetic and Stateless: kind strives for reproducibility by avoiding external services or pre-pull dependencies. All cluster state is stored within the "node" containers (labels, files, processes); kind itself does not manage external state.
    • Minimize Assumptions: kind assumes a CRI is available (currently defaulting to docker or podman/nerdctl) and that node images follow the expected format.
    • Automation First: While designed for local UX, the primary use case is automation for end-to-end testing. All features should be considered from an automated usage perspective.