Little helper to run CNCF's k3s in Docker
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
k3d/v5.6.0/search/search_index.json

1 lines
144 KiB

{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Overview","text":""},{"location":"#what-is-k3d","title":"What is k3d?","text":"<p>k3d is a lightweight wrapper to run k3s (Rancher Lab\u2019s minimal Kubernetes distribution) in docker.</p> <p>k3d makes it very easy to create single- and multi-node k3s clusters in docker, e.g. for local development on Kubernetes.</p> <p>Note: k3d is a community-driven project but it\u2019s not an official Rancher (SUSE) product. Sponsoring: To spend any significant amount of time improving k3d, we rely on sponsorships:</p> <p>- GitHub Sponsors: - LiberaPay: - IssueHunt: https://issuehunt.io/r/k3d-io/k3d</p> View a quick demo <p></p>"},{"location":"#learning","title":"Learning","text":"<p>k3d demo repository: iwilltry42/k3d-demo</p> <p>Featured use-cases include:</p> <ul> <li>hot-reloading of code when developing on k3d (Python Flask App)</li> <li>build-deploy-test cycle using Tilt</li> <li>full cluster lifecycle for simple and multi-server clusters</li> <li>Proof of Concept of using k3d as a service in Drone CI</li> </ul> <ul> <li>Rancher Meetup - May 2020 - Simplifying Your Cloud-Native Development Workflow With K3s, K3c and K3d (YouTube)</li> </ul>"},{"location":"#requirements","title":"Requirements","text":"<ul> <li>docker to be able to use k3d at all<ul> <li>Note: k3d v5.x.x requires at least Docker v20.10.5 (runc &gt;= v1.0.0-rc93) to work properly (see #807)</li> </ul> </li> <li>kubectl to interact with the Kubernetes cluster</li> </ul>"},{"location":"#releases","title":"Releases","text":"Platform Stage Version Release Date Downloads so far GitHub Releases stable GitHub Releases latest Homebrew stable - - Chocolatey stable - -"},{"location":"#installation","title":"Installation","text":"<p>You have several options there:</p>"},{"location":"#install-script","title":"Install Script","text":""},{"location":"#install-current-latest-release","title":"Install current latest release","text":"<ul> <li>wget:<pre><code>wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash\n</code></pre> </li> </ul> <ul> <li>curl:<pre><code>curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash\n</code></pre> </li> </ul>"},{"location":"#install-specific-release","title":"Install specific release","text":"<p>Use the install script to grab a specific release (via <code>TAG</code> environment variable):</p> <ul> <li>wget:<pre><code>wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=v5.0.0 bash\n</code></pre> </li> </ul> <ul> <li>curl:<pre><code>curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=v5.0.0 bash\n</code></pre> </li> </ul>"},{"location":"#other-installers","title":"Other Installers","text":"Other Installation Methods <ul> <li> <p>:fontawesome-solid-beer: Homebrew (MacOS/Linux): <pre><code>brew install k3d\n</code></pre></p> <p>Note: The formula can be found in homebrew/homebrew-core and is mirrored to homebrew/linuxbrew-core</p> </li> </ul> <ul> <li> <p> AUR (Arch Linux User Repository): <pre><code>yay -S rancher-k3d-bin\n</code></pre></p> <p>Package rancher-k3d-bin</p> </li> </ul> <ul> <li> <p> Download GitHub Release</p> <p>Grab a release binary from the release tab and install it yourself</p> </li> </ul> <ul> <li> <p> Chocolatey (Windows): <code>choco install k3d</code></p> <p>Note: package source can be found in erwinkersten/chocolatey-packages</p> </li> </ul> <ul> <li>arkade: <code>arkade get k3d</code></li> </ul> <ul> <li> <p>asdf: <code>asdf plugin-add k3d &amp;&amp; asdf install k3d latest</code></p> <p>Note: <code>asdf plugin-add k3d</code>, then <code>asdf install k3d &lt;tag&gt;</code> with <code>&lt;tag&gt; = latest</code> or <code>5.x.x</code> for a specific version (maintained by spencergilbert/asdf-k3d)</p> </li> </ul> <ul> <li>Others<ul> <li>install via go: <code>go install github.com/k3d-io/k3d/v5@latest</code> (Note: this will give you unreleased/bleeding-edge changes)</li> </ul> </li> </ul>"},{"location":"#quick-start","title":"Quick Start","text":"<p>Create a cluster named <code>mycluster</code> with just a single server node:</p> <pre><code>k3d cluster create mycluster\n</code></pre> <p>Use the new cluster with <code>kubectl</code>, e.g.:</p> <pre><code>kubectl get nodes\n</code></pre> Getting the cluster\u2019s kubeconfig (included in <code>k3d cluster create</code>) <p>Get the new cluster\u2019s connection details merged into your default kubeconfig (usually specified using the <code>KUBECONFIG</code> environment variable or the default path <code>$HOME/.kube/config</code>) and directly switch to the new context:</p> <pre><code>k3d kubeconfig merge mycluster --kubeconfig-switch-context\n</code></pre>"},{"location":"#connect","title":"Connect","text":"<ol> <li>Join the Rancher community on slack via slack.rancher.io</li> <li>Go to rancher-users.slack.com and join our channel #k3d</li> <li>Start chatting</li> </ol>"},{"location":"#related-projects","title":"Related Projects","text":"<ul> <li>vscode-k3d: VSCode Extension to handle k3d clusters from within VSCode</li> <li>k3x: a graphics interface (for Linux) to k3d.</li> <li>AbsaOSS/k3d-action: fully customizable GitHub Action to run lightweight Kubernetes clusters.</li> <li>AutoK3s: a lightweight tool to help run K3s everywhere including k3d provider.</li> <li>nolar/setup-k3d-k3s: setup K3d/K3s for GitHub Actions.</li> </ul>"},{"location":"design/concepts/","title":"Concepts","text":""},{"location":"design/concepts/#nodefilters","title":"Nodefilters","text":""},{"location":"design/concepts/#about","title":"About","text":"<p>Nodefilters are a concept in k3d to specify which nodes of a newly created cluster a condition or setting should apply to.</p>"},{"location":"design/concepts/#syntax","title":"Syntax","text":"<p>The overall syntax is <code>@&lt;group&gt;:&lt;subset&gt;[:&lt;suffix]</code>.</p> <ul> <li><code>@</code> denotes the start of a nodefilter in a k3d flag value</li> <li><code>&lt;group&gt;</code> denotes the node group you want to filter in<ul> <li>one of <code>server</code>, <code>servers</code>, <code>agent</code>, <code>agents</code>, <code>loadbalancer</code>, <code>all</code><ul> <li>note, that <code>all</code> also includes the cluster-external server loadbalancer (<code>k3d-proxy</code> container)</li> </ul> </li> </ul> </li> <li><code>&lt;subset&gt;</code> denotes the subset of the chosen group you want to apply the flag to<ul> <li>wildcard <code>*</code>: all nodes in that group</li> <li>index, e.g. <code>0</code>: only the first node of that group</li> <li>list, e.g. <code>1,3,5</code>: nodes 1, 3 and 5 of that group</li> <li>range, e.g. <code>2-4</code>: nodes 2 to 4 of that group</li> </ul> </li> <li><code>&lt;suffix&gt;</code> (optional) can hold some flag specific configuration<ul> <li>e.g. for the <code>--port</code> flag this could be <code>direct</code> or <code>proxy</code> (default) to configure the way of exposing ports</li> </ul> </li> </ul>"},{"location":"design/concepts/#example","title":"Example","text":"<ul> <li>Problem: You want to have Nginx as your ingress controller, but by default, K3s deploys Traefik.</li> <li>Solution: Disabling the default Traefik deployment using K3s\u2019 <code>--disable=traefik</code> flag.</li> <li>Note: It\u2019s enough to do this on the first (initializing) server node.</li> <li>How-To: <code>k3d cluster create notraefik --k3s-arg=\"--disable=traefik@server:0\"</code><ul> <li>Looking at <code>--k3s-arg=\"--disable=traefik@server:0\"</code>, everything after the <code>@</code> sign is part of the nodefilter.<ul> <li><code>server</code> is the node group: server nodes</li> <li>after the <code>:</code> follows the subset, which in this case is the index <code>0</code>: the first server node to be created (<code>k3d-notraefik-server-0</code>)</li> </ul> </li> </ul> </li> </ul>"},{"location":"design/defaults/","title":"Defaults","text":""},{"location":"design/defaults/#k3d-reserved-settings","title":"k3d reserved settings","text":"<p>When you create a K3s cluster in Docker using k3d, we make use of some K3s configuration options, making them \u201creserved\u201d for k3d. This means, that overriding those options with your own may break the cluster setup.</p>"},{"location":"design/defaults/#environment-variables","title":"Environment Variables","text":"<p>The following K3s environment variables are used to configure the cluster:</p> Variable K3d Default Configurable? <code>K3S_URL</code> <code>https://$CLUSTERNAME-server-0:6443</code> no <code>K3S_TOKEN</code> random yes (<code>--token</code>) <code>K3S_KUBECONFIG_OUTPUT</code> <code>/output/kubeconfig.yaml</code> no"},{"location":"design/defaults/#k3d-loadbalancer","title":"k3d Loadbalancer","text":"<p>By default, k3d creates an Nginx loadbalancer alongside the clusters it creates to handle the port-forwarding. The loadbalancer can partly be configured using k3d-defined settings.</p> Nginx setting k3d default k3d setting <code>proxy_timeout</code> (default for all server stanzas) <code>600</code> (s) <code>settings.defaultProxyTimeout</code> <code>worker_connections</code> <code>1024</code> <code>settings.workerConnections</code>"},{"location":"design/defaults/#overrides","title":"Overrides","text":"<ul> <li>Example via CLI: <code>k3d cluster create --lb-config-override settings.defaultProxyTimeout=900</code></li> <li> <p>Example via Config File:</p> <pre><code># ... truncated ...\nk3d:\n loadbalancer:\n configOverrides:\n - settings.workerConnections=2048\n</code></pre> </li> </ul>"},{"location":"design/defaults/#multiple-server-nodes","title":"Multiple server nodes","text":"<ul> <li>by default, when <code>--server</code> &gt; 1 and no <code>--datastore-x</code> option is set, the first server node (server-0) will be the initializing server node<ul> <li>the initializing server node will have the <code>--cluster-init</code> flag appended</li> <li>all other server nodes will refer to the initializing server node via <code>--server https://&lt;init-node&gt;:6443</code></li> </ul> </li> </ul>"},{"location":"design/defaults/#api-ports","title":"API-Ports","text":"<ul> <li>by default, we expose the API-Port (<code>6443</code>) by forwarding traffic from the default server loadbalancer (nginx container) to the server node(s)</li> <li>port <code>6443</code> of the loadbalancer is then mapped to a specific (<code>--api-port</code> flag) or a random (default) port on the host system</li> </ul>"},{"location":"design/defaults/#kubeconfig","title":"Kubeconfig","text":"<ul> <li>if <code>--kubeconfig-update-default</code> is set, we use the default loading rules to get the default kubeconfig:<ul> <li>First: kubeconfig specified via the KUBECONFIG environment variable (error out if multiple are specified)</li> <li>Second: default kubeconfig in home directory (e.g. <code>$HOME/.kube/config</code>)</li> </ul> </li> </ul>"},{"location":"design/defaults/#networking","title":"Networking","text":"<ul> <li>by default, k3d creates a new (docker) network for every cluster</li> </ul>"},{"location":"design/networking/","title":"Networking","text":"<ul> <li>Related issues:<ul> <li>k3d-io/k3d #220</li> </ul> </li> </ul>"},{"location":"design/networking/#introduction","title":"Introduction","text":"<p>By default, k3d creates a new (docker) network for every new cluster. Using the <code>--network STRING</code> flag upon creation to connect to an existing network. Existing networks won\u2019t be managed by k3d together with the cluster lifecycle.</p>"},{"location":"design/networking/#connecting-to-docker-internalpre-defined-networks","title":"Connecting to docker \u201cinternal\u201d/pre-defined networks","text":""},{"location":"design/networking/#host-network","title":"<code>host</code> network","text":"<p>When using the <code>--network</code> flag to connect to the host network (i.e. <code>k3d cluster create --network host</code>), you won\u2019t be able to create more than one server node. An edge case would be one server node (with agent disabled) and one agent node.</p>"},{"location":"design/networking/#bridge-network","title":"<code>bridge</code> network","text":"<p>By default, every network that k3d creates is working in <code>bridge</code> mode. But when you try to use <code>--network bridge</code> to connect to docker\u2019s internal <code>bridge</code> network, you may run into issues with grabbing certificates from the API-Server. Single-Node clusters should work though.</p>"},{"location":"design/networking/#none-network","title":"<code>none</code> \u201cnetwork\u201d","text":"<p>Well.. this doesn\u2019t really make sense for k3d anyway \u00af\\_(\u30c4)_/\u00af</p>"},{"location":"design/project/","title":"Project Overview","text":""},{"location":"design/project/#about-this-page","title":"About This Page","text":"<p>On this page we\u2019ll try to give an overview of all the moving bits and pieces in k3d to ease contributions to the project.</p>"},{"location":"design/project/#directory-overview","title":"Directory Overview","text":"<ul> <li><code>.github/</code><ul> <li>templates for issues and pull requests</li> <li>GitHub Action workflow definitions</li> </ul> </li> <li><code>cmd/</code><ul> <li>everything related to the actual k3d CLI, like the whole command tree, config initialization, argument parsing, etc.</li> </ul> </li> <li><code>docgen/</code><ul> <li>sub-module used to auto-generate the documentation for the CLI commands, which ends up in <code>docs/usage/commands/</code></li> </ul> </li> <li><code>docs/</code><ul> <li>all the resources used to build k3d.io using mkdocs</li> </ul> </li> <li><code>pkg/</code><ul> <li>the place where the magic happens.. here you find all the main logic of k3d</li> <li>all function calls within <code>cmd/</code> that do non-trivial things are imported from here</li> <li>this (or rather sub-packages) is what other projects would import as a module to work with k3d without using the CLI</li> </ul> </li> <li><code>proxy/</code><ul> <li>configuration to build the <code>k3d-io/k3d-proxy</code> container image which is used as a loadbalancer/proxy in front of (almost) every k3d cluster</li> <li>this is basically just a combination of NGINX with confd and some k3d-specific configuration details</li> </ul> </li> <li><code>tests/</code><ul> <li>a set of bash scripts used for end-to-end (E2E) tests of k3d</li> <li>mostly used for all the functionality of the k3d CLI which cannot be tested using Go unit tests</li> </ul> </li> <li><code>tools/</code><ul> <li>sub-module used to build the <code>k3d-io/k3d-tools</code> container image which supports some k3d functionality like <code>k3d image import</code></li> </ul> </li> <li><code>vendor/</code><ul> <li>result of <code>go mod vendor</code>, which contains all dependencies of k3d</li> </ul> </li> <li><code>version/</code><ul> <li>package used to code k3d/k3s versions into releases</li> <li>this is where <code>go build</code> injects the version tags when building k3d<ul> <li>that\u2019s the output you see when issuing <code>k3d version</code></li> </ul> </li> </ul> </li> </ul>"},{"location":"design/project/#packages-overview","title":"Packages Overview","text":"<ul> <li><code>pkg/</code><ul> <li><code>actions/</code><ul> <li>hook actions describing actions (commands, etc.) that run at specific stages of the node/cluster lifecycle<ul> <li>e.g. writing configuration files to the container filesystem just before the node (container) starts</li> </ul> </li> </ul> </li> <li><code>client/</code><ul> <li>all the top level functionality to work with k3d primitives<ul> <li>create/retrieve/update/delete/start/stop clusters, nodes, registries, etc. managed by k3d</li> </ul> </li> </ul> </li> <li><code>config/</code><ul> <li>everything related to the k3d configuration (files), like <code>SimpleConfig</code> and <code>ClusterConfig</code></li> </ul> </li> <li><code>runtimes/</code><ul> <li>interface and implementations of runtimes that power k3d (currently, that\u2019s only Docker)</li> <li>functions in <code>client/</code> eventually call runtime functions to \u201cmaterialize\u201d nodes and clusters</li> </ul> </li> <li><code>tools/</code><ul> <li>functions eventually calling the <code>k3d-tools</code> container (see <code>tools/</code> in the repo root)</li> </ul> </li> <li><code>types/</code><ul> <li>definition of all k3d primitives and many other details and defaults</li> <li>e.g. contains the definition of a <code>Node</code> or a <code>Cluster</code> in k3d</li> </ul> </li> <li><code>util/</code><ul> <li>some helper functions e.g. for string manipulation/generation, regexp or other re-usable usages</li> </ul> </li> </ul> </li> </ul>"},{"location":"design/project/#anatomy-of-a-cluster","title":"Anatomy of a Cluster","text":"<p>By default, every k3d cluster consists of at least 2 containers (nodes):</p> <ol> <li> <p>(optional, but default and strongly recommended) loadbalancer</p> <ul> <li>image: <code>ghcr.io/k3d-io/k3d-proxy</code>, built from <code>proxy/</code></li> <li>purpose: proxy and load balance requests from the outside (i.e. most of the times your local host) to the cluster<ul> <li>by default, it e.g. proxies all the traffic for the Kubernetes API to port <code>6443</code> (default listening port of K3s) to all the server nodes in the cluster</li> <li>can be used for multiple port-mappings to one or more nodes in your cluster<ul> <li>that way, port-mappings can also easily be added/removed after the cluster creation, as we can simply re-create the proxy without affecting cluster state</li> </ul> </li> </ul> </li> </ul> </li> <li> <p>(required, always present) primary server node</p> <ul> <li>image: <code>rancher/k3s</code>, built from <code>github.com/k3s-io/k3s</code></li> <li>purpose: (initializing) server (formerly: master) node of the cluster<ul> <li>runs the K3s executable (which runs containerd, the Kubernetes API Server, etcd/sqlite, etc.): <code>k3s server</code></li> <li>in a multi-server setup, it initializes the cluster with an embedded etcd database (using the K3s <code>--cluster-init</code> flag)</li> </ul> </li> </ul> </li> <li> <p>(optional) secondary server node(s)</p> <ul> <li>image: <code>rancher/k3s</code>, built from <code>github.com/k3s-io/k3s</code></li> </ul> </li> <li> <p>(optional) agent node(s)</p> <ul> <li>image: <code>rancher/k3s</code>, built from <code>github.com/k3s-io/k3s</code></li> <li>purpose: running the K3s agent process (kubelet, etc.): <code>k3s agent</code></li> </ul> </li> </ol>"},{"location":"design/project/#automation-ci","title":"Automation (CI)","text":"<p>The k3d repository mainly leverages the following two CI systems:</p> <ul> <li>GitHub Actions<ul> <li>2 workflows in https://github.com/k3d-io/k3d/tree/main/.github/workflows to push the artifact to AUR (Arch Linux User Repository)</li> <li>logs/history can be seen in the Actions tab: https://github.com/k3d-io/k3d/actions</li> <li>static code analysis</li> <li>build</li> <li>tests</li> <li>docker builds + pushes</li> <li>render + push docs</li> <li>(pre-) release to GitHub</li> </ul> </li> </ul>"},{"location":"design/project/#documentation","title":"Documentation","text":"<p>The website k3d.io containing all the documentation for k3d is built using <code>mkdocs</code>, configured via the <code>mkdocs.yml</code> config file with all the content residing in the <code>docs/</code> directory (Markdown). Use <code>mkdocs serve</code> in the repository root to build and serve the webpage locally. Some parts of the documentation are being auto-generated, like <code>docs/usage/commands/</code> is auto-generated using Cobra\u2019s command docs generation functionality in <code>docgen/</code>.</p>"},{"location":"faq/compatibility/","title":"Compatibility","text":"<p>With each release, we test if k3d works with specific versions of Docker and K3s, to ensure, that at least the most recent versions of Docker and the active releases (i.e. non-EOL release channels, similar to Kubernetes) work properly with it. The tests happen automatically in GitHub Actions. Some versions of Docker and K3s are expected to fail with specific versions of k3d due to e.g. incompatible dependencies or missing features. We test a full cluster lifecycle with different K3s channels, meaning that the following list refers to the current latest version released under the given channel.</p>"},{"location":"faq/compatibility/#releases","title":"Releases","text":""},{"location":"faq/compatibility/#v540-26032022","title":"v5.4.0 - 26.03.2022","text":"<p>Test Workflow: https://github.com/k3d-io/k3d/actions/runs/2044325827</p>"},{"location":"faq/compatibility/#docker","title":"Docker","text":"<ul> <li>20.10.5</li> <li>20.10.12</li> </ul> <p>Expected to Fail with the following versions:</p> <ul> <li>&lt;= 20.10.4 (due to runc, see https://github.com/k3d-io/k3d/issues/807)</li> </ul>"},{"location":"faq/compatibility/#k3s","title":"K3s","text":"<ul> <li>Channel v1.23</li> <li>Channel v1.22</li> </ul> <p>Expected to Fail with the following versions:</p> <ul> <li>&lt;= v1.18 (due to not included, but expected CoreDNS in K3s)</li> </ul>"},{"location":"faq/compatibility/#v530-03022022","title":"v5.3.0 - 03.02.2022","text":""},{"location":"faq/compatibility/#docker_1","title":"Docker","text":"<ul> <li>20.10.5</li> <li>20.10.12</li> </ul> <p>Expected to Fail with the following versions:</p> <ul> <li>&lt;= 20.10.4 (due to runc, see https://github.com/k3d-io/k3d/issues/807)</li> </ul>"},{"location":"faq/compatibility/#k3s_1","title":"K3s","text":"<ul> <li>Channel v1.23</li> <li>Channel v1.22</li> </ul> <p>Expected to Fail with the following versions:</p> <ul> <li>&lt;= v1.18 (due to not included, but expected CoreDNS in K3s)</li> </ul>"},{"location":"faq/faq/","title":"FAQ","text":""},{"location":"faq/faq/#issues-with-btrfs","title":"Issues with BTRFS","text":"<ul> <li>As @jaredallard pointed out, people running <code>k3d</code> on a system with btrfs, may need to mount <code>/dev/mapper</code> into the nodes for the setup to work.<ul> <li>This will do: <code>k3d cluster create CLUSTER_NAME -v /dev/mapper:/dev/mapper</code></li> </ul> </li> </ul>"},{"location":"faq/faq/#issues-with-zfs","title":"Issues with ZFS","text":"<ul> <li> <p>k3s currently has no support for ZFS and thus, creating multi-server setups (e.g. <code>k3d cluster create multiserver --servers 3</code>) fails, because the initializing server node (server flag <code>--cluster-init</code>) errors out with the following log:</p> <pre><code>starting kubernetes: preparing server: start cluster and https: raft_init(): io: create I/O capabilities probe file: posix_allocate: operation not supported on socket\n</code></pre> <ul> <li>This issue can be worked around by providing docker with a different filesystem (that\u2019s also better for docker-in-docker stuff).</li> <li>A possible solution can be found here: https://github.com/rancher/k3s/issues/1688#issuecomment-619570374</li> </ul> </li> </ul>"},{"location":"faq/faq/#pods-evicted-due-to-lack-of-disk-space","title":"Pods evicted due to lack of disk space","text":"<ul> <li>Pods go to evicted state after doing X<ul> <li>Related issues: #133 - Pods evicted due to <code>NodeHasDiskPressure</code> (collection of #119 and #130)</li> <li>Background: somehow docker runs out of space for the k3d node containers, which triggers a hard eviction in the kubelet</li> <li>Possible fix/workaround by @zer0def:<ul> <li>use a docker storage driver which cleans up properly (e.g. overlay2)</li> <li>clean up or expand docker root filesystem</li> <li> <p>change the kubelet\u2019s eviction thresholds upon cluster creation:</p> <pre><code>k3d cluster create \\\n --k3s-arg '--kubelet-arg=eviction-hard=imagefs.available&lt;1%,nodefs.available&lt;1%@agent:*' \\\n --k3s-arg '--kubelet-arg=eviction-minimum-reclaim=imagefs.available=1%,nodefs.available=1%@agent:*'\n</code></pre> </li> </ul> </li> </ul> </li> </ul>"},{"location":"faq/faq/#restarting-a-multi-server-cluster-or-the-initializing-server-node-fails","title":"Restarting a multi-server cluster or the initializing server node fails","text":"<ul> <li>What you do: You create a cluster with more than one server node and later, you either stop <code>server-0</code> or stop/start the whole cluster</li> <li>What fails: After the restart, you cannot connect to the cluster anymore and <code>kubectl</code> will give you a lot of errors</li> <li>What causes this issue: it\u2019s a known issue with dqlite in <code>k3s</code> which doesn\u2019t allow the initializing server node to go down</li> <li>What\u2019s the solution: Hopefully, this will be solved by the planned replacement of dqlite with embedded etcd in k3s</li> <li>Related issues: #262</li> </ul>"},{"location":"faq/faq/#passing-additional-argumentsflags-to-k3s-and-on-to-eg-the-kube-apiserver","title":"Passing additional arguments/flags to k3s (and on to e.g. the kube-apiserver)","text":"<ul> <li>The Problem: Passing a feature flag to the Kubernetes API Server running inside k3s.</li> <li>Example: you want to enable the EphemeralContainers feature flag in Kubernetes</li> <li> <p>Solution:</p> <pre><code> k3d cluster create \\\n --k3s-arg '--kube-apiserver-arg=feature-gates=EphemeralContainers=true@server:*' \\\n --k3s-arg '--kube-scheduler-arg=feature-gates=EphemeralContainers=true@server:*' \\\n --k3s-arg '--kubelet-arg=feature-gates=EphemeralContainers=true@agent:*'\n</code></pre> <ul> <li>Note: Be aware of where the flags require dashes (<code>--</code>) and where not.<ul> <li>the k3s flag (<code>--kube-apiserver-arg</code>) has the dashes</li> <li>the kube-apiserver flag <code>feature-gates</code> doesn\u2019t have them (k3s adds them internally)</li> </ul> </li> </ul> </li> </ul> <ul> <li> <p>Second example:</p> <pre><code>k3d cluster create k3d-one \\\n --k3s-arg \"--cluster-cidr=10.118.0.0/17@server:*\" \\\n --k3s-arg \"--service-cidr=10.118.128.0/17@server:*\" \\\n --k3s-arg \"--disable=servicelb@server:*\" \\\n --k3s-arg \"--disable=traefik@server:*\" \\\n --verbose\n</code></pre> <ul> <li>Note: There are many ways to use the <code>\"</code> and <code>'</code> quotes, just be aware, that sometimes shells also try to interpret/interpolate parts of the commands</li> </ul> </li> </ul>"},{"location":"faq/faq/#how-to-access-services-like-a-database-running-on-my-docker-host-machine","title":"How to access services (like a database) running on my Docker Host Machine","text":"<ul> <li>As of version v3.1.0, we\u2019re injecting the <code>host.k3d.internal</code> entry into the k3d containers (k3s nodes) and into the CoreDNS ConfigMap, enabling you to access your host system by referring to it as <code>host.k3d.internal</code></li> </ul>"},{"location":"faq/faq/#running-behind-a-corporate-proxy","title":"Running behind a corporate proxy","text":"<p>Running k3d behind a corporate proxy can lead to some issues with k3d that have already been reported in more than one issue. Some can be fixed by passing the <code>HTTP_PROXY</code> environment variables to k3d, some have to be fixed in docker\u2019s <code>daemon.json</code> file and some are as easy as adding a volume mount.</p>"},{"location":"faq/faq/#pods-fail-to-start-x509-certificate-signed-by-unknown-authority","title":"Pods fail to start: <code>x509: certificate signed by unknown authority</code>","text":"<ul> <li> <p>Example Error Message:</p> <pre><code>Failed to create pod sandbox: rpc error: code = Unknown desc = failed to get sandbox image \"docker.io/rancher/pause:3.1\": failed to pull image \"docker.io/rancher/pause:3.1\": failed to pull and unpack image \"docker.io/rancher/pause:3.1\": failed to resolve reference \"docker.io/rancher/pause:3.1\": failed to do request: Head https://registry-1.docker.io/v2/rancher/pause/manifests/3.1: x509: certificate signed by unknown authority\n</code></pre> </li> </ul> <ul> <li>Problem: inside the container, the certificate of the corporate proxy cannot be validated</li> <li>Possible Solution: Mounting the CA Certificate from your host into the node containers at start time via <code>k3d cluster create --volume /path/to/your/certs.crt:/etc/ssl/certs/yourcert.crt</code></li> <li>Issue: k3d-io/k3d#535</li> </ul>"},{"location":"faq/faq/#spurious-pid-entries-in-proc-after-deleting-k3d-cluster-with-shared-mounts","title":"Spurious PID entries in <code>/proc</code> after deleting <code>k3d</code> cluster with shared mounts","text":"<ul> <li>When you perform cluster create and deletion operations multiple times with same cluster name and shared volume mounts, it was observed that <code>grep k3d /proc/*/mountinfo</code> shows many spurious entries</li> <li>Problem: Due to above, at times you\u2019ll see <code>no space left on device: unknown</code> when a pod is scheduled to the nodes</li> <li>If you observe anything of above sort you can check for inaccessible file systems and unmount them by using below command (note: please remove <code>xargs umount -l</code> and check for the diff o/p first)</li> <li><code>diff &lt;(df -ha | grep pods | awk '{print $NF}') &lt;(df -h | grep pods | awk '{print $NF}') | awk '{print $2}' | xargs umount -l</code></li> <li>As per the conversation on k3d-io/k3d#594 above issue wasn\u2019t reported/known earlier and so there are high chances that it\u2019s not universal.</li> </ul>"},{"location":"faq/faq/#solved-nodes-fail-to-start-or-get-stuck-in-notready-state-with-log-nf_conntrack_max-permission-denied","title":"[SOLVED] Nodes fail to start or get stuck in <code>NotReady</code> state with log <code>nf_conntrack_max: permission denied</code>","text":""},{"location":"faq/faq/#problem","title":"Problem","text":"<ul> <li>When: This happens when running k3d on a Linux system with a kernel version &gt;= 5.12.2 (and others like &gt;= 5.11.19) when creating a new cluster<ul> <li>the node(s) stop or get stuck with a log line like this: <code>&lt;TIMESTAMP&gt; F0516 05:05:31.782902 7 server.go:495] open /proc/sys/net/netfilter/nf_conntrack_max: permission denied</code></li> </ul> </li> <li>Why: The issue was introduced by a change in the Linux kernel (Changelog 5.12.2: Commit), that changed the netfilter_conntrack behavior in a way that <code>kube-proxy</code> is not able to set the <code>nf_conntrack_max</code> value anymore</li> </ul>"},{"location":"faq/faq/#workaround","title":"Workaround","text":"<ul> <li> <p>Workaround: as a workaround, we can tell <code>kube-proxy</code> to not even try to set this value:</p> <pre><code>k3d cluster create \\\n --k3s-arg \"--kube-proxy-arg=conntrack-max-per-core=0@server:*\" \\\n --k3s-arg \"--kube-proxy-arg=conntrack-max-per-core=0@agent:*\" \\\n --image rancher/k3s:v1.20.6-k3s\n</code></pre> </li> </ul>"},{"location":"faq/faq/#fix","title":"Fix","text":"<ul> <li>Note: k3d v4.4.5 already uses rancher/k3s:v1.21.1-k3s1 as the new default k3s image, so no workarounds needed there!</li> </ul> <p>This is going to be fixed \u201cupstream\u201d in k3s itself in rancher/k3s#3337 and backported to k3s versions as low as v1.18.</p> <ul> <li>The fix was released and backported in k3s, so you don\u2019t need to use the workaround when using one of the following k3s versions (or later ones)<ul> <li>v1.18.19-k3s1 (rancher/k3s#3344)</li> <li>v1.19.11-k3s1 (rancher/k3s#3343)</li> <li>v1.20.7-k3s1 (rancher/k3s#3342)</li> <li>v1.21.1-k3s1 (rancher/k3s#3341))</li> </ul> </li> <li>Issue Reference: rancher/k3s#607</li> </ul>"},{"location":"faq/faq/#dockerhub-pull-rate-limit","title":"DockerHub Pull Rate Limit","text":""},{"location":"faq/faq/#problem_1","title":"Problem","text":"<p>You\u2019re deploying something to the cluster using an image from DockerHub and the image fails to be pulled, with a <code>429</code> response code and a message saying <code>You have reached your pull rate limit. You may increase the limit by authenticating and upgrading</code>.</p>"},{"location":"faq/faq/#cause","title":"Cause","text":"<p>This is caused by DockerHub\u2019s pull rate limit (see https://docs.docker.com/docker-hub/download-rate-limit/), which limits pulls from unauthenticated/anonymous users to 100 pulls per hour and for authenticated users (not paying customers) to 200 pulls per hour (as of the time of writing).</p>"},{"location":"faq/faq/#solution","title":"Solution","text":"<p>a) use images from a private registry, e.g. configured as a pull-through cache for DockerHub b) use a different public registry without such limitations, if the same image is stored there c) authenticate containerd inside k3s/k3d to use your DockerHub user </p>"},{"location":"faq/faq/#c-authenticate-containerd-against-dockerhub","title":"(c) Authenticate Containerd against DockerHub","text":"<ol> <li> <p>Create a registry configuration file for containerd:</p> <pre><code># saved as e.g. $HOME/registries.yaml\nconfigs:\n \"docker.io\":\n auth:\n username: \"$USERNAME\"\n password: \"$PASSWORD\"\n</code></pre> </li> <li> <p>Create a k3d cluster using that config:</p> <pre><code>k3d cluster create --registry-config $HOME/registries.yaml\n</code></pre> </li> <li> <p>Profit. That\u2019s it. In the test for this, we pulled the same image 120 times in a row (confirmed, that pull numbers went up), without being rate limited (as a non-paying, normal user)</p> </li> </ol>"},{"location":"faq/faq/#longhorn-in-k3d","title":"Longhorn in k3d","text":""},{"location":"faq/faq/#problem_2","title":"Problem","text":"<p>Longhorn is not working when deployed in a K3s cluster spawned with k3d.</p>"},{"location":"faq/faq/#cause_1","title":"Cause","text":"<p>The container image of K3s is quite limited and doesn\u2019t contain the necessary libraries. Also, additional volume mounts and more would be required to get Longhorn up and running properly. So basically Longhorn does rely too much on the host OS to work properly in the dockerized environment without quite some modifications.</p>"},{"location":"faq/faq/#solution_1","title":"Solution","text":"<p>There are a few ways one can build a working image to use with k3d. See https://github.com/k3d-io/k3d/discussions/478 for more info.</p>"},{"location":"usage/commands/","title":"Command Tree","text":"<pre><code>k3d\n --verbose # GLOBAL: enable verbose (debug) logging (default: false)\n --trace # GLOBAL: enable super verbose logging (trace logging) (default: false)\n --version # show k3d and k3s version\n -h, --help # GLOBAL: show help text\n\n cluster [CLUSTERNAME] # default cluster name is 'k3s-default'\n create\n -a, --agents # specify how many agent nodes you want to create (integer, default: 0)\n --agents-memory # specify memory limit for agent containers/nodes (unit, e.g. 1g)\n --api-port # specify the port on which the cluster will be accessible (format '[HOST:]HOSTPORT', default: random)\n -c, --config # use a config file (format 'PATH')\n -e, --env # add environment variables to the nodes (quoted string, format: 'KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]', use flag multiple times)\n --gpus # [from docker CLI] add GPU devices to the node containers (string, e.g. 'all')\n -i, --image # specify which k3s image should be used for the nodes (string, default: 'docker.io/rancher/k3s:v1.20.0-k3s2', tag changes per build)\n --k3s-arg # add additional arguments to the k3s server/agent (quoted string, use flag multiple times) (see https://rancher.com/docs/k3s/latest/en/installation/install-options/server-config/#k3s-server-cli-help &amp; https://rancher.com/docs/k3s/latest/en/installation/install-options/agent-config/#k3s-agent-cli-help)\n --kubeconfig-switch-context # (implies --kubeconfig-update-default) automatically sets the current-context of your default kubeconfig to the new cluster's context (default: true)\n --kubeconfig-update-default # enable the automated update of the default kubeconfig with the details of the newly created cluster (also sets '--wait=true') (default: true)\n -l, --label # add (docker) labels to the node containers (format: 'KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]', use flag multiple times)\n --network # specify an existing (docker) network you want to connect to (string)\n --no-hostip # disable the automatic injection of the Host IP as 'host.k3d.internal' into the containers and CoreDNS (default: false)\n --no-image-volume # disable the creation of a volume for storing images (used for the 'k3d image import' command) (default: false)\n --no-lb # disable the creation of a load balancer in front of the server nodes (default: false)\n --no-rollback # disable the automatic rollback actions, if anything goes wrong (default: false)\n -p, --port # add some more port mappings (format: '[HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER]', use flag multiple times)\n --registry-create # create a new (docker) registry dedicated for this cluster (default: false)\n --registry-use # use an existing local (docker) registry with this cluster (string, use multiple times)\n -s, --servers # specify how many server nodes you want to create (integer, default: 1)\n --servers-memory # specify memory limit for server containers/nodes (unit, e.g. 1g)\n --token # specify a cluster token (string, default: auto-generated)\n --timeout # specify a timeout, after which the cluster creation will be interrupted and changes rolled back (duration, e.g. '10s')\n -v, --volume # specify additional bind-mounts (format: '[SOURCE:]DEST[@NODEFILTER[;NODEFILTER...]]', use flag multiple times)\n --wait # enable waiting for all server nodes to be ready before returning (default: true)\n start CLUSTERNAME # start a (stopped) cluster\n -a, --all # start all clusters (default: false)\n --wait # wait for all servers and server-loadbalancer to be up before returning (default: true)\n --timeout # maximum waiting time for '--wait' before canceling/returning (duration, e.g. '10s')\n stop CLUSTERNAME # stop a cluster\n -a, --all # stop all clusters (default: false)\n delete CLUSTERNAME # delete an existing cluster\n -a, --all # delete all existing clusters (default: false)\n list [CLUSTERNAME [CLUSTERNAME ...]]\n --no-headers # do not print headers (default: false)\n --token # show column with cluster tokens (default: false)\n -o, --output # format the output (format: 'json|yaml')\n completion [bash | zsh | fish | (psh | powershell)] # generate completion scripts for common shells\n config\n init # write a default k3d config (as a starting point)\n -f, --force # force overwrite target file (default: false)\n -o, --output # file to write to (string, default \"k3d-default.yaml\")\n help [COMMAND] # show help text for any command\n image\n import [IMAGE | ARCHIVE [IMAGE | ARCHIVE ...]] # Load one or more images from the local runtime environment or tar-archives into k3d clusters\n -c, --cluster # clusters to load the image into (string, use flag multiple times, default: k3s-default)\n -k, --keep-tarball # do not delete the image tarball from the shared volume after completion (default: false)\n kubeconfig\n get (CLUSTERNAME [CLUSTERNAME ...] | --all) # get kubeconfig from cluster(s) and write it to stdout\n -a, --all # get kubeconfigs from all clusters (default: false)\n merge | write (CLUSTERNAME [CLUSTERNAME ...] | --all) # get kubeconfig from cluster(s) and merge it/them into a (kubeconfig-)file\n -a, --all # get kubeconfigs from all clusters (default: false)\n -s, --kubeconfig-switch-context # switch current-context in kubeconfig to the new context (default: true)\n -d, --kubeconfig-merge-default # update the default kubeconfig (usually $KUBECONFIG or $HOME/.kube/config)\n -o, --output # specify the output file where the kubeconfig should be written to (string)\n --overwrite # [Careful!] forcefully overwrite the output file, ignoring existing contents (default: false)\n -u, --update # update conflicting fields in existing kubeconfig (default: true)\n node\n create NODENAME # Create new nodes (and add them to existing clusters)\n -c, --cluster # specify the cluster that the node shall connect to (string, default: k3s-default)\n -i, --image # specify which k3s image should be used for the node(s) (string, default: 'docker.io/rancher/k3s:v1.20.0-k3s2', tag changes per build)\n --replicas # specify how many replicas you want to create with this spec (integer, default: 1)\n --role # specify the node role (string, format: 'agent|server', default: agent)\n --timeout # specify a timeout duration, after which the node creation will be interrupted, if not done yet (duration, e.g. '10s')\n --wait # wait for the node to be up and running before returning (default: true)\n start NODENAME # start a (stopped) node\n stop NODENAME # stop a node\n delete NODENAME # delete an existing node\n -a, --all # delete all existing nodes (default: false)\n -r, --registries # also delete registries, as a special type of node (default: false)\n list NODENAME\n --no-headers # do not print headers (default: false)\n registry\n create REGISTRYNAME\n -i, --image # specify image used for the registry (string, default: \"docker.io/library/registry:2\")\n -p, --port # select host port to map to (format: '[HOST:]HOSTPORT', default: 'random')\n delete REGISTRYNAME\n -a, --all # delete all existing registries (default: false)\n list [NAME [NAME...]]\n --no-headers # disable table headers (default: false)\n version # show k3d and k3s version\n</code></pre>"},{"location":"usage/configfile/","title":"Using Config Files","text":"<p>The config file feature is available as of k3d v4.0.0</p>"},{"location":"usage/configfile/#introduction","title":"Introduction","text":"<p>Syntax &amp; Semantics</p> <p>The options defined in the config file are not 100% the same as the CLI flags. This concerns naming and style/usage/structure, e.g.</p> <ul> <li><code>--api-port</code> is split up into a field named <code>kubeAPI</code> that has 3 different \u201cchild fields\u201d (<code>host</code>, <code>hostIP</code> and <code>hostPort</code>)</li> <li>k3d options are bundled in a scope named <code>options.k3d</code>, where <code>--no-rollback</code> is defined as <code>options.k3d.disableRollback</code></li> <li>repeatable flags (like <code>--port</code>) are reflected as YAML lists</li> </ul>"},{"location":"usage/configfile/#usage","title":"Usage","text":"<p>Using a config file is as easy as putting it in a well-known place in your file system and then referencing it via flag:</p> <ul> <li>All options in config file: <code>k3d cluster create --config /home/me/my-awesome-config.yaml</code> (must be <code>.yaml</code>/<code>.yml</code>)</li> <li>With CLI override (name): <code>k3d cluster create somename --config /home/me/my-awesome-config.yaml</code></li> <li>With CLI override (extra volume): <code>k3d cluster create --config /home/me/my-awesome-config.yaml --volume '/some/path:/some:path@server:0'</code></li> </ul>"},{"location":"usage/configfile/#required-fields","title":"Required Fields","text":"<p>As of the time of writing this documentation, the config file only requires you to define two fields:</p> <ul> <li><code>apiVersion</code> to match the version of the config file that you want to use (at this time it would be <code>apiVersion: k3d.io/v1alpha5</code>)</li> <li><code>kind</code> to define the kind of config file that you want to use (currently we only have the <code>Simple</code> config)</li> </ul> <p>So this would be the minimal config file, which configures absolutely nothing:</p> <pre><code>apiVersion: k3d.io/v1alpha5\nkind: Simple\n</code></pre>"},{"location":"usage/configfile/#config-options","title":"Config Options","text":"<p>The configuration options for k3d are continuously evolving and so is the config file (syntax) itself. Currently, the config file is still in an Alpha-State, meaning, that it is subject to change anytime (though we try to keep breaking changes low).</p> <p>Validation via JSON-Schema</p> <p>k3d uses a JSON-Schema to describe the expected format and fields of the configuration file. This schema is also used to validate a user-given config file. This JSON-Schema can be found in the specific config version sub-directory in the repository (e.g. here for <code>v1alpha5</code>) and could be used to lookup supported fields or by linters to validate the config file, e.g. in your code editor. </p>"},{"location":"usage/configfile/#all-options-example","title":"All Options: Example","text":"<p>Since the config options and the config file are changing quite a bit, it\u2019s hard to keep track of all the supported config file settings, so here\u2019s an example showing all of them as of the time of writing:</p> <pre><code># k3d configuration file, saved as e.g. /home/me/myk3dcluster.yaml\napiVersion: k3d.io/v1alpha5 # this will change in the future as we make everything more stable\nkind: Simple # internally, we also have a Cluster config, which is not yet available externally\nmetadata:\n name: mycluster # name that you want to give to your cluster (will still be prefixed with `k3d-`)\nservers: 1 # same as `--servers 1`\nagents: 2 # same as `--agents 2`\nkubeAPI: # same as `--api-port myhost.my.domain:6445` (where the name would resolve to 127.0.0.1)\n host: \"myhost.my.domain\" # important for the `server` setting in the kubeconfig\n hostIP: \"127.0.0.1\" # where the Kubernetes API will be listening on\n hostPort: \"6445\" # where the Kubernetes API listening port will be mapped to on your host system\nimage: rancher/k3s:v1.20.4-k3s1 # same as `--image rancher/k3s:v1.20.4-k3s1`\nnetwork: my-custom-net # same as `--network my-custom-net`\nsubnet: \"172.28.0.0/16\" # same as `--subnet 172.28.0.0/16`\ntoken: superSecretToken # same as `--token superSecretToken`\nvolumes: # repeatable flags are represented as YAML lists\n - volume: /my/host/path:/path/in/node # same as `--volume '/my/host/path:/path/in/node@server:0;agent:*'`\n nodeFilters:\n - server:0\n - agent:*\nports:\n - port: 8080:80 # same as `--port '8080:80@loadbalancer'`\n nodeFilters:\n - loadbalancer\nenv:\n - envVar: bar=baz # same as `--env 'bar=baz@server:0'`\n nodeFilters:\n - server:0\nregistries: # define how registries should be created or used\n create: # creates a default registry to be used with the cluster; same as `--registry-create registry.localhost`\n name: registry.localhost\n host: \"0.0.0.0\"\n hostPort: \"5000\"\n proxy: # omit this to have a \"normal\" registry, set this to create a registry proxy (pull-through cache)\n remoteURL: https://registry-1.docker.io # mirror the DockerHub registry\n username: \"\" # unauthenticated\n password: \"\" # unauthenticated\n volumes:\n - /some/path:/var/lib/registry # persist registry data locally\n use:\n - k3d-myotherregistry:5000 # some other k3d-managed registry; same as `--registry-use 'k3d-myotherregistry:5000'`\n config: | # define contents of the `registries.yaml` file (or reference a file); same as `--registry-config /path/to/config.yaml`\n mirrors:\n \"my.company.registry\":\n endpoint:\n - http://my.company.registry:5000\nhostAliases: # /etc/hosts style entries to be injected into /etc/hosts in the node containers and in the NodeHosts section in CoreDNS\n - ip: 1.2.3.4\n hostnames: \n - my.host.local\n - that.other.local\n - ip: 1.1.1.1\n hostnames:\n - cloud.flare.dns\noptions:\n k3d: # k3d runtime settings\n wait: true # wait for cluster to be usable before returning; same as `--wait` (default: true)\n timeout: \"60s\" # wait timeout before aborting; same as `--timeout 60s`\n disableLoadbalancer: false # same as `--no-lb`\n disableImageVolume: false # same as `--no-image-volume`\n disableRollback: false # same as `--no-Rollback`\n loadbalancer:\n configOverrides:\n - settings.workerConnections=2048\n k3s: # options passed on to K3s itself\n extraArgs: # additional arguments passed to the `k3s server|agent` command; same as `--k3s-arg`\n - arg: \"--tls-san=my.host.domain\"\n nodeFilters:\n - server:*\n nodeLabels:\n - label: foo=bar # same as `--k3s-node-label 'foo=bar@agent:1'` -&gt; this results in a Kubernetes node label\n nodeFilters:\n - agent:1\n kubeconfig:\n updateDefaultKubeconfig: true # add new cluster to your default Kubeconfig; same as `--kubeconfig-update-default` (default: true)\n switchCurrentContext: true # also set current-context to the new cluster's context; same as `--kubeconfig-switch-context` (default: true)\n runtime: # runtime (docker) specific options\n gpuRequest: all # same as `--gpus all`\n labels:\n - label: bar=baz # same as `--runtime-label 'bar=baz@agent:1'` -&gt; this results in a runtime (docker) container label\n nodeFilters:\n - agent:1\n ulimits:\n - name: nofile\n soft: 26677\n hard: 26677\n</code></pre>"},{"location":"usage/configfile/#tips","title":"Tips","text":"<ul> <li>k3d expands environment variables (<code>$VAR</code> or <code>${VAR}</code>) unconditionally in the config file, even before processing it in any way. </li> </ul>"},{"location":"usage/configfile/#config-file-vs-cli-flags","title":"Config File vs. CLI Flags","text":"<p>k3d uses <code>Cobra</code> and <code>Viper</code> for CLI and general config handling respectively. This automatically introduces a \u201cconfig option order of priority\u201d (precedence order):</p> <p>Config Precedence Order</p> <p>Source: spf13/viper#why-viper </p> <p>Internal Setting &gt; CLI Flag &gt; Environment Variable &gt; Config File &gt; (k/v store &gt;) Defaults</p> <p>This means, that you can define e.g. a \u201cbase configuration file\u201d with settings that you share across different clusters and override only the fields that differ between those clusters in your CLI flags/arguments. For example, you use the same config file to create three clusters which only have different names and <code>kubeAPI</code> (<code>--api-port</code>) settings.</p>"},{"location":"usage/configfile/#references","title":"References","text":"<ul> <li>k3d demo repository: https://github.com/iwilltry42/k3d-demo/blob/main/README.md#config-file-support</li> <li>SUSE Blog: https://www.suse.com/c/introduction-k3d-run-k3s-docker-src/ (Search for <code>The \u201cConfiguration as Code\u201d Way</code>)</li> </ul>"},{"location":"usage/exposing_services/","title":"Exposing Services","text":""},{"location":"usage/exposing_services/#1-via-ingress-recommended","title":"1. via Ingress (recommended)","text":"<p>In this example, we will deploy a simple nginx webserver deployment and make it accessible via ingress. Therefore, we have to create the cluster in a way, that the internal port 80 (where the <code>traefik</code> ingress controller is listening on) is exposed on the host system.</p> <ol> <li> <p>Create a cluster, mapping the ingress port 80 to localhost:8081</p> <p><code>k3d cluster create --api-port 6550 -p \"8081:80@loadbalancer\" --agents 2</code></p> <p>Good to know</p> <ul> <li><code>--api-port 6550</code> is not required for the example to work. It\u2019s used to have <code>k3s</code>\u2019s API-Server listening on port 6550 with that port mapped to the host system.</li> <li>the port-mapping construct <code>8081:80@loadbalancer</code> means: \u201cmap port <code>8081</code> from the host to port <code>80</code> on the container which matches the nodefilter <code>loadbalancer</code>\u201c<ul> <li>the <code>loadbalancer</code> nodefilter matches only the <code>serverlb</code> that\u2019s deployed in front of a cluster\u2019s server nodes<ul> <li>all ports exposed on the <code>serverlb</code> will be proxied to the same ports on all server nodes in the cluster</li> </ul> </li> </ul> </li> </ul> </li> <li> <p>Get the kubeconfig file (redundant, as <code>k3d cluster create</code> already merges it into your default kubeconfig file)</p> <p><code>export KUBECONFIG=\"$(k3d kubeconfig write k3s-default)\"</code></p> </li> <li> <p>Create a nginx deployment</p> <p><code>kubectl create deployment nginx --image=nginx</code></p> </li> <li> <p>Create a ClusterIP service for it</p> <p><code>kubectl create service clusterip nginx --tcp=80:80</code></p> </li> <li> <p>Create an ingress object for it by copying the following manifest to a file and applying with <code>kubectl apply -f thatfile.yaml</code></p> <p>Note: <code>k3s</code> deploys <code>traefik</code> as the default ingress controller</p> <pre><code># apiVersion: networking.k8s.io/v1beta1 # for k3s &lt; v1.19\napiVersion: networking.k8s.io/v1\nkind: Ingress\nmetadata:\n name: nginx\n annotations:\n ingress.kubernetes.io/ssl-redirect: \"false\"\nspec:\n rules:\n - http:\n paths:\n - path: /\n pathType: Prefix\n backend:\n service:\n name: nginx\n port:\n number: 80\n</code></pre> </li> <li> <p>Curl it via localhost</p> <p><code>curl localhost:8081/</code></p> </li> </ol>"},{"location":"usage/exposing_services/#2-via-nodeport","title":"2. via NodePort","text":"<ol> <li> <p>Create a cluster, mapping the port <code>30080</code> from <code>agent-0</code> to <code>localhost:8082</code></p> <p><code>k3d cluster create mycluster -p \"8082:30080@agent:0\" --agents 2</code></p> <ul> <li>Note 1: Kubernetes\u2019 default NodePort range is <code>30000-32767</code></li> <li> <p>Note 2: You may as well expose the whole NodePort range from the very beginning, e.g. via <code>k3d cluster create mycluster --agents 3 -p \"30000-32767:30000-32767@server:0\"</code> (See this video from @portainer)</p> <ul> <li>Warning: Docker creates iptable entries and a new proxy process per port-mapping, so this may take a very long time or even freeze your system!</li> </ul> <p>\u2026 (Steps 2 and 3 like above) \u2026</p> </li> </ul> </li> <li> <p>Create a NodePort service for it by copying the following manifest to a file and applying it with <code>kubectl apply -f</code></p> <pre><code>apiVersion: v1\nkind: Service\nmetadata:\n labels:\n app: nginx\n name: nginx\nspec:\n ports:\n - name: 80-80\n nodePort: 30080\n port: 80\n protocol: TCP\n targetPort: 80\n selector:\n app: nginx\n type: NodePort\n</code></pre> </li> <li> <p>Curl it via localhost</p> <p><code>curl localhost:8082/</code></p> </li> </ol>"},{"location":"usage/importing_images/","title":"Importing modes","text":""},{"location":"usage/importing_images/#auto","title":"Auto","text":"<p>Auto-determine whether to use <code>direct</code> or <code>tools-node</code>.</p> <p>For remote container runtimes, <code>tools-node</code> is faster due to less network overhead, thus it is automatically selected for remote runtimes.</p> <p>Otherwise direct is used.</p>"},{"location":"usage/importing_images/#direct","title":"Direct","text":"<p>Directly load the given images to the k3s nodes. No separate container is spawned, no intermediate files are written.</p>"},{"location":"usage/importing_images/#tools-node","title":"Tools Node","text":"<p>Start a <code>k3d-tools</code> container in the container runtime, copy images to that runtime, then load the images to k3s nodes from there.</p>"},{"location":"usage/k3s/","title":"K3s Features in k3d","text":"<p>K3s ships with lots of built-in features and services, some of which may only be used in \u201cnon-normal\u201d ways in k3d due to the fact that K3s is running in containers.</p>"},{"location":"usage/k3s/#general-k3s-documentation","title":"General: K3s documentation","text":"<ul> <li>Automatically Deploying Manifests and Helm Charts: https://rancher.com/docs/k3s/latest/en/helm/#automatically-deploying-manifests-and-helm-charts<ul> <li>Note: <code>/var/lib/rancher/k3s/server/manifests</code> is also the path inside the K3s container filesystem, where all built-in component manifests are, so you can override them or provide your own variants by mounting files there, e.g. <code>--volume /path/to/my/custom/coredns.yaml:/var/lib/rancher/k3s/server/manifests/coredns.yaml</code> will override the packaged CoreDNS component.</li> </ul> </li> <li>Customizing packaged Components with <code>HelmChartConfig</code>: https://rancher.com/docs/k3s/latest/en/helm/#customizing-packaged-components-with-helmchartconfig</li> </ul>"},{"location":"usage/k3s/#coredns","title":"CoreDNS","text":"<p>Cluster DNS service</p>"},{"location":"usage/k3s/#resources","title":"Resources","text":"<ul> <li>Manifest embedded in K3s: https://github.com/k3s-io/k3s/blob/master/manifests/coredns.yaml<ul> <li>Note: it includes template variables (like <code>%{CLUSTER_DOMAIN}%</code>) that will be replaced by K3s before writing the file to the filesystem</li> </ul> </li> </ul>"},{"location":"usage/k3s/#coredns-in-k3d","title":"CoreDNS in k3d","text":"<p>Basically, CoreDNS works the same in k3d as it does in other clusters. One thing to note though is, that the default <code>forward . /etc/resolv.conf</code> configured in the <code>Corefile</code> doesn\u2019t work the same, as the <code>/etc/resolv.conf</code> file inside the K3s node containers is not the same as the one on your local machine.</p>"},{"location":"usage/k3s/#modifications","title":"Modifications","text":"<p>As of k3d v5.x, k3d injects entries to the <code>NodeHosts</code> (basically a hosts file similar to <code>/etc/hosts</code> in Linux, which is managed by K3s) to enable Pods in the cluster to resolve the names of other containers in the same docker network (cluster network) and a special entry called <code>host.k3d.internal</code> which resolves to the IP of the network gateway (can be used to e.g. resolve DNS queries using your local resolver). There\u2019s a PR in progress to make customizations easier (for k3d and for users): https://github.com/k3s-io/k3s/pull/4397</p>"},{"location":"usage/k3s/#local-path-provisioner","title":"local-path-provisioner","text":"<p>Dynamically provisioning persistent local storage with Kubernetes</p>"},{"location":"usage/k3s/#resources_1","title":"Resources","text":"<ul> <li>Source: https://github.com/rancher/local-path-provisioner</li> <li>Manifest embedded in K3s: https://github.com/k3s-io/k3s/blob/master/manifests/local-storage.yaml</li> </ul>"},{"location":"usage/k3s/#local-path-provisioner-in-k3d","title":"local-path-provisioner in k3d","text":"<p>In k3d, the local paths that the <code>local-path-provisioner</code> uses (default is <code>/var/lib/rancher/k3s/storage</code>) lies inside the container\u2019s filesystem, meaning that by default it\u2019s not mapped somewhere e.g. in your user home directory for you to use. You\u2019d need to map some local directory to that path to easily use the files inside this path: add <code>--volume $HOME/some/directory:/var/lib/rancher/k3s/storage@all</code> to your <code>k3d cluster create</code> command.</p>"},{"location":"usage/k3s/#traefik","title":"Traefik","text":"<p>Kubernetes Ingress Controller</p>"},{"location":"usage/k3s/#resources_2","title":"Resources","text":"<ul> <li>Official Documentation: https://doc.traefik.io/traefik/providers/kubernetes-ingress/</li> <li>Manifest embedded in K3s: https://github.com/k3s-io/k3s/blob/master/manifests/traefik.yaml</li> </ul>"},{"location":"usage/k3s/#traefik-in-k3d","title":"Traefik in k3d","text":"<p>k3d runs K3s in containers, so you\u2019ll need to expose the http/https ports on your host to easily access Ingress resources in your cluster. We have a guide over here explaining how to do this, see</p>"},{"location":"usage/k3s/#servicelb-klipper-lb","title":"servicelb (klipper-lb)","text":"<p>Embedded service load balancer in Klipper Allows you to use services with <code>type: LoadBalancer</code> in K3s by creating tiny proxies that use <code>hostPort</code>s</p>"},{"location":"usage/k3s/#resources_3","title":"Resources","text":"<ul> <li>Source: https://github.com/k3s-io/klipper-lb</li> </ul>"},{"location":"usage/k3s/#servicelb-in-k3d","title":"servicelb in k3d","text":"<p><code>klipper-lb</code> creates new pods that proxy traffic from <code>hostPort</code>s to the service ports of <code>type: LoadBalancer</code>. The <code>hostPort</code> in this case is a port in a K3s container, not your local host, so you\u2019d need to add the port-mapping via the <code>--port</code> flag when creating the cluster.</p>"},{"location":"usage/kubeconfig/","title":"Handling Kubeconfigs","text":"<p>By default, k3d will update your default kubeconfig with your new cluster\u2019s details and set the current-context to it (can be disabled). To get a kubeconfig set up for you to connect to a k3d cluster without this automatism, you can go different ways.</p> What is the default kubeconfig? <p>We determine the path of the used or default kubeconfig in two ways:</p> <ol> <li>Using the <code>KUBECONFIG</code> environment variable, if it specifies exactly one file</li> <li>Using the default path (e.g. on Linux it\u2019s <code>$HOME/.kube/config</code>)</li> </ol>"},{"location":"usage/kubeconfig/#getting-the-kubeconfig-for-a-newly-created-cluster","title":"Getting the kubeconfig for a newly created cluster","text":"<ol> <li> <p>Create a new kubeconfig file after cluster creation</p> <ul> <li><code>k3d kubeconfig write mycluster</code><ul> <li>Note: this will create (or update) the file <code>$HOME/.k3d/kubeconfig-mycluster.yaml</code></li> <li>Tip: Use it: <code>export KUBECONFIG=$(k3d kubeconfig write mycluster)</code></li> <li>Note 2: alternatively you can use <code>k3d kubeconfig get mycluster &gt; some-file.yaml</code></li> </ul> </li> </ul> </li> <li> <p>Update your default kubeconfig upon cluster creation (DEFAULT)</p> <ul> <li><code>k3d cluster create mycluster --kubeconfig-update-default</code><ul> <li>Note: this won\u2019t switch the current-context (append <code>--kubeconfig-switch-context</code> to do so)</li> </ul> </li> </ul> </li> <li> <p>Update your default kubeconfig after cluster creation</p> <ul> <li><code>k3d kubeconfig merge mycluster --kubeconfig-merge-default</code><ul> <li>Note: this won\u2019t switch the current-context (append <code>--kubeconfig-switch-context</code> to do so)</li> </ul> </li> </ul> </li> <li> <p>Update a different kubeconfig after cluster creation</p> <ul> <li><code>k3d kubeconfig merge mycluster --output some/other/file.yaml</code><ul> <li>Note: this won\u2019t switch the current-context</li> </ul> </li> <li>The file will be created if it doesn\u2019t exist</li> </ul> </li> </ol> <p>Switching the current context</p> <p>None of the above options switch the current-context by default. This is intended to be least intrusive, since the current-context has a global effect. You can switch the current-context directly with the <code>kubeconfig merge</code> command by adding the <code>--kubeconfig-switch-context</code> flag.</p>"},{"location":"usage/kubeconfig/#removing-cluster-details-from-the-kubeconfig","title":"Removing cluster details from the kubeconfig","text":"<p><code>k3d cluster delete mycluster</code> will always remove the details for <code>mycluster</code> from the default kubeconfig. It will also delete the respective kubeconfig file in <code>$HOME/.k3d/</code> if it exists.</p>"},{"location":"usage/kubeconfig/#handling-multiple-clusters","title":"Handling multiple clusters","text":"<p><code>k3d kubeconfig merge</code> let\u2019s you specify one or more clusters via arguments or all via <code>--all</code>. All kubeconfigs will then be merged into a single file if <code>--kubeconfig-merge-default</code> or <code>--output</code> is specified. If none of those two flags was specified, a new file will be created per cluster and the merged path (e.g. <code>$HOME/.k3d/kubeconfig-cluster1.yaml:$HOME/.k3d/cluster2.yaml</code>) will be returned. Note, that with multiple cluster specified, the <code>--kubeconfig-switch-context</code> flag will change the current context to the cluster which was last in the list.</p>"},{"location":"usage/multiserver/","title":"Creating multi-server clusters","text":"<p>Important note</p> <p>For the best results (and less unexpected issues), choose 1, 3, 5, \u2026 server nodes. (Read more on etcd quorum on etcd.io) At least 2 cores and 4GiB of RAM are recommended.</p>"},{"location":"usage/multiserver/#embedded-etcd","title":"Embedded etcd","text":"<p>Create a cluster with 3 server nodes using k3s\u2019 embedded etcd database. The first server to be created will use the <code>--cluster-init</code> flag and k3d will wait for it to be up and running before creating (and connecting) the other server nodes.</p> <pre><code>k3d cluster create multiserver --servers 3\n</code></pre>"},{"location":"usage/multiserver/#adding-server-nodes-to-a-running-cluster","title":"Adding server nodes to a running cluster","text":"<p>In theory (and also in practice in most cases), this is as easy as executing the following command:</p> <pre><code>k3d node create newserver --cluster multiserver --role server\n</code></pre> <p>There\u2019s a trap!</p> <p>If your cluster was initially created with only a single server node, then this will fail. That\u2019s because the initial server node was not started with the <code>--cluster-init</code> flag and thus is not using the etcd backend.</p>"},{"location":"usage/registries/","title":"Using Image Registries","text":""},{"location":"usage/registries/#registries-configuration-file","title":"Registries configuration file","text":"<p>You can add registries by specifying them in a <code>registries.yaml</code> and referencing it at creation time: <code>k3d cluster create mycluster --registry-config \"/home/YOU/my-registries.yaml\"</code>.</p> <p>This file is a regular k3s registries configuration file, and looks like this:</p> <pre><code>mirrors:\n \"my.company.registry:5000\":\n endpoint:\n - http://my.company.registry:5000\n</code></pre> <p>In this example, an image with a name like <code>my.company.registry:5000/nginx:latest</code> would be pulled from the registry running at <code>http://my.company.registry:5000</code>.</p> <p>This file can also be used for providing additional information necessary for accessing some registries, like authentication and certificates.</p>"},{"location":"usage/registries/#registries-configuration-file-embedded-in-k3ds-simpleconfig","title":"Registries Configuration File embedded in k3d\u2019s SimpleConfig","text":"<p>If you\u2019re using a <code>SimpleConfig</code> file to configure your k3d cluster, you may as well embed the registries.yaml in there directly:</p> <pre><code>apiVersion: k3d.io/v1alpha5\nkind: Simple\nmetadata:\n name: test\nservers: 1\nagents: 2\nregistries:\n create: \n name: myregistry\n config: |\n mirrors:\n \"my.company.registry\":\n endpoint:\n - http://my.company.registry:5000\n</code></pre> <p>Here, the config for the k3d-managed registry, created by the <code>create: {...}</code> option will be merged with the config specified under <code>config: |</code>.</p>"},{"location":"usage/registries/#authenticated-registries","title":"Authenticated registries","text":"<p>When using authenticated registries, we can add the username and password in a <code>configs</code> section in the <code>registries.yaml</code>, like this:</p> <pre><code>mirrors:\n my.company.registry:\n endpoint:\n - http://my.company.registry\n\nconfigs:\n my.company.registry:\n auth:\n username: aladin\n password: abracadabra\n</code></pre>"},{"location":"usage/registries/#secure-registries","title":"Secure registries","text":"<p>When using secure registries, the <code>registries.yaml</code> file must include information about the certificates. For example, if you want to use images from the secure registry running at <code>https://my.company.registry</code>, you must first download a CA file valid for that server and store it in some well-known directory like <code>${HOME}/.k3d/my-company-root.pem</code>. </p> <p>Then you have to mount the CA file in some directory in the nodes in the cluster and include that mounted file in a <code>configs</code> section in the <code>registries.yaml</code> file. For example, if we mount the CA file in <code>/etc/ssl/certs/my-company-root.pem</code>, the <code>registries.yaml</code> will look like:</p> <pre><code>mirrors:\n my.company.registry:\n endpoint:\n - https://my.company.registry\n\nconfigs:\n my.company.registry:\n tls:\n # we will mount \"my-company-root.pem\" in the /etc/ssl/certs/ directory.\n ca_file: \"/etc/ssl/certs/my-company-root.pem\"\n</code></pre> <p>Finally, we can create the cluster, mounting the CA file in the path we specified in <code>ca_file</code>:</p> <pre><code>k3d cluster create \\\n --volume \"${HOME}/.k3d/my-registries.yaml:/etc/rancher/k3s/registries.yaml\" \\\n --volume \"${HOME}/.k3d/my-company-root.pem:/etc/ssl/certs/my-company-root.pem\"\n</code></pre>"},{"location":"usage/registries/#using-a-local-registry","title":"Using a local registry","text":""},{"location":"usage/registries/#preface-referencing-local-registries","title":"Preface: Referencing local registries","text":"<p>In the next sections, you\u2019re going to create a local registry (i.e. a container image registry running in a container in your docker host). That container will have a name, e.g. <code>mycluster-registry</code>. If you follow the guide closely (or definitely if you use the k3d-managed option), this name will be known to all the hosts (K3s containers) and workloads in your k3d cluster. However, you usually want to push images into that registry from your local machine, which does not know that name by default. Now you have a few options, including the following three: </p> <ol> <li>Use <code>localhost</code>: Since the container will have a port mapped to your local host, you can just directly reference it via e.g. <code>localhost:12345</code>, where <code>12345</code> is the mapped port<ul> <li>If you later pull the image from the registry, only the repository path (e.g. <code>myrepo/myimage:mytag</code> in <code>mycluster-registry:5000/myrepo/myimage:mytag</code>) matters to find your image in the targeted registry.</li> </ul> </li> <li> <p>Get your machine to know the container name: For this you can use the plain old hosts file (<code>/etc/hosts</code> on Unix systems and <code>C:\\windows\\system32\\drivers\\etc\\hosts</code> on Windows) by adding an entry like the following to the end of the file: </p> <pre><code>127.0.0.1 mycluster-registry\n</code></pre> </li> <li> <p>Use some special resolving magic: Tools like <code>dnsmasq</code> or <code>nss-myhostname</code> (see info box below) and others can setup your local resolver to directly resolve the registry name to <code>127.0.0.1</code>.</p> </li> </ol> <p>nss-myhostname to resolve <code>*.localhost</code></p> <p>Luckily (for Linux users), NSS-myhostname ships with many Linux distributions and should resolve <code>*.localhost</code> automatically to <code>127.0.0.1</code>. Otherwise, it\u2019s installable using <code>sudo apt install libnss-myhostname</code>.</p>"},{"location":"usage/registries/#using-k3d-managed-registries","title":"Using k3d-managed registries","text":""},{"location":"usage/registries/#create-a-dedicated-registry-together-with-your-cluster","title":"Create a dedicated registry together with your cluster","text":"<ol> <li> <p><code>k3d cluster create mycluster --registry-create mycluster-registry</code>: This creates your cluster <code>mycluster</code> together with a registry container called <code>mycluster-registry</code></p> <ul> <li>k3d sets everything up in the cluster for containerd to be able to pull images from that registry (using the <code>registries.yaml</code> file)</li> <li>the port, which the registry is listening on will be mapped to a random port on your host system</li> </ul> </li> <li> <p>Check the k3d command output or <code>docker ps -f name=mycluster-registry</code> to find the exposed port</p> </li> <li>Test your registry</li> </ol>"},{"location":"usage/registries/#create-a-customized-k3d-managed-registry","title":"Create a customized k3d-managed registry","text":"<ol> <li><code>k3d registry create myregistry.localhost --port 12345</code> creates a new registry called <code>k3d-myregistry.localhost</code> (could be used with automatic resolution of <code>*.localhost</code>, see next section - also, note the <code>k3d-</code> prefix that k3d adds to all resources it creates)</li> <li><code>k3d cluster create newcluster --registry-use k3d-myregistry.localhost:12345</code> (make sure you use the <code>k3d-</code> prefix here) creates a new cluster set up to use that registry</li> <li>Test your registry</li> </ol>"},{"location":"usage/registries/#using-your-own-not-k3d-managed-local-registry","title":"Using your own (not k3d-managed) local registry","text":"<p>We recommend using a k3d-managed registry, as it plays nicely together with k3d clusters, but here\u2019s also a guide to create your own (not k3d-managed) registry, if you need features or customizations, that k3d does not provide:</p> Using your own (not k3d-managed) local registry <p>You can start your own local registry it with some <code>docker</code> commands, like:</p> <pre><code>docker volume create local_registry\ndocker container run -d --name registry.localhost -v local_registry:/var/lib/registry --restart always -p 12345:5000 registry:2\n</code></pre> <p>These commands will start your registry container with name and port (on your host) <code>registry.localhost:12345</code>. In order to push to this registry, you will need to make it accessible as described in the next section. Once your registry is up and running, we will need to add it to your <code>registries.yaml</code> configuration file. Finally, you have to connect the registry network to the k3d cluster network: <code>docker network connect k3d-k3s-default registry.localhost</code>. And then you can test your local registry.</p>"},{"location":"usage/registries/#pushing-to-your-local-registry-address","title":"Pushing to your local registry address","text":"<p>See Preface</p> <p>The information below has been addressed in the preface for this section.</p>"},{"location":"usage/registries/#testing-your-registry","title":"Testing your registry","text":"<p>You should test that you can</p> <ul> <li>push to your registry from your local development machine.</li> <li>use images from that registry in <code>Deployments</code> in your k3d cluster.</li> </ul> <p>We will verify these two things for a local registry (located at <code>k3d-registry.localhost:12345</code>) running in your development machine. Things would be basically the same for checking an external registry, but some additional configuration could be necessary in your local machine when using an authenticated or secure registry (please refer to Docker\u2019s documentation for this).</p> <p>Assumptions: In the following test cases, we assume that the registry name <code>k3d-registry.localhost</code> resolves to <code>127.0.0.1</code> in your local machine (see section preface for more details) and to the registry container IP for the k3d cluster nodes (K3s containers).</p> <p>Note: as per the explanation in the preface, you could replace <code>k3d-registry.localhost:12345</code> with <code>localhost:12345</code> in the <code>docker tag</code> and <code>docker push</code> commands below (but not in the <code>kubectl</code> part!)</p>"},{"location":"usage/registries/#nginx-deployment","title":"Nginx Deployment","text":"<p>First, we can download some image (like <code>nginx</code>) and push it to our local registry with:</p> <pre><code>docker pull nginx:latest\ndocker tag nginx:latest k3d-registry.localhost:12345/nginx:latest\ndocker push k3d-registry.localhost:12345/nginx:latest\n</code></pre> <p>Then we can deploy a pod referencing this image to your cluster:</p> <pre><code>cat &lt;&lt;EOF | kubectl apply -f -\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: nginx-test-registry\n labels:\n app: nginx-test-registry\nspec:\n replicas: 1\n selector:\n matchLabels:\n app: nginx-test-registry\n template:\n metadata:\n labels:\n app: nginx-test-registry\n spec:\n containers:\n - name: nginx-test-registry\n image: k3d-registry.localhost:12345/nginx:latest\n ports:\n - containerPort: 80\nEOF\n</code></pre> <p>Then you should check that the pod is running with <code>kubectl get pods -l \"app=nginx-test-registry\"</code>.</p>"},{"location":"usage/registries/#alpine-pod","title":"Alpine Pod","text":"<ol> <li>Pull the alpine image: <code>docker pull alpine:latest</code></li> <li>re-tag it to reference your newly created registry: <code>docker tag alpine:latest k3d-registry.localhost:12345/testimage:local</code></li> <li>push it: <code>docker push k3d-registry.localhost:12345/testimage:local</code></li> <li>Use kubectl to create a new pod in your cluster using that image to see, if the cluster can pull from the new registry: <code>kubectl run --image k3d-registry.localhost:12345/testimage:local testimage --command -- tail -f /dev/null</code><ul> <li>(creates a container that will not do anything but keep on running)</li> </ul> </li> </ol>"},{"location":"usage/registries/#creating-a-registry-proxy-pull-through-registry","title":"Creating a registry proxy / pull-through registry","text":"<ol> <li> <p>Create a pull-through registry</p> <pre><code>k3d registry create docker-io `# Create a registry named k3d-docker-io` \\\n -p 5000 `# listening on local host port 5000` \\ \n --proxy-remote-url https://registry-1.docker.io `# let it mirror the Docker Hub registry` \\\n -v ~/.local/share/docker-io-registry:/var/lib/registry `# also persist the downloaded images on the device outside the container`\n</code></pre> </li> <li> <p>Create <code>registry.yml</code></p> <pre><code>mirrors:\n \"docker.io\":\n endpoint:\n - http://k3d-docker-io:5000\n</code></pre> </li> <li> <p>Create a cluster and using the pull-through cache</p> <pre><code>k3d cluster create cluster01 --registry-use k3d-docker-io:5000 --registry-config registry.yml\n</code></pre> </li> <li> <p>After cluster01 ready, create another cluster with the same registry or rebuild the cluster, it will use the already locally cached images.</p> <pre><code>k3d cluster create cluster02 --registry-use k3d-docker-io:5000 --registry-config registry.yml\n</code></pre> </li> </ol>"},{"location":"usage/registries/#creating-a-registry-proxy-pull-through-registry-via-configfile","title":"Creating a registry proxy / pull-through registry via configfile","text":"<ol> <li> <p>Create a config file, e.g. <code>/home/me/test-regcache.yaml</code></p> <pre><code>apiVersion: k3d.io/v1alpha5\nkind: Simple\nmetadata:\n name: test-regcache\nregistries:\n create:\n name: docker-io # name of the registry container\n proxy:\n remoteURL: https://registry-1.docker.io # proxy DockerHub\n volumes:\n - /tmp/reg:/var/lib/registry # persist data locally in /tmp/reg\n config: | # tell K3s to use this registry when pulling from DockerHub\n mirrors:\n \"docker.io\":\n endpoint:\n - http://docker-io:5000\n</code></pre> </li> <li> <p>Create cluster from config:</p> <pre><code>k3d cluster create -c /home/me/test-regcache.yaml\n</code></pre> </li> </ol>"},{"location":"usage/advanced/calico/","title":"Use Calico instead of Flannel","text":"<p>Network Policies</p> <p>k3s comes with a controller that enforces network policies by default. You do not need to switch to Calico for network policies to be enforced. See https://github.com/k3s-io/k3s/issues/1308 for more information. The docs below assume you want to switch to Calico\u2019s policy engine, thus setting <code>--disable-network-policy</code>.</p>"},{"location":"usage/advanced/calico/#1-download-and-modify-the-calico-descriptor","title":"1. Download and modify the Calico descriptor","text":"<p>You can following the documentation</p> <p>And then you have to change the ConfigMap <code>calico-config</code>. On the <code>cni_network_config</code> add the entry for allowing IP forwarding </p> <pre><code>\"container_settings\": {\n \"allow_ip_forwarding\": true\n}\n</code></pre> <p>Or you can directly use this calico.yaml manifest</p>"},{"location":"usage/advanced/calico/#2-create-the-cluster-without-flannel-and-with-calico","title":"2. Create the cluster without flannel and with calico","text":"<p>On the k3s cluster creation :</p> <ul> <li>add the flags <code>--flannel-backend=none</code> and <code>--disable-network-policy</code>. For this, on k3d you need to forward this flag to k3s with the option <code>--k3s-arg</code>.</li> <li>mount (<code>--volume</code>) the calico descriptor in the auto deploy manifest directory of k3s <code>/var/lib/rancher/k3s/server/manifests/</code></li> </ul> <p>So the command of the cluster creation is (when you are at root of the k3d repository)</p> <pre><code>k3d cluster create \"${clustername}\" \\\n --k3s-arg '--flannel-backend=none@server:*' \\\n --k3s-arg '--disable-network-policy' \\\n --volume \"$(pwd)/docs/usage/guides/calico.yaml:/var/lib/rancher/k3s/server/manifests/calico.yaml\"\n</code></pre> <p>In this example :</p> <ul> <li>change <code>\"${clustername}\"</code> with the name of the cluster (or set a variable).</li> <li><code>$(pwd)/docs/usage/guides/calico.yaml</code> is the absolute path of the calico manifest, you can adapt it.</li> </ul> <p>You can add other options, see. </p> <p>The cluster will start without flannel and with Calico as CNI Plugin.</p> <p>For watching for the pod(s) deployment</p> <pre><code>watch \"kubectl get pods -n kube-system\" \n</code></pre> <p>You will have something like this at beginning (with the command line <code>kubectl get pods -n kube-system</code>)</p> <pre><code>NAME READY STATUS RESTARTS AGE\nhelm-install-traefik-pn84f 0/1 Pending 0 3s\ncalico-node-97rx8 0/1 Init:0/3 0 3s\nmetrics-server-7566d596c8-hwnqq 0/1 Pending 0 2s\ncalico-kube-controllers-58b656d69f-2z7cn 0/1 Pending 0 2s\nlocal-path-provisioner-6d59f47c7-rmswg 0/1 Pending 0 2s\ncoredns-8655855d6-cxtnr 0/1 Pending 0 2s\n</code></pre> <p>And when it finish to start</p> <pre><code>NAME READY STATUS RESTARTS AGE\nmetrics-server-7566d596c8-hwnqq 1/1 Running 0 56s\ncalico-node-97rx8 1/1 Running 0 57s\nhelm-install-traefik-pn84f 0/1 Completed 1 57s\nsvclb-traefik-lmjr5 2/2 Running 0 28s\ncalico-kube-controllers-58b656d69f-2z7cn 1/1 Running 0 56s\nlocal-path-provisioner-6d59f47c7-rmswg 1/1 Running 0 56s\ntraefik-758cd5fc85-x8p57 1/1 Running 0 28s\ncoredns-8655855d6-cxtnr 1/1 Running 0 56s\n</code></pre> <p>Note :</p> <ul> <li>you can use the auto deploy manifest or a kubectl apply depending on your needs</li> <li> Calico is not as quick as Flannel (but it provides more features)</li> </ul>"},{"location":"usage/advanced/calico/#references","title":"References","text":"<ul> <li>https://rancher.com/docs/k3s/latest/en/installation/network-options/ </li> <li>https://docs.projectcalico.org/getting-started/kubernetes/k3s/</li> </ul>"},{"location":"usage/advanced/cuda/","title":"Running CUDA workloads","text":"<p>If you want to run CUDA workloads on the K3s container you need to customize the container. CUDA workloads require the NVIDIA Container Runtime, so containerd needs to be configured to use this runtime. The K3s container itself also needs to run with this runtime. If you are using Docker you can install the NVIDIA Container Toolkit.</p>"},{"location":"usage/advanced/cuda/#building-a-customized-k3s-image","title":"Building a customized K3s image","text":"<p>To get the NVIDIA container runtime in the K3s image you need to build your own K3s image. The native K3s image is based on Alpine but the NVIDIA container runtime is not supported on Alpine yet. To get around this we need to build the image with a supported base image.</p>"},{"location":"usage/advanced/cuda/#dockerfile","title":"Dockerfile","text":"<p>Dockerfile: </p> <pre><code>ARG K3S_TAG=\"v1.21.2-k3s1\"\nFROM rancher/k3s:$K3S_TAG as k3s\n\nFROM nvidia/cuda:11.2.0-base-ubuntu18.04\n\nARG NVIDIA_CONTAINER_RUNTIME_VERSION\nENV NVIDIA_CONTAINER_RUNTIME_VERSION=$NVIDIA_CONTAINER_RUNTIME_VERSION\n\nRUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections\n\nRUN apt-get update &amp;&amp; \\\n apt-get -y install gnupg2 curl\n\n# Install NVIDIA Container Runtime\nRUN curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | apt-key add -\n\nRUN curl -s -L https://nvidia.github.io/nvidia-container-runtime/ubuntu18.04/nvidia-container-runtime.list | tee /etc/apt/sources.list.d/nvidia-container-runtime.list\n\nRUN apt-get update &amp;&amp; \\\n apt-get -y install nvidia-container-runtime=${NVIDIA_CONTAINER_RUNTIME_VERSION}\n\nCOPY --from=k3s / /\n\nRUN mkdir -p /etc &amp;&amp; \\\n echo 'hosts: files dns' &gt; /etc/nsswitch.conf\n\nRUN chmod 1777 /tmp\n\n# Provide custom containerd configuration to configure the nvidia-container-runtime\nRUN mkdir -p /var/lib/rancher/k3s/agent/etc/containerd/\n\nCOPY config.toml.tmpl /var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl\n\n# Deploy the nvidia driver plugin on startup\nRUN mkdir -p /var/lib/rancher/k3s/server/manifests\n\nCOPY device-plugin-daemonset.yaml /var/lib/rancher/k3s/server/manifests/nvidia-device-plugin-daemonset.yaml\n\nVOLUME /var/lib/kubelet\nVOLUME /var/lib/rancher/k3s\nVOLUME /var/lib/cni\nVOLUME /var/log\n\nENV PATH=\"$PATH:/bin/aux\"\n\nENTRYPOINT [\"/bin/k3s\"]\nCMD [\"agent\"]\n</code></pre> <p>This Dockerfile is based on the K3s Dockerfile The following changes are applied:</p> <ol> <li>Change the base images to nvidia/cuda:11.2.0-base-ubuntu18.04 so the NVIDIA Container Runtime can be installed. The version of <code>cuda:xx.x.x</code> must match the one you\u2019re planning to use.</li> <li>Add a custom containerd <code>config.toml</code> template to add the NVIDIA Container Runtime. This replaces the default <code>runc</code> runtime</li> <li>Add a manifest for the NVIDIA driver plugin for Kubernetes</li> </ol>"},{"location":"usage/advanced/cuda/#configure-containerd","title":"Configure containerd","text":"<p>We need to configure containerd to use the NVIDIA Container Runtime. We need to customize the config.toml that is used at startup. K3s provides a way to do this using a config.toml.tmpl file. More information can be found on the K3s site.</p> <pre><code>[plugins.opt]\n path = \"{{ .NodeConfig.Containerd.Opt }}\"\n\n[plugins.cri]\n stream_server_address = \"127.0.0.1\"\n stream_server_port = \"10010\"\n\n{{- if .IsRunningInUserNS }}\n disable_cgroup = true\n disable_apparmor = true\n restrict_oom_score_adj = true\n{{end}}\n\n{{- if .NodeConfig.AgentConfig.PauseImage }}\n sandbox_image = \"{{ .NodeConfig.AgentConfig.PauseImage }}\"\n{{end}}\n\n{{- if not .NodeConfig.NoFlannel }}\n[plugins.cri.cni]\n bin_dir = \"{{ .NodeConfig.AgentConfig.CNIBinDir }}\"\n conf_dir = \"{{ .NodeConfig.AgentConfig.CNIConfDir }}\"\n{{end}}\n\n[plugins.cri.containerd.runtimes.runc]\n # ---- changed from 'io.containerd.runc.v2' for GPU support\n runtime_type = \"io.containerd.runtime.v1.linux\"\n\n# ---- added for GPU support\n[plugins.linux]\n runtime = \"nvidia-container-runtime\"\n\n{{ if .PrivateRegistryConfig }}\n{{ if .PrivateRegistryConfig.Mirrors }}\n[plugins.cri.registry.mirrors]{{end}}\n{{range $k, $v := .PrivateRegistryConfig.Mirrors }}\n[plugins.cri.registry.mirrors.\"{{$k}}\"]\n endpoint = [{{range $i, $j := $v.Endpoints}}{{if $i}}, {{end}}{{printf \"%q\" .}}{{end}}]\n{{end}}\n\n{{range $k, $v := .PrivateRegistryConfig.Configs }}\n{{ if $v.Auth }}\n[plugins.cri.registry.configs.\"{{$k}}\".auth]\n {{ if $v.Auth.Username }}username = \"{{ $v.Auth.Username }}\"{{end}}\n {{ if $v.Auth.Password }}password = \"{{ $v.Auth.Password }}\"{{end}}\n {{ if $v.Auth.Auth }}auth = \"{{ $v.Auth.Auth }}\"{{end}}\n {{ if $v.Auth.IdentityToken }}identitytoken = \"{{ $v.Auth.IdentityToken }}\"{{end}}\n{{end}}\n{{ if $v.TLS }}\n[plugins.cri.registry.configs.\"{{$k}}\".tls]\n {{ if $v.TLS.CAFile }}ca_file = \"{{ $v.TLS.CAFile }}\"{{end}}\n {{ if $v.TLS.CertFile }}cert_file = \"{{ $v.TLS.CertFile }}\"{{end}}\n {{ if $v.TLS.KeyFile }}key_file = \"{{ $v.TLS.KeyFile }}\"{{end}}\n{{end}}\n{{end}}\n{{end}}\n</code></pre>"},{"location":"usage/advanced/cuda/#the-nvidia-device-plugin","title":"The NVIDIA device plugin","text":"<p>To enable NVIDIA GPU support on Kubernetes you also need to install the NVIDIA device plugin. The device plugin is a deamonset and allows you to automatically:</p> <ul> <li>Expose the number of GPUs on each nodes of your cluster</li> <li>Keep track of the health of your GPUs</li> <li>Run GPU enabled containers in your Kubernetes cluster.</li> </ul> <pre><code>apiVersion: apps/v1\nkind: DaemonSet\nmetadata:\n name: nvidia-device-plugin-daemonset\n namespace: kube-system\nspec:\n selector:\n matchLabels:\n name: nvidia-device-plugin-ds\n template:\n metadata:\n # Mark this pod as a critical add-on; when enabled, the critical add-on scheduler\n # reserves resources for critical add-on pods so that they can be rescheduled after\n # a failure. This annotation works in tandem with the toleration below.\n annotations:\n scheduler.alpha.kubernetes.io/critical-pod: \"\"\n labels:\n name: nvidia-device-plugin-ds\n spec:\n tolerations:\n # Allow this pod to be rescheduled while the node is in \"critical add-ons only\" mode.\n # This, along with the annotation above marks this pod as a critical add-on.\n - key: CriticalAddonsOnly\n operator: Exists\n containers:\n - env:\n - name: DP_DISABLE_HEALTHCHECKS\n value: xids\n image: nvidia/k8s-device-plugin:1.11\n name: nvidia-device-plugin-ctr\n securityContext:\n allowPrivilegeEscalation: true\n capabilities:\n drop: [\"ALL\"]\n volumeMounts:\n - name: device-plugin\n mountPath: /var/lib/kubelet/device-plugins\n volumes:\n - name: device-plugin\n hostPath:\n path: /var/lib/kubelet/device-plugins\n</code></pre>"},{"location":"usage/advanced/cuda/#build-the-k3s-image","title":"Build the K3s image","text":"<p>To build the custom image we need to build K3s because we need the generated output.</p> <p>Put the following files in a directory:</p> <ul> <li>Dockerfile</li> <li>config.toml.tmpl</li> <li>device-plugin-daemonset.yaml</li> <li>build.sh</li> <li>cuda-vector-add.yaml</li> </ul> <p>The <code>build.sh</code> script is configured using exports &amp; defaults to <code>v1.21.2+k3s1</code>. Please set at least the <code>IMAGE_REGISTRY</code> variable! The script performs the following steps builds the custom K3s image including the nvidia drivers.</p> <p>build.sh:</p> <pre><code>#!/bin/bash\n\nset -euxo pipefail\n\nK3S_TAG=${K3S_TAG:=\"v1.21.2-k3s1\"} # replace + with -, if needed\nIMAGE_REGISTRY=${IMAGE_REGISTRY:=\"MY_REGISTRY\"}\nIMAGE_REPOSITORY=${IMAGE_REPOSITORY:=\"rancher/k3s\"}\nIMAGE_TAG=\"$K3S_TAG-cuda\"\nIMAGE=${IMAGE:=\"$IMAGE_REGISTRY/$IMAGE_REPOSITORY:$IMAGE_TAG\"}\n\nNVIDIA_CONTAINER_RUNTIME_VERSION=${NVIDIA_CONTAINER_RUNTIME_VERSION:=\"3.5.0-1\"}\n\necho \"IMAGE=$IMAGE\"\n\n# due to some unknown reason, copying symlinks fails with buildkit enabled\nDOCKER_BUILDKIT=0 docker build \\\n --build-arg K3S_TAG=$K3S_TAG \\\n --build-arg NVIDIA_CONTAINER_RUNTIME_VERSION=$NVIDIA_CONTAINER_RUNTIME_VERSION \\\n -t $IMAGE .\ndocker push $IMAGE\necho \"Done!\"\n</code></pre>"},{"location":"usage/advanced/cuda/#run-and-test-the-custom-image-with-k3d","title":"Run and test the custom image with k3d","text":"<p>You can use the image with k3d:</p> <pre><code>k3d cluster create gputest --image=$IMAGE --gpus=1\n</code></pre> <p>Deploy a test pod:</p> <pre><code>kubectl apply -f cuda-vector-add.yaml\nkubectl logs cuda-vector-add\n</code></pre> <p>This should output something like the following:</p> <pre><code>$ kubectl logs cuda-vector-add\n\n[Vector addition of 50000 elements]\nCopy input data from the host memory to the CUDA device\nCUDA kernel launch with 196 blocks of 256 threads\nCopy output data from the CUDA device to the host memory\nTest PASSED\nDone\n</code></pre> <p>If the <code>cuda-vector-add</code> pod is stuck in <code>Pending</code> state, probably the device-driver daemonset didn\u2019t get deployed correctly from the auto-deploy manifests. In that case, you can apply it manually via <code>kubectl apply -f device-plugin-daemonset.yaml</code>.</p>"},{"location":"usage/advanced/cuda/#known-issues","title":"Known issues","text":"<ul> <li>This approach does not work on WSL2 yet. The NVIDIA driver plugin and container runtime rely on the NVIDIA Management Library (NVML) which is not yet supported. See the CUDA on WSL User Guide.</li> </ul>"},{"location":"usage/advanced/cuda/#acknowledgements","title":"Acknowledgements","text":"<p>Most of the information in this article was obtained from various sources:</p> <ul> <li>Add NVIDIA GPU support to k3s with containerd</li> <li>microk8s</li> <li>K3s</li> <li>k3s-gpu</li> </ul>"},{"location":"usage/advanced/cuda/#authors","title":"Authors","text":"<ul> <li>@markrexwinkel</li> <li>@vainkop</li> <li>@iwilltry42</li> </ul>"},{"location":"usage/advanced/podman/","title":"Using Podman instead of Docker","text":"<p>Podman has an Docker API compatibility layer. k3d uses the Docker API and is compatible with Podman v4 and higher.</p> <p>Podman support is experimental</p> <p>k3d is not guaranteed to work with Podman. If you find a bug, do help by filing an issue</p> <p>Tested with podman version: <pre><code>Client: Podman Engine\nVersion: 4.3.1\nAPI Version: 4.3.1\n</code></pre></p>"},{"location":"usage/advanced/podman/#using-podman","title":"Using Podman","text":"<p>Ensure the Podman system socket is available:</p> <pre><code>sudo systemctl enable --now podman.socket\n# or to start the socket daemonless\n# sudo podman system service --time=0 &amp;\n</code></pre> <p>Disable timeout for podman service: See the podman-system-service (1) man page for more information. <pre><code>mkdir -p /etc/containers/containers.conf.d\necho 'service_timeout=0' &gt; /etc/containers/containers.conf.d/timeout.conf\n</code></pre></p> <p>To point k3d at the right Docker socket, create a symbolic link:</p> <pre><code>sudo ln -s /run/podman/podman.sock /var/run/docker.sock\n# or install your system podman-docker if available\nsudo k3d cluster create\n</code></pre> <p>Alternatively, set <code>DOCKER_HOST</code> when running k3d:</p> <pre><code>export DOCKER_HOST=unix:///run/podman/podman.sock\nexport DOCKER_SOCK=/run/podman/podman.sock\nsudo --preserve-env=DOCKER_HOST --preserve-env=DOCKER_SOCK k3d cluster create\n</code></pre>"},{"location":"usage/advanced/podman/#using-rootless-podman","title":"Using rootless Podman","text":"<p>Ensure the Podman user socket is available:</p> <pre><code>systemctl --user enable --now podman.socket\n# or podman system service --time=0 &amp;\n</code></pre> <p>Set <code>DOCKER_HOST</code> when running k3d:</p> <pre><code>XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/run/user/$(id -u)}\nexport DOCKER_HOST=unix://$XDG_RUNTIME_DIR/podman/podman.sock\nexport DOCKER_SOCK=$XDG_RUNTIME_DIR/podman/podman.sock\nk3d cluster create\n</code></pre>"},{"location":"usage/advanced/podman/#using-cgroup-v2","title":"Using cgroup (v2)","text":"<p>By default, a non-root user can only get memory controller and pids controller to be delegated.</p> <p>To run properly we need to enable CPU, CPUSET, and I/O delegation</p> <p>Make sure you\u2019re running cgroup v2</p> <p>If <code>/sys/fs/cgroup/cgroup.controllers</code> is present on your system, you are using v2, otherwise you are using v1.</p> <pre><code>mkdir -p /etc/systemd/system/user@.service.d\ncat &gt; /etc/systemd/system/user@.service.d/delegate.conf &lt;&lt;EOF\n[Service]\nDelegate=cpu cpuset io memory pids\nEOF\nsystemctl daemon-reload\n</code></pre> <p>Reference: https://rootlesscontaine.rs/getting-started/common/cgroup2/#enabling-cpu-cpuset-and-io-delegation</p>"},{"location":"usage/advanced/podman/#using-remote-podman","title":"Using remote Podman","text":"<p>Start Podman on the remote host, and then set <code>DOCKER_HOST</code> when running k3d:</p> <pre><code>export DOCKER_HOST=ssh://username@hostname\nexport DOCKER_SOCK=/run/user/1000/podman/podman.sock\nk3d cluster create\n</code></pre>"},{"location":"usage/advanced/podman/#macos","title":"macOS","text":"<p>Initialize a podman machine if not done already</p> <pre><code>podman machine init\n</code></pre> <p>Or start an already existing podman machine</p> <pre><code>podman machine start\n</code></pre> <p>Grab connection details </p> <pre><code>podman system connection ls\nName URI Identity Default\npodman-machine-default ssh://core@localhost:53685/run/user/501/podman/podman.sock /Users/myusername/.ssh/podman-machine-default true\npodman-machine-default-root ssh://root@localhost:53685/run/podman/podman.sock /Users/myusername/.ssh/podman-machine-default false\n</code></pre> <p>Edit your OpenSSH config file to specify the IdentityFile</p> <pre><code>vim ~/.ssh/config\n\nHost localhost\n IdentityFile /Users/myusername/.ssh/podman-machine-default\n</code></pre>"},{"location":"usage/advanced/podman/#rootless-mode","title":"Rootless mode","text":"<p>Delegate the <code>cpuset</code> cgroup controller to the user\u2019s systemd slice, export the docker environment variables referenced above for the non-root connection, and create the cluster:</p> <pre><code>podman machine ssh bash -e &lt;&lt;EOF\n printf '[Service]\\nDelegate=cpuset\\n' | sudo tee /etc/systemd/system/user@.service.d/k3d.conf\n sudo systemctl daemon-reload\n sudo systemctl restart \"user@\\${UID}\"\nEOF\n\nexport DOCKER_HOST=ssh://core@localhost:53685\nexport DOCKER_SOCKET=/run/user/501/podman/podman.sock\nk3d cluster create --k3s-arg '--kubelet-arg=feature-gates=KubeletInUserNamespace=true@server:*'\n</code></pre>"},{"location":"usage/advanced/podman/#rootful-mode","title":"Rootful mode","text":"<p>Export the docker environment variables referenced above for the root connection and create the cluster:</p> <pre><code>export DOCKER_HOST=ssh://root@localhost:53685\nexport DOCKER_SOCK=/run/podman/podman.sock\nk3d cluster create\n</code></pre>"},{"location":"usage/advanced/podman/#podman-network","title":"Podman network","text":"<p>The default <code>podman</code> network has dns disabled. To allow k3d cluster nodes to communicate with dns a new network must be created. <pre><code>podman network create k3d\npodman network inspect k3d -f '{{ .DNSEnabled }}'\ntrue\n</code></pre></p>"},{"location":"usage/advanced/podman/#creating-local-registries","title":"Creating local registries","text":"<p>Because Podman does not have a default \u201cbridge\u201d network, you have to specify a network using the <code>--default-network</code> flag when creating a local registry:</p> <pre><code>k3d registry create --default-network podman mycluster-registry\n</code></pre> <p>To use this registry with a cluster, pass the <code>--registry-use</code> flag:</p> <pre><code>k3d cluster create --registry-use mycluster-registry mycluster\n</code></pre> <p>Incompatibility with <code>--registry-create</code></p> <p>Because <code>--registry-create</code> assumes the default network to be \u201cbridge\u201d, avoid <code>--registry-create</code> when using Podman. Instead, always create a registry before creating a cluster.</p> <p>Missing cpuset cgroup controller</p> <p>If you experince an error regarding missing cpuset cgroup controller, ensure the user unit <code>xdg-document-portal.service</code> is disabled by running <code>systemctl --user stop xdg-document-portal.service</code>. See this issue</p>"},{"location":"usage/commands/k3d/","title":"K3d","text":""},{"location":"usage/commands/k3d/#k3d","title":"k3d","text":"<p>https://k3d.io/ -&gt; Run k3s in Docker!</p>"},{"location":"usage/commands/k3d/#synopsis","title":"Synopsis","text":"<p>https://k3d.io/ k3d is a wrapper CLI that helps you to easily create k3s clusters inside docker. Nodes of a k3d cluster are docker containers running a k3s image. All Nodes of a k3d cluster are part of the same docker network.</p> <pre><code>k3d [flags]\n</code></pre>"},{"location":"usage/commands/k3d/#options","title":"Options","text":"<pre><code> -h, --help help for k3d\n --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n --version Show k3d and default k3s version\n</code></pre>"},{"location":"usage/commands/k3d/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d cluster - Manage cluster(s)</li> <li>k3d completion - Generate completion scripts for [bash, zsh, fish, powershell | psh]</li> <li>k3d config - Work with config file(s)</li> <li>k3d image - Handle container images.</li> <li>k3d kubeconfig - Manage kubeconfig(s)</li> <li>k3d node - Manage node(s)</li> <li>k3d registry - Manage registry/registries</li> <li>k3d version - Show k3d and default k3s version</li> </ul>"},{"location":"usage/commands/k3d_cluster/","title":"K3d cluster","text":""},{"location":"usage/commands/k3d_cluster/#k3d-cluster","title":"k3d cluster","text":"<p>Manage cluster(s)</p>"},{"location":"usage/commands/k3d_cluster/#synopsis","title":"Synopsis","text":"<p>Manage cluster(s)</p> <pre><code>k3d cluster [flags]\n</code></pre>"},{"location":"usage/commands/k3d_cluster/#options","title":"Options","text":"<pre><code> -h, --help help for cluster\n</code></pre>"},{"location":"usage/commands/k3d_cluster/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_cluster/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d - https://k3d.io/ -&gt; Run k3s in Docker!</li> <li>k3d cluster create - Create a new cluster</li> <li>k3d cluster delete - Delete cluster(s).</li> <li>k3d cluster edit - [EXPERIMENTAL] Edit cluster(s).</li> <li>k3d cluster list - List cluster(s)</li> <li>k3d cluster start - Start existing k3d cluster(s)</li> <li>k3d cluster stop - Stop existing k3d cluster(s)</li> </ul>"},{"location":"usage/commands/k3d_cluster_create/","title":"K3d cluster create","text":""},{"location":"usage/commands/k3d_cluster_create/#k3d-cluster-create","title":"k3d cluster create","text":"<p>Create a new cluster</p>"},{"location":"usage/commands/k3d_cluster_create/#synopsis","title":"Synopsis","text":"<p>Create a new k3s cluster with containerized nodes (k3s in docker). Every cluster will consist of one or more containers:</p> <ul> <li>1 (or more) server node container (k3s)</li> <li>(optionally) 1 loadbalancer container as the entrypoint to the cluster (nginx)</li> <li>(optionally) 1 (or more) agent node containers (k3s)</li> </ul> <pre><code>k3d cluster create NAME [flags]\n</code></pre>"},{"location":"usage/commands/k3d_cluster_create/#options","title":"Options","text":"<pre><code> -a, --agents int Specify how many agents you want to create\n --agents-memory string Memory limit imposed on the agents nodes [From docker]\n --api-port [HOST:]HOSTPORT Specify the Kubernetes API server port exposed on the LoadBalancer (Format: [HOST:]HOSTPORT)\n - Example: `k3d cluster create --servers 3 --api-port 0.0.0.0:6550`\n -c, --config string Path of a config file to use\n -e, --env KEY[=VALUE][@NODEFILTER[;NODEFILTER...]] Add environment variables to nodes (Format: KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]\n - Example: `k3d cluster create --agents 2 -e \"HTTP_PROXY=my.proxy.com@server:0\" -e \"SOME_KEY=SOME_VAL@server:0\"`\n --gpus string GPU devices to add to the cluster node containers ('all' to pass all GPUs) [From docker]\n -h, --help help for create\n --host-alias ip:host[,host,...] Add ip:host[,host,...] mappings\n --host-pid-mode Enable host pid mode of server(s) and agent(s)\n -i, --image string Specify k3s image that you want to use for the nodes\n --k3s-arg ARG@NODEFILTER[;@NODEFILTER] Additional args passed to k3s command (Format: ARG@NODEFILTER[;@NODEFILTER])\n - Example: `k3d cluster create --k3s-arg \"--disable=traefik@server:0\"`\n --k3s-node-label KEY[=VALUE][@NODEFILTER[;NODEFILTER...]] Add label to k3s node (Format: KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]\n - Example: `k3d cluster create --agents 2 --k3s-node-label \"my.label@agent:0,1\" --k3s-node-label \"other.label=somevalue@server:0\"`\n --kubeconfig-switch-context Directly switch the default kubeconfig's current-context to the new cluster's context (requires --kubeconfig-update-default) (default true)\n --kubeconfig-update-default Directly update the default kubeconfig with the new cluster's context (default true)\n --lb-config-override strings Use dotted YAML path syntax to override nginx loadbalancer settings\n --network string Join an existing network\n --no-image-volume Disable the creation of a volume for importing images\n --no-lb Disable the creation of a LoadBalancer in front of the server nodes\n --no-rollback Disable the automatic rollback actions, if anything goes wrong\n -p, --port [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER] Map ports from the node containers (via the serverlb) to the host (Format: [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER])\n - Example: `k3d cluster create --agents 2 -p 8080:80@agent:0 -p 8081@agent:1`\n --registry-config string Specify path to an extra registries.yaml file\n --registry-create NAME[:HOST][:HOSTPORT] Create a k3d-managed registry and connect it to the cluster (Format: NAME[:HOST][:HOSTPORT]\n - Example: `k3d cluster create --registry-create mycluster-registry:0.0.0.0:5432`\n --registry-use stringArray Connect to one or more k3d-managed registries running locally\n --runtime-label KEY[=VALUE][@NODEFILTER[;NODEFILTER...]] Add label to container runtime (Format: KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]\n - Example: `k3d cluster create --agents 2 --runtime-label \"my.label@agent:0,1\" --runtime-label \"other.label=somevalue@server:0\"`\n --runtime-ulimit NAME[=SOFT]:[HARD] Add ulimit to container runtime (Format: NAME[=SOFT]:[HARD]\n - Example: `k3d cluster create --agents 2 --runtime-ulimit \"nofile=1024:1024\" --runtime-ulimit \"noproc=1024:1024\"`\n -s, --servers int Specify how many servers you want to create\n --servers-memory string Memory limit imposed on the server nodes [From docker]\n --subnet 172.28.0.0/16 [Experimental: IPAM] Define a subnet for the newly created container network (Example: 172.28.0.0/16)\n --timeout duration Rollback changes if cluster couldn't be created in specified duration.\n --token string Specify a cluster token. By default, we generate one.\n -v, --volume [SOURCE:]DEST[@NODEFILTER[;NODEFILTER...]] Mount volumes into the nodes (Format: [SOURCE:]DEST[@NODEFILTER[;NODEFILTER...]]\n - Example: `k3d cluster create --agents 2 -v /my/path@agent:0,1 -v /tmp/test:/tmp/other@server:0`\n --wait Wait for the server(s) to be ready before returning. Use '--timeout DURATION' to not wait forever. (default true)\n</code></pre>"},{"location":"usage/commands/k3d_cluster_create/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_cluster_create/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d cluster - Manage cluster(s)</li> </ul>"},{"location":"usage/commands/k3d_cluster_delete/","title":"K3d cluster delete","text":""},{"location":"usage/commands/k3d_cluster_delete/#k3d-cluster-delete","title":"k3d cluster delete","text":"<p>Delete cluster(s).</p>"},{"location":"usage/commands/k3d_cluster_delete/#synopsis","title":"Synopsis","text":"<p>Delete cluster(s).</p> <pre><code>k3d cluster delete [NAME [NAME ...] | --all] [flags]\n</code></pre>"},{"location":"usage/commands/k3d_cluster_delete/#options","title":"Options","text":"<pre><code> -a, --all Delete all existing clusters\n -c, --config string Path of a config file to use\n -h, --help help for delete\n</code></pre>"},{"location":"usage/commands/k3d_cluster_delete/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_cluster_delete/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d cluster - Manage cluster(s)</li> </ul>"},{"location":"usage/commands/k3d_cluster_edit/","title":"K3d cluster edit","text":""},{"location":"usage/commands/k3d_cluster_edit/#k3d-cluster-edit","title":"k3d cluster edit","text":"<p>[EXPERIMENTAL] Edit cluster(s).</p>"},{"location":"usage/commands/k3d_cluster_edit/#synopsis","title":"Synopsis","text":"<p>[EXPERIMENTAL] Edit cluster(s).</p> <pre><code>k3d cluster edit CLUSTER [flags]\n</code></pre>"},{"location":"usage/commands/k3d_cluster_edit/#options","title":"Options","text":"<pre><code> -h, --help help for edit\n --port-add [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER] [EXPERIMENTAL] Map ports from the node containers (via the serverlb) to the host (Format: [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER])\n - Example: `k3d node edit k3d-mycluster-serverlb --port-add 8080:80`\n</code></pre>"},{"location":"usage/commands/k3d_cluster_edit/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_cluster_edit/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d cluster - Manage cluster(s)</li> </ul>"},{"location":"usage/commands/k3d_cluster_list/","title":"K3d cluster list","text":""},{"location":"usage/commands/k3d_cluster_list/#k3d-cluster-list","title":"k3d cluster list","text":"<p>List cluster(s)</p>"},{"location":"usage/commands/k3d_cluster_list/#synopsis","title":"Synopsis","text":"<p>List cluster(s).</p> <pre><code>k3d cluster list [NAME [NAME...]] [flags]\n</code></pre>"},{"location":"usage/commands/k3d_cluster_list/#options","title":"Options","text":"<pre><code> -h, --help help for list\n --no-headers Disable headers\n -o, --output string Output format. One of: json|yaml\n --token Print k3s cluster token\n</code></pre>"},{"location":"usage/commands/k3d_cluster_list/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_cluster_list/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d cluster - Manage cluster(s)</li> </ul>"},{"location":"usage/commands/k3d_cluster_start/","title":"K3d cluster start","text":""},{"location":"usage/commands/k3d_cluster_start/#k3d-cluster-start","title":"k3d cluster start","text":"<p>Start existing k3d cluster(s)</p>"},{"location":"usage/commands/k3d_cluster_start/#synopsis","title":"Synopsis","text":"<p>Start existing k3d cluster(s)</p> <pre><code>k3d cluster start [NAME [NAME...] | --all] [flags]\n</code></pre>"},{"location":"usage/commands/k3d_cluster_start/#options","title":"Options","text":"<pre><code> -a, --all Start all existing clusters\n -h, --help help for start\n --timeout duration Maximum waiting time for '--wait' before canceling/returning.\n --wait Wait for the server(s) (and loadbalancer) to be ready before returning. (default true)\n</code></pre>"},{"location":"usage/commands/k3d_cluster_start/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_cluster_start/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d cluster - Manage cluster(s)</li> </ul>"},{"location":"usage/commands/k3d_cluster_stop/","title":"K3d cluster stop","text":""},{"location":"usage/commands/k3d_cluster_stop/#k3d-cluster-stop","title":"k3d cluster stop","text":"<p>Stop existing k3d cluster(s)</p>"},{"location":"usage/commands/k3d_cluster_stop/#synopsis","title":"Synopsis","text":"<p>Stop existing k3d cluster(s).</p> <pre><code>k3d cluster stop [NAME [NAME...] | --all] [flags]\n</code></pre>"},{"location":"usage/commands/k3d_cluster_stop/#options","title":"Options","text":"<pre><code> -a, --all Stop all existing clusters\n -h, --help help for stop\n</code></pre>"},{"location":"usage/commands/k3d_cluster_stop/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_cluster_stop/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d cluster - Manage cluster(s)</li> </ul>"},{"location":"usage/commands/k3d_completion/","title":"K3d completion","text":""},{"location":"usage/commands/k3d_completion/#k3d-completion","title":"k3d completion","text":"<p>Generate completion scripts for [bash, zsh, fish, powershell | psh]</p>"},{"location":"usage/commands/k3d_completion/#synopsis","title":"Synopsis","text":"<p>To load completions:</p> <p>Bash:</p> <pre><code>$ source &lt;(k3d completion bash)\n\n# To load completions for each session, execute once:\n# Linux:\n$ k3d completion bash &gt; /etc/bash_completion.d/k3d\n# macOS:\n$ k3d completion bash &gt; /usr/local/etc/bash_completion.d/k3d\n</code></pre> <p>Zsh:</p> <pre><code># If shell completion is not already enabled in your environment,\n# you will need to enable it. You can execute the following once:\n\n$ echo \"autoload -U compinit; compinit\" &gt;&gt; ~/.zshrc\n\n# To load completions for each session, execute once:\n$ k3d completion zsh &gt; \"${fpath[1]}/_k3d\"\n\n# You will need to start a new shell for this setup to take effect.\n</code></pre> <p>fish:</p> <pre><code>$ k3d completion fish | source\n\n# To load completions for each session, execute once:\n$ k3d completion fish &gt; ~/.config/fish/completions/k3d.fish\n</code></pre> <p>PowerShell:</p> <pre><code>PS&gt; k3d completion powershell | Out-String | Invoke-Expression\n\n# To load completions for every new session, run:\nPS&gt; k3d completion powershell &gt; k3d.ps1\n# and source this file from your PowerShell profile.\n</code></pre> <pre><code>k3d completion SHELL\n</code></pre>"},{"location":"usage/commands/k3d_completion/#options","title":"Options","text":"<pre><code> -h, --help help for completion\n</code></pre>"},{"location":"usage/commands/k3d_completion/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_completion/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d - https://k3d.io/ -&gt; Run k3s in Docker!</li> </ul>"},{"location":"usage/commands/k3d_config/","title":"K3d config","text":""},{"location":"usage/commands/k3d_config/#k3d-config","title":"k3d config","text":"<p>Work with config file(s)</p>"},{"location":"usage/commands/k3d_config/#synopsis","title":"Synopsis","text":"<p>Work with config file(s)</p> <pre><code>k3d config [flags]\n</code></pre>"},{"location":"usage/commands/k3d_config/#options","title":"Options","text":"<pre><code> -h, --help help for config\n</code></pre>"},{"location":"usage/commands/k3d_config/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_config/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d - https://k3d.io/ -&gt; Run k3s in Docker!</li> <li>k3d config init - </li> <li>k3d config migrate - </li> </ul>"},{"location":"usage/commands/k3d_config_init/","title":"K3d config init","text":""},{"location":"usage/commands/k3d_config_init/#k3d-config-init","title":"k3d config init","text":"<pre><code>k3d config init [flags]\n</code></pre>"},{"location":"usage/commands/k3d_config_init/#options","title":"Options","text":"<pre><code> -f, --force Force overwrite of target file\n -h, --help help for init\n -o, --output string Write a default k3d config (default \"k3d-default.yaml\")\n</code></pre>"},{"location":"usage/commands/k3d_config_init/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_config_init/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d config - Work with config file(s)</li> </ul>"},{"location":"usage/commands/k3d_config_migrate/","title":"K3d config migrate","text":""},{"location":"usage/commands/k3d_config_migrate/#k3d-config-migrate","title":"k3d config migrate","text":"<pre><code>k3d config migrate INPUT [OUTPUT] [flags]\n</code></pre>"},{"location":"usage/commands/k3d_config_migrate/#options","title":"Options","text":"<pre><code> -h, --help help for migrate\n</code></pre>"},{"location":"usage/commands/k3d_config_migrate/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_config_migrate/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d config - Work with config file(s)</li> </ul>"},{"location":"usage/commands/k3d_image/","title":"K3d image","text":""},{"location":"usage/commands/k3d_image/#k3d-image","title":"k3d image","text":"<p>Handle container images.</p>"},{"location":"usage/commands/k3d_image/#synopsis","title":"Synopsis","text":"<p>Handle container images.</p> <pre><code>k3d image [flags]\n</code></pre>"},{"location":"usage/commands/k3d_image/#options","title":"Options","text":"<pre><code> -h, --help help for image\n</code></pre>"},{"location":"usage/commands/k3d_image/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_image/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d - https://k3d.io/ -&gt; Run k3s in Docker!</li> <li>k3d image import - Import image(s) from docker into k3d cluster(s).</li> </ul>"},{"location":"usage/commands/k3d_image_import/","title":"K3d image import","text":""},{"location":"usage/commands/k3d_image_import/#k3d-image-import","title":"k3d image import","text":"<p>Import image(s) from docker into k3d cluster(s).</p>"},{"location":"usage/commands/k3d_image_import/#synopsis","title":"Synopsis","text":"<p>Import image(s) from docker into k3d cluster(s).</p> <p>If an IMAGE starts with the prefix \u2018docker.io/\u2019, then this prefix is stripped internally. That is, \u2018docker.io/k3d-io/k3d-tools:latest\u2019 is treated as \u2018k3d-io/k3d-tools:latest\u2019.</p> <p>If an IMAGE starts with the prefix \u2018library/\u2019 (or \u2018docker.io/library/\u2019), then this prefix is stripped internally. That is, \u2018library/busybox:latest\u2019 (or \u2018docker.io/library/busybox:latest\u2019) are treated as \u2018busybox:latest\u2019.</p> <p>If an IMAGE does not have a version tag, then \u2018:latest\u2019 is assumed. That is, \u2018k3d-io/k3d-tools\u2019 is treated as \u2018k3d-io/k3d-tools:latest\u2019.</p> <p>A file ARCHIVE always takes precedence. So if a file \u2018./k3d-io/k3d-tools\u2019 exists, k3d will try to import it instead of the IMAGE of the same name.</p> <pre><code>k3d image import [IMAGE | ARCHIVE [IMAGE | ARCHIVE...]] [flags]\n</code></pre>"},{"location":"usage/commands/k3d_image_import/#options","title":"Options","text":"<pre><code> -c, --cluster stringArray Select clusters to load the image to. (default [k3s-default])\n -h, --help help for import\n -k, --keep-tarball Do not delete the tarball containing the saved images from the shared volume\n -t, --keep-tools Do not delete the tools node after import\n -m, --mode string Which method to use to import images into the cluster [auto, direct, tools]. See https://k3d.io/stable/usage/importing_images/ (default \"tools-node\")\n</code></pre>"},{"location":"usage/commands/k3d_image_import/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_image_import/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d image - Handle container images.</li> </ul>"},{"location":"usage/commands/k3d_kubeconfig/","title":"K3d kubeconfig","text":""},{"location":"usage/commands/k3d_kubeconfig/#k3d-kubeconfig","title":"k3d kubeconfig","text":"<p>Manage kubeconfig(s)</p>"},{"location":"usage/commands/k3d_kubeconfig/#synopsis","title":"Synopsis","text":"<p>Manage kubeconfig(s)</p> <pre><code>k3d kubeconfig [flags]\n</code></pre>"},{"location":"usage/commands/k3d_kubeconfig/#options","title":"Options","text":"<pre><code> -h, --help help for kubeconfig\n</code></pre>"},{"location":"usage/commands/k3d_kubeconfig/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_kubeconfig/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d - https://k3d.io/ -&gt; Run k3s in Docker!</li> <li>k3d kubeconfig get - Print kubeconfig(s) from cluster(s).</li> <li>k3d kubeconfig merge - Write/Merge kubeconfig(s) from cluster(s) into new or existing kubeconfig/file.</li> </ul>"},{"location":"usage/commands/k3d_kubeconfig_get/","title":"K3d kubeconfig get","text":""},{"location":"usage/commands/k3d_kubeconfig_get/#k3d-kubeconfig-get","title":"k3d kubeconfig get","text":"<p>Print kubeconfig(s) from cluster(s).</p>"},{"location":"usage/commands/k3d_kubeconfig_get/#synopsis","title":"Synopsis","text":"<p>Print kubeconfig(s) from cluster(s).</p> <pre><code>k3d kubeconfig get [CLUSTER [CLUSTER [...]] | --all] [flags]\n</code></pre>"},{"location":"usage/commands/k3d_kubeconfig_get/#options","title":"Options","text":"<pre><code> -a, --all Output kubeconfigs from all existing clusters\n -h, --help help for get\n</code></pre>"},{"location":"usage/commands/k3d_kubeconfig_get/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_kubeconfig_get/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d kubeconfig - Manage kubeconfig(s)</li> </ul>"},{"location":"usage/commands/k3d_kubeconfig_merge/","title":"K3d kubeconfig merge","text":""},{"location":"usage/commands/k3d_kubeconfig_merge/#k3d-kubeconfig-merge","title":"k3d kubeconfig merge","text":"<p>Write/Merge kubeconfig(s) from cluster(s) into new or existing kubeconfig/file.</p>"},{"location":"usage/commands/k3d_kubeconfig_merge/#synopsis","title":"Synopsis","text":"<p>Write/Merge kubeconfig(s) from cluster(s) into new or existing kubeconfig/file.</p> <pre><code>k3d kubeconfig merge [CLUSTER [CLUSTER [...]] | --all] [flags]\n</code></pre>"},{"location":"usage/commands/k3d_kubeconfig_merge/#options","title":"Options","text":"<pre><code> -a, --all Get kubeconfigs from all existing clusters\n -h, --help help for merge\n -d, --kubeconfig-merge-default Merge into the default kubeconfig ($KUBECONFIG or /home/thklein/.kube/config)\n -s, --kubeconfig-switch-context Switch to new context (default true)\n -o, --output string Define output [ - | FILE ] (default from $KUBECONFIG or /home/thklein/.kube/config\n --overwrite [Careful!] Overwrite existing file, ignoring its contents\n -u, --update Update conflicting fields in existing kubeconfig (default true)\n</code></pre>"},{"location":"usage/commands/k3d_kubeconfig_merge/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_kubeconfig_merge/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d kubeconfig - Manage kubeconfig(s)</li> </ul>"},{"location":"usage/commands/k3d_node/","title":"K3d node","text":""},{"location":"usage/commands/k3d_node/#k3d-node","title":"k3d node","text":"<p>Manage node(s)</p>"},{"location":"usage/commands/k3d_node/#synopsis","title":"Synopsis","text":"<p>Manage node(s)</p> <pre><code>k3d node [flags]\n</code></pre>"},{"location":"usage/commands/k3d_node/#options","title":"Options","text":"<pre><code> -h, --help help for node\n</code></pre>"},{"location":"usage/commands/k3d_node/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_node/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d - https://k3d.io/ -&gt; Run k3s in Docker!</li> <li>k3d node create - Create a new k3s node in docker</li> <li>k3d node delete - Delete node(s).</li> <li>k3d node edit - [EXPERIMENTAL] Edit node(s).</li> <li>k3d node list - List node(s)</li> <li>k3d node start - Start an existing k3d node</li> <li>k3d node stop - Stop an existing k3d node</li> </ul>"},{"location":"usage/commands/k3d_node_create/","title":"K3d node create","text":""},{"location":"usage/commands/k3d_node_create/#k3d-node-create","title":"k3d node create","text":"<p>Create a new k3s node in docker</p>"},{"location":"usage/commands/k3d_node_create/#synopsis","title":"Synopsis","text":"<p>Create a new containerized k3s node (k3s in docker).</p> <pre><code>k3d node create NAME [flags]\n</code></pre>"},{"location":"usage/commands/k3d_node_create/#options","title":"Options","text":"<pre><code> -c, --cluster string Cluster URL or k3d cluster name to connect to. (default \"k3s-default\")\n -h, --help help for create\n -i, --image string Specify k3s image used for the node(s) (default: copied from existing node)\n --k3s-arg stringArray Additional args passed to k3d command\n --k3s-node-label strings Specify k3s node labels in format \"foo=bar\"\n --memory string Memory limit imposed on the node [From docker]\n -n, --network strings Add node to (another) runtime network\n --replicas int Number of replicas of this node specification. (default 1)\n --role string Specify node role [server, agent] (default \"agent\")\n --runtime-label strings Specify container runtime labels in format \"foo=bar\"\n --runtime-ulimit strings Specify container runtime ulimit in format \"ulimit=soft:hard\"\n --timeout duration Maximum waiting time for '--wait' before canceling/returning.\n -t, --token string Override cluster token (required when connecting to an external cluster)\n --wait Wait for the node(s) to be ready before returning. (default true)\n</code></pre>"},{"location":"usage/commands/k3d_node_create/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_node_create/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d node - Manage node(s)</li> </ul>"},{"location":"usage/commands/k3d_node_delete/","title":"K3d node delete","text":""},{"location":"usage/commands/k3d_node_delete/#k3d-node-delete","title":"k3d node delete","text":"<p>Delete node(s).</p>"},{"location":"usage/commands/k3d_node_delete/#synopsis","title":"Synopsis","text":"<p>Delete node(s).</p> <pre><code>k3d node delete (NAME | --all) [flags]\n</code></pre>"},{"location":"usage/commands/k3d_node_delete/#options","title":"Options","text":"<pre><code> -a, --all Delete all existing nodes\n -h, --help help for delete\n -r, --registries Also delete registries\n</code></pre>"},{"location":"usage/commands/k3d_node_delete/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_node_delete/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d node - Manage node(s)</li> </ul>"},{"location":"usage/commands/k3d_node_edit/","title":"K3d node edit","text":""},{"location":"usage/commands/k3d_node_edit/#k3d-node-edit","title":"k3d node edit","text":"<p>[EXPERIMENTAL] Edit node(s).</p>"},{"location":"usage/commands/k3d_node_edit/#synopsis","title":"Synopsis","text":"<p>[EXPERIMENTAL] Edit node(s).</p> <pre><code>k3d node edit NODE [flags]\n</code></pre>"},{"location":"usage/commands/k3d_node_edit/#options","title":"Options","text":"<pre><code> -h, --help help for edit\n --port-add [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER] [EXPERIMENTAL] (serverlb only!) Map ports from the node container to the host (Format: [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER])\n - Example: `k3d node edit k3d-mycluster-serverlb --port-add 8080:80`\n</code></pre>"},{"location":"usage/commands/k3d_node_edit/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_node_edit/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d node - Manage node(s)</li> </ul>"},{"location":"usage/commands/k3d_node_list/","title":"K3d node list","text":""},{"location":"usage/commands/k3d_node_list/#k3d-node-list","title":"k3d node list","text":"<p>List node(s)</p>"},{"location":"usage/commands/k3d_node_list/#synopsis","title":"Synopsis","text":"<p>List node(s).</p> <pre><code>k3d node list [NODE [NODE...]] [flags]\n</code></pre>"},{"location":"usage/commands/k3d_node_list/#options","title":"Options","text":"<pre><code> -h, --help help for list\n --no-headers Disable headers\n -o, --output string Output format. One of: json|yaml\n</code></pre>"},{"location":"usage/commands/k3d_node_list/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_node_list/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d node - Manage node(s)</li> </ul>"},{"location":"usage/commands/k3d_node_start/","title":"K3d node start","text":""},{"location":"usage/commands/k3d_node_start/#k3d-node-start","title":"k3d node start","text":"<p>Start an existing k3d node</p>"},{"location":"usage/commands/k3d_node_start/#synopsis","title":"Synopsis","text":"<p>Start an existing k3d node.</p> <pre><code>k3d node start NODE [flags]\n</code></pre>"},{"location":"usage/commands/k3d_node_start/#options","title":"Options","text":"<pre><code> -h, --help help for start\n</code></pre>"},{"location":"usage/commands/k3d_node_start/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_node_start/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d node - Manage node(s)</li> </ul>"},{"location":"usage/commands/k3d_node_stop/","title":"K3d node stop","text":""},{"location":"usage/commands/k3d_node_stop/#k3d-node-stop","title":"k3d node stop","text":"<p>Stop an existing k3d node</p>"},{"location":"usage/commands/k3d_node_stop/#synopsis","title":"Synopsis","text":"<p>Stop an existing k3d node.</p> <pre><code>k3d node stop NAME [flags]\n</code></pre>"},{"location":"usage/commands/k3d_node_stop/#options","title":"Options","text":"<pre><code> -h, --help help for stop\n</code></pre>"},{"location":"usage/commands/k3d_node_stop/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_node_stop/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d node - Manage node(s)</li> </ul>"},{"location":"usage/commands/k3d_registry/","title":"K3d registry","text":""},{"location":"usage/commands/k3d_registry/#k3d-registry","title":"k3d registry","text":"<p>Manage registry/registries</p>"},{"location":"usage/commands/k3d_registry/#synopsis","title":"Synopsis","text":"<p>Manage registry/registries</p> <pre><code>k3d registry [flags]\n</code></pre>"},{"location":"usage/commands/k3d_registry/#options","title":"Options","text":"<pre><code> -h, --help help for registry\n</code></pre>"},{"location":"usage/commands/k3d_registry/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_registry/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d - https://k3d.io/ -&gt; Run k3s in Docker!</li> <li>k3d registry create - Create a new registry</li> <li>k3d registry delete - Delete registry/registries.</li> <li>k3d registry list - List registries</li> </ul>"},{"location":"usage/commands/k3d_registry_create/","title":"K3d registry create","text":""},{"location":"usage/commands/k3d_registry_create/#k3d-registry-create","title":"k3d registry create","text":"<p>Create a new registry</p>"},{"location":"usage/commands/k3d_registry_create/#synopsis","title":"Synopsis","text":"<p>Create a new registry.</p> <pre><code>k3d registry create NAME [flags]\n</code></pre>"},{"location":"usage/commands/k3d_registry_create/#options","title":"Options","text":"<pre><code> --default-network string Specify the network connected to the registry (default \"bridge\")\n -h, --help help for create\n -i, --image string Specify image used for the registry (default \"docker.io/library/registry:2\")\n --no-help Disable the help text (How-To use the registry)\n -p, --port [HOST:]HOSTPORT Select which port the registry should be listening on on your machine (localhost) (Format: [HOST:]HOSTPORT)\n - Example: `k3d registry create --port 0.0.0.0:5111` (default \"random\")\n --proxy-password string Specify the password of the proxied remote registry\n --proxy-remote-url string Specify the url of the proxied remote registry\n --proxy-username string Specify the username of the proxied remote registry\n -v, --volume [SOURCE:]DEST Mount volumes into the registry node (Format: [SOURCE:]DEST\n</code></pre>"},{"location":"usage/commands/k3d_registry_create/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_registry_create/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d registry - Manage registry/registries</li> </ul>"},{"location":"usage/commands/k3d_registry_delete/","title":"K3d registry delete","text":""},{"location":"usage/commands/k3d_registry_delete/#k3d-registry-delete","title":"k3d registry delete","text":"<p>Delete registry/registries.</p>"},{"location":"usage/commands/k3d_registry_delete/#synopsis","title":"Synopsis","text":"<p>Delete registry/registries.</p> <pre><code>k3d registry delete (NAME | --all) [flags]\n</code></pre>"},{"location":"usage/commands/k3d_registry_delete/#options","title":"Options","text":"<pre><code> -a, --all Delete all existing registries\n -h, --help help for delete\n</code></pre>"},{"location":"usage/commands/k3d_registry_delete/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_registry_delete/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d registry - Manage registry/registries</li> </ul>"},{"location":"usage/commands/k3d_registry_list/","title":"K3d registry list","text":""},{"location":"usage/commands/k3d_registry_list/#k3d-registry-list","title":"k3d registry list","text":"<p>List registries</p>"},{"location":"usage/commands/k3d_registry_list/#synopsis","title":"Synopsis","text":"<p>List registries.</p> <pre><code>k3d registry list [NAME [NAME...]] [flags]\n</code></pre>"},{"location":"usage/commands/k3d_registry_list/#options","title":"Options","text":"<pre><code> -h, --help help for list\n --no-headers Disable headers\n -o, --output string Output format. One of: json|yaml\n</code></pre>"},{"location":"usage/commands/k3d_registry_list/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_registry_list/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d registry - Manage registry/registries</li> </ul>"},{"location":"usage/commands/k3d_version/","title":"K3d version","text":""},{"location":"usage/commands/k3d_version/#k3d-version","title":"k3d version","text":"<p>Show k3d and default k3s version</p>"},{"location":"usage/commands/k3d_version/#synopsis","title":"Synopsis","text":"<p>Show k3d and default k3s version</p> <pre><code>k3d version [flags]\n</code></pre>"},{"location":"usage/commands/k3d_version/#options","title":"Options","text":"<pre><code> -h, --help help for version\n -o, --output string This will return version information as a different format. Only json is supported\n</code></pre>"},{"location":"usage/commands/k3d_version/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_version/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d - https://k3d.io/ -&gt; Run k3s in Docker!</li> <li>k3d version list - List k3d/K3s versions. Component can be one of \u2018k3d\u2019, \u2018k3s\u2019, \u2018k3d-proxy\u2019, \u2018k3d-tools\u2019.</li> </ul>"},{"location":"usage/commands/k3d_version_list/","title":"K3d version list","text":""},{"location":"usage/commands/k3d_version_list/#k3d-version-list","title":"k3d version list","text":"<p>List k3d/K3s versions. Component can be one of \u2018k3d\u2019, \u2018k3s\u2019, \u2018k3d-proxy\u2019, \u2018k3d-tools\u2019.</p> <pre><code>k3d version list COMPONENT [flags]\n</code></pre>"},{"location":"usage/commands/k3d_version_list/#options","title":"Options","text":"<pre><code> -e, --exclude string Exclude Regexp (default excludes pre-releases and arch-specific tags) (default \".+(rc|engine|alpha|beta|dev|test|arm|arm64|amd64).*\")\n -f, --format string [DEPRECATED] Use --output instead (default \"raw\")\n -h, --help help for list\n -i, --include string Include Regexp (default includes everything (default \".*\")\n -l, --limit int Limit number of tags in output (0 = unlimited)\n -o, --output string Output Format [raw | repo] (default \"raw\")\n -s, --sort string Sort Mode (asc | desc | off) (default \"desc\")\n</code></pre>"},{"location":"usage/commands/k3d_version_list/#options-inherited-from-parent-commands","title":"Options inherited from parent commands","text":"<pre><code> --timestamps Enable Log timestamps\n --trace Enable super verbose output (trace logging)\n --verbose Enable verbose output (debug logging)\n</code></pre>"},{"location":"usage/commands/k3d_version_list/#see-also","title":"SEE ALSO","text":"<ul> <li>k3d version - Show k3d and default k3s version</li> </ul>"}]}