├── .go-version ├── site ├── data │ └── apiVersions.yaml ├── .gitignore ├── layouts │ ├── shortcodes │ │ ├── stableVersion.html │ │ ├── absURL.html │ │ ├── readFile.html │ │ ├── minify.html │ │ ├── securitygoose.html │ │ ├── codeFromInline.html │ │ └── codeFromFile.html │ ├── robots.txt │ ├── partials │ │ ├── inlinecss.html │ │ ├── inlinescript.html │ │ ├── navbar.html │ │ ├── fancymarkdown.html │ │ ├── footer.html │ │ ├── header.html │ │ └── sidebar.html │ ├── index.redirects │ ├── index.html │ └── docs │ │ ├── index.html │ │ ├── section.html │ │ └── single.html ├── static │ ├── favicon.ico │ ├── logo │ │ ├── logo.png │ │ └── LICENSE │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── mstile-150x150.png │ ├── apple-touch-icon.png │ ├── android-chrome-192x192.png │ ├── android-chrome-512x512.png │ ├── third_party │ │ ├── shiny_goose.png │ │ └── GitHub-Mark-120px-plus.png │ ├── images │ │ └── kind-create-cluster.png │ ├── copycode.svg │ ├── browserconfig.xml │ ├── examples │ │ ├── config-with-port-mapping.yaml │ │ ├── loadbalancer │ │ │ └── usage.yaml │ │ ├── config-with-mounts.yaml │ │ ├── ingress │ │ │ └── usage.yaml │ │ └── kind-gcr.sh │ └── site.webmanifest ├── content │ └── docs │ │ ├── images │ │ └── diagram.png │ │ ├── user │ │ ├── images │ │ │ ├── docker-pref-1.png │ │ │ ├── docker-pref-2.png │ │ │ ├── docker-pref-1-win.png │ │ │ ├── docker-pref-build.png │ │ │ └── docker-pref-build-win.png │ │ ├── kind-example-config.yaml │ │ └── local-registry.md │ │ └── design │ │ ├── base-image.md │ │ └── node-image.md ├── README.md ├── tools.go ├── Makefile └── config.toml ├── images ├── haproxy │ ├── Makefile │ ├── cloudbuild.yaml │ ├── README.md │ └── haproxy.cfg ├── kindnetd │ ├── Makefile │ ├── scripts │ │ └── third_party │ │ │ └── gimme │ │ │ ├── README.md │ │ │ └── LICENSE │ ├── files │ │ └── LICENSES │ │ │ └── README.txt │ ├── cloudbuild.yaml │ ├── README.md │ └── Dockerfile ├── base │ ├── files │ │ ├── etc │ │ │ ├── crictl.yaml │ │ │ ├── default │ │ │ │ └── kubelet │ │ │ ├── systemd │ │ │ │ └── system │ │ │ │ │ ├── kubelet.slice │ │ │ │ │ ├── undo-mount-hacks.service │ │ │ │ │ ├── containerd-fuse-overlayfs.service │ │ │ │ │ ├── kubelet.service.d │ │ │ │ │ ├── 11-kind.conf │ │ │ │ │ └── 10-kubeadm.conf │ │ │ │ │ ├── containerd.service │ │ │ │ │ └── kubelet.service │ │ │ ├── sysctl.d │ │ │ │ ├── 10-network-security.conf │ │ │ │ └── 10-network-magic.conf │ │ │ └── containerd │ │ │ │ └── config.toml │ │ ├── LICENSES │ │ │ └── README.txt │ │ ├── kind │ │ │ ├── README.txt │ │ │ └── bin │ │ │ │ └── undo-mount-hacks.sh │ │ └── usr │ │ │ └── local │ │ │ └── bin │ │ │ └── clean-install │ ├── scripts │ │ ├── third_party │ │ │ └── gimme │ │ │ │ ├── README.md │ │ │ │ └── LICENSE │ │ └── target-cc │ ├── cloudbuild.yaml │ ├── Makefile │ └── README.md ├── local-path-provisioner │ ├── scripts │ │ └── third_party │ │ │ └── gimme │ │ │ ├── README.md │ │ │ └── LICENSE │ ├── files │ │ └── LICENSES │ │ │ └── README.txt │ ├── cloudbuild.yaml │ ├── README.md │ ├── Makefile │ └── Dockerfile ├── local-path-helper │ ├── README.md │ ├── cloudbuild.yaml │ └── Makefile └── node │ └── README.md ├── hack ├── build │ ├── README.md │ ├── gotoolchain.sh │ ├── goinstalldir.sh │ ├── setup-go.sh │ └── init-buildx.sh ├── make-rules │ ├── verify │ │ ├── README.md │ │ ├── lint.sh │ │ └── all.sh │ └── update │ │ ├── README.md │ │ ├── gofmt.sh │ │ ├── all.sh │ │ ├── deps.sh │ │ └── generated.sh ├── release │ ├── build │ │ └── README.md │ └── get-contributors.sh ├── tools │ ├── README.md │ ├── tools.go │ ├── boilerplate.go.txt │ └── .golangci.yml ├── ci │ ├── README.md │ ├── push-latest-cli │ │ ├── README.md │ │ └── cloudbuild.yaml │ ├── build-all.sh │ ├── vagrant-helper.sh │ ├── e2e.sh │ └── Vagrantfile └── third_party │ └── gimme │ ├── README.md │ └── LICENSE ├── logo ├── logo.png └── LICENSE ├── pkg ├── cluster │ ├── internal │ │ ├── providers │ │ │ ├── docker │ │ │ │ ├── OWNERS │ │ │ │ └── constants.go │ │ │ ├── nerdctl │ │ │ │ ├── OWNERS │ │ │ │ ├── constants.go │ │ │ │ ├── util.go │ │ │ │ └── network_test.go │ │ │ ├── podman │ │ │ │ ├── OWNERS │ │ │ │ └── constants.go │ │ │ └── common │ │ │ │ ├── doc.go │ │ │ │ ├── constants.go │ │ │ │ ├── images.go │ │ │ │ ├── namer.go │ │ │ │ ├── logs.go │ │ │ │ ├── getport.go │ │ │ │ └── images_test.go │ │ ├── logs │ │ │ └── doc.go │ │ ├── kubeadm │ │ │ ├── doc.go │ │ │ └── const.go │ │ ├── loadbalancer │ │ │ ├── doc.go │ │ │ └── const.go │ │ ├── kubeconfig │ │ │ └── internal │ │ │ │ └── kubeconfig │ │ │ │ ├── write.go │ │ │ │ ├── lock.go │ │ │ │ ├── helpers.go │ │ │ │ └── encode_test.go │ │ └── delete │ │ │ └── delete.go │ ├── doc.go │ ├── nodes │ │ ├── doc.go │ │ └── types.go │ ├── nodeutils │ │ └── doc.go │ └── constants │ │ └── constants.go ├── internal │ ├── apis │ │ └── config │ │ │ ├── encoding │ │ │ ├── testdata │ │ │ │ ├── invalid-yaml.yaml │ │ │ │ ├── v1alpha4 │ │ │ │ │ ├── valid-minimal.yaml │ │ │ │ │ ├── valid-minimal-two-nodes.yaml │ │ │ │ │ ├── valid-full-ha.yaml │ │ │ │ │ ├── valid-port-and-mount.yaml │ │ │ │ │ ├── invalid-bad-indent.yaml │ │ │ │ │ ├── invalid-bogus-field.yaml │ │ │ │ │ ├── valid-many-fields.yaml │ │ │ │ │ ├── valid-kind-workers-patches.yaml │ │ │ │ │ └── valid-kind-patches.yaml │ │ │ │ ├── invalid-apiversion.yaml │ │ │ │ └── invalid-kind.yaml │ │ │ ├── doc.go │ │ │ └── convert.go │ │ │ ├── doc.go │ │ │ └── cluster_util.go │ ├── cli │ │ └── override.go │ ├── patch │ │ ├── doc.go │ │ ├── matchinfo.go │ │ ├── json6902patch.go │ │ └── mergepatch.go │ ├── runtime │ │ └── runtime.go │ ├── sets │ │ ├── empty.go │ │ └── doc.go │ ├── version │ │ └── doc.go │ └── integration │ │ └── integration.go ├── cmd │ ├── doc.go │ ├── kind │ │ ├── completion │ │ │ ├── fish │ │ │ │ └── fish.go │ │ │ ├── zsh │ │ │ │ └── zsh.go │ │ │ └── bash │ │ │ │ └── bash.go │ │ ├── create │ │ │ └── create.go │ │ ├── build │ │ │ └── build.go │ │ ├── load │ │ │ └── load.go │ │ ├── export │ │ │ └── export.go │ │ ├── delete │ │ │ └── delete.go │ │ └── get │ │ │ ├── get.go │ │ │ └── clusters │ │ │ └── clusters.go │ ├── iostreams.go │ └── logger.go ├── errors │ ├── doc.go │ ├── aggregate_test.go │ ├── errors_test.go │ ├── aggregate.go │ └── concurrent.go ├── build │ └── nodeimage │ │ ├── doc.go │ │ ├── internal │ │ ├── kube │ │ │ ├── doc.go │ │ │ ├── builder.go │ │ │ ├── bits.go │ │ │ └── tar.go │ │ └── container │ │ │ └── docker │ │ │ ├── doc.go │ │ │ ├── save.go │ │ │ ├── run.go │ │ │ └── pull.go │ │ ├── const.go │ │ ├── defaults.go │ │ ├── containerd.go │ │ └── helpers.go ├── log │ ├── doc.go │ └── noop.go ├── apis │ └── config │ │ ├── v1alpha4 │ │ └── doc.go │ │ └── defaults │ │ └── image.go └── exec │ ├── doc.go │ └── default.go ├── code-of-conduct.md ├── OWNERS ├── .github ├── ISSUE_TEMPLATE │ ├── question.md │ ├── enhancement.md │ ├── documentation.md │ ├── cleanup.md │ └── bug-report.md ├── dependabot.yml └── actions │ └── setup-env │ └── action.yaml ├── .gitignore ├── netlify.toml ├── SECURITY_CONTACTS ├── cmd └── kind │ └── main.go ├── main.go ├── go.mod └── CONTRIBUTING.md /.go-version: -------------------------------------------------------------------------------- 1 | 1.22.4 2 | -------------------------------------------------------------------------------- /site/data/apiVersions.yaml: -------------------------------------------------------------------------------- 1 | - v1alpha4 2 | -------------------------------------------------------------------------------- /images/haproxy/Makefile: -------------------------------------------------------------------------------- 1 | include $(CURDIR)/../Makefile.common.in -------------------------------------------------------------------------------- /images/kindnetd/Makefile: -------------------------------------------------------------------------------- 1 | include $(CURDIR)/../Makefile.common.in -------------------------------------------------------------------------------- /site/.gitignore: -------------------------------------------------------------------------------- 1 | public/* 2 | resources/* 3 | .hugo_build.lock -------------------------------------------------------------------------------- /hack/build/README.md: -------------------------------------------------------------------------------- 1 | This directory contains tooling used for building -------------------------------------------------------------------------------- /logo/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/logo/logo.png -------------------------------------------------------------------------------- /site/layouts/shortcodes/stableVersion.html: -------------------------------------------------------------------------------- 1 | {{- site.Params.stable -}} 2 | -------------------------------------------------------------------------------- /pkg/cluster/internal/providers/docker/OWNERS: -------------------------------------------------------------------------------- 1 | labels: 2 | - area/provider/docker 3 | -------------------------------------------------------------------------------- /pkg/cluster/internal/providers/nerdctl/OWNERS: -------------------------------------------------------------------------------- 1 | labels: 2 | - area/provider/nerdctl 3 | -------------------------------------------------------------------------------- /images/base/files/etc/crictl.yaml: -------------------------------------------------------------------------------- 1 | runtime-endpoint: unix:///run/containerd/containerd.sock -------------------------------------------------------------------------------- /site/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/site/static/favicon.ico -------------------------------------------------------------------------------- /site/static/logo/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/site/static/logo/logo.png -------------------------------------------------------------------------------- /hack/make-rules/verify/README.md: -------------------------------------------------------------------------------- 1 | This directory contains tools to verify the state and quality of the repo. -------------------------------------------------------------------------------- /images/base/files/etc/default/kubelet: -------------------------------------------------------------------------------- 1 | KUBELET_EXTRA_ARGS=--runtime-cgroups=/system.slice/containerd.service -------------------------------------------------------------------------------- /site/static/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/site/static/favicon-16x16.png -------------------------------------------------------------------------------- /site/static/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/site/static/favicon-32x32.png -------------------------------------------------------------------------------- /site/static/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/site/static/mstile-150x150.png -------------------------------------------------------------------------------- /hack/make-rules/update/README.md: -------------------------------------------------------------------------------- 1 | This directory contains tools used to update dependencies, generated files, etc. -------------------------------------------------------------------------------- /hack/release/build/README.md: -------------------------------------------------------------------------------- 1 | This directory contains temporary tooling used to make releasing kind easier. 2 | -------------------------------------------------------------------------------- /pkg/internal/apis/config/encoding/testdata/invalid-yaml.yaml: -------------------------------------------------------------------------------- 1 | # intentionally invalid yaml file for testing 2 | ": -------------------------------------------------------------------------------- /site/static/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/site/static/apple-touch-icon.png -------------------------------------------------------------------------------- /site/layouts/shortcodes/absURL.html: -------------------------------------------------------------------------------- 1 | {{/* the one input should be a relative url */}} 2 | {{- .Get 0 | absURL }} 3 | -------------------------------------------------------------------------------- /site/content/docs/images/diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/site/content/docs/images/diagram.png -------------------------------------------------------------------------------- /site/layouts/shortcodes/readFile.html: -------------------------------------------------------------------------------- 1 | {{/* the one input should be a file path */}} 2 | {{- .Get 0 | readFile | safeHTML -}} -------------------------------------------------------------------------------- /site/static/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/site/static/android-chrome-192x192.png -------------------------------------------------------------------------------- /site/static/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/site/static/android-chrome-512x512.png -------------------------------------------------------------------------------- /site/static/third_party/shiny_goose.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/site/static/third_party/shiny_goose.png -------------------------------------------------------------------------------- /site/static/images/kind-create-cluster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/site/static/images/kind-create-cluster.png -------------------------------------------------------------------------------- /site/content/docs/user/images/docker-pref-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/site/content/docs/user/images/docker-pref-1.png -------------------------------------------------------------------------------- /site/content/docs/user/images/docker-pref-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/site/content/docs/user/images/docker-pref-2.png -------------------------------------------------------------------------------- /hack/tools/README.md: -------------------------------------------------------------------------------- 1 | This directory contains a stub go module used to track version of development 2 | tools like the Kubernetes code generators. -------------------------------------------------------------------------------- /site/static/third_party/GitHub-Mark-120px-plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/site/static/third_party/GitHub-Mark-120px-plus.png -------------------------------------------------------------------------------- /logo/LICENSE: -------------------------------------------------------------------------------- 1 | # The kind logo files are licensed under a choice of either Apache-2.0 or CC-BY-4.0 (Creative Commons Attribution 4.0 International). 2 | -------------------------------------------------------------------------------- /site/content/docs/user/images/docker-pref-1-win.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/site/content/docs/user/images/docker-pref-1-win.png -------------------------------------------------------------------------------- /site/content/docs/user/images/docker-pref-build.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/site/content/docs/user/images/docker-pref-build.png -------------------------------------------------------------------------------- /site/layouts/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | {{ if ne ( getenv "HUGO_ENV" ) "production" -}} 3 | Disallow: / 4 | {{- else -}} 5 | Allow: / 6 | {{- end -}} -------------------------------------------------------------------------------- /site/content/docs/user/images/docker-pref-build-win.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker/kind/main/site/content/docs/user/images/docker-pref-build-win.png -------------------------------------------------------------------------------- /site/layouts/partials/inlinecss.html: -------------------------------------------------------------------------------- 1 | {{ with resources.Get "css/inline.css" | resources.Minify }} 2 | 3 | {{ end }} -------------------------------------------------------------------------------- /site/layouts/partials/inlinescript.html: -------------------------------------------------------------------------------- 1 | {{ with resources.Get "js/inline.js" | resources.Minify }} 2 | 3 | {{ end }} -------------------------------------------------------------------------------- /site/static/logo/LICENSE: -------------------------------------------------------------------------------- 1 | # The kind logo files are licensed under a choice of either Apache-2.0 or CC-BY-4.0 (Creative Commons Attribution 4.0 International). 2 | -------------------------------------------------------------------------------- /pkg/internal/apis/config/encoding/testdata/v1alpha4/valid-minimal.yaml: -------------------------------------------------------------------------------- 1 | # technically valid, minimal config file 2 | kind: Cluster 3 | apiVersion: kind.x-k8s.io/v1alpha4 4 | -------------------------------------------------------------------------------- /code-of-conduct.md: -------------------------------------------------------------------------------- 1 | # Kubernetes Community Code of Conduct 2 | 3 | Please refer to our [Kubernetes Community Code of Conduct](https://git.k8s.io/community/code-of-conduct.md) 4 | -------------------------------------------------------------------------------- /pkg/internal/apis/config/encoding/testdata/invalid-apiversion.yaml: -------------------------------------------------------------------------------- 1 | # this file contains an invalid config api version for testing 2 | kind: Node 3 | apiVersion: not-valid 4 | -------------------------------------------------------------------------------- /pkg/internal/apis/config/encoding/testdata/invalid-kind.yaml: -------------------------------------------------------------------------------- 1 | # this file contains an invalid config kind for testing 2 | kind: not-valid 3 | apiVersion: kind.x-k8s.io/v1alpha4 -------------------------------------------------------------------------------- /hack/ci/README.md: -------------------------------------------------------------------------------- 1 | This directory contains glue used to test the kind repo in CI. 2 | 3 | We don't recommend reusing anything from these scripts, and intend to replace 4 | them at some point. -------------------------------------------------------------------------------- /hack/third_party/gimme/README.md: -------------------------------------------------------------------------------- 1 | # gimme 2 | 3 | This is an unmodified copy of [gimme], so we don't have to download it 4 | from the internet. 5 | 6 | [gimme]: https://github.com/travis-ci/gimme -------------------------------------------------------------------------------- /images/base/files/etc/systemd/system/kubelet.slice: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=slice used to run Kubernetes / Kubelet 3 | Before=slices.target 4 | 5 | [Slice] 6 | MemoryAccounting=true 7 | CPUAccounting=true 8 | -------------------------------------------------------------------------------- /images/base/scripts/third_party/gimme/README.md: -------------------------------------------------------------------------------- 1 | # gimme 2 | 3 | This is an unmodified copy of [gimme], so we don't have to download it 4 | from the internet. 5 | 6 | [gimme]: https://github.com/travis-ci/gimme -------------------------------------------------------------------------------- /images/kindnetd/scripts/third_party/gimme/README.md: -------------------------------------------------------------------------------- 1 | # gimme 2 | 3 | This is an unmodified copy of [gimme], so we don't have to download it 4 | from the internet. 5 | 6 | [gimme]: https://github.com/travis-ci/gimme -------------------------------------------------------------------------------- /site/layouts/shortcodes/minify.html: -------------------------------------------------------------------------------- 1 | {{ $file := .Get "file" }} 2 | {{- $contents := readFile $file -}} 3 | {{ $res := $contents | resources.FromString $file }} 4 | {{- safeHTML (($res | resources.Minify).Content) -}} 5 | -------------------------------------------------------------------------------- /images/base/files/etc/sysctl.d/10-network-security.conf: -------------------------------------------------------------------------------- 1 | # Turn on Source Address Verification in all interfaces to 2 | # prevent some spoofing attacks. 3 | net.ipv4.conf.default.rp_filter=1 4 | net.ipv4.conf.all.rp_filter=1 5 | -------------------------------------------------------------------------------- /images/local-path-provisioner/scripts/third_party/gimme/README.md: -------------------------------------------------------------------------------- 1 | # gimme 2 | 3 | This is an unmodified copy of [gimme], so we don't have to download it 4 | from the internet. 5 | 6 | [gimme]: https://github.com/travis-ci/gimme -------------------------------------------------------------------------------- /images/base/files/LICENSES/README.txt: -------------------------------------------------------------------------------- 1 | This directory contains license files and notices from binaries built for this 2 | image and the dependencies of those binaries, 3 | as collected by https://github.com/google/go-licenses. 4 | -------------------------------------------------------------------------------- /images/kindnetd/files/LICENSES/README.txt: -------------------------------------------------------------------------------- 1 | This directory contains license files and notices from binaries built for this 2 | image and the dependencies of those binaries, 3 | as collected by https://github.com/google/go-licenses. 4 | -------------------------------------------------------------------------------- /images/base/files/kind/README.txt: -------------------------------------------------------------------------------- 1 | This directory is reserved for KIND [^1] internal purposes. 2 | 3 | Modifying or depending on the contents of this directory is NOT supported. 4 | 5 | Here be dragons. 6 | 7 | [^1]: https://kind.sigs.k8s.io/ 8 | -------------------------------------------------------------------------------- /images/local-path-provisioner/files/LICENSES/README.txt: -------------------------------------------------------------------------------- 1 | This directory contains license files and notices from binaries built for this 2 | image and the dependencies of those binaries, 3 | as collected by https://github.com/google/go-licenses. 4 | -------------------------------------------------------------------------------- /pkg/internal/apis/config/encoding/testdata/v1alpha4/valid-minimal-two-nodes.yaml: -------------------------------------------------------------------------------- 1 | # technically valid, minimal config file with two nodes 2 | kind: Cluster 3 | apiVersion: kind.x-k8s.io/v1alpha4 4 | nodes: 5 | - role: control-plane 6 | - role: worker -------------------------------------------------------------------------------- /site/README.md: -------------------------------------------------------------------------------- 1 | # kind's docs 2 | 3 | kind's docs are built with [hugo], and can be browsed live at https://kind.sigs.k8s.io/ 4 | 5 | To browse them locally, install hugo and run `make serve` from this directory. 6 | 7 | [hugo]: https://gohugo.io 8 | -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | reviewers: 4 | - aojea 5 | - BenTheElder 6 | - neolit123 7 | - stmcginnis 8 | approvers: 9 | - aojea 10 | - BenTheElder 11 | emeritus_approvers: 12 | - amwat 13 | - munnerz 14 | -------------------------------------------------------------------------------- /site/static/copycode.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /images/local-path-helper/README.md: -------------------------------------------------------------------------------- 1 | # local-path-helper 2 | 3 | This image is the image used for the https://github.com/rancher/local-path-provisioner helper pod. 4 | 5 | ## Building 6 | 7 | You can `make quick` in this directory to build a test image. 8 | 9 | To push an actual image use `make push`. -------------------------------------------------------------------------------- /pkg/cluster/internal/providers/podman/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | reviewers: 4 | - aojea 5 | - BenTheElder 6 | approvers: 7 | - aojea 8 | - BenTheElder 9 | emeritus_approvers: 10 | - amwat 11 | 12 | labels: 13 | - area/provider/podman 14 | -------------------------------------------------------------------------------- /images/base/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | # See https://cloud.google.com/cloud-build/docs/build-config 2 | options: 3 | substitution_option: ALLOW_LOOSE 4 | machineType: E2_HIGHCPU_32 5 | steps: 6 | - name: gcr.io/k8s-testimages/krte:latest-master 7 | entrypoint: make 8 | args: ['-C', 'images/base', 'push'] 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Ask a question about using kind 4 | labels: kind/support 5 | 6 | --- 7 | 8 | 9 | -------------------------------------------------------------------------------- /images/haproxy/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | # See https://cloud.google.com/cloud-build/docs/build-config 2 | options: 3 | substitution_option: ALLOW_LOOSE 4 | machineType: E2_HIGHCPU_8 5 | steps: 6 | - name: gcr.io/k8s-testimages/krte:latest-master 7 | entrypoint: make 8 | args: ['-C', 'images/haproxy', 'push'] 9 | -------------------------------------------------------------------------------- /images/kindnetd/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | # See https://cloud.google.com/cloud-build/docs/build-config 2 | options: 3 | substitution_option: ALLOW_LOOSE 4 | machineType: E2_HIGHCPU_32 5 | steps: 6 | - name: gcr.io/k8s-testimages/krte:latest-master 7 | entrypoint: make 8 | args: ['-C', 'images/kindnetd', 'push'] 9 | -------------------------------------------------------------------------------- /images/base/files/etc/systemd/system/undo-mount-hacks.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Undo KIND mount hacks 3 | After=slices.target 4 | Before=containerd.service kubelet.service 5 | 6 | [Service] 7 | Type=oneshot 8 | ExecStart=/kind/bin/undo-mount-hacks.sh 9 | 10 | [Install] 11 | WantedBy=multi-user.target 12 | -------------------------------------------------------------------------------- /site/static/browserconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #2d89ef 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/enhancement.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Enhancement Request 3 | about: Suggest an enhancement to kind 4 | labels: kind/feature 5 | 6 | --- 7 | 8 | 9 | **What would you like to be added**: 10 | 11 | **Why is this needed**: 12 | -------------------------------------------------------------------------------- /images/local-path-helper/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | # See https://cloud.google.com/cloud-build/docs/build-config 2 | options: 3 | substitution_option: ALLOW_LOOSE 4 | machineType: E2_HIGHCPU_8 5 | steps: 6 | - name: gcr.io/k8s-testimages/krte:latest-master 7 | entrypoint: make 8 | args: ['-C', 'images/local-path-helper', 'push'] 9 | -------------------------------------------------------------------------------- /pkg/internal/apis/config/encoding/testdata/v1alpha4/valid-full-ha.yaml: -------------------------------------------------------------------------------- 1 | # technically valid, config file with a full ha cluster 2 | kind: Cluster 3 | apiVersion: kind.x-k8s.io/v1alpha4 4 | nodes: 5 | - role: control-plane 6 | - role: control-plane 7 | - role: control-plane 8 | - role: worker 9 | - role: worker 10 | - role: worker -------------------------------------------------------------------------------- /site/layouts/index.redirects: -------------------------------------------------------------------------------- 1 | {{- $apiVersions := site.Data.apiVersions -}} 2 | {{- range $apiVersions }} 3 | /{{ . }} https://godoc.org/sigs.k8s.io/kind/pkg/apis/config/{{ . }} 4 | {{- end }} 5 | /dl/v* https://github.com/kubernetes-sigs/kind/releases/download/v:splat 6 | /dl/* https://storage.googleapis.com/k8s-staging-kind/:splat -------------------------------------------------------------------------------- /hack/ci/push-latest-cli/README.md: -------------------------------------------------------------------------------- 1 | This tooling is used for our automated builds. 2 | 3 | These are meant to be consumed *only* by The Kubernetes Project's CI for 4 | testing Kubernetes. 5 | 6 | These builds are currently not supported for other purposes. 7 | 8 | See github.com/kubernetes/test-infra for the automation that invokes these. -------------------------------------------------------------------------------- /images/local-path-provisioner/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | # See https://cloud.google.com/cloud-build/docs/build-config 2 | options: 3 | substitution_option: ALLOW_LOOSE 4 | machineType: E2_HIGHCPU_8 5 | steps: 6 | - name: gcr.io/k8s-testimages/krte:latest-master 7 | entrypoint: make 8 | args: ['-C', 'images/local-path-provisioner', 'push'] 9 | -------------------------------------------------------------------------------- /site/tools.go: -------------------------------------------------------------------------------- 1 | //go:build tools 2 | // +build tools 3 | 4 | /* 5 | Package site is used to track binary dependencies with go modules 6 | https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module 7 | Namely: hugo 8 | */ 9 | package site 10 | 11 | import ( 12 | _ "github.com/gohugoio/hugo" 13 | ) 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Documentation Request 3 | about: Suggest what should be documented in kind 4 | labels: kind/documentation 5 | 6 | --- 7 | 8 | 9 | **What would you like to be documented**: 10 | 11 | **Why is this needed**: 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # build and test outputs 2 | /bin/ 3 | /_output/ 4 | /_artifacts/ 5 | 6 | # used for the code generators only 7 | /vendor/ 8 | 9 | # macOS 10 | .DS_Store 11 | 12 | # Vagrant 13 | .vagrant 14 | 15 | # files generated by editors 16 | .idea/ 17 | *.iml 18 | .vscode/ 19 | *.swp 20 | *.sublime-project 21 | *.sublime-workspace 22 | *~ 23 | -------------------------------------------------------------------------------- /pkg/internal/apis/config/encoding/testdata/v1alpha4/valid-port-and-mount.yaml: -------------------------------------------------------------------------------- 1 | kind: Cluster 2 | apiVersion: kind.x-k8s.io/v1alpha4 3 | nodes: 4 | - role: control-plane 5 | # map an extra port 6 | extraPortMappings: 7 | - hostPort: 80 8 | containerPort: 80 9 | # mount an extra path from the host 10 | extraMounts: 11 | - hostPath: ./foo 12 | containerPath: /bar -------------------------------------------------------------------------------- /site/layouts/partials/navbar.html: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/cleanup.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Cleanup 3 | about: Pay down technical debt, reduce friction, etc. 4 | labels: kind/cleanup 5 | 6 | --- 7 | 8 | 9 | 10 | **What should be cleaned up or changed**: 11 | 12 | **Why is this needed**: 13 | 14 | -------------------------------------------------------------------------------- /hack/ci/push-latest-cli/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | # See https://cloud.google.com/cloud-build/docs/build-config 2 | options: 3 | substitution_option: ALLOW_LOOSE 4 | steps: 5 | - name: gcr.io/k8s-testimages/krte:latest-master 6 | env: 7 | - PULL_BASE_SHA=$_PULL_BASE_SHA 8 | entrypoint: hack/ci/push-latest-cli/push-latest-cli.sh 9 | substitutions: 10 | _GIT_TAG: '12345' 11 | _PULL_BASE_SHA: 'oops' 12 | -------------------------------------------------------------------------------- /images/base/files/etc/systemd/system/containerd-fuse-overlayfs.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=containerd fuse-overlayfs snapshotter 3 | PartOf=containerd.service 4 | 5 | [Service] 6 | ExecStart=/usr/local/bin/containerd-fuse-overlayfs-grpc /run/containerd-fuse-overlayfs.sock /var/lib/containerd-fuse-overlayfs 7 | Type=notify 8 | Restart=always 9 | RestartSec=1 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /site/layouts/shortcodes/securitygoose.html: -------------------------------------------------------------------------------- 1 |
security goose says

Security Goose Says:

{{ .Inner | markdownify }}
2 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 2 3 | updates: 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" 8 | labels: 9 | - "area/dependency" 10 | - "release-note-none" 11 | - "ok-to-test" 12 | open-pull-requests-limit: 10 13 | groups: 14 | actions: 15 | update-types: 16 | - "minor" 17 | - "patch" 18 | -------------------------------------------------------------------------------- /site/layouts/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ partial "header.html" . }} 4 | 5 | {{ partial "sidebar.html" . }} 6 |
{{ partial "navbar.html" . }} 7 | 8 |
{{ partial "fancymarkdown.html" . }}
9 | {{ partial "footer.html" . }} 10 |
11 | 12 | -------------------------------------------------------------------------------- /site/layouts/docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ partial "header.html" . }} 4 | 5 | {{ partial "sidebar.html" . }} 6 |
{{ partial "navbar.html" . }} 7 | 8 |
{{ partial "fancymarkdown.html" . }}
9 | {{ partial "footer.html" . }} 10 |
11 | 12 | -------------------------------------------------------------------------------- /site/layouts/docs/section.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ partial "header.html" . }} 4 | 5 | {{ partial "sidebar.html" . }} 6 |
{{ partial "navbar.html" . }} 7 | 8 |
{{ partial "fancymarkdown.html" . }}
9 | {{ partial "footer.html" . }} 10 |
11 | 12 | -------------------------------------------------------------------------------- /site/layouts/docs/single.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ partial "header.html" . }} 4 | 5 | {{ partial "sidebar.html" . }} 6 |
{{ partial "navbar.html" . }} 7 | 8 |
{{ partial "fancymarkdown.html" . }}
9 | {{ partial "footer.html" . }} 10 |
11 | 12 | -------------------------------------------------------------------------------- /images/local-path-provisioner/README.md: -------------------------------------------------------------------------------- 1 | # local-path-provisioner 2 | 3 | This image packages https://github.com/rancher/local-path-provisioner to meet 4 | our requirements. 5 | 6 | - Not based on alpine (see: https://github.com/kubernetes/kubernetes/issues/109406#issuecomment-1103479928) 7 | - Control over building with current patched go version 8 | 9 | ## Building 10 | 11 | You can `make quick` in this directory to build a test image. 12 | 13 | To push an actual image use `make push`. 14 | -------------------------------------------------------------------------------- /pkg/internal/apis/config/encoding/testdata/v1alpha4/invalid-bad-indent.yaml: -------------------------------------------------------------------------------- 1 | kind: Cluster 2 | apiVersion: kind.x-k8s.io/v1alpha4 3 | networking: 4 | ipFamily: ipv6 5 | nodes: 6 | - role: control-plane 7 | - role: worker 8 | extraMounts: 9 | - containerPath: /foo 10 | hostPath: /bar 11 | readOnly: true 12 | selinuxRelabel: false 13 | propagation: Bidirectional 14 | extraPortMappings: 15 | - containerPort: 8080 16 | hostPort: 8080 17 | protocol: UDP 18 | - role: worker 19 | -------------------------------------------------------------------------------- /pkg/internal/cli/override.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/spf13/pflag" 7 | ) 8 | 9 | // OverrideDefaultName conditionally allows overriding the default cluster name 10 | // by setting the KIND_CLUSTER_NAME environment variable 11 | // only if --name wasn't set explicitly 12 | func OverrideDefaultName(fs *pflag.FlagSet) { 13 | if !fs.Changed("name") { 14 | if name := os.Getenv("KIND_CLUSTER_NAME"); name != "" { 15 | _ = fs.Set("name", name) 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /pkg/internal/apis/config/encoding/testdata/v1alpha4/invalid-bogus-field.yaml: -------------------------------------------------------------------------------- 1 | kind: Cluster 2 | apiVersion: kind.x-k8s.io/v1alpha4 3 | networking: 4 | ipFamily: ipv6 5 | nodes: 6 | - role: control-plane 7 | - role: worker 8 | extraMounts: 9 | - containerPath: /foo 10 | hostPath: /bar 11 | readOnly: true 12 | selinuxRelabel: false 13 | propagation: Bidirectional 14 | extraPortMappings: 15 | - containerPort: 8080 16 | hostPort: 8080 17 | protocol: UDP 18 | nOtAReaLFielD: bar 19 | -------------------------------------------------------------------------------- /hack/tools/tools.go: -------------------------------------------------------------------------------- 1 | //go:build tools 2 | // +build tools 3 | 4 | /* 5 | Package tools is used to track binary dependencies with go modules 6 | https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module 7 | */ 8 | package tools 9 | 10 | import ( 11 | // linter(s) 12 | _ "github.com/golangci/golangci-lint/cmd/golangci-lint" 13 | 14 | // kubernetes code generators 15 | _ "k8s.io/code-generator/cmd/deepcopy-gen" 16 | 17 | // test runner 18 | _ "gotest.tools/gotestsum" 19 | ) 20 | -------------------------------------------------------------------------------- /site/static/examples/config-with-port-mapping.yaml: -------------------------------------------------------------------------------- 1 | kind: Cluster 2 | apiVersion: kind.x-k8s.io/v1alpha4 3 | nodes: 4 | - role: control-plane 5 | # port forward 80 on the host to 80 on this node 6 | extraPortMappings: 7 | - containerPort: 80 8 | hostPort: 80 9 | # optional: set the bind address on the host 10 | # 0.0.0.0 is the current default 11 | listenAddress: "127.0.0.1" 12 | # optional: set the protocol to one of TCP, UDP, SCTP. 13 | # TCP is the default 14 | protocol: TCP 15 | -------------------------------------------------------------------------------- /site/static/site.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "short_name": "", 4 | "icons": [ 5 | { 6 | "src": "/android-chrome-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | }, 10 | { 11 | "src": "/android-chrome-512x512.png", 12 | "sizes": "512x512", 13 | "type": "image/png" 14 | } 15 | ], 16 | "theme_color": "#ffffff", 17 | "background_color": "#ffffff", 18 | "display": "standalone" 19 | } 20 | -------------------------------------------------------------------------------- /images/haproxy/README.md: -------------------------------------------------------------------------------- 1 | # haproxy 2 | 3 | This image is used internally by kind to implement kubeadm's "HA" mode, 4 | specifically to load balance the API server. 5 | 6 | We cannot merely use the upstream haproxy image as haproxy will exit without 7 | a minimal config, so we introduce one that will list on the intended port and 8 | hot reload it at runtime with the actual desired config. 9 | 10 | ## Building 11 | 12 | You can `make quick` in this directory to build a test image. 13 | 14 | To push an actual image use `make push`. 15 | -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | # netlify configuration 2 | [build] 3 | base = "site/" 4 | publish = "site/public/" 5 | command = "hugo" 6 | 7 | [build.environment] 8 | HUGO_VERSION = "0.111.3" 9 | 10 | [context.production.environment] 11 | # this controls our robots.txt 12 | HUGO_ENV = "production" 13 | HUGO_BASEURL = "https://kind.sigs.k8s.io/" 14 | 15 | [context.deploy-preview] 16 | command = "hugo --enableGitInfo --buildFuture -b $DEPLOY_PRIME_URL" 17 | 18 | [context.branch-deploy] 19 | command = "hugo --enableGitInfo --buildFuture -b $DEPLOY_PRIME_URL" 20 | -------------------------------------------------------------------------------- /pkg/internal/apis/config/encoding/testdata/v1alpha4/valid-many-fields.yaml: -------------------------------------------------------------------------------- 1 | kind: Cluster 2 | apiVersion: kind.x-k8s.io/v1alpha4 3 | name: not-default 4 | featureGates: 5 | AllBeta: false 6 | networking: 7 | ipFamily: ipv6 8 | nodes: 9 | - role: control-plane 10 | - role: worker 11 | extraMounts: 12 | - containerPath: /foo 13 | hostPath: /bar 14 | readOnly: true 15 | selinuxRelabel: false 16 | propagation: Bidirectional 17 | extraPortMappings: 18 | - containerPort: 8080 19 | hostPort: 8080 20 | protocol: UDP 21 | -------------------------------------------------------------------------------- /site/layouts/partials/fancymarkdown.html: -------------------------------------------------------------------------------- 1 | {{ if not (eq .Site.Title .Params.title) }} 2 |

{{ .Params.title }}

3 | 4 | {{ end }} 5 | {{ if .Params.description }} 6 |
{{ .Params.description | markdownify }}
7 | {{end}} 8 | {{ if .Params.toc }} 9 |

Contents 🔗︎

10 | 13 | 14 | {{ end }} 15 | {{ .Content | replaceRE "()" `${1} 🔗︎ ${3}` | safeHTML }} 16 | -------------------------------------------------------------------------------- /hack/tools/boilerplate.go.txt: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | -------------------------------------------------------------------------------- /SECURITY_CONTACTS: -------------------------------------------------------------------------------- 1 | # Defined below are the security contacts for this repo. 2 | # 3 | # They are the contact point for the Product Security Team to reach out 4 | # to for triaging and handling of incoming issues. 5 | # 6 | # The below names agree to abide by the 7 | # [Embargo Policy](https://github.com/kubernetes/sig-release/blob/master/security-release-process-documentation/security-release-process.md#embargo-policy) 8 | # and will be removed and replaced if they violate that agreement. 9 | # 10 | # DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE 11 | # INSTRUCTIONS AT https://kubernetes.io/security/ 12 | 13 | BenTheElder 14 | munnerz 15 | -------------------------------------------------------------------------------- /images/base/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Kubernetes Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | include $(CURDIR)/../Makefile.common.in 16 | -------------------------------------------------------------------------------- /images/local-path-helper/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2022 The Kubernetes Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | include $(CURDIR)/../Makefile.common.in -------------------------------------------------------------------------------- /pkg/cmd/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | // Package cmd provides helpers used by kind's commands / cli 15 | package cmd 16 | -------------------------------------------------------------------------------- /pkg/internal/patch/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package patch contains helpers for applying patches 18 | package patch 19 | -------------------------------------------------------------------------------- /pkg/errors/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package errors provides common utilities for dealing with errors 18 | package errors 19 | -------------------------------------------------------------------------------- /site/layouts/partials/footer.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /site/layouts/shortcodes/codeFromInline.html: -------------------------------------------------------------------------------- 1 | {{ $code := trim .Inner "\n" }} 2 | {{ $lang := "" }} 3 | {{ with .Get "lang" }}{{ $lang = . }}{{ end }} 4 | {{ $hash := md5 $code }} 5 | 6 | 7 | 8 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
9 | 12 |
{{ highlight $code $lang "" }}
22 | -------------------------------------------------------------------------------- /pkg/cluster/internal/logs/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package logs contains tooling for obtaining cluster logs 18 | package logs 19 | -------------------------------------------------------------------------------- /pkg/cluster/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package cluster implements kind kubernetes-in-docker cluster management 18 | package cluster 19 | -------------------------------------------------------------------------------- /pkg/cluster/nodes/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package nodes provides a kind specific definition of a cluster node 18 | package nodes 19 | -------------------------------------------------------------------------------- /pkg/build/nodeimage/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package nodeimage implements functionality to build the kind node image 18 | package nodeimage 19 | -------------------------------------------------------------------------------- /site/static/examples/loadbalancer/usage.yaml: -------------------------------------------------------------------------------- 1 | kind: Pod 2 | apiVersion: v1 3 | metadata: 4 | name: foo-app 5 | labels: 6 | app: http-echo 7 | spec: 8 | containers: 9 | - name: foo-app 10 | image: hashicorp/http-echo:0.2.3 11 | args: 12 | - "-text=foo" 13 | --- 14 | kind: Pod 15 | apiVersion: v1 16 | metadata: 17 | name: bar-app 18 | labels: 19 | app: http-echo 20 | spec: 21 | containers: 22 | - name: bar-app 23 | image: hashicorp/http-echo:0.2.3 24 | args: 25 | - "-text=bar" 26 | --- 27 | kind: Service 28 | apiVersion: v1 29 | metadata: 30 | name: foo-service 31 | spec: 32 | type: LoadBalancer 33 | selector: 34 | app: http-echo 35 | ports: 36 | # Default port used by the image 37 | - port: 5678 38 | -------------------------------------------------------------------------------- /pkg/cluster/internal/kubeadm/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package kubeadm contains kubeadm related constants and configuration 18 | package kubeadm 19 | -------------------------------------------------------------------------------- /pkg/cluster/internal/providers/common/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impliep. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package common contains common code for implementing providers 18 | package common 19 | -------------------------------------------------------------------------------- /cmd/kind/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package main 18 | 19 | import ( 20 | "sigs.k8s.io/kind/cmd/kind/app" 21 | ) 22 | 23 | func main() { 24 | app.Main() 25 | } 26 | -------------------------------------------------------------------------------- /images/local-path-provisioner/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2022 The Kubernetes Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | VERSION=v0.0.24 15 | EXTRA_BUILD_OPT=--build-arg=VERSION=$(VERSION) 16 | include $(CURDIR)/../Makefile.common.in -------------------------------------------------------------------------------- /pkg/internal/apis/config/encoding/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package encoding implements utilities for decoding from yaml the `kind` Config 18 | package encoding 19 | -------------------------------------------------------------------------------- /pkg/cluster/internal/loadbalancer/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package loadbalancer contains external loadbalancer related constants and configuration 18 | package loadbalancer 19 | -------------------------------------------------------------------------------- /images/base/files/etc/sysctl.d/10-network-magic.conf: -------------------------------------------------------------------------------- 1 | # Do not consider loopback addresses as martian source or destination while routing 2 | # - Docker with custom networks uses an embedded DNS server with address 172.0.0.11 3 | # - Kubernetes pods mount the node resolv.conf, so they can't use a loopack address 4 | # that is only reachable from the node. 5 | # 6 | # KIND rewrites the well-known docker DNS address 127.0.0.11 by a non-loopback address. 7 | # The DNS traffic coming from a pod will have to route to a localhost address to be NATed, 8 | # hence we have to enable route_localnet or pods DNS will not work. 9 | # Kubernetes mitigates the possible security issue caused by enabling this option. 10 | # ref: https://nvd.nist.gov/vuln/detail/CVE-2020-8558 11 | net.ipv4.conf.all.route_localnet=1 12 | -------------------------------------------------------------------------------- /pkg/log/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package log defines a logging interface that kind uses 18 | // This is roughly a minimal subset of klog github.com/kubernetes/klog 19 | package log 20 | -------------------------------------------------------------------------------- /pkg/build/nodeimage/internal/kube/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package kube implements functionality to build Kubernetes for the purposes 18 | // of installing into the kind node image 19 | package kube 20 | -------------------------------------------------------------------------------- /pkg/apis/config/v1alpha4/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package v1alpha4 implements the v1alpha4 apiVersion of kind's cluster 18 | // configuration 19 | // 20 | // +k8s:deepcopy-gen=package 21 | package v1alpha4 22 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // This package is a stub main wrapping cmd/kind.Main() 18 | package main 19 | 20 | import ( 21 | "sigs.k8s.io/kind/cmd/kind/app" 22 | ) 23 | 24 | func main() { 25 | app.Main() 26 | } 27 | -------------------------------------------------------------------------------- /pkg/build/nodeimage/internal/container/docker/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package docker contains helpers for working with docker 18 | // This package has no stability guarantees whatsoever! 19 | package docker 20 | -------------------------------------------------------------------------------- /pkg/cluster/nodeutils/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package nodeutils contains functionality for Kubernetes-in-Docker nodes 18 | // It mostly exists to break up functionality from sigs.k8s.io/kind/pkg/cluster 19 | package nodeutils 20 | -------------------------------------------------------------------------------- /hack/tools/.golangci.yml: -------------------------------------------------------------------------------- 1 | run: 2 | timeout: 2m 3 | 4 | linters: 5 | disable-all: true 6 | enable: 7 | - errcheck 8 | - gosimple 9 | - govet 10 | - ineffassign 11 | - staticcheck 12 | - typecheck 13 | - gochecknoinits 14 | - gofmt 15 | - revive # replaces golint for now 16 | - misspell 17 | - exportloopref 18 | - unparam 19 | 20 | linters-settings: 21 | staticcheck: 22 | checks: 23 | - all 24 | 25 | issues: 26 | exclude-rules: 27 | # this requires renaming all unused parameters, we'd rather leave a preferred 28 | # placeholder name in place when implementing an interface etc. 29 | # we can revisit this later, right now it's generating a lot of new warnings 30 | # after upgrading golangci-lint 31 | - text: "^unused-parameter: .*" 32 | linters: 33 | - revive 34 | -------------------------------------------------------------------------------- /pkg/cluster/internal/providers/common/constants.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package common 18 | 19 | // APIServerInternalPort defines the port where the control plane is listening 20 | // _inside_ the node network 21 | const APIServerInternalPort = 6443 22 | -------------------------------------------------------------------------------- /images/base/files/etc/systemd/system/kubelet.service.d/11-kind.conf: -------------------------------------------------------------------------------- 1 | # kind specific additions go in this file 2 | [Service] 3 | # On cgroup v1, the /kubelet cgroup is created in the entrypoint script before running systemd. 4 | # On cgroup v2, the /kubelet cgroup is created here. (See the comments in the entrypoint script for the reason.) 5 | ExecStartPre=/bin/sh -euc "if [ -f /sys/fs/cgroup/cgroup.controllers ]; then /kind/bin/create-kubelet-cgroup-v2.sh; fi" 6 | # on WSL2 (and potentially other distros without systemd) /sys/fs/cgroup/systemd is created after the entrypoint, during /sbin/init. 7 | # This eventually leads to kubelet failing to start, see: https://github.com/kubernetes-sigs/kind/issues/2323 8 | ExecStartPre=/bin/sh -euc "if [ ! -f /sys/fs/cgroup/cgroup.controllers ] && [ ! -d /sys/fs/cgroup/systemd/kubelet ]; then mkdir -p /sys/fs/cgroup/systemd/kubelet; fi" 9 | -------------------------------------------------------------------------------- /pkg/exec/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package exec contains an interface for executing commands, along with helpers 18 | // TODO(bentheelder): add standardized timeout functionality & a default timeout 19 | // so that commands cannot hang indefinitely (!) 20 | package exec 21 | -------------------------------------------------------------------------------- /images/node/README.md: -------------------------------------------------------------------------------- 1 | ## images/node 2 | 3 | See: [`pkg/build/nodeimage/build.go`][pkg/build/nodeimage/build.go] 4 | and [`pkg/build/nodeimage/buildcontext.go`][pkg/build/nodeimage/buildcontext.go], this 5 | image is built programmatically with docker run / exec / commit for performance 6 | reasons with large artifacts. 7 | 8 | Roughly this image is [the base image](./../base), with the addition of: 9 | - installing the Kubernetes packages / binaries 10 | - placing the Kubernetes docker images in `/kind/images/*.tar` 11 | - placing a file in `/kind/version` containing the Kubernetes semver 12 | 13 | See [`node-image`][node-image.md] for more design details. 14 | 15 | [pkg/build/nodeimage/build.go]: ./../../pkg/build/nodeimage/build.go 16 | [pkg/build/nodeimage/buildcontext.go]: ./../../pkg/build/nodeimage/buildcontext.go 17 | [node-image.md]: https://kind.sigs.k8s.io/docs/design/node-image 18 | -------------------------------------------------------------------------------- /site/layouts/partials/header.html: -------------------------------------------------------------------------------- 1 | 2 | {{ .Site.Title }}{{ if and .Params.title (not (eq .Site.Title .Params.Title)) }} – {{ .Params.title }}{{ end }} 3 | {{ partialCached "inlinecss.html" . }} 4 | {{ partialCached "inlinescript.html" . }} 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /site/content/docs/user/kind-example-config.yaml: -------------------------------------------------------------------------------- 1 | # this config file contains all config fields with comments 2 | # NOTE: this is not a particularly useful config file 3 | kind: Cluster 4 | apiVersion: kind.x-k8s.io/v1alpha4 5 | # patch the generated kubeadm config with some extra settings 6 | kubeadmConfigPatches: 7 | - | 8 | apiVersion: kubelet.config.k8s.io/v1beta1 9 | kind: KubeletConfiguration 10 | evictionHard: 11 | nodefs.available: "0%" 12 | # patch it further using a JSON 6902 patch 13 | kubeadmConfigPatchesJSON6902: 14 | - group: kubeadm.k8s.io 15 | version: v1beta3 16 | kind: ClusterConfiguration 17 | patch: | 18 | - op: add 19 | path: /apiServer/certSANs/- 20 | value: my-hostname 21 | # 1 control plane node and 3 workers 22 | nodes: 23 | # the control plane node config 24 | - role: control-plane 25 | # the three workers 26 | - role: worker 27 | - role: worker 28 | - role: worker 29 | -------------------------------------------------------------------------------- /images/base/files/etc/systemd/system/containerd.service: -------------------------------------------------------------------------------- 1 | # derived containerd systemd service file from the official: 2 | # https://github.com/containerd/containerd/blob/master/containerd.service 3 | [Unit] 4 | Description=containerd container runtime 5 | Documentation=https://containerd.io 6 | After=network.target local-fs.target 7 | # disable rate limiting 8 | StartLimitIntervalSec=0 9 | 10 | [Service] 11 | ExecStartPre=-/sbin/modprobe overlay 12 | ExecStart=/usr/local/bin/containerd 13 | 14 | Type=notify 15 | Delegate=yes 16 | KillMode=process 17 | Restart=always 18 | RestartSec=1 19 | # Having non-zero Limit*s causes performance problems due to accounting overhead 20 | # in the kernel. We recommend using cgroups to do container-local accounting. 21 | LimitNPROC=infinity 22 | LimitCORE=infinity 23 | LimitNOFILE=infinity 24 | TasksMax=infinity 25 | OOMScoreAdjust=-999 26 | 27 | [Install] 28 | WantedBy=multi-user.target 29 | -------------------------------------------------------------------------------- /pkg/build/nodeimage/internal/container/docker/save.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package docker 18 | 19 | import ( 20 | "sigs.k8s.io/kind/pkg/exec" 21 | ) 22 | 23 | // Save saves image to dest, as in `docker save` 24 | func Save(image, dest string) error { 25 | return exec.Command("docker", "save", "-o", dest, image).Run() 26 | } 27 | -------------------------------------------------------------------------------- /pkg/internal/apis/config/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package config implements the current apiVersion of the `kind` Config 18 | // along with some common abstractions 19 | // 20 | // +k8s:deepcopy-gen=package 21 | // +k8s:conversion-gen=sigs.k8s.io/kind/pkg/internal/apis/config 22 | // +k8s:defaulter-gen=TypeMeta 23 | package config 24 | -------------------------------------------------------------------------------- /pkg/internal/runtime/runtime.go: -------------------------------------------------------------------------------- 1 | package runtime 2 | 3 | import ( 4 | "os" 5 | 6 | "sigs.k8s.io/kind/pkg/cluster" 7 | "sigs.k8s.io/kind/pkg/log" 8 | ) 9 | 10 | // GetDefault selected the default runtime from the environment override 11 | func GetDefault(logger log.Logger) cluster.ProviderOption { 12 | switch p := os.Getenv("KIND_EXPERIMENTAL_PROVIDER"); p { 13 | case "": 14 | return nil 15 | case "podman": 16 | logger.Warn("using podman due to KIND_EXPERIMENTAL_PROVIDER") 17 | return cluster.ProviderWithPodman() 18 | case "docker": 19 | logger.Warn("using docker due to KIND_EXPERIMENTAL_PROVIDER") 20 | return cluster.ProviderWithDocker() 21 | case "nerdctl", "finch", "nerdctl.lima": 22 | logger.Warnf("using %s due to KIND_EXPERIMENTAL_PROVIDER", p) 23 | return cluster.ProviderWithNerdctl(p) 24 | default: 25 | logger.Warnf("ignoring unknown value %q for KIND_EXPERIMENTAL_PROVIDER", p) 26 | return nil 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /pkg/internal/sets/empty.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by set-gen. DO NOT EDIT. 18 | 19 | package sets 20 | 21 | // Empty is public since it is used by some internal API objects for conversions between external 22 | // string arrays and internal sets, and conversion logic requires public types today. 23 | type Empty struct{} 24 | -------------------------------------------------------------------------------- /pkg/cluster/internal/loadbalancer/const.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package loadbalancer 18 | 19 | // Image defines the loadbalancer image:tag 20 | const Image = "docker.io/kindest/haproxy:v20230606-42a2262b" 21 | 22 | // ConfigPath defines the path to the config file in the image 23 | const ConfigPath = "/usr/local/etc/haproxy/haproxy.cfg" 24 | -------------------------------------------------------------------------------- /hack/build/gotoolchain.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2020 The Kubernetes Authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # script to set GOTOOLCHAIN as needed 17 | # MUST BE RUN FROM THE REPO ROOT DIRECTORY 18 | 19 | # read go-version file unless GO_VERSION is set 20 | GO_VERSION="${GO_VERSION:-"$(cat .go-version)"}" 21 | 22 | GOTOOLCHAIN="go${GO_VERSION}" 23 | export GOTOOLCHAIN GO_VERSION 24 | -------------------------------------------------------------------------------- /pkg/apis/config/defaults/image.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package defaults contains cross-api-version configuration defaults 18 | package defaults 19 | 20 | // Image is the default for the Config.Image field, aka the default node image. 21 | const Image = "kindest/node:v1.30.2@sha256:ecfe5841b9bee4fe9690f49c118c33629fa345e3350a0c67a5a34482a99d6bba" 22 | -------------------------------------------------------------------------------- /pkg/cluster/internal/kubeadm/const.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package kubeadm 18 | 19 | // Token defines a dummy, well known token for automating TLS bootstrap process 20 | const Token = "abcdef.0123456789abcdef" 21 | 22 | // ObjectName is the name every generated object will have 23 | // I.E. `metadata:\nname: config` 24 | const ObjectName = "config" 25 | -------------------------------------------------------------------------------- /images/base/scripts/target-cc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2023 The Kubernetes Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # this script maps buildx TARGETARCH to $CC 18 | 19 | set -o errexit -o nounset -o pipefail 20 | 21 | case $TARGETARCH in 22 | arm64) 23 | echo -n 'aarch64-linux-gnu-gcc' ;; 24 | amd64) 25 | echo -n 'x86_64-linux-gnu-gcc' ;; 26 | *) 27 | exit 1 ;; 28 | esac 29 | -------------------------------------------------------------------------------- /pkg/internal/version/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package version provides utilities for version number comparisons 18 | // 19 | // This is forked from k8s.io/apimachinery/pkg/util/version to make 20 | // kind easier to import (k8s.io/apimachinery/pkg/util/version is a stable, 21 | // mature package with no externaldependencies within a large, heavy module) 22 | package version 23 | -------------------------------------------------------------------------------- /pkg/cluster/internal/providers/nerdctl/constants.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impliep. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package nerdctl 18 | 19 | // clusterLabelKey is applied to each "node" container for identification 20 | const clusterLabelKey = "io.x-k8s.kind.cluster" 21 | 22 | // nodeRoleLabelKey is applied to each "node" container for categorization 23 | // of nodes by role 24 | const nodeRoleLabelKey = "io.x-k8s.kind.role" 25 | -------------------------------------------------------------------------------- /pkg/cluster/internal/providers/docker/constants.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impliep. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package docker 18 | 19 | // clusterLabelKey is applied to each "node" docker container for identification 20 | const clusterLabelKey = "io.x-k8s.kind.cluster" 21 | 22 | // nodeRoleLabelKey is applied to each "node" docker container for categorization 23 | // of nodes by role 24 | const nodeRoleLabelKey = "io.x-k8s.kind.role" 25 | -------------------------------------------------------------------------------- /pkg/cluster/internal/providers/podman/constants.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impliep. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package podman 18 | 19 | // clusterLabelKey is applied to each "node" podman container for identification 20 | const clusterLabelKey = "io.x-k8s.kind.cluster" 21 | 22 | // nodeRoleLabelKey is applied to each "node" podman container for categorization 23 | // of nodes by role 24 | const nodeRoleLabelKey = "io.x-k8s.kind.role" 25 | -------------------------------------------------------------------------------- /hack/ci/build-all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2018 The Kubernetes Authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # simple CI script to verify kind's own sources 17 | # TODO(bentheelder): rename / refactor. consider building kindnetd 18 | 19 | set -o errexit -o nounset -o pipefail 20 | 21 | # cd to the repo root 22 | REPO_ROOT=$(git rev-parse --show-toplevel) 23 | cd "${REPO_ROOT}" 24 | 25 | # build kind 26 | hack/release/build/cross.sh 27 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module sigs.k8s.io/kind 2 | 3 | // NOTE: This is the go language version, NOT the compiler version. 4 | // 5 | // This controls the *minimum* required go version and therefore available Go 6 | // language features. 7 | // 8 | // See ./.go-version for the go compiler version used when building binaries 9 | // 10 | // https://go.dev/doc/modules/gomod-ref#go 11 | go 1.17 12 | 13 | require ( 14 | github.com/BurntSushi/toml v1.4.0 15 | github.com/alessio/shellescape v1.4.2 16 | github.com/evanphx/json-patch/v5 v5.6.0 17 | github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 18 | github.com/mattn/go-isatty v0.0.20 19 | github.com/pelletier/go-toml v1.9.5 20 | github.com/pkg/errors v0.9.1 21 | github.com/spf13/cobra v1.8.0 22 | github.com/spf13/pflag v1.0.5 23 | gopkg.in/yaml.v3 v3.0.1 24 | sigs.k8s.io/yaml v1.4.0 25 | ) 26 | 27 | require ( 28 | github.com/inconshreveable/mousetrap v1.1.0 // indirect 29 | github.com/kr/text v0.2.0 // indirect 30 | golang.org/x/sys v0.6.0 // indirect 31 | ) 32 | -------------------------------------------------------------------------------- /images/base/files/kind/bin/undo-mount-hacks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2023 The Kubernetes Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -o errexit 18 | set -o nounset 19 | set -o pipefail 20 | 21 | # don't run on cgroups v2 22 | if [[ -f "/sys/fs/cgroup/cgroup.controllers" ]]; then 23 | exit 0 24 | fi 25 | 26 | # on cgroups v1 we want to undo bind mounting over this to hide misc 27 | # see entrypoint 28 | umount /proc/cgroups || true 29 | -------------------------------------------------------------------------------- /images/base/files/etc/systemd/system/kubelet.service: -------------------------------------------------------------------------------- 1 | # slightly modified from: 2 | # https://github.com/kubernetes/kubernetes/blob/ba8fcafaf8c502a454acd86b728c857932555315/build/debs/kubelet.service 3 | [Unit] 4 | Description=kubelet: The Kubernetes Node Agent 5 | Documentation=http://kubernetes.io/docs/ 6 | # NOTE: kind deviates from upstream here to avoid crashlooping 7 | # This does *not* support altering the kubelet config path though. 8 | # We intend to upstream this change but first need to solve the upstream 9 | # Packaging problem (all kubernetes versions use the same files out of tree). 10 | ConditionPathExists=/var/lib/kubelet/config.yaml 11 | 12 | [Service] 13 | ExecStart=/usr/bin/kubelet 14 | Restart=always 15 | StartLimitInterval=0 16 | # NOTE: kind deviates from upstream here with a lower RestartSec 17 | RestartSec=1s 18 | # And by adding the [Service] lines below 19 | CPUAccounting=true 20 | MemoryAccounting=true 21 | Slice=kubelet.slice 22 | KillMode=process 23 | 24 | [Install] 25 | WantedBy=multi-user.target 26 | -------------------------------------------------------------------------------- /site/layouts/shortcodes/codeFromFile.html: -------------------------------------------------------------------------------- 1 | {{ $file := .Get "file" }} 2 | {{ $lang := "" }} 3 | {{ $suffix := findRE "(\\.[^.]+)$" $file 1 }} 4 | {{ with $suffix }} 5 | {{ $lang = (index . 0 | strings.TrimPrefix ".") }} 6 | {{ end }} 7 | {{ with .Get "lang" }}{{ $lang = . }}{{ end }} 8 | {{ $virtualPath := strings.TrimPrefix `static/` $file }} 9 | 10 | 11 | 12 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
13 | {{ $virtualPath }} 14 | 17 |
{{- highlight (trim ($file | readFile) "\n") $lang "" | -}}
27 | -------------------------------------------------------------------------------- /hack/make-rules/update/gofmt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2018 The Kubernetes Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # script to run gofmt over our code (not vendor) 18 | set -o errexit -o nounset -o pipefail 19 | 20 | # cd to the repo root and setup go 21 | REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." &> /dev/null && pwd -P)" 22 | cd "${REPO_ROOT}" 23 | source hack/build/setup-go.sh 24 | 25 | find . -name '*.go' -type f -print0 | xargs -0 gofmt -s -w 26 | -------------------------------------------------------------------------------- /pkg/build/nodeimage/const.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package nodeimage 18 | 19 | // these are well known paths within the node image 20 | const ( 21 | // TODO: refactor kubernetesVersionLocation to a common internal package 22 | kubernetesVersionLocation = "/kind/version" 23 | defaultCNIManifestLocation = "/kind/manifests/default-cni.yaml" 24 | defaultStorageManifestLocation = "/kind/manifests/default-storage.yaml" 25 | ) 26 | -------------------------------------------------------------------------------- /hack/make-rules/update/all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2018 The Kubernetes Authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # script to run all update scripts (except deps) 17 | set -o errexit -o nounset -o pipefail 18 | 19 | # cd to the repo root 20 | REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." &> /dev/null && pwd -P)" 21 | cd "${REPO_ROOT}" 22 | 23 | hack/make-rules/update/deps.sh 24 | hack/make-rules/update/generated.sh 25 | hack/make-rules/update/gofmt.sh 26 | -------------------------------------------------------------------------------- /images/haproxy/haproxy.cfg: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Kubernetes Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # minimal config file to avoid haproxy exiting due to invalid / missing config 16 | # kind will rewrite this config at runtime 17 | global 18 | # limit memory usage to approximately 18 MB 19 | maxconn 100000 20 | 21 | frontend controlPlane 22 | bind 0.0.0.0:6443 23 | mode tcp 24 | default_backend kube-apiservers 25 | 26 | backend kube-apiservers 27 | mode tcp 28 | -------------------------------------------------------------------------------- /pkg/build/nodeimage/defaults.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package nodeimage 18 | 19 | // DefaultImage is the default name:tag for the built image 20 | const DefaultImage = "kindest/node:latest" 21 | 22 | // DefaultBaseImage is the default base image used 23 | // TODO: come up with a reasonable solution to digest pinning 24 | // https://github.com/moby/moby/issues/43188 25 | const DefaultBaseImage = "docker.io/kindest/base:v20240701-2cec31c3" 26 | -------------------------------------------------------------------------------- /pkg/internal/apis/config/encoding/convert.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package encoding 18 | 19 | import ( 20 | "sigs.k8s.io/kind/pkg/apis/config/v1alpha4" 21 | 22 | "sigs.k8s.io/kind/pkg/internal/apis/config" 23 | ) 24 | 25 | // V1Alpha4ToInternal converts to the internal API version 26 | func V1Alpha4ToInternal(cluster *v1alpha4.Cluster) *config.Cluster { 27 | v1alpha4.SetDefaultsCluster(cluster) 28 | return config.Convertv1alpha4(cluster) 29 | } 30 | -------------------------------------------------------------------------------- /images/kindnetd/README.md: -------------------------------------------------------------------------------- 1 | # kindnetd 2 | 3 | `kindnetd` is a simple networking daemon with the following responsibilities: 4 | 5 | - IP masquerade (of traffic leaving the nodes that is headed out of the cluster) 6 | - Ensuring netlink routes to pod CIDRs via the host node IP for each 7 | - Ensuring a simple CNI config based on the standard [ptp] / [host-local] [plugins] and the node's pod CIDR 8 | 9 | kindnetd is based on [aojea/kindnet] which is in turn based on [leblancd/kube-v6-test]. 10 | 11 | We use this to implement KIND's standard CNI / cluster networking configuration. 12 | 13 | ## Building 14 | 15 | cd to this directory on mac / linux with docker installed and run `make quick`. 16 | 17 | To push an image run `make push`. 18 | 19 | [ptp]: https://www.cni.dev/plugins/current/main/ptp/ 20 | [host-local]: https://www.cni.dev/plugins/current/ipam/host-local/ 21 | [plugins]: https://github.com/containernetworking/plugins 22 | [aojea/kindnet]: https://github.com/aojea/kindnet 23 | [leblancd/kube-v6-test]: https://github.com/leblancd/kube-v6-test/tree/master 24 | -------------------------------------------------------------------------------- /pkg/internal/apis/config/encoding/testdata/v1alpha4/valid-kind-workers-patches.yaml: -------------------------------------------------------------------------------- 1 | # this config file contains all config fields with comments 2 | kind: Cluster 3 | apiVersion: kind.x-k8s.io/v1alpha4 4 | 5 | # 1 control plane node and 3 workers 6 | nodes: 7 | # the control plane node config 8 | - role: control-plane 9 | # the three workers 10 | - role: worker 11 | kubeadmConfigPatches: 12 | - | 13 | apiVersion: kubeadm.k8s.io/v1beta2 14 | kind: JoinConfiguration 15 | nodeRegistration: 16 | kubeletExtraArgs: 17 | node-labels: "aqua=gateway" 18 | authorization-mode: "AlwaysAllow" 19 | - role: worker 20 | kubeadmConfigPatchesJSON6902: 21 | - group: kubelet.config.k8s.io 22 | version: v1beta1 23 | kind: KubeletConfiguration 24 | patch: | 25 | - op: add 26 | path: /authentication 27 | value: {"anonymous": {"enabled": true}} 28 | - op: add 29 | path: /tlsCipherSuites 30 | value: ["TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256","TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"] 31 | - role: worker 32 | -------------------------------------------------------------------------------- /pkg/build/nodeimage/internal/kube/builder.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package kube 18 | 19 | // Builder represents and implementation of building Kubernetes 20 | // building may constitute downloading a release 21 | type Builder interface { 22 | // Build returns a Bits and any errors encountered while building Kubernetes. 23 | // Some implementations (upstream binaries) may use this step to obtain 24 | // an existing build instead 25 | Build() (Bits, error) 26 | } 27 | -------------------------------------------------------------------------------- /pkg/internal/apis/config/encoding/testdata/v1alpha4/valid-kind-patches.yaml: -------------------------------------------------------------------------------- 1 | # this config file contains all config fields with comments 2 | kind: Cluster 3 | apiVersion: kind.x-k8s.io/v1alpha4 4 | # patch the generated kubeadm config with some extra settings 5 | kubeadmConfigPatches: 6 | - | 7 | apiVersion: kubeadm.k8s.io/v1beta2 8 | kind: ClusterConfiguration 9 | metadata: 10 | name: config 11 | networking: 12 | serviceSubnet: 10.0.0.0/16 13 | # patch it further using a JSON 6902 patch 14 | kubeadmConfigPatchesJSON6902: 15 | - group: kubeadm.k8s.io 16 | version: v1beta2 17 | kind: ClusterConfiguration 18 | patch: | 19 | - op: add 20 | path: /apiServer/certSANs/- 21 | value: my-hostname 22 | # patch containerd config 23 | containerdConfigPatches: 24 | # configure a local insecure registry 25 | - |- 26 | [plugins."io.containerd.grpc.v1.cri".registry.mirrors."registry:5000"] 27 | # 1 control plane node and 3 workers 28 | nodes: 29 | # the control plane node config 30 | - role: control-plane 31 | # the three workers 32 | - role: worker 33 | - role: worker 34 | - role: worker 35 | -------------------------------------------------------------------------------- /images/base/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf: -------------------------------------------------------------------------------- 1 | # https://github.com/kubernetes/kubernetes/blob/ba8fcafaf8c502a454acd86b728c857932555315/build/debs/10-kubeadm.conf 2 | # Note: This dropin only works with kubeadm and kubelet v1.11+ 3 | [Service] 4 | Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf" 5 | Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml" 6 | # This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically 7 | EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env 8 | # This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use 9 | # the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file. 10 | EnvironmentFile=-/etc/default/kubelet 11 | ExecStart= 12 | ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS 13 | -------------------------------------------------------------------------------- /pkg/internal/sets/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package sets implements set types. 18 | // 19 | // This is forked from k8s.io/apimachinery/pkg/util/sets (under the same project 20 | // and license), because k8s.io/apimachinery is a relatively heavy dependency 21 | // and we only need some trivial utilities. Avoiding importing k8s.io/apimachinery 22 | // makes kind easier to embed in other projects for testing etc. 23 | // 24 | // The set implementation is relatively small and very stable. 25 | package sets 26 | -------------------------------------------------------------------------------- /site/layouts/partials/sidebar.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pkg/internal/integration/integration.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package integration 18 | 19 | import "testing" 20 | 21 | // *testing.T methods used by assert 22 | type testingDotT interface { 23 | Skip(args ...interface{}) 24 | } 25 | 26 | // MaybeSkip skips if integration tests should be skipped 27 | // currently this is when testing.Short() is true 28 | // This should be called at the beginning of an integration test 29 | func MaybeSkip(t testingDotT) { 30 | if testing.Short() { 31 | t.Skip("Skipping integration test due to -short") 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /hack/ci/vagrant-helper.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2021 The Kubernetes Authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | set -o errexit -o nounset -o pipefail 17 | 18 | 19 | : "${KIND_EXPERIMENTAL_PROVIDER:=docker}" 20 | SSH_CONFIG=".vagrant/ssh-config" 21 | if [ ! -f "$SSH_CONFIG" ]; then 22 | vagrant ssh-config > "$SSH_CONFIG" 23 | fi 24 | 25 | if [ "$ROOTLESS" = "rootless" ]; then 26 | exec ssh -F "$SSH_CONFIG" default KIND_EXPERIMENTAL_PROVIDER="$KIND_EXPERIMENTAL_PROVIDER" "${@}" 27 | fi 28 | exec ssh -F "$SSH_CONFIG" default sudo KIND_EXPERIMENTAL_PROVIDER="$KIND_EXPERIMENTAL_PROVIDER" "${@}" 29 | -------------------------------------------------------------------------------- /.github/actions/setup-env/action.yaml: -------------------------------------------------------------------------------- 1 | name: "Setup environment" 2 | description: "Performs common setup operations." 3 | runs: 4 | using: "composite" 5 | steps: 6 | - name: Get go version 7 | id: golangversion 8 | run: | 9 | echo "go_version=$(cat .go-version)" >> "$GITHUB_OUTPUT" 10 | shell: bash 11 | 12 | - name: Set up Go 13 | id: go 14 | uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 15 | with: 16 | go-version: ${{ steps.golangversion.outputs.go_version }} 17 | check-latest: true 18 | 19 | - name: Install kind 20 | run: sudo make install INSTALL_DIR=/usr/local/bin 21 | shell: bash 22 | 23 | - name: Install kubectl 24 | run: | 25 | curl -LO https://dl.k8s.io/release/$(curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl 26 | chmod +x ./kubectl 27 | sudo mv ./kubectl /usr/local/bin/kubectl 28 | shell: bash 29 | 30 | - name: Enable ipv4 and ipv6 forwarding 31 | run: | 32 | sudo sysctl -w net.ipv6.conf.all.forwarding=1 33 | sudo sysctl -w net.ipv4.ip_forward=1 34 | shell: bash 35 | -------------------------------------------------------------------------------- /pkg/build/nodeimage/internal/container/docker/run.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package docker 18 | 19 | import ( 20 | "sigs.k8s.io/kind/pkg/exec" 21 | ) 22 | 23 | // Run creates a container with "docker run", with some error handling 24 | func Run(image string, runArgs []string, containerArgs []string) error { 25 | // construct the actual docker run argv 26 | args := []string{"run"} 27 | args = append(args, runArgs...) 28 | args = append(args, image) 29 | args = append(args, containerArgs...) 30 | cmd := exec.Command("docker", args...) 31 | return cmd.Run() 32 | } 33 | -------------------------------------------------------------------------------- /hack/third_party/gimme/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2018 gimme contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /images/base/scripts/third_party/gimme/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2018 gimme contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /images/kindnetd/scripts/third_party/gimme/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2018 gimme contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /images/local-path-provisioner/scripts/third_party/gimme/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2018 gimme contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /images/base/README.md: -------------------------------------------------------------------------------- 1 | 2 | # images/base 3 | 4 | This directory contains sources for building the `kind` base "node" image. 5 | 6 | The image can be built with `make quick`. 7 | 8 | ## Maintenance 9 | 10 | This image needs to do a number of unusual things to support running systemd, 11 | nested containers, and Kubernetes. All of what we do and why we do it 12 | is documented inline in the [Dockerfile](./Dockerfile). 13 | 14 | If you make any changes to this image, please continue to document exactly 15 | why we do what we do, citing upstream documentation where possible. 16 | 17 | See also [`pkg/cluster`](./../../pkg/cluster) for logic that interacts with this image. 18 | 19 | 20 | ## Alternate Sources 21 | 22 | Kind frequently picks up new releases of dependent projects including 23 | containerd, runc, cni, and crictl. If you choose to use the provided Dockerfile 24 | but use build arguments to specify a different base image or application version 25 | for dependencies, be aware that you may possibly encounter bugs and undesired 26 | behavior. 27 | 28 | ## Design 29 | 30 | See [base-image](https://kind.sigs.k8s.io/docs/design/base-image/) for more design details. 31 | -------------------------------------------------------------------------------- /site/Makefile: -------------------------------------------------------------------------------- 1 | REPO_ROOT:=${CURDIR}/.. 2 | # setup go for managing hugo 3 | PATH:=$(shell cd $(REPO_ROOT) && . hack/build/setup-go.sh && echo "$${PATH}") 4 | # go1.9+ can autodetect GOROOT, but if some other tool sets it ... 5 | GOROOT:= 6 | # enable modules 7 | GO111MODULE=on 8 | # disable CGO by default for static binaries 9 | CGO_ENABLED=0 10 | export PATH GOROOT GO111MODULE CGO_ENABLED 11 | # work around broken PATH export 12 | SPACE:=$(subst ,, ) 13 | SHELL:=env PATH=$(subst $(SPACE),\$(SPACE),$(PATH)) $(SHELL) 14 | 15 | # from https://github.com/kubernetes/website/blob/master/Makefile 16 | DOCKER = docker 17 | HUGO_VERSION = 0.60.0 18 | DOCKER_IMAGE = jojomi/hugo:$(HUGO_VERSION) 19 | DOCKER_RUN = $(DOCKER) run --rm --interactive --tty --volume $(realpath $(CURDIR)/..):/src -p 1313:1313 --workdir /src/site --entrypoint=hugo --platform linux/amd64 $(DOCKER_IMAGE) 20 | 21 | HUGO_BIN:=$(REPO_ROOT)/bin/hugo 22 | 23 | $(HUGO_BIN): 24 | go build -o $(HUGO_BIN) github.com/gohugoio/hugo 25 | 26 | hugo: $(HUGO_BIN) 27 | 28 | serve: hugo 29 | $(HUGO_BIN) server --bind="0.0.0.0" \ 30 | --ignoreCache \ 31 | --buildFuture \ 32 | --disableFastRender 33 | 34 | build: hugo 35 | $(HUGO_BIN) 36 | 37 | .PHONY: build serve hugo 38 | -------------------------------------------------------------------------------- /pkg/cluster/internal/providers/common/images.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impliep. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package common 18 | 19 | import ( 20 | "sigs.k8s.io/kind/pkg/internal/apis/config" 21 | "sigs.k8s.io/kind/pkg/internal/sets" 22 | ) 23 | 24 | // RequiredNodeImages returns the set of _node_ images specified by the config 25 | // This does not include the loadbalancer image, and is only used to improve 26 | // the UX by explicit pulling the node images prior to running 27 | func RequiredNodeImages(cfg *config.Cluster) sets.String { 28 | images := sets.NewString() 29 | for _, node := range cfg.Nodes { 30 | images.Insert(node.Image) 31 | } 32 | return images 33 | } 34 | -------------------------------------------------------------------------------- /hack/make-rules/update/deps.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2018 The Kubernetes Authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Runs go mod tidy, go mod vendor, and then prunes vendor 17 | # 18 | # Usage: 19 | # deps.sh 20 | set -o errexit -o nounset -o pipefail 21 | 22 | # cd to the repo root and setup go 23 | REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." &> /dev/null && pwd -P)" 24 | cd "${REPO_ROOT}" 25 | source hack/build/setup-go.sh 26 | 27 | # tidy all modules 28 | go mod tidy 29 | 30 | cd "${REPO_ROOT}/hack/tools" 31 | go mod tidy 32 | 33 | # NOTE: kindnetd is only built for linux and uses linux APIs 34 | cd "${REPO_ROOT}/images/kindnetd" 35 | GOOS=linux go mod tidy 36 | -------------------------------------------------------------------------------- /pkg/cluster/internal/providers/common/namer.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impliep. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package common 18 | 19 | import ( 20 | "fmt" 21 | ) 22 | 23 | // MakeNodeNamer returns a func(role string)(nodeName string) 24 | // used to name nodes based on their role and the clusterName 25 | func MakeNodeNamer(clusterName string) func(string) string { 26 | counter := make(map[string]int) 27 | return func(role string) string { 28 | count := 1 29 | suffix := "" 30 | if v, ok := counter[role]; ok { 31 | count += v 32 | suffix = fmt.Sprintf("%d", count) 33 | } 34 | counter[role] = count 35 | return fmt.Sprintf("%s-%s%s", clusterName, role, suffix) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /pkg/errors/aggregate_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package errors 18 | 19 | import ( 20 | "testing" 21 | 22 | "sigs.k8s.io/kind/pkg/internal/assert" 23 | ) 24 | 25 | func TestErrors(t *testing.T) { 26 | t.Parallel() 27 | t.Run("wrapped aggregate", func(t *testing.T) { 28 | t.Parallel() 29 | errs := []error{New("foo"), Errorf("bar")} 30 | err := Wrapf(NewAggregate(errs), "baz: %s", "quux") 31 | result := Errors(err) 32 | assert.DeepEqual(t, errs, result) 33 | }) 34 | t.Run("nil", func(t *testing.T) { 35 | t.Parallel() 36 | result := Errors(nil) 37 | var expected []error 38 | assert.DeepEqual(t, expected, result) 39 | }) 40 | } 41 | -------------------------------------------------------------------------------- /pkg/cmd/kind/completion/fish/fish.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package fish implements the `fish` command 18 | package fish 19 | 20 | import ( 21 | "github.com/spf13/cobra" 22 | 23 | "sigs.k8s.io/kind/pkg/cmd" 24 | "sigs.k8s.io/kind/pkg/log" 25 | ) 26 | 27 | // NewCommand returns a new cobra.Command for cluster creation 28 | func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { 29 | cmd := &cobra.Command{ 30 | Use: "fish", 31 | Short: "Output shell completions for fish", 32 | RunE: func(cmd *cobra.Command, args []string) error { 33 | return cmd.Parent().Parent().GenFishCompletion(streams.Out, true) 34 | }, 35 | } 36 | return cmd 37 | } 38 | -------------------------------------------------------------------------------- /pkg/cmd/kind/completion/zsh/zsh.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package zsh implements the `zsh` command 18 | package zsh 19 | 20 | import ( 21 | "github.com/spf13/cobra" 22 | 23 | "sigs.k8s.io/kind/pkg/cmd" 24 | "sigs.k8s.io/kind/pkg/log" 25 | ) 26 | 27 | // NewCommand returns a new cobra.Command for cluster creation 28 | func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { 29 | cmd := &cobra.Command{ 30 | Args: cobra.NoArgs, 31 | Use: "zsh", 32 | Short: "Output shell completions for zsh", 33 | RunE: func(cmd *cobra.Command, args []string) error { 34 | return cmd.Parent().Parent().GenZshCompletion(streams.Out) 35 | }, 36 | } 37 | return cmd 38 | } 39 | -------------------------------------------------------------------------------- /pkg/cmd/kind/completion/bash/bash.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package bash implements the `bash` command 18 | package bash 19 | 20 | import ( 21 | "github.com/spf13/cobra" 22 | 23 | "sigs.k8s.io/kind/pkg/cmd" 24 | "sigs.k8s.io/kind/pkg/log" 25 | ) 26 | 27 | // NewCommand returns a new cobra.Command for cluster creation 28 | func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { 29 | cmd := &cobra.Command{ 30 | Args: cobra.NoArgs, 31 | Use: "bash", 32 | Short: "Output shell completions for bash", 33 | RunE: func(cmd *cobra.Command, args []string) error { 34 | return cmd.Parent().Parent().GenBashCompletion(streams.Out) 35 | }, 36 | } 37 | return cmd 38 | } 39 | -------------------------------------------------------------------------------- /pkg/errors/errors_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package errors 18 | 19 | import ( 20 | "testing" 21 | 22 | pkgerrors "github.com/pkg/errors" 23 | 24 | "sigs.k8s.io/kind/pkg/internal/assert" 25 | ) 26 | 27 | func TestStackTrace(t *testing.T) { 28 | t.Parallel() 29 | t.Run("wrapped chain", func(t *testing.T) { 30 | t.Parallel() 31 | err := New("foo") 32 | expected := err.(StackTracer).StackTrace() 33 | result := StackTrace(Wrap(Wrap(err, "bar"), "baz")) 34 | assert.DeepEqual(t, expected, result) 35 | }) 36 | t.Run("nil", func(t *testing.T) { 37 | t.Parallel() 38 | result := StackTrace(nil) 39 | var expected pkgerrors.StackTrace 40 | assert.DeepEqual(t, expected, result) 41 | }) 42 | } 43 | -------------------------------------------------------------------------------- /pkg/internal/apis/config/cluster_util.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package config 18 | 19 | // ClusterHasIPv6 returns true if the cluster should have IPv6 enabled due to either 20 | // being IPv6 cluster family or Dual Stack 21 | func ClusterHasIPv6(c *Cluster) bool { 22 | return c.Networking.IPFamily == IPv6Family || c.Networking.IPFamily == DualStackFamily 23 | } 24 | 25 | // ClusterHasImplicitLoadBalancer returns true if this cluster has an implicit api-server LoadBalancer 26 | func ClusterHasImplicitLoadBalancer(c *Cluster) bool { 27 | controlPlanes := 0 28 | for _, node := range c.Nodes { 29 | if node.Role == ControlPlaneRole { 30 | controlPlanes++ 31 | } 32 | } 33 | return controlPlanes > 1 34 | } 35 | -------------------------------------------------------------------------------- /site/static/examples/config-with-mounts.yaml: -------------------------------------------------------------------------------- 1 | kind: Cluster 2 | apiVersion: kind.x-k8s.io/v1alpha4 3 | nodes: 4 | - role: control-plane 5 | # add a mount from /path/to/my/files on the host to /files on the node 6 | extraMounts: 7 | - hostPath: /path/to/my/files 8 | containerPath: /files 9 | # 10 | # add an additional mount leveraging *all* of the config fields 11 | # 12 | # generally you only need the two fields above ... 13 | # 14 | - hostPath: /path/to/my/other-files/ 15 | containerPath: /other-files 16 | # optional: if set, the mount is read-only. 17 | # default false 18 | readOnly: true 19 | # optional: if set, the mount needs SELinux relabeling. 20 | # default false 21 | selinuxRelabel: false 22 | # optional: set propagation mode (None, HostToContainer or Bidirectional) 23 | # see https://kubernetes.io/docs/concepts/storage/volumes/#mount-propagation 24 | # default None 25 | # 26 | # WARNING: You very likely do not need this field. 27 | # 28 | # This field controls propagation of *additional* mounts created 29 | # *at runtime* underneath this mount. 30 | # 31 | # On MacOS with Docker Desktop, if the mount is from macOS and not the 32 | # docker desktop VM, you cannot use this field. You can use it for 33 | # mounts to the linux VM. 34 | propagation: None 35 | -------------------------------------------------------------------------------- /images/base/files/usr/local/bin/clean-install: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright 2017 The Kubernetes Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # A script encapsulating a common Dockerimage pattern for installing packages 18 | # and then cleaning up the unnecessary install artifacts. 19 | # e.g. clean-install iptables ebtables conntrack 20 | 21 | set -o errexit 22 | 23 | if [ $# = 0 ]; then 24 | echo >&2 "No packages specified" 25 | exit 1 26 | fi 27 | 28 | apt-get update 29 | apt-get upgrade -y 30 | apt-get install -y --no-install-recommends "$@" 31 | apt-get clean -y 32 | rm -rf \ 33 | /var/cache/debconf/* \ 34 | /var/lib/apt/lists/* \ 35 | /var/log/* \ 36 | /tmp/* \ 37 | /var/tmp/* \ 38 | /usr/share/doc/* \ 39 | /usr/share/doc-base/* \ 40 | /usr/share/man/* \ 41 | /usr/share/local/* 42 | -------------------------------------------------------------------------------- /pkg/cmd/iostreams.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package cmd 15 | 16 | import ( 17 | "io" 18 | "os" 19 | ) 20 | 21 | // IOStreams provides the standard names for iostreams. 22 | // This is useful for embedding and for unit testing. 23 | // Inconsistent and different names make it hard to read and review code 24 | // This is based on cli-runtime, but just the nice type without the dependency 25 | type IOStreams struct { 26 | // In think, os.Stdin 27 | In io.Reader 28 | // Out think, os.Stdout 29 | Out io.Writer 30 | // ErrOut think, os.Stderr 31 | ErrOut io.Writer 32 | } 33 | 34 | // StandardIOStreams returns an IOStreams from os.Stdin, os.Stdout 35 | func StandardIOStreams() IOStreams { 36 | return IOStreams{ 37 | In: os.Stdin, 38 | Out: os.Stdout, 39 | ErrOut: os.Stderr, 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Report a bug encountered using kind 4 | labels: kind/bug 5 | 6 | --- 7 | 8 | 9 | 10 | 11 | **What happened**: 12 | 13 | 14 | 15 | **What you expected to happen**: 16 | 17 | **How to reproduce it (as _minimally_ and precisely as possible)**: 18 | 19 | **Anything else we need to know?**: 20 | 21 | **Environment:** 22 | 23 | - kind version: (use `kind version`): 24 | - Runtime info: (use `docker info`, `podman info` or `nerdctl info`): 25 | - OS (e.g. from `/etc/os-release`): 26 | - Kubernetes version: (use `kubectl version`): 27 | - Any proxies or other special environment settings?: 28 | -------------------------------------------------------------------------------- /site/content/docs/user/local-registry.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Local Registry" 3 | menu: 4 | main: 5 | parent: "user" 6 | identifier: "user-local-registry" 7 | weight: 3 8 | description: |- 9 | This guide covers how to configure KIND with a local container image registry. 10 | 11 | In the future this will be replaced by [a built-in feature](https://github.com/kubernetes-sigs/kind/issues/1213), and this guide will 12 | cover usage instead. 13 | --- 14 | ## Create A Cluster And Registry 15 | 16 | The following shell script will create a local docker registry and a kind cluster 17 | with it enabled. 18 | 19 | {{< codeFromFile file="static/examples/kind-with-registry.sh" >}} 20 | 21 | ## Using The Registry 22 | 23 | The registry can be used like this. 24 | 25 | 1. First we'll pull an image `docker pull gcr.io/google-samples/hello-app:1.0` 26 | 2. Then we'll tag the image to use the local registry `docker tag gcr.io/google-samples/hello-app:1.0 localhost:5001/hello-app:1.0` 27 | 3. Then we'll push it to the registry `docker push localhost:5001/hello-app:1.0` 28 | 4. And now we can use the image `kubectl create deployment hello-server --image=localhost:5001/hello-app:1.0` 29 | 30 | If you build your own image and tag it like `localhost:5001/image:foo` and then use 31 | it in kubernetes as `localhost:5001/image:foo`. And use it from inside of your cluster application as `kind-registry:5000`. 32 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Welcome to Kubernetes. We are excited about the prospect of you joining our [community](https://github.com/kubernetes/community)! The Kubernetes community abides by the CNCF [code of conduct](code-of-conduct.md). Here is an excerpt: 4 | 5 | _As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities._ 6 | 7 | ## Getting Started 8 | 9 | We have full documentation on how to get started contributing here: https://kind.sigs.k8s.io/docs/contributing/getting-started/, _please_ read this! 10 | A lot of work went into this guide 🙃 11 | 12 | ## Mentorship 13 | 14 | - [Mentoring Initiatives](https://git.k8s.io/community/mentoring) - Kubernetes has a diverse set of mentorship programs available that are always looking for volunteers! 15 | 16 | 25 | -------------------------------------------------------------------------------- /hack/make-rules/verify/lint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2019 The Kubernetes Authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # script to run linters 17 | set -o errexit -o nounset -o pipefail 18 | 19 | # cd to the repo root and setup go 20 | REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." &> /dev/null && pwd -P)" 21 | cd "${REPO_ROOT}" 22 | source hack/build/setup-go.sh 23 | 24 | # build golangci-lint 25 | cd "${REPO_ROOT}/hack/tools" 26 | go build -o "${REPO_ROOT}"/bin/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint 27 | cd "${REPO_ROOT}" 28 | 29 | # first for the repo in general 30 | "${REPO_ROOT}"/bin/golangci-lint --config "${REPO_ROOT}/hack/tools/.golangci.yml" run ./... 31 | 32 | # then for kindnetd module 33 | cd "${REPO_ROOT}/images/kindnetd" 34 | GOOS=linux "${REPO_ROOT}"/bin/golangci-lint --config "${REPO_ROOT}/hack/tools/.golangci.yml" run ./... 35 | -------------------------------------------------------------------------------- /pkg/cmd/logger.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package cmd 18 | 19 | import ( 20 | "io" 21 | "os" 22 | 23 | "sigs.k8s.io/kind/pkg/log" 24 | 25 | "sigs.k8s.io/kind/pkg/internal/cli" 26 | "sigs.k8s.io/kind/pkg/internal/env" 27 | ) 28 | 29 | // NewLogger returns the standard logger used by the kind CLI 30 | // This logger writes to os.Stderr 31 | func NewLogger() log.Logger { 32 | var writer io.Writer = os.Stderr 33 | if env.IsSmartTerminal(writer) { 34 | writer = cli.NewSpinner(writer) 35 | } 36 | return cli.NewLogger(writer, 0) 37 | } 38 | 39 | // ColorEnabled returns true if color is enabled for the logger 40 | // this should be used to control output 41 | func ColorEnabled(logger log.Logger) bool { 42 | type maybeColorer interface { 43 | ColorEnabled() bool 44 | } 45 | v, ok := logger.(maybeColorer) 46 | return ok && v.ColorEnabled() 47 | } 48 | -------------------------------------------------------------------------------- /pkg/errors/aggregate.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package errors 18 | 19 | // NewAggregate is a k8s.io/apimachinery/pkg/util/errors.NewAggregate compatible wrapper 20 | // note that while it returns a StackTrace wrapped Aggregate 21 | // That has been Flattened and Reduced 22 | func NewAggregate(errlist []error) error { 23 | return WithStack( 24 | reduce( 25 | flatten( 26 | newAggregate(errlist), 27 | ), 28 | ), 29 | ) 30 | } 31 | 32 | // Errors returns the deepest Aggregate in a Cause chain 33 | func Errors(err error) []error { 34 | var errors Aggregate 35 | for { 36 | if v, ok := err.(Aggregate); ok { 37 | errors = v 38 | } 39 | if causerErr, ok := err.(Causer); ok { 40 | err = causerErr.Cause() 41 | } else { 42 | break 43 | } 44 | } 45 | if errors != nil { 46 | return errors.Errors() 47 | } 48 | return nil 49 | } 50 | -------------------------------------------------------------------------------- /pkg/exec/default.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package exec 18 | 19 | import "context" 20 | 21 | // DefaultCmder is a LocalCmder instance used for convenience, packages 22 | // originally using os/exec.Command can instead use pkg/kind/exec.Command 23 | // which forwards to this instance 24 | // TODO(bentheelder): swap this for testing 25 | // TODO(bentheelder): consider not using a global for this :^) 26 | var DefaultCmder = &LocalCmder{} 27 | 28 | // Command is a convenience wrapper over DefaultCmder.Command 29 | func Command(command string, args ...string) Cmd { 30 | return DefaultCmder.Command(command, args...) 31 | } 32 | 33 | // CommandContext is a convenience wrapper over DefaultCmder.CommandContext 34 | func CommandContext(ctx context.Context, command string, args ...string) Cmd { 35 | return DefaultCmder.CommandContext(ctx, command, args...) 36 | } 37 | -------------------------------------------------------------------------------- /site/content/docs/design/base-image.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Base Image" 3 | menu: 4 | main: 5 | parent: "design" 6 | identifier: "base-image" 7 | --- 8 | 9 | > **NOTE**: This may not completely cover the current implementation. 10 | 11 | The ["base" image][base image] is a small-ish Docker image for running 12 | nested containers, systemd, and kubernetes components. 13 | 14 | To do this we need to set up an environment that will meet the CRI 15 | (currently containerd and runc) and systemd's particular needs. Documentation for each 16 | step we take is inline to the image's [Dockerfile][dockerfile], 17 | but essentially: 18 | 19 | - we preinstall tools / packages expected by systemd / containerd / Kubernetes other 20 | than Kubernetes itself 21 | 22 | - we install a custom entrypoint that allows us to perform some actions before 23 | the container truly boots 24 | 25 | - we set up a systemd service to forward journal logs to the container tty 26 | 27 | - we do a few tricks to minimize unnecessary services and inform systemd that it 28 | is in docker (see the [Dockerfile][dockerfile]) 29 | 30 | This image is based on the `debian-slim` image which starts relatively small for 31 | a Kubernetes node image, has near exclusively packages we need, and has 32 | relatively up to date packages. 33 | We strive to minimize the image size where possible. 34 | 35 | [base image]: https://sigs.k8s.io/kind/images/base 36 | [dockerfile]: https://sigs.k8s.io/kind/images/base/Dockerfile 37 | -------------------------------------------------------------------------------- /pkg/cluster/nodes/types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package nodes 18 | 19 | import ( 20 | "io" 21 | 22 | "sigs.k8s.io/kind/pkg/exec" 23 | ) 24 | 25 | // Node represents a kind cluster node 26 | type Node interface { 27 | // The node should implement exec.Cmder for running commands against the node 28 | // see: sigs.k8s.io/kind/pkg/exec 29 | exec.Cmder 30 | // String should return the node name 31 | String() string // see also: fmt.Stringer 32 | // Role should return the node's role 33 | Role() (string, error) // see also: pkg/cluster/constants 34 | // TODO(bentheelder): should return node addresses more generally 35 | // Possibly remove this method in favor of obtaining this detail with 36 | // exec or from the provider 37 | IP() (ipv4 string, ipv6 string, err error) 38 | // SerialLogs collects the "node" container logs 39 | SerialLogs(writer io.Writer) error 40 | } 41 | -------------------------------------------------------------------------------- /pkg/cluster/internal/kubeconfig/internal/kubeconfig/write.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package kubeconfig 18 | 19 | import ( 20 | "os" 21 | "path/filepath" 22 | 23 | "sigs.k8s.io/kind/pkg/errors" 24 | ) 25 | 26 | // write writes cfg to configPath 27 | // it will ensure the directories in the path if necessary 28 | func write(cfg *Config, configPath string) error { 29 | encoded, err := Encode(cfg) 30 | if err != nil { 31 | return err 32 | } 33 | // NOTE: 0755 / 0600 are to match client-go 34 | dir := filepath.Dir(configPath) 35 | if _, err := os.Stat(dir); os.IsNotExist(err) { 36 | if err = os.MkdirAll(dir, 0755); err != nil { 37 | return errors.Wrap(err, "failed to create directory for KUBECONFIG") 38 | } 39 | } 40 | if err := os.WriteFile(configPath, encoded, 0600); err != nil { 41 | return errors.Wrap(err, "failed to write KUBECONFIG") 42 | } 43 | return nil 44 | } 45 | -------------------------------------------------------------------------------- /hack/build/goinstalldir.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright 2019 The Kubernetes Authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # this utility prints out the golang install dir, even if go is not installed 17 | # IE it prints the directory where `go install ...` would theoretically place 18 | # binaries 19 | 20 | # if we have go, just ask go! 21 | if which go >/dev/null 2>&1; then 22 | DIR=$(go env GOBIN) 23 | if [ -n "${DIR}" ]; then 24 | echo "${DIR}" 25 | exit 0 26 | fi 27 | DIR=$(go env GOPATH) 28 | if [ -n "${DIR}" ]; then 29 | echo "${DIR}/bin" 30 | exit 0 31 | fi 32 | fi 33 | 34 | # mimic go behavior 35 | 36 | # check if GOBIN is set anyhow 37 | if [ -n "${GOBIN}" ]; then 38 | echo "${GOBIN}" 39 | exit 0 40 | fi 41 | 42 | # check if GOPATH is set anyhow 43 | if [ -n "${GOPATH}" ]; then 44 | echo "${GOPATH}/bin" 45 | exit 0 46 | fi 47 | 48 | # finally use default for no $GOPATH or $GOBIN 49 | echo "${HOME}/go/bin" 50 | -------------------------------------------------------------------------------- /pkg/cluster/internal/kubeconfig/internal/kubeconfig/lock.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package kubeconfig 18 | 19 | import ( 20 | "os" 21 | "path/filepath" 22 | ) 23 | 24 | // these are from 25 | // https://github.com/kubernetes/client-go/blob/611184f7c43ae2d520727f01d49620c7ed33412d/tools/clientcmd/loader.go#L439-L440 26 | 27 | func lockFile(filename string) error { 28 | // Make sure the dir exists before we try to create a lock file. 29 | dir := filepath.Dir(filename) 30 | if _, err := os.Stat(dir); os.IsNotExist(err) { 31 | if err = os.MkdirAll(dir, 0755); err != nil { 32 | return err 33 | } 34 | } 35 | f, err := os.OpenFile(lockName(filename), os.O_CREATE|os.O_EXCL, 0) 36 | if err != nil { 37 | return err 38 | } 39 | f.Close() 40 | return nil 41 | } 42 | 43 | func unlockFile(filename string) error { 44 | return os.Remove(lockName(filename)) 45 | } 46 | 47 | func lockName(filename string) string { 48 | return filename + ".lock" 49 | } 50 | -------------------------------------------------------------------------------- /pkg/cmd/kind/create/create.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package create implements the `create` command 18 | package create 19 | 20 | import ( 21 | "errors" 22 | 23 | "github.com/spf13/cobra" 24 | 25 | "sigs.k8s.io/kind/pkg/cmd" 26 | createcluster "sigs.k8s.io/kind/pkg/cmd/kind/create/cluster" 27 | "sigs.k8s.io/kind/pkg/log" 28 | ) 29 | 30 | // NewCommand returns a new cobra.Command for cluster creation 31 | func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { 32 | cmd := &cobra.Command{ 33 | Args: cobra.NoArgs, 34 | Use: "create", 35 | Short: "Creates one of [cluster]", 36 | Long: "Creates one of local Kubernetes cluster (cluster)", 37 | RunE: func(cmd *cobra.Command, args []string) error { 38 | err := cmd.Help() 39 | if err != nil { 40 | return err 41 | } 42 | return errors.New("Subcommand is required") 43 | }, 44 | } 45 | cmd.AddCommand(createcluster.NewCommand(logger, streams)) 46 | return cmd 47 | } 48 | -------------------------------------------------------------------------------- /pkg/build/nodeimage/internal/container/docker/pull.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package docker 18 | 19 | import ( 20 | "time" 21 | 22 | "sigs.k8s.io/kind/pkg/exec" 23 | "sigs.k8s.io/kind/pkg/log" 24 | ) 25 | 26 | // Pull pulls an image, retrying up to retries times 27 | func Pull(logger log.Logger, image string, platform string, retries int) error { 28 | logger.V(1).Infof("Pulling image: %s for platform %s ...", image, platform) 29 | err := exec.Command("docker", "pull", "--platform="+platform, image).Run() 30 | // retry pulling up to retries times if necessary 31 | if err != nil { 32 | for i := 0; i < retries; i++ { 33 | time.Sleep(time.Second * time.Duration(i+1)) 34 | logger.V(1).Infof("Trying again to pull image: %q ... %v", image, err) 35 | // TODO(bentheelder): add some backoff / sleep? 36 | err = exec.Command("docker", "pull", "--platform="+platform, image).Run() 37 | if err == nil { 38 | break 39 | } 40 | } 41 | } 42 | return err 43 | } 44 | -------------------------------------------------------------------------------- /pkg/cluster/internal/kubeconfig/internal/kubeconfig/helpers.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package kubeconfig 18 | 19 | import ( 20 | "sigs.k8s.io/kind/pkg/errors" 21 | ) 22 | 23 | // KINDClusterKey identifies kind clusters in kubeconfig files 24 | func KINDClusterKey(clusterName string) string { 25 | return "docker-" + clusterName 26 | } 27 | 28 | // checkKubeadmExpectations validates that a kubeadm created KUBECONFIG meets 29 | // our expectations, namely on the number of entries 30 | func checkKubeadmExpectations(cfg *Config) error { 31 | if len(cfg.Clusters) != 1 { 32 | return errors.Errorf("kubeadm KUBECONFIG should have one cluster, but read %d", len(cfg.Clusters)) 33 | } 34 | if len(cfg.Users) != 1 { 35 | return errors.Errorf("kubeadm KUBECONFIG should have one user, but read %d", len(cfg.Users)) 36 | } 37 | if len(cfg.Contexts) != 1 { 38 | return errors.Errorf("kubeadm KUBECONFIG should have one context, but read %d", len(cfg.Contexts)) 39 | } 40 | return nil 41 | } 42 | -------------------------------------------------------------------------------- /pkg/cmd/kind/build/build.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package build implements the `build` command 18 | package build 19 | 20 | import ( 21 | "errors" 22 | 23 | "github.com/spf13/cobra" 24 | 25 | "sigs.k8s.io/kind/pkg/cmd" 26 | "sigs.k8s.io/kind/pkg/cmd/kind/build/nodeimage" 27 | "sigs.k8s.io/kind/pkg/log" 28 | ) 29 | 30 | // NewCommand returns a new cobra.Command for building 31 | func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { 32 | cmd := &cobra.Command{ 33 | Args: cobra.NoArgs, 34 | // TODO(bentheelder): more detailed usage 35 | Use: "build", 36 | Short: "Build one of [node-image]", 37 | Long: "Build one of [node-image]", 38 | RunE: func(cmd *cobra.Command, args []string) error { 39 | err := cmd.Help() 40 | if err != nil { 41 | return err 42 | } 43 | return errors.New("Subcommand is required") 44 | }, 45 | } 46 | // add subcommands 47 | cmd.AddCommand(nodeimage.NewCommand(logger, streams)) 48 | return cmd 49 | } 50 | -------------------------------------------------------------------------------- /pkg/cluster/internal/providers/nerdctl/util.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package nerdctl 18 | 19 | import ( 20 | "strings" 21 | 22 | "sigs.k8s.io/kind/pkg/exec" 23 | ) 24 | 25 | // IsAvailable checks if nerdctl (or finch) is available in the system 26 | func IsAvailable() bool { 27 | cmd := exec.Command("nerdctl", "-v") 28 | lines, err := exec.OutputLines(cmd) 29 | if err != nil || len(lines) != 1 { 30 | // check finch 31 | cmd = exec.Command("finch", "-v") 32 | lines, err = exec.OutputLines(cmd) 33 | if err != nil || len(lines) != 1 { 34 | return false 35 | } 36 | return strings.HasPrefix(lines[0], "finch version") 37 | } 38 | return strings.HasPrefix(lines[0], "nerdctl version") 39 | } 40 | 41 | // rootless: use fuse-overlayfs by default 42 | // https://github.com/kubernetes-sigs/kind/issues/2275 43 | func mountFuse(binaryName string) bool { 44 | i, err := info(binaryName) 45 | if err != nil { 46 | return false 47 | } 48 | if i != nil && i.Rootless { 49 | return true 50 | } 51 | return false 52 | } 53 | -------------------------------------------------------------------------------- /pkg/build/nodeimage/internal/kube/bits.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package kube 18 | 19 | // Bits provides the locations of Kubernetes Binaries / Images 20 | // needed on the cluster nodes 21 | // Implementations should be registered with RegisterNamedBits 22 | type Bits interface { 23 | // BinaryPaths returns a list of paths to binaries on the host machine that 24 | // should be added to PATH in the Node image 25 | BinaryPaths() []string 26 | // ImagePaths returns a list of paths to image archives to be loaded into 27 | // the Node 28 | ImagePaths() []string 29 | // Version 30 | Version() string 31 | } 32 | 33 | // shared real bits implementation for now 34 | 35 | type bits struct { 36 | // computed at build time 37 | binaryPaths []string 38 | imagePaths []string 39 | version string 40 | } 41 | 42 | var _ Bits = &bits{} 43 | 44 | func (b *bits) BinaryPaths() []string { 45 | return b.binaryPaths 46 | } 47 | 48 | func (b *bits) ImagePaths() []string { 49 | return b.imagePaths 50 | } 51 | 52 | func (b *bits) Version() string { 53 | return b.version 54 | } 55 | -------------------------------------------------------------------------------- /pkg/internal/patch/matchinfo.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package patch 18 | 19 | import ( 20 | "sigs.k8s.io/yaml" 21 | 22 | "sigs.k8s.io/kind/pkg/errors" 23 | 24 | "sigs.k8s.io/kind/pkg/internal/apis/config" 25 | ) 26 | 27 | // we match resources and patches on their v1 TypeMeta 28 | type matchInfo struct { 29 | Kind string `json:"kind,omitempty"` 30 | APIVersion string `json:"apiVersion,omitempty"` 31 | } 32 | 33 | func parseYAMLMatchInfo(raw string) (matchInfo, error) { 34 | m := matchInfo{} 35 | if err := yaml.Unmarshal([]byte(raw), &m); err != nil { 36 | return matchInfo{}, errors.Wrapf(err, "failed to parse type meta for %q", raw) 37 | } 38 | return m, nil 39 | } 40 | 41 | func matchInfoForConfigJSON6902Patch(patch config.PatchJSON6902) matchInfo { 42 | return matchInfo{ 43 | Kind: patch.Kind, 44 | APIVersion: groupVersionToAPIVersion(patch.Group, patch.Version), 45 | } 46 | } 47 | 48 | func groupVersionToAPIVersion(group, version string) string { 49 | if group == "" { 50 | return version 51 | } 52 | return group + "/" + version 53 | } 54 | -------------------------------------------------------------------------------- /site/static/examples/ingress/usage.yaml: -------------------------------------------------------------------------------- 1 | kind: Pod 2 | apiVersion: v1 3 | metadata: 4 | name: foo-app 5 | labels: 6 | app: foo 7 | spec: 8 | containers: 9 | - command: 10 | - /agnhost 11 | - netexec 12 | - --http-port 13 | - "8080" 14 | image: registry.k8s.io/e2e-test-images/agnhost:2.39 15 | name: foo-app 16 | --- 17 | kind: Service 18 | apiVersion: v1 19 | metadata: 20 | name: foo-service 21 | spec: 22 | selector: 23 | app: foo 24 | ports: 25 | # Default port used by the image 26 | - port: 8080 27 | --- 28 | kind: Pod 29 | apiVersion: v1 30 | metadata: 31 | name: bar-app 32 | labels: 33 | app: bar 34 | spec: 35 | containers: 36 | - command: 37 | - /agnhost 38 | - netexec 39 | - --http-port 40 | - "8080" 41 | image: registry.k8s.io/e2e-test-images/agnhost:2.39 42 | name: bar-app 43 | --- 44 | kind: Service 45 | apiVersion: v1 46 | metadata: 47 | name: bar-service 48 | spec: 49 | selector: 50 | app: bar 51 | ports: 52 | # Default port used by the image 53 | - port: 8080 54 | --- 55 | apiVersion: networking.k8s.io/v1 56 | kind: Ingress 57 | metadata: 58 | name: example-ingress 59 | annotations: 60 | nginx.ingress.kubernetes.io/rewrite-target: /$2 61 | spec: 62 | rules: 63 | - http: 64 | paths: 65 | - pathType: Prefix 66 | path: /foo(/|$)(.*) 67 | backend: 68 | service: 69 | name: foo-service 70 | port: 71 | number: 8080 72 | - pathType: Prefix 73 | path: /bar(/|$)(.*) 74 | backend: 75 | service: 76 | name: bar-service 77 | port: 78 | number: 8080 79 | --- 80 | -------------------------------------------------------------------------------- /pkg/cluster/internal/providers/common/logs.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | 7 | "sigs.k8s.io/kind/pkg/cluster/nodes" 8 | "sigs.k8s.io/kind/pkg/errors" 9 | "sigs.k8s.io/kind/pkg/exec" 10 | ) 11 | 12 | // CollectLogs provides the common functionality 13 | // to get various debug info from the node 14 | func CollectLogs(n nodes.Node, dir string) error { 15 | execToPathFn := func(cmd exec.Cmd, path string) func() error { 16 | return func() error { 17 | f, err := FileOnHost(filepath.Join(dir, path)) 18 | if err != nil { 19 | return err 20 | } 21 | defer f.Close() 22 | return cmd.SetStdout(f).SetStderr(f).Run() 23 | } 24 | } 25 | 26 | return errors.AggregateConcurrent([]func() error{ 27 | // record info about the node container 28 | execToPathFn( 29 | n.Command("cat", "/kind/version"), 30 | "kubernetes-version.txt", 31 | ), 32 | execToPathFn( 33 | n.Command("journalctl", "--no-pager"), 34 | "journal.log", 35 | ), 36 | execToPathFn( 37 | n.Command("journalctl", "--no-pager", "-u", "kubelet.service"), 38 | "kubelet.log", 39 | ), 40 | execToPathFn( 41 | n.Command("journalctl", "--no-pager", "-u", "containerd.service"), 42 | "containerd.log", 43 | ), 44 | execToPathFn( 45 | n.Command("crictl", "images"), 46 | "images.log", 47 | ), 48 | }) 49 | } 50 | 51 | // FileOnHost is a helper to create a file at path 52 | // even if the parent directory doesn't exist 53 | // in which case it will be created with ModePerm 54 | func FileOnHost(path string) (*os.File, error) { 55 | if err := os.MkdirAll(filepath.Dir(path), os.ModePerm); err != nil { 56 | return nil, err 57 | } 58 | return os.Create(path) 59 | } 60 | -------------------------------------------------------------------------------- /pkg/cmd/kind/load/load.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package load implements the `load` command 18 | package load 19 | 20 | import ( 21 | "errors" 22 | 23 | "github.com/spf13/cobra" 24 | 25 | "sigs.k8s.io/kind/pkg/cmd" 26 | dockerimage "sigs.k8s.io/kind/pkg/cmd/kind/load/docker-image" 27 | imagearchive "sigs.k8s.io/kind/pkg/cmd/kind/load/image-archive" 28 | "sigs.k8s.io/kind/pkg/log" 29 | ) 30 | 31 | // NewCommand returns a new cobra.Command for get 32 | func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { 33 | cmd := &cobra.Command{ 34 | Args: cobra.NoArgs, 35 | Use: "load", 36 | Short: "Loads images into nodes", 37 | Long: "Loads images into node from an archive or image on host", 38 | RunE: func(cmd *cobra.Command, args []string) error { 39 | err := cmd.Help() 40 | if err != nil { 41 | return err 42 | } 43 | return errors.New("Subcommand is required") 44 | }, 45 | } 46 | // add subcommands 47 | cmd.AddCommand(dockerimage.NewCommand(logger, streams)) 48 | cmd.AddCommand(imagearchive.NewCommand(logger, streams)) 49 | return cmd 50 | } 51 | -------------------------------------------------------------------------------- /hack/ci/e2e.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2018 The Kubernetes Authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # hack script for running a kind e2e 17 | # must be run with a kubernetes checkout in $PWD (IE from the checkout) 18 | # Usage: SKIP="ginkgo skip regex" FOCUS="ginkgo focus regex" kind-e2e.sh 19 | 20 | set -o errexit -o nounset -o pipefail -o xtrace 21 | 22 | REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" 23 | 24 | # our exit handler (trap) 25 | cleanup() { 26 | # remove our tempdir, this needs to be last, or it will prevent kind delete 27 | [[ -n "${TMP_DIR:-}" ]] && rm -rf "${TMP_DIR:?}" 28 | } 29 | 30 | # install kind to a tempdir GOPATH from this script's kind checkout 31 | install_kind() { 32 | mkdir -p "${TMP_DIR}/bin" 33 | make -C "${REPO_ROOT}" install INSTALL_PATH="${TMP_DIR}/bin" 34 | export PATH="${TMP_DIR}/bin:${PATH}" 35 | } 36 | 37 | main() { 38 | # create temp dir and setup cleanup 39 | TMP_DIR=$(mktemp -d) 40 | trap cleanup INT TERM EXIT 41 | 42 | # install kind 43 | install_kind 44 | 45 | # build kubernetes / e2e test 46 | "${REPO_ROOT}/hack/ci/e2e-k8s.sh" 47 | } 48 | 49 | main 50 | -------------------------------------------------------------------------------- /pkg/cmd/kind/export/export.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package export implements the `export` command 18 | package export 19 | 20 | import ( 21 | "errors" 22 | 23 | "github.com/spf13/cobra" 24 | 25 | "sigs.k8s.io/kind/pkg/cmd" 26 | "sigs.k8s.io/kind/pkg/cmd/kind/export/kubeconfig" 27 | "sigs.k8s.io/kind/pkg/cmd/kind/export/logs" 28 | "sigs.k8s.io/kind/pkg/log" 29 | ) 30 | 31 | // NewCommand returns a new cobra.Command for export 32 | func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { 33 | cmd := &cobra.Command{ 34 | Args: cobra.NoArgs, 35 | // TODO(bentheelder): more detailed usage 36 | Use: "export", 37 | Short: "Exports one of [kubeconfig, logs]", 38 | Long: "Exports one of [kubeconfig, logs]", 39 | RunE: func(cmd *cobra.Command, args []string) error { 40 | err := cmd.Help() 41 | if err != nil { 42 | return err 43 | } 44 | return errors.New("Subcommand is required") 45 | }, 46 | } 47 | // add subcommands 48 | cmd.AddCommand(logs.NewCommand(logger, streams)) 49 | cmd.AddCommand(kubeconfig.NewCommand(logger, streams)) 50 | return cmd 51 | } 52 | -------------------------------------------------------------------------------- /pkg/cluster/internal/delete/delete.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package delete 18 | 19 | import ( 20 | "sigs.k8s.io/kind/pkg/errors" 21 | "sigs.k8s.io/kind/pkg/log" 22 | 23 | "sigs.k8s.io/kind/pkg/cluster/internal/kubeconfig" 24 | "sigs.k8s.io/kind/pkg/cluster/internal/providers" 25 | ) 26 | 27 | // Cluster deletes the cluster identified by ctx 28 | // explicitKubeconfigPath is --kubeconfig, following the rules from 29 | // https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands 30 | func Cluster(logger log.Logger, p providers.Provider, name, explicitKubeconfigPath string) error { 31 | n, err := p.ListNodes(name) 32 | if err != nil { 33 | return errors.Wrap(err, "error listing nodes") 34 | } 35 | 36 | kerr := kubeconfig.Remove(name, explicitKubeconfigPath) 37 | if kerr != nil { 38 | logger.Errorf("failed to update kubeconfig: %v", kerr) 39 | } 40 | 41 | if len(n) > 0 { 42 | err = p.DeleteNodes(n) 43 | if err != nil { 44 | return err 45 | } 46 | logger.V(0).Infof("Deleted nodes: %q", n) 47 | } 48 | 49 | if kerr != nil { 50 | return kerr 51 | } 52 | 53 | return nil 54 | } 55 | -------------------------------------------------------------------------------- /pkg/cmd/kind/delete/delete.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package delete implements the `delete` command 18 | package delete 19 | 20 | import ( 21 | "errors" 22 | 23 | "github.com/spf13/cobra" 24 | 25 | "sigs.k8s.io/kind/pkg/cmd" 26 | deletecluster "sigs.k8s.io/kind/pkg/cmd/kind/delete/cluster" 27 | deleteclusters "sigs.k8s.io/kind/pkg/cmd/kind/delete/clusters" 28 | "sigs.k8s.io/kind/pkg/log" 29 | ) 30 | 31 | // NewCommand returns a new cobra.Command for cluster deletion 32 | func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { 33 | cmd := &cobra.Command{ 34 | Args: cobra.NoArgs, 35 | // TODO(bentheelder): more detailed usage 36 | Use: "delete", 37 | Short: "Deletes one of [cluster]", 38 | Long: "Deletes one of [cluster]", 39 | RunE: func(cmd *cobra.Command, args []string) error { 40 | err := cmd.Help() 41 | if err != nil { 42 | return err 43 | } 44 | return errors.New("Subcommand is required") 45 | }, 46 | } 47 | cmd.AddCommand(deletecluster.NewCommand(logger, streams)) 48 | cmd.AddCommand(deleteclusters.NewCommand(logger, streams)) 49 | return cmd 50 | } 51 | -------------------------------------------------------------------------------- /pkg/build/nodeimage/internal/kube/tar.go: -------------------------------------------------------------------------------- 1 | package kube 2 | 3 | import ( 4 | "archive/tar" 5 | "compress/gzip" 6 | "fmt" 7 | "io" 8 | "os" 9 | "path/filepath" 10 | 11 | "sigs.k8s.io/kind/pkg/log" 12 | ) 13 | 14 | // extractTarball takes a gzipped-tarball and extracts the contents into a specified directory 15 | func extractTarball(tarPath, destDirectory string, logger log.Logger) (err error) { 16 | // Open the tar file 17 | f, err := os.Open(tarPath) 18 | if err != nil { 19 | return fmt.Errorf("opening tarball: %w", err) 20 | } 21 | defer f.Close() 22 | 23 | gzipReader, err := gzip.NewReader(f) 24 | if err != nil { 25 | return err 26 | } 27 | tr := tar.NewReader(gzipReader) 28 | 29 | numFiles := 0 30 | for { 31 | hdr, err := tr.Next() 32 | if err == io.EOF { 33 | break 34 | } 35 | if err != nil { 36 | return fmt.Errorf("reading tarfile %s: %w", tarPath, err) 37 | } 38 | 39 | if hdr.FileInfo().IsDir() { 40 | continue 41 | } 42 | 43 | if err := os.MkdirAll( 44 | filepath.Join(destDirectory, filepath.Dir(hdr.Name)), os.FileMode(0o755), 45 | ); err != nil { 46 | return fmt.Errorf("creating image directory structure: %w", err) 47 | } 48 | 49 | f, err := os.Create(filepath.Join(destDirectory, hdr.Name)) 50 | if err != nil { 51 | return fmt.Errorf("creating image layer file: %w", err) 52 | } 53 | 54 | if _, err := io.CopyN(f, tr, hdr.Size); err != nil { 55 | f.Close() 56 | if err == io.EOF { 57 | break 58 | } 59 | 60 | return fmt.Errorf("extracting image data: %w", err) 61 | } 62 | f.Close() 63 | 64 | numFiles++ 65 | } 66 | 67 | logger.V(2).Infof("Successfully extracted %d files from image tarball %s", numFiles, tarPath) 68 | return err 69 | } 70 | -------------------------------------------------------------------------------- /site/static/examples/kind-gcr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -o errexit 3 | 4 | # desired cluster name; default is "kind" 5 | KIND_CLUSTER_NAME="${KIND_CLUSTER_NAME:-kind}" 6 | 7 | # create a temp file for the docker config 8 | echo "Creating temporary docker client config directory ..." 9 | DOCKER_CONFIG=$(mktemp -d) 10 | export DOCKER_CONFIG 11 | trap 'echo "Removing ${DOCKER_CONFIG}/*" && rm -rf ${DOCKER_CONFIG:?}' EXIT 12 | 13 | echo "Creating a temporary config.json" 14 | # This is to force the omission of credsStore, which is automatically 15 | # created on supported system. With credsStore missing, "docker login" 16 | # will store the password in the config.json file. 17 | # https://docs.docker.com/engine/reference/commandline/login/#credentials-store 18 | cat <"${DOCKER_CONFIG}/config.json" 19 | { 20 | "auths": { "gcr.io": {} } 21 | } 22 | EOF 23 | # login to gcr in DOCKER_CONFIG using an access token 24 | # https://cloud.google.com/container-registry/docs/advanced-authentication#access_token 25 | echo "Logging in to GCR in temporary docker client config directory ..." 26 | gcloud auth print-access-token | \ 27 | docker login -u oauth2accesstoken --password-stdin https://gcr.io 28 | 29 | # setup credentials on each node 30 | echo "Moving credentials to kind cluster name='${KIND_CLUSTER_NAME}' nodes ..." 31 | for node in $(kind get nodes --name "${KIND_CLUSTER_NAME}"); do 32 | # the -oname format is kind/name (so node/name) we just want name 33 | node_name=${node#node/} 34 | # copy the config to where kubelet will look 35 | docker cp "${DOCKER_CONFIG}/config.json" "${node_name}:/var/lib/kubelet/config.json" 36 | # restart kubelet to pick up the config 37 | docker exec "${node_name}" systemctl restart kubelet.service 38 | done 39 | 40 | echo "Done!" 41 | -------------------------------------------------------------------------------- /images/local-path-provisioner/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2022 The Kubernetes Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # NOTE the actual go version will be overridden 16 | FROM --platform=$BUILDPLATFORM docker.io/library/golang:latest 17 | COPY --chmod=0755 scripts/third_party/gimme/gimme /usr/local/bin/ 18 | RUN git clone --filter=tree:0 https://github.com/rancher/local-path-provisioner 19 | ARG VERSION 20 | # set by makefile to .go-version 21 | ARG TARGETARCH GO_VERSION 22 | RUN eval "$(gimme "${GO_VERSION}")" \ 23 | && export GOTOOLCHAIN="go${GO_VERSION}" \ 24 | && cd local-path-provisioner \ 25 | && git fetch && git checkout "${VERSION}" \ 26 | && GOARCH=$TARGETARCH scripts/build \ 27 | && mv bin/local-path-provisioner /usr/local/bin/local-path-provisioner \ 28 | && GOBIN=/usr/local/bin go install github.com/google/go-licenses@latest \ 29 | && GOARCH=$TARGETARCH go-licenses save --save_path=/_LICENSES . 30 | 31 | FROM gcr.io/distroless/base-debian11 32 | COPY --from=0 /usr/local/bin/local-path-provisioner /usr/local/bin/local-path-provisioner 33 | COPY --from=0 /_LICENSES/* /LICENSES/ 34 | COPY --chmod=0644 files/LICENSES/* /LICENSES/* 35 | ENTRYPOINT /usr/local/bin/local-path-provisioner 36 | -------------------------------------------------------------------------------- /pkg/internal/patch/json6902patch.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package patch 18 | 19 | import ( 20 | jsonpatch "github.com/evanphx/json-patch/v5" 21 | 22 | "sigs.k8s.io/yaml" 23 | 24 | "sigs.k8s.io/kind/pkg/errors" 25 | 26 | "sigs.k8s.io/kind/pkg/internal/apis/config" 27 | ) 28 | 29 | type json6902Patch struct { 30 | raw string // raw original contents 31 | patch jsonpatch.Patch // processed JSON 6902 patch 32 | matchInfo matchInfo // used to match resources 33 | } 34 | 35 | func convertJSON6902Patches(patchesJSON6902 []config.PatchJSON6902) ([]json6902Patch, error) { 36 | patches := []json6902Patch{} 37 | for _, configPatch := range patchesJSON6902 { 38 | patchJSON, err := yaml.YAMLToJSON([]byte(configPatch.Patch)) 39 | if err != nil { 40 | return nil, errors.WithStack(err) 41 | } 42 | patch, err := jsonpatch.DecodePatch(patchJSON) 43 | if err != nil { 44 | return nil, errors.WithStack(err) 45 | } 46 | patches = append(patches, json6902Patch{ 47 | raw: configPatch.Patch, 48 | patch: patch, 49 | matchInfo: matchInfoForConfigJSON6902Patch(configPatch), 50 | }) 51 | } 52 | return patches, nil 53 | } 54 | -------------------------------------------------------------------------------- /pkg/build/nodeimage/containerd.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package nodeimage 18 | 19 | import ( 20 | "strings" 21 | 22 | "sigs.k8s.io/kind/pkg/errors" 23 | "sigs.k8s.io/kind/pkg/exec" 24 | 25 | "sigs.k8s.io/kind/pkg/internal/patch" 26 | ) 27 | 28 | const containerdConfigPath = "/etc/containerd/config.toml" 29 | 30 | const containerdConfigPatchSystemdCgroupFalse = ` 31 | [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options] 32 | SystemdCgroup = false 33 | 34 | [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.test-handler.options] 35 | SystemdCgroup = false 36 | ` 37 | 38 | func configureContainerdSystemdCgroupFalse(containerCmdr exec.Cmder, config string) error { 39 | patched, err := patch.TOML(config, []string{containerdConfigPatchSystemdCgroupFalse}, []string{}) 40 | if err != nil { 41 | return errors.Wrap(err, "failed to configure containerd SystemdCgroup=false") 42 | } 43 | err = containerCmdr.Command( 44 | "cp", "/dev/stdin", containerdConfigPath, 45 | ).SetStdin(strings.NewReader(patched)).Run() 46 | if err != nil { 47 | return errors.Wrap(err, "failed to configure containerd SystemdCgroup=false") 48 | } 49 | return nil 50 | } 51 | -------------------------------------------------------------------------------- /site/config.toml: -------------------------------------------------------------------------------- 1 | title = "kind" 2 | baseURL = "https://kind.sigs.k8s.io" 3 | languageCode = "en-us" 4 | 5 | # we use this to disable indexing for the non-production build 6 | enableRobotsTXT = true 7 | 8 | # this allows us to show the source commit in the footer 9 | enableGitInfo = true 10 | 11 | # we don't use these currently 12 | disableKinds = ["taxonomy", "taxonomyTerm"] 13 | 14 | # syntax highlighting options 15 | [markup] 16 | [markup.highlight] 17 | codeFences = true 18 | hl_Lines = "" 19 | lineNoStart = 1 20 | lineNos = false 21 | lineNumbersInTable = true 22 | noClasses = true 23 | style = "vs" 24 | tabWidth = 4 25 | 26 | # allow html in markdown 27 | [markup.goldmark.renderer] 28 | unsafe = true 29 | 30 | # enable hugo's menu system for the site, name the primary menu 31 | sectionPagesMenu = "main" 32 | # menu entries 33 | [menu] 34 | [[menu.main]] 35 | identifier = "ome" 36 | name = "Home" 37 | title = "Home" 38 | url = "/" 39 | weight = 1 40 | [[menu.main]] 41 | identifier = "user" 42 | name = "User Guide" 43 | title = "User Guide" 44 | weight = 2 45 | [[menu.main]] 46 | identifier = "design" 47 | name = "Design" 48 | title = "Design" 49 | url = "/docs/design/" 50 | weight = 5 51 | [[menu.main]] 52 | identifier = "contributing" 53 | name = "Contributing" 54 | title = "contributing" 55 | url = "/docs/contributing/" 56 | weight = 6 57 | 58 | # enable auto-generated _redirects file 59 | [mediaTypes."text/netlify"] 60 | delimiter = "" 61 | 62 | [outputFormats.REDIRECTS] 63 | mediaType = "text/netlify" 64 | baseName = "_redirects" 65 | 66 | [outputs] 67 | home = ["HTML", "REDIRECTS"] 68 | 69 | [params] 70 | stable = "v0.23.0" 71 | 72 | # privacy settings 73 | [privacy] 74 | [privacy.youtube] 75 | # enable the cookie-less youtube in built-in hugo shortcode 76 | privacyEnhanced = true 77 | -------------------------------------------------------------------------------- /hack/make-rules/verify/all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2018 The Kubernetes Authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | set -o errexit -o nounset -o pipefail 17 | 18 | # cd to the repo root 19 | REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." &> /dev/null && pwd -P)" 20 | cd "${REPO_ROOT}" 21 | 22 | # exit code, if a script fails we'll set this to 1 23 | res=0 24 | 25 | # run all verify scripts, optionally skipping any of them 26 | 27 | if [[ "${VERIFY_LINT:-true}" == "true" ]]; then 28 | echo "verifying lints ..." 29 | hack/make-rules/verify/lint.sh || res=1 30 | cd "${REPO_ROOT}" 31 | fi 32 | 33 | if [[ "${VERIFY_GENERATED:-true}" == "true" ]]; then 34 | echo "verifying generated ..." 35 | hack/make-rules/verify/generated.sh || res=1 36 | cd "${REPO_ROOT}" 37 | fi 38 | 39 | if [[ "${VERIFY_SHELLCHECK:-true}" == "true" ]]; then 40 | echo "verifying shellcheck ..." 41 | hack/make-rules/verify/shellcheck.sh || res=1 42 | cd "${REPO_ROOT}" 43 | fi 44 | 45 | # exit based on verify scripts 46 | if [[ "${res}" = 0 ]]; then 47 | echo "" 48 | echo "All verify checks passed, congrats!" 49 | else 50 | echo "" 51 | echo "One or more verify checks failed! See output above..." 52 | fi 53 | exit "${res}" 54 | 55 | -------------------------------------------------------------------------------- /hack/build/setup-go.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2020 The Kubernetes Authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # script to setup go version with gimme as needed 17 | # MUST BE RUN FROM THE REPO ROOT DIRECTORY 18 | 19 | # read go-version file unless GO_VERSION is set 20 | # override GOTOOLCHAIN unless set as well 21 | . ./hack/build/gotoolchain.sh 22 | 23 | # we don't actually care where the .env files are 24 | # however, GIMME_SILENT_ENV doesn't trigger re-generating a .env if it 25 | # already exists and isn't "silent" (no `go version` command in it) 26 | # so we fix that by changing where the .env is written, ensuring ours 27 | # is generated from this repo and silent. 28 | export GIMME_ENV_PREFIX=./bin/.gimme/ 29 | export GIMME_SILENT_ENV=y 30 | 31 | # only setup go if we haven't set FORCE_HOST_GO, or `go version` doesn't match 32 | # go version output looks like: 33 | # go version go1.14.5 darwin/amd64 34 | if ! ([ -n "${FORCE_HOST_GO:-}" ] || \ 35 | (command -v go >/dev/null && [ "$(go version | cut -d' ' -f3)" = "go${GO_VERSION}" ])); then 36 | # eval because the output of this is shell to set PATH etc. 37 | eval "$(hack/third_party/gimme/gimme "${GO_VERSION}")" 38 | fi 39 | 40 | # force go modules 41 | export GO111MODULE=on 42 | -------------------------------------------------------------------------------- /pkg/cmd/kind/get/get.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package get implements the `get` command 18 | package get 19 | 20 | import ( 21 | "errors" 22 | 23 | "github.com/spf13/cobra" 24 | 25 | "sigs.k8s.io/kind/pkg/cmd" 26 | "sigs.k8s.io/kind/pkg/cmd/kind/get/clusters" 27 | "sigs.k8s.io/kind/pkg/cmd/kind/get/kubeconfig" 28 | "sigs.k8s.io/kind/pkg/cmd/kind/get/nodes" 29 | "sigs.k8s.io/kind/pkg/log" 30 | ) 31 | 32 | // NewCommand returns a new cobra.Command for get 33 | func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { 34 | cmd := &cobra.Command{ 35 | Args: cobra.NoArgs, 36 | // TODO(bentheelder): more detailed usage 37 | Use: "get", 38 | Short: "Gets one of [clusters, nodes, kubeconfig]", 39 | Long: "Gets one of [clusters, nodes, kubeconfig]", 40 | RunE: func(cmd *cobra.Command, args []string) error { 41 | err := cmd.Help() 42 | if err != nil { 43 | return err 44 | } 45 | return errors.New("Subcommand is required") 46 | }, 47 | } 48 | // add subcommands 49 | cmd.AddCommand(clusters.NewCommand(logger, streams)) 50 | cmd.AddCommand(nodes.NewCommand(logger, streams)) 51 | cmd.AddCommand(kubeconfig.NewCommand(logger, streams)) 52 | return cmd 53 | } 54 | -------------------------------------------------------------------------------- /images/kindnetd/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Kubernetes Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # first stage build kindnetd binary 16 | # NOTE: the actual go version will be overridden 17 | FROM --platform=$BUILDPLATFORM docker.io/library/golang:latest 18 | WORKDIR /go/src 19 | COPY --chmod=0755 scripts/third_party/gimme/gimme /usr/local/bin/ 20 | # make deps fetching cacheable 21 | COPY go.mod go.sum ./ 22 | # set by makefile to .go-version 23 | ARG GO_VERSION 24 | RUN eval "$(gimme "${GO_VERSION}")" \ 25 | && export GOTOOLCHAIN="go${GO_VERSION}" \ 26 | && go mod download \ 27 | && GOBIN=/usr/local/bin go install github.com/google/go-licenses@latest 28 | # build 29 | COPY . . 30 | ARG TARGETARCH 31 | RUN eval "$(gimme "${GO_VERSION}")" \ 32 | && export GOTOOLCHAIN="go${GO_VERSION}" \ 33 | && CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o ./kindnetd ./cmd/kindnetd \ 34 | && GOARCH=$TARGETARCH go-licenses save --save_path=/_LICENSES ./cmd/kindnetd 35 | 36 | # build real kindnetd image 37 | FROM registry.k8s.io/build-image/distroless-iptables:v0.5.5 38 | COPY --from=0 --chown=root:root ./go/src/kindnetd /bin/kindnetd 39 | COPY --from=0 /_LICENSES/* /LICENSES/ 40 | COPY --chmod=0644 files/LICENSES/* /LICENSES/* 41 | CMD ["/bin/kindnetd"] 42 | -------------------------------------------------------------------------------- /hack/build/init-buildx.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2020 The Kubernetes Authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | set -o errexit -o nounset -o pipefail 17 | 18 | # We can skip setup if the current builder already has multi-arch 19 | # AND if it isn't the docker driver, which doesn't work 20 | current_builder="$(docker buildx inspect)" 21 | # linux/amd64, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6 22 | if ! grep -q "^Driver: docker$" <<<"${current_builder}" && \ 23 | grep -q "linux/amd64" <<<"${current_builder}" && \ 24 | grep -q "linux/arm64" <<<"${current_builder}"; then 25 | exit 0 26 | fi 27 | 28 | # Ensure qemu is in binfmt_misc 29 | # Docker desktop already has these in versions recent enough to have buildx 30 | # We only need to do this setup on linux hosts 31 | if [ "$(uname)" == 'Linux' ]; then 32 | # NOTE: this is pinned to a digest for a reason! 33 | docker run --rm --privileged tonistiigi/binfmt:qemu-v7.0.0-28@sha256:66e11bea77a5ea9d6f0fe79b57cd2b189b5d15b93a2bdb925be22949232e4e55 --install all 34 | fi 35 | 36 | # Ensure we use a builder that can leverage it (the default on linux will not) 37 | docker buildx rm kind-builder || true 38 | docker buildx create --use --name=kind-builder 39 | -------------------------------------------------------------------------------- /pkg/internal/patch/mergepatch.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package patch 18 | 19 | import ( 20 | "sigs.k8s.io/yaml" 21 | 22 | "sigs.k8s.io/kind/pkg/errors" 23 | ) 24 | 25 | type mergePatch struct { 26 | raw string // the original raw data 27 | json []byte // the processed data (in JSON form) 28 | matchInfo matchInfo // for matching resources 29 | } 30 | 31 | func parseMergePatches(rawPatches []string) ([]mergePatch, error) { 32 | patches := []mergePatch{} 33 | // split document streams before trying to parse them 34 | splitRawPatches := make([]string, 0, len(rawPatches)) 35 | for _, raw := range rawPatches { 36 | splitRaw, err := splitYAMLDocuments(raw) 37 | if err != nil { 38 | return nil, err 39 | } 40 | splitRawPatches = append(splitRawPatches, splitRaw...) 41 | } 42 | for _, raw := range splitRawPatches { 43 | matchInfo, err := parseYAMLMatchInfo(raw) 44 | if err != nil { 45 | return nil, errors.WithStack(err) 46 | } 47 | json, err := yaml.YAMLToJSON([]byte(raw)) 48 | if err != nil { 49 | return nil, errors.WithStack(err) 50 | } 51 | patches = append(patches, mergePatch{ 52 | raw: raw, 53 | json: json, 54 | matchInfo: matchInfo, 55 | }) 56 | } 57 | return patches, nil 58 | } 59 | -------------------------------------------------------------------------------- /hack/make-rules/update/generated.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2018 The Kubernetes Authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # 'go generate's kind, using tools from vendor (go-bindata) 17 | set -o errexit -o nounset -o pipefail 18 | 19 | # cd to the repo root and setup go 20 | REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." &> /dev/null && pwd -P)" 21 | cd "${REPO_ROOT}" 22 | source hack/build/setup-go.sh 23 | 24 | # build the generators using the tools module 25 | cd "${REPO_ROOT}/hack/tools" 26 | go build -o "${REPO_ROOT}/bin/deepcopy-gen" k8s.io/code-generator/cmd/deepcopy-gen 27 | # go back to the root 28 | cd "${REPO_ROOT}" 29 | 30 | # turn off module mode before running the generators 31 | # https://github.com/kubernetes/code-generator/issues/69 32 | # we also need to populate vendor 33 | 34 | # run the generators 35 | # TODO: -o "${REPO_ROOT}/../.." is a weird work-around ... 36 | bin/deepcopy-gen -i ./pkg/internal/apis/config/ -o "${REPO_ROOT}/../.." -O zz_generated.deepcopy --go-header-file hack/tools/boilerplate.go.txt 37 | bin/deepcopy-gen -i ./pkg/apis/config/v1alpha4 -o "${REPO_ROOT}/../.." -O zz_generated.deepcopy --go-header-file hack/tools/boilerplate.go.txt 38 | 39 | 40 | # set module mode back, return to repo root and gofmt to ensure we format generated code 41 | make gofmt 42 | -------------------------------------------------------------------------------- /pkg/cluster/internal/providers/nerdctl/network_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package nerdctl 18 | 19 | import ( 20 | "fmt" 21 | "testing" 22 | ) 23 | 24 | func Test_generateULASubnetFromName(t *testing.T) { 25 | t.Parallel() 26 | cases := []struct { 27 | name string 28 | attempt int32 29 | subnet string 30 | }{ 31 | { 32 | name: "kind", 33 | subnet: "fc00:f853:ccd:e793::/64", 34 | }, 35 | { 36 | name: "foo", 37 | attempt: 1, 38 | subnet: "fc00:8edf:7f02:ec8f::/64", 39 | }, 40 | { 41 | name: "foo", 42 | attempt: 2, 43 | subnet: "fc00:9968:306b:2c65::/64", 44 | }, 45 | { 46 | name: "kind2", 47 | subnet: "fc00:444c:147a:44ab::/64", 48 | }, 49 | { 50 | name: "kin", 51 | subnet: "fc00:fcd9:c2be:8e23::/64", 52 | }, 53 | { 54 | name: "mysupernetwork", 55 | subnet: "fc00:7ae1:1e0d:b4d4::/64", 56 | }, 57 | } 58 | for _, tc := range cases { 59 | tc := tc // capture variable 60 | t.Run(fmt.Sprintf("%s,%d", tc.name, tc.attempt), func(t *testing.T) { 61 | t.Parallel() 62 | subnet := generateULASubnetFromName(tc.name, tc.attempt) 63 | if subnet != tc.subnet { 64 | t.Errorf("Wrong subnet from %v: expected %v, received %v", tc.name, tc.subnet, subnet) 65 | } 66 | }) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /pkg/log/noop.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package log 18 | 19 | // NoopLogger implements the Logger interface and never logs anything 20 | type NoopLogger struct{} 21 | 22 | // Warn meets the Logger interface but does nothing 23 | func (n NoopLogger) Warn(message string) {} 24 | 25 | // Warnf meets the Logger interface but does nothing 26 | func (n NoopLogger) Warnf(format string, args ...interface{}) {} 27 | 28 | // Error meets the Logger interface but does nothing 29 | func (n NoopLogger) Error(message string) {} 30 | 31 | // Errorf meets the Logger interface but does nothing 32 | func (n NoopLogger) Errorf(format string, args ...interface{}) {} 33 | 34 | // V meets the Logger interface but does nothing 35 | func (n NoopLogger) V(level Level) InfoLogger { return NoopInfoLogger{} } 36 | 37 | // NoopInfoLogger implements the InfoLogger interface and never logs anything 38 | type NoopInfoLogger struct{} 39 | 40 | // Enabled meets the InfoLogger interface but always returns false 41 | func (n NoopInfoLogger) Enabled() bool { return false } 42 | 43 | // Info meets the InfoLogger interface but does nothing 44 | func (n NoopInfoLogger) Info(message string) {} 45 | 46 | // Infof meets the InfoLogger interface but does nothing 47 | func (n NoopInfoLogger) Infof(format string, args ...interface{}) {} 48 | -------------------------------------------------------------------------------- /hack/ci/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrant box for testing kind with non-Ubuntu 5 | Vagrant.configure("2") do |config| 6 | config.vm.box = "fedora/39-cloud-base" 7 | # https://mirrormanager.fedoraproject.org/mirrors/Fedora/39/x86_64 8 | config.vm.box_url = "https://gsl-syd.mm.fcix.net/fedora/linux/releases/39/Cloud/x86_64/images/Fedora-Cloud-Base-Vagrant-39-1.5.x86_64.vagrant-virtualbox.box" 9 | # assume some ram is needed for the host environment but very little CPU 10 | memory = 10240 11 | cpus = 3 12 | config.vm.provider :virtualbox do |v| 13 | v.memory = memory 14 | v.cpus = cpus 15 | end 16 | config.vm.provision "install-packages", type: "shell", run: "once" do |sh| 17 | sh.inline = <<~SHELL 18 | set -eux -o pipefail 19 | # Ensure network-related modules to be loaded 20 | modprobe tap ip_tables iptable_nat ip6_tables ip6table_nat 21 | 22 | # The moby-engine package included in Fedora lacks support for rootless, 23 | # So we need to install docker-ce and docker-ce-rootless-extras from the upstream. 24 | curl -fsSL https://get.docker.com | sh 25 | dnf install -y golang-go make kubernetes-client podman docker-ce-rootless-extras 26 | systemctl enable --now docker 27 | 28 | # Configuration for rootless: https://kind.sigs.k8s.io/docs/user/rootless/ 29 | mkdir -p "/etc/systemd/system/user@.service.d" 30 | cat <"/etc/systemd/system/user@.service.d/delegate.conf" 31 | [Service] 32 | Delegate=yes 33 | EOF 34 | systemctl daemon-reload 35 | loginctl enable-linger vagrant 36 | SHELL 37 | end 38 | config.vm.provision "install-kind", type: "shell", run: "once" do |sh| 39 | sh.inline = <<~SHELL 40 | set -eux -o pipefail 41 | git config --global --add safe.directory /vagrant 42 | make -C /vagrant install INSTALL_DIR=/usr/local/bin 43 | SHELL 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /pkg/cluster/internal/providers/common/getport.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impliep. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package common 18 | 19 | import ( 20 | "net" 21 | ) 22 | 23 | // PortOrGetFreePort is a helper that either returns the provided port 24 | // if valid or returns a new free port on listenAddr and a cleanup function 25 | func PortOrGetFreePort(port int32, listenAddr string) (int32, func(), error) { 26 | // in the case of -1 we actually want to pass 0 to the backend to let it pick 27 | if port == -1 { 28 | return 0, nil, nil 29 | } 30 | // in the case of 0 (unset) we want kind to pick one and supply it to the backend 31 | if port == 0 { 32 | return GetFreePort(listenAddr) 33 | } 34 | // otherwise keep the port 35 | return port, nil, nil 36 | } 37 | 38 | // GetFreePort is a helper used to get a free TCP port on the host 39 | // returns the free port and a cleanup function, the cleanup function must be called 40 | // after all free ports have been determined to ensure the same port is not returned 41 | // multiple times 42 | func GetFreePort(listenAddr string) (int32, func(), error) { 43 | dummyListener, err := net.Listen("tcp", net.JoinHostPort(listenAddr, "0")) 44 | if err != nil { 45 | return 0, nil, err 46 | } 47 | port := dummyListener.Addr().(*net.TCPAddr).Port 48 | return int32(port), func() { dummyListener.Close() }, nil 49 | } 50 | -------------------------------------------------------------------------------- /pkg/build/nodeimage/helpers.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package nodeimage 18 | 19 | import ( 20 | "path" 21 | "regexp" 22 | "strings" 23 | 24 | "sigs.k8s.io/kind/pkg/errors" 25 | "sigs.k8s.io/kind/pkg/exec" 26 | ) 27 | 28 | // createFile creates the file at filePath in the container, 29 | // ensuring the directory exists and writing contents to the file 30 | func createFile(containerCmder exec.Cmder, filePath, contents string) error { 31 | // NOTE: the paths inside the container should use the path package 32 | // and not filepath (!), we want posixy paths in the linux container, NOT 33 | // whatever path format the host uses. For paths on the host we use filepath 34 | if err := containerCmder.Command("mkdir", "-p", path.Dir(filePath)).Run(); err != nil { 35 | return err 36 | } 37 | 38 | return containerCmder.Command( 39 | "cp", "/dev/stdin", filePath, 40 | ).SetStdin( 41 | strings.NewReader(contents), 42 | ).Run() 43 | } 44 | 45 | func findSandboxImage(config string) (string, error) { 46 | match := regexp.MustCompile(`sandbox_image\s+=\s+"([^\n]+)"`).FindStringSubmatch(config) 47 | if len(match) < 2 { 48 | return "", errors.New("failed to parse sandbox_image from config") 49 | } 50 | return match[1], nil 51 | } 52 | 53 | func dockerBuildOsAndArch(arch string) string { 54 | return "linux/" + arch 55 | } 56 | -------------------------------------------------------------------------------- /images/base/files/etc/containerd/config.toml: -------------------------------------------------------------------------------- 1 | # explicitly use v2 config format 2 | version = 2 3 | 4 | [proxy_plugins] 5 | # fuse-overlayfs is used for rootless 6 | [proxy_plugins."fuse-overlayfs"] 7 | type = "snapshot" 8 | address = "/run/containerd-fuse-overlayfs.sock" 9 | 10 | [plugins."io.containerd.grpc.v1.cri".containerd] 11 | # save disk space when using a single snapshotter 12 | discard_unpacked_layers = true 13 | # explicitly use default snapshotter so we can sed it in entrypoint 14 | snapshotter = "overlayfs" 15 | # explicit default here, as we're configuring it below 16 | default_runtime_name = "runc" 17 | [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc] 18 | # set default runtime handler to v2, which has a per-pod shim 19 | runtime_type = "io.containerd.runc.v2" 20 | # Generated by "ctr oci spec" and modified at base container to mount poduct_uuid 21 | base_runtime_spec = "/etc/containerd/cri-base.json" 22 | [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options] 23 | # use systemd cgroup by default 24 | SystemdCgroup = true 25 | 26 | # Setup a runtime with the magic name ("test-handler") used for Kubernetes 27 | # runtime class tests ... 28 | [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.test-handler] 29 | # same settings as runc 30 | runtime_type = "io.containerd.runc.v2" 31 | base_runtime_spec = "/etc/containerd/cri-base.json" 32 | [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.test-handler.options] 33 | SystemdCgroup = true 34 | 35 | [plugins."io.containerd.grpc.v1.cri"] 36 | # use fixed sandbox image 37 | sandbox_image = "registry.k8s.io/pause:3.10" 38 | # allow hugepages controller to be missing 39 | # see https://github.com/containerd/cri/pull/1501 40 | tolerate_missing_hugepages_controller = true 41 | # restrict_oom_score_adj needs to be true when running inside UserNS (rootless) 42 | restrict_oom_score_adj = false 43 | -------------------------------------------------------------------------------- /pkg/cluster/constants/constants.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package constants contains well known constants for kind clusters 18 | package constants 19 | 20 | // DefaultClusterName is the default cluster Context name 21 | const DefaultClusterName = "kind" 22 | 23 | /* node role value constants */ 24 | const ( 25 | // ControlPlaneNodeRoleValue identifies a node that hosts a Kubernetes 26 | // control-plane. 27 | // 28 | // NOTE: in single node clusters, control-plane nodes act as worker nodes 29 | ControlPlaneNodeRoleValue string = "control-plane" 30 | 31 | // WorkerNodeRoleValue identifies a node that hosts a Kubernetes worker 32 | WorkerNodeRoleValue string = "worker" 33 | 34 | // ExternalLoadBalancerNodeRoleValue identifies a node that hosts an 35 | // external load balancer for the API server in HA configurations. 36 | // 37 | // Please note that `kind` nodes hosting external load balancer are not 38 | // kubernetes nodes 39 | ExternalLoadBalancerNodeRoleValue string = "external-load-balancer" 40 | 41 | // ExternalEtcdNodeRoleValue identifies a node that hosts an external-etcd 42 | // instance. 43 | // 44 | // WARNING: this node type is not yet implemented! 45 | // 46 | // Please note that `kind` nodes hosting external etcd are not 47 | // kubernetes nodes 48 | ExternalEtcdNodeRoleValue string = "external-etcd" 49 | ) 50 | -------------------------------------------------------------------------------- /pkg/cluster/internal/kubeconfig/internal/kubeconfig/encode_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package kubeconfig 18 | 19 | import ( 20 | "testing" 21 | 22 | "sigs.k8s.io/kind/pkg/internal/assert" 23 | ) 24 | 25 | func TestEncodeRoundtrip(t *testing.T) { 26 | t.Parallel() 27 | // test round tripping a kubeconfig 28 | const aConfig = `apiVersion: v1 29 | clusters: 30 | - cluster: 31 | certificate-authority-data: definitelyacert 32 | server: https://192.168.9.4:6443 33 | name: kind-kind 34 | contexts: 35 | - context: 36 | cluster: kind-kind 37 | user: kind-kind 38 | name: kind-kind 39 | current-context: kind-kind 40 | kind: Config 41 | preferences: {} 42 | users: 43 | - name: kind-kind 44 | user: 45 | client-certificate-data: seemslegit 46 | client-key-data: yup 47 | ` 48 | cfg, err := KINDFromRawKubeadm(aConfig, "kind", "") 49 | if err != nil { 50 | t.Fatalf("failed to decode kubeconfig: %v", err) 51 | } 52 | encoded, err := Encode(cfg) 53 | if err != nil { 54 | t.Fatalf("failed to encode kubeconfig: %v", err) 55 | } 56 | assert.StringEqual(t, aConfig, string(encoded)) 57 | } 58 | 59 | func TestEncodeEmpty(t *testing.T) { 60 | t.Parallel() 61 | encoded, err := Encode(&Config{}) 62 | if err != nil { 63 | t.Fatalf("failed to encode kubeconfig: %v", err) 64 | } 65 | assert.StringEqual(t, "", string(encoded)) 66 | } 67 | -------------------------------------------------------------------------------- /pkg/errors/concurrent.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package errors 18 | 19 | import ( 20 | "sync" 21 | ) 22 | 23 | // UntilErrorConcurrent runs all funcs in separate goroutines, returning the 24 | // first non-nil error returned from funcs, or nil if all funcs return nil 25 | func UntilErrorConcurrent(funcs []func() error) error { 26 | errCh := make(chan error, len(funcs)) 27 | for _, f := range funcs { 28 | f := f // capture f 29 | go func() { 30 | errCh <- f() 31 | }() 32 | } 33 | for i := 0; i < len(funcs); i++ { 34 | if err := <-errCh; err != nil { 35 | return err 36 | } 37 | } 38 | return nil 39 | } 40 | 41 | // AggregateConcurrent runs fns concurrently, returning a NewAggregate if there are > 1 errors 42 | func AggregateConcurrent(funcs []func() error) error { 43 | // run all fns concurrently 44 | ch := make(chan error, len(funcs)) 45 | var wg sync.WaitGroup 46 | for _, f := range funcs { 47 | f := f // capture f 48 | wg.Add(1) 49 | go func() { 50 | defer wg.Done() 51 | ch <- f() 52 | }() 53 | } 54 | wg.Wait() 55 | close(ch) 56 | // collect up and return errors 57 | errs := []error{} 58 | for err := range ch { 59 | if err != nil { 60 | errs = append(errs, err) 61 | } 62 | } 63 | if len(errs) > 1 { 64 | return NewAggregate(errs) 65 | } else if len(errs) == 1 { 66 | return errs[0] 67 | } 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /pkg/cmd/kind/get/clusters/clusters.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package clusters implements the `clusters` command 18 | package clusters 19 | 20 | import ( 21 | "fmt" 22 | 23 | "github.com/spf13/cobra" 24 | 25 | "sigs.k8s.io/kind/pkg/cluster" 26 | "sigs.k8s.io/kind/pkg/cmd" 27 | "sigs.k8s.io/kind/pkg/log" 28 | 29 | "sigs.k8s.io/kind/pkg/internal/runtime" 30 | ) 31 | 32 | // NewCommand returns a new cobra.Command for getting the list of clusters 33 | func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { 34 | cmd := &cobra.Command{ 35 | Args: cobra.NoArgs, 36 | // TODO(bentheelder): more detailed usage 37 | Use: "clusters", 38 | Short: "Lists existing kind clusters by their name", 39 | Long: "Lists existing kind clusters by their name", 40 | RunE: func(cmd *cobra.Command, args []string) error { 41 | return runE(logger, streams) 42 | }, 43 | } 44 | return cmd 45 | } 46 | 47 | func runE(logger log.Logger, streams cmd.IOStreams) error { 48 | provider := cluster.NewProvider( 49 | cluster.ProviderWithLogger(logger), 50 | runtime.GetDefault(logger), 51 | ) 52 | clusters, err := provider.List() 53 | if err != nil { 54 | return err 55 | } 56 | if len(clusters) == 0 { 57 | logger.V(0).Info("No kind clusters found.") 58 | return nil 59 | } 60 | for _, cluster := range clusters { 61 | fmt.Fprintln(streams.Out, cluster) 62 | } 63 | return nil 64 | } 65 | -------------------------------------------------------------------------------- /pkg/cluster/internal/providers/common/images_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impliep. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package common 18 | 19 | import ( 20 | "reflect" 21 | "testing" 22 | 23 | "sigs.k8s.io/kind/pkg/internal/apis/config" 24 | "sigs.k8s.io/kind/pkg/internal/sets" 25 | ) 26 | 27 | func TestRequiredNodeImages(t *testing.T) { 28 | t.Parallel() 29 | tests := []struct { 30 | name string 31 | cluster *config.Cluster 32 | want sets.String 33 | }{ 34 | { 35 | name: "Cluster with different images", 36 | cluster: func() *config.Cluster { 37 | c := config.Cluster{} 38 | n, n2 := config.Node{}, config.Node{} 39 | n.Image = "node1" 40 | n2.Image = "node2" 41 | c.Nodes = []config.Node{n, n2} 42 | return &c 43 | }(), 44 | want: sets.NewString("node1", "node2"), 45 | }, 46 | { 47 | name: "Cluster with nodes with same image", 48 | cluster: func() *config.Cluster { 49 | c := config.Cluster{} 50 | n, n2 := config.Node{}, config.Node{} 51 | n.Image = "node1" 52 | n2.Image = "node1" 53 | c.Nodes = []config.Node{n, n2} 54 | return &c 55 | }(), 56 | want: sets.NewString("node1"), 57 | }, 58 | } 59 | for _, tt := range tests { 60 | tt := tt 61 | t.Run(tt.name, func(t *testing.T) { 62 | t.Parallel() 63 | if got := RequiredNodeImages(tt.cluster); !reflect.DeepEqual(got, tt.want) { 64 | t.Errorf("RequiredNodeImages() = %v, want %v", got, tt.want) 65 | } 66 | }) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /hack/release/get-contributors.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2020 The Kubernetes Authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # inputs are: 17 | # - LAST_VERSION_TAG -- This is the version to get commits since 18 | # like: LAST_VERSION_TAG="v0.8.1" 19 | # - GITHUB_OATH_TOKEN -- used to avoid hitting API rate limits 20 | ORG="kubernetes-sigs" 21 | REPO="kind" 22 | 23 | # query git for contributors since the tag 24 | contributors=() 25 | while IFS='' read -r line; do contributors+=("$line"); done < <(git log --format="%aN <%aE>" "${LAST_VERSION_TAG:?}.." | sort | uniq) 26 | 27 | # query github for usernames and output bulleted list 28 | contributor_logins=() 29 | for contributor in "${contributors[@]}"; do 30 | # get a commit for this author 31 | commit_for_contributor="$(git log --author="${contributor}" --pretty=format:"%H" -1)" 32 | # lookup the commit info to get the login 33 | contributor_logins+=("$(curl \ 34 | -sG \ 35 | ${GITHUB_OAUTH_TOKEN:+-H "Authorization: Bearer ${GITHUB_OAUTH_TOKEN:?}"} \ 36 | --data-urlencode "q=${contributor}" \ 37 | "https://api.github.com/repos/${ORG}/${REPO}/commits/${commit_for_contributor}" \ 38 | | jq -r .author.login 39 | )") 40 | done 41 | 42 | echo "Contributors since ${LAST_VERSION_TAG}:" 43 | # echo sorted formatted list 44 | while IFS='' read -r contributor_login; do 45 | echo "- @${contributor_login}" 46 | done < <(for c in "${contributor_logins[@]}"; do echo "$c"; done | LC_COLLATE=C sort --ignore-case | uniq) 47 | -------------------------------------------------------------------------------- /site/content/docs/design/node-image.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Node Image" 3 | menu: 4 | main: 5 | parent: "design" 6 | identifier: "node-image" 7 | --- 8 | 9 | > **NOTE**: This may not completely cover the current implementation. 10 | 11 | The ["node" image][node image] is a Docker image for running 12 | nested containers, systemd, and Kubernetes components. 13 | 14 | This image is built on top of the ["base" image][base image]. 15 | 16 | Logic for building the ["node" image][node image] can be found in [`pkg/build`][build package], 17 | and it can be built with `kind build node-image` respectively. 18 | 19 | ## Design 20 | 21 | Other than the requirements that this image inherits from the "base" image, which 22 | provides most of the tools statically needed for a Kubernetes deployment 23 | (eg `systemd`), variants of this image have the following properties: 24 | 25 | - `/kind/images/` contains various `*.tar` files which are 26 | [Docker image archives][docker image archives], 27 | these images will be loaded by the cluster tooling prior to running `kubeadm` 28 | 29 | - `kubeadm`, `kubectl`, `kubelet` are in the path 30 | 31 | - A [systemd service][systemd service] is enabled for `kubelet`, and is 32 | configured to not fail on swap being enabled. (we must do the latter because 33 | swap is inherited from the host and we don't want to force users to disable swap 34 | before using `kind`) 35 | 36 | - `/kind/version` is a regular text file containing the `gitVersion` of the 37 | installed Kubernetes build 38 | 39 | These properties are used by the [cluster][cluster package] tooling to boot 40 | each "node" container with [kubeadm][kubeadm]. 41 | 42 | [node image]: https://sigs.k8s.io/kind/images/node 43 | [base image]: /docs/design/base-image 44 | [build package]: https://sigs.k8s.io/kind/pkg/build 45 | [cluster package]: https://sigs.k8s.io/kind/pkg/cluster 46 | [docker image archives]: https://docs.docker.com/engine/reference/commandline/save/ 47 | [systemd service]: https://www.freedesktop.org/software/systemd/man/systemd.service.html 48 | [kubeadm]: https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm/ 49 | --------------------------------------------------------------------------------