Merge: 4b1148f c6df144
Author: Thorsten Klein <iwilltry42@gmail.com>
Date:   Thu Jan 14 13:16:05 2021 +0100

    [NEW VERSION v4] Merge pull request #447 from rancher/main-v4
pull/667/head
iwilltry42 4 years ago
parent 1e8206705d
commit 68770ec23f
  1. 4
      faq/v1vsv3-comparison/index.html
  2. 22
      index.html
  3. 21
      internals/defaults/index.html
  4. 6
      internals/networking/index.html
  5. 2
      search/search_index.json
  6. 24
      sitemap.xml
  7. BIN
      sitemap.xml.gz
  8. 128
      usage/commands/index.html
  9. 2
      usage/guides/cuda/build.sh
  10. 84
      usage/guides/cuda/index.html
  11. 15
      usage/guides/exposing_services/index.html
  12. 139
      usage/guides/registries/index.html
  13. 22
      usage/kubeconfig/index.html

@ -581,7 +581,7 @@
- --label -&gt; planned
- --workers -&gt; implemented
- --auto-restart -&gt; dropped (docker&#39;s `unless-stopped` is set by default)
- --enable-registry -&gt; planned (possible consolidation into less registry-related commands?)
- --enable-registry -&gt; coming in v4.0.0 (2021) as `--registry-create` and `--registry-use`
- --registry-name -&gt; TBD
- --registry-port -&gt; TBD
- --registry-volume -&gt; TBD
@ -626,7 +626,7 @@
<div class="md-source-date">
<small>
Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">July 14, 2020</span>
Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">January 5, 2021</span>
</small>
</div>

@ -628,7 +628,7 @@
<h1 id="overview">Overview<a class="headerlink" href="#overview" title="Permanent link">&para;</a></h1>
<p><img alt="k3d" src="static/img/k3d_logo_black_blue.svg" /></p>
<p><strong>This page is targeting k3d v3.0.0 and newer!</strong></p>
<p><strong>This page is targeting k3d v4.0.0 and newer!</strong></p>
<p>k3d is a lightweight wrapper to run <a href="https://github.com/rancher/k3s">k3s</a> (Rancher Lab&rsquo;s minimal Kubernetes distribution) in docker.</p>
<p>k3d makes it very easy to create single- and multi-node <a href="https://github.com/rancher/k3s">k3s</a> clusters in docker, e.g. for local development on Kubernetes.</p>
<details class="tip"><summary>View a quick demo</summary><p><asciinema-player src="/static/asciicast/20200715_k3d.01.cast" cols=200 rows=32></asciinema-player></p>
@ -687,24 +687,18 @@
<h2 id="installation">Installation<a class="headerlink" href="#installation" title="Permanent link">&para;</a></h2>
<p>You have several options there:</p>
<ul>
<li>use the install script to grab the latest release:<ul>
<li>use the install script to grab the latest release:</li>
<li>wget: <code class="highlight">wget -q -O - https://raw.githubusercontent.com/rancher/k3d/main/install.sh <span class="p">|</span> bash</code></li>
<li>curl: <code class="highlight">curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh <span class="p">|</span> bash</code></li>
</ul>
</li>
<li>use the install script to grab a specific release (via <code>TAG</code> environment variable):</li>
<li>wget: <code class="highlight">wget -q -O - https://raw.githubusercontent.com/rancher/k3d/main/install.sh <span class="p">|</span> <span class="nv">TAG</span><span class="o">=</span>v4.0.0 bash</code></li>
<li>
<p>use the install script to grab a specific release (via <code>TAG</code> environment variable):</p>
<ul>
<li>wget: <code class="highlight">wget -q -O - https://raw.githubusercontent.com/rancher/k3d/main/install.sh <span class="p">|</span> <span class="nv">TAG</span><span class="o">=</span>v3.0.0 bash</code></li>
<li>curl: <code class="highlight">curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh <span class="p">|</span> <span class="nv">TAG</span><span class="o">=</span>v3.0.0 bash</code></li>
</ul>
<p>curl: <code class="highlight">curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh <span class="p">|</span> <span class="nv">TAG</span><span class="o">=</span>v4.0.0 bash</code></p>
</li>
<li>
<p>use <a href="https://brew.sh">Homebrew</a>: <code class="highlight">brew install k3d</code> (Homebrew is available for MacOS and Linux)</p>
<ul>
<li>Formula can be found in <a href="https://github.com/Homebrew/homebrew-core/blob/master/Formula/k3d.rb">homebrew/homebrew-core</a> and is mirrored to <a href="https://github.com/Homebrew/linuxbrew-core/blob/master/Formula/k3d.rb">homebrew/linuxbrew-core</a></li>
</ul>
</li>
<li>Formula can be found in <a href="https://github.com/Homebrew/homebrew-core/blob/master/Formula/k3d.rb">homebrew/homebrew-core</a> and is mirrored to <a href="https://github.com/Homebrew/linuxbrew-core/blob/master/Formula/k3d.rb">homebrew/linuxbrew-core</a></li>
<li>install via <a href="https://aur.archlinux.org/">AUR</a> package <a href="https://aur.archlinux.org/packages/rancher-k3d-bin/">rancher-k3d-bin</a>: <code>yay -S rancher-k3d-bin</code></li>
<li>grab a release from the <a href="https://github.com/rancher/k3d/releases">release tab</a> and install it yourself.</li>
<li>install via go: <code class="highlight">go install github.com/rancher/k3d</code> (<strong>Note</strong>: this will give you unreleased/bleeding-edge changes)</li>
@ -718,7 +712,7 @@
<div class="highlight"><pre><span></span><code>k3d cluster create mycluster
</code></pre></div>
<p>Get the new cluster&rsquo;s connection details merged into your default kubeconfig (usually specified using the <code>KUBECONFIG</code> environment variable or the default path <code class="highlight"><span class="nv">$HOME</span>/.kube/config</code>) and directly switch to the new context:</p>
<div class="highlight"><pre><span></span><code>k3d kubeconfig merge mycluster --switch-context
<div class="highlight"><pre><span></span><code>k3d kubeconfig merge mycluster --kubeconfig-switch-context
</code></pre></div>
<p>Use the new cluster with <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/"><code>kubectl</code></a>, e.g.:</p>
<div class="highlight"><pre><span></span><code>kubectl get nodes
@ -735,7 +729,7 @@
<div class="md-source-date">
<small>
Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">January 13, 2021</span>
Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">January 14, 2021</span>
</small>
</div>

@ -516,26 +516,23 @@
<h1 id="defaults">Defaults<a class="headerlink" href="#defaults" title="Permanent link">&para;</a></h1>
<ul>
<li>multiple server nodes<ul>
<li>multiple server nodes</li>
<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>
</li>
<li>API-Ports<ul>
<li>by default, we don&rsquo;t expose any API-Port (no host port mapping)</li>
</ul>
</li>
<li>kubeconfig<ul>
<li>if <code>--[update|merge]-default-kubeconfig</code> is set, we use the default loading rules to get the default kubeconfig:<ul>
<li>API-Ports</li>
<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>
<li>kubeconfig</li>
<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>
</li>
<li>Networking</li>
<li><a href="./networking">by default, k3d creates a new (docker) network for every cluster</a></li>
</ul>
@ -545,7 +542,7 @@
<div class="md-source-date">
<small>
Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">July 14, 2020</span>
Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">January 5, 2021</span>
</small>
</div>

@ -628,11 +628,9 @@
<h1 id="networking">Networking<a class="headerlink" href="#networking" title="Permanent link">&para;</a></h1>
<ul>
<li>Related issues:<ul>
<li>Related issues:</li>
<li><a href="https://github.com/rancher/k3d/issues/220">rancher/k3d #220</a></li>
</ul>
</li>
</ul>
<h2 id="introduction">Introduction<a class="headerlink" href="#introduction" title="Permanent link">&para;</a></h2>
<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.
@ -656,7 +654,7 @@ run into issues with grabbing certificates from the API-Server. Single-Node clus
<div class="md-source-date">
<small>
Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">July 14, 2020</span>
Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">January 5, 2021</span>
</small>
</div>

File diff suppressed because one or more lines are too long

@ -1,51 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url>
<loc>https://k3d.io/</loc>
<lastmod>2021-01-13</lastmod>
<lastmod>2021-01-14</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>https://k3d.io/usage/commands/</loc>
<lastmod>2021-01-13</lastmod>
<lastmod>2021-01-14</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>https://k3d.io/usage/kubeconfig/</loc>
<lastmod>2021-01-13</lastmod>
<lastmod>2021-01-14</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>https://k3d.io/usage/multiserver/</loc>
<lastmod>2021-01-13</lastmod>
<lastmod>2021-01-14</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>https://k3d.io/usage/guides/exposing_services/</loc>
<lastmod>2021-01-13</lastmod>
<lastmod>2021-01-14</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>https://k3d.io/usage/guides/registries/</loc>
<lastmod>2021-01-13</lastmod>
<lastmod>2021-01-14</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>https://k3d.io/usage/guides/calico/</loc>
<lastmod>2021-01-13</lastmod>
<lastmod>2021-01-14</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>https://k3d.io/usage/guides/cuda/</loc>
<lastmod>2021-01-13</lastmod>
<lastmod>2021-01-14</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>https://k3d.io/internals/defaults/</loc>
<lastmod>2021-01-13</lastmod>
<lastmod>2021-01-14</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>https://k3d.io/internals/networking/</loc>
<lastmod>2021-01-13</lastmod>
<lastmod>2021-01-14</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>https://k3d.io/faq/faq/</loc>
<lastmod>2021-01-13</lastmod>
<lastmod>2021-01-14</lastmod>
<changefreq>daily</changefreq>
</url><url>
<loc>https://k3d.io/faq/v1vsv3-comparison/</loc>
<lastmod>2021-01-13</lastmod>
<lastmod>2021-01-14</lastmod>
<changefreq>daily</changefreq>
</url>
</urlset>

Binary file not shown.

@ -516,72 +516,92 @@
<h1 id="command-tree">Command Tree<a class="headerlink" href="#command-tree" title="Permanent link">&para;</a></h1>
<div class="highlight"><pre><span></span><code>k3d
--verbose <span class="c1"># enable verbose (debug) logging (default: false)</span>
--verbose <span class="c1"># GLOBAL: enable verbose (debug) logging (default: false)</span>
--trace <span class="c1"># GLOBAL: enable super verbose logging (trace logging) (default: false)</span>
--version <span class="c1"># show k3d and k3s version</span>
-h, --help <span class="c1"># show help text</span>
version <span class="c1"># show k3d and k3s version</span>
<span class="nb">help</span> <span class="o">[</span>COMMAND<span class="o">]</span> <span class="c1"># show help text for any command</span>
completion <span class="o">[</span>bash <span class="p">|</span> zsh <span class="p">|</span> <span class="o">(</span>psh <span class="p">|</span> powershell<span class="o">)]</span> <span class="c1"># generate completion scripts for common shells</span>
-h, --help <span class="c1"># GLOBAL: show help text</span>
cluster <span class="o">[</span>CLUSTERNAME<span class="o">]</span> <span class="c1"># default cluster name is &#39;k3s-default&#39;</span>
create
--api-port <span class="c1"># specify the port on which the cluster will be accessible (e.g. via kubectl)</span>
-i, --image <span class="c1"># specify which k3s image should be used for the nodes</span>
--k3s-agent-arg <span class="c1"># add additional arguments to the k3s agent (see https://rancher.com/docs/k3s/latest/en/installation/install-options/agent-config/#k3s-agent-cli-help)</span>
--k3s-server-arg <span class="c1"># add additional arguments to the k3s server (see https://rancher.com/docs/k3s/latest/en/installation/install-options/server-config/#k3s-server-cli-help)</span>
-s, --servers <span class="c1"># specify how many server nodes you want to create</span>
--network <span class="c1"># specify a network you want to connect to</span>
--no-hostip <span class="c1"># disable the automatic injection of the Host IP as &#39;host.k3d.internal&#39; into the containers and CoreDN</span>
--no-image-volume <span class="c1"># disable the creation of a volume for storing images (used for the &#39;k3d load image&#39; command)</span>
--no-lb <span class="c1"># disable the creation of a LoadBalancer in front of the server nodes</span>
--no-rollback <span class="c1"># disable the automatic rollback actions, if anything goes wrong</span>
-p, --port <span class="c1"># add some more port mappings</span>
--token <span class="c1"># specify a cluster token (default: auto-generated)</span>
--timeout <span class="c1"># specify a timeout, after which the cluster creation will be interrupted and changes rolled back</span>
--update-default-kubeconfig <span class="c1"># enable the automated update of the default kubeconfig with the details of the newly created cluster (also sets &#39;--wait=true&#39;)</span>
--switch-context <span class="c1"># (implies --update-default-kubeconfig) automatically sets the current-context of your default kubeconfig to the new cluster&#39;s context</span>
-v, --volume <span class="c1"># specify additional bind-mounts</span>
--wait <span class="c1"># enable waiting for all server nodes to be ready before returning</span>
-a, --agents <span class="c1"># specify how many agent nodes you want to create</span>
-e, --env <span class="c1"># add environment variables to the node containers</span>
-a, --agents <span class="c1"># specify how many agent nodes you want to create (integer, default: 0)</span>
--api-port <span class="c1"># specify the port on which the cluster will be accessible (format &#39;[HOST:]HOSTPORT&#39;, default: random)</span>
-c, --config <span class="c1"># use a config file (format &#39;PATH&#39;)</span>
-e, --env <span class="c1"># add environment variables to the nodes (quoted string, format: &#39;KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]&#39;, use flag multiple times)</span>
--gpus <span class="c1"># [from docker CLI] add GPU devices to the node containers (string, e.g. &#39;all&#39;)</span>
-i, --image <span class="c1"># specify which k3s image should be used for the nodes (string, default: &#39;docker.io/rancher/k3s:v1.20.0-k3s2&#39;, tag changes per build)</span>
--k3s-agent-arg <span class="c1"># add additional arguments to the k3s agent (quoted string, use flag multiple times) (see https://rancher.com/docs/k3s/latest/en/installation/install-options/agent-config/#k3s-agent-cli-help)</span>
--k3s-server-arg <span class="c1"># add additional arguments to the k3s server (quoted string, use flag multiple times) (see https://rancher.com/docs/k3s/latest/en/installation/install-options/server-config/#k3s-server-cli-help)</span>
--kubeconfig-switch-context <span class="c1"># (implies --kubeconfig-update-default) automatically sets the current-context of your default kubeconfig to the new cluster&#39;s context (default: true)</span>
--kubeconfig-update-default <span class="c1"># enable the automated update of the default kubeconfig with the details of the newly created cluster (also sets &#39;--wait=true&#39;) (default: true)</span>
-l, --label <span class="c1"># add (docker) labels to the node containers (format: &#39;KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]&#39;, use flag multiple times)</span>
--network <span class="c1"># specify an existing (docker) network you want to connect to (string)</span>
--no-hostip <span class="c1"># disable the automatic injection of the Host IP as &#39;host.k3d.internal&#39; into the containers and CoreDNS (default: false)</span>
--no-image-volume <span class="c1"># disable the creation of a volume for storing images (used for the &#39;k3d image import&#39; command) (default: false)</span>
--no-lb <span class="c1"># disable the creation of a load balancer in front of the server nodes (default: false)</span>
--no-rollback <span class="c1"># disable the automatic rollback actions, if anything goes wrong (default: false)</span>
-p, --port <span class="c1"># add some more port mappings (format: &#39;[HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER]&#39;, use flag multiple times)</span>
--registry-create <span class="c1"># create a new (docker) registry dedicated for this cluster (default: false)</span>
--registry-use <span class="c1"># use an existing local (docker) registry with this cluster (string, use multiple times)</span>
-s, --servers <span class="c1"># specify how many server nodes you want to create (integer, default: 1)</span>
--token <span class="c1"># specify a cluster token (string, default: auto-generated)</span>
--timeout <span class="c1"># specify a timeout, after which the cluster creation will be interrupted and changes rolled back (duration, e.g. &#39;10s&#39;)</span>
-v, --volume <span class="c1"># specify additional bind-mounts (format: &#39;[SOURCE:]DEST[@NODEFILTER[;NODEFILTER...]]&#39;, use flag multiple times)</span>
--wait <span class="c1"># enable waiting for all server nodes to be ready before returning (default: true)</span>
start CLUSTERNAME <span class="c1"># start a (stopped) cluster</span>
-a, --all <span class="c1"># start all clusters</span>
--wait <span class="c1"># wait for all servers and server-loadbalancer to be up before returning</span>
--timeout <span class="c1"># maximum waiting time for &#39;--wait&#39; before canceling/returning</span>
-a, --all <span class="c1"># start all clusters (default: false)</span>
--wait <span class="c1"># wait for all servers and server-loadbalancer to be up before returning (default: true)</span>
--timeout <span class="c1"># maximum waiting time for &#39;--wait&#39; before canceling/returning (duration, e.g. &#39;10s&#39;)</span>
stop CLUSTERNAME <span class="c1"># stop a cluster</span>
-a, --all <span class="c1"># stop all clusters</span>
-a, --all <span class="c1"># stop all clusters (default: false)</span>
delete CLUSTERNAME <span class="c1"># delete an existing cluster</span>
-a, --all <span class="c1"># delete all existing clusters</span>
-a, --all <span class="c1"># delete all existing clusters (default: false)</span>
list <span class="o">[</span>CLUSTERNAME <span class="o">[</span>CLUSTERNAME ...<span class="o">]]</span>
--no-headers <span class="c1"># do not print headers</span>
--token <span class="c1"># show column with cluster tokens</span>
--no-headers <span class="c1"># do not print headers (default: false)</span>
--token <span class="c1"># show column with cluster tokens (default: false)</span>
-o, --output <span class="c1"># format the output (format: &#39;json|yaml&#39;)</span>
completion <span class="o">[</span>bash <span class="p">|</span> zsh <span class="p">|</span> fish <span class="p">|</span> <span class="o">(</span>psh <span class="p">|</span> powershell<span class="o">)]</span> <span class="c1"># generate completion scripts for common shells</span>
config
init <span class="c1"># write a default k3d config (as a starting point)</span>
-f, --force <span class="c1"># force overwrite target file (default: false)</span>
-o, --output <span class="c1"># file to write to (string, default &quot;k3d-default.yaml&quot;)</span>
<span class="nb">help</span> <span class="o">[</span>COMMAND<span class="o">]</span> <span class="c1"># show help text for any command</span>
image
import <span class="o">[</span>IMAGE <span class="p">|</span> ARCHIVE <span class="o">[</span>IMAGE <span class="p">|</span> ARCHIVE ...<span class="o">]]</span> <span class="c1"># Load one or more images from the local runtime environment or tar-archives into k3d clusters</span>
-c, --cluster <span class="c1"># clusters to load the image into (string, use flag multiple times, default: k3s-default)</span>
-k, --keep-tarball <span class="c1"># do not delete the image tarball from the shared volume after completion (default: false)</span>
kubeconfig
get <span class="o">(</span>CLUSTERNAME <span class="o">[</span>CLUSTERNAME ...<span class="o">]</span> <span class="p">|</span> --all<span class="o">)</span> <span class="c1"># get kubeconfig from cluster(s) and write it to stdout</span>
-a, --all <span class="c1"># get kubeconfigs from all clusters (default: false)</span>
merge <span class="p">|</span> write <span class="o">(</span>CLUSTERNAME <span class="o">[</span>CLUSTERNAME ...<span class="o">]</span> <span class="p">|</span> --all<span class="o">)</span> <span class="c1"># get kubeconfig from cluster(s) and merge it/them into a (kubeconfig-)file</span>
-a, --all <span class="c1"># get kubeconfigs from all clusters (default: false)</span>
-s, --kubeconfig-switch-context <span class="c1"># switch current-context in kubeconfig to the new context (default: true)</span>
-d, --kubeconfig-merge-default <span class="c1"># update the default kubeconfig (usually $KUBECONFIG or $HOME/.kube/config)</span>
-o, --output <span class="c1"># specify the output file where the kubeconfig should be written to (string)</span>
--overwrite <span class="c1"># [Careful!] forcefully overwrite the output file, ignoring existing contents (default: false)</span>
-u, --update <span class="c1"># update conflicting fields in existing kubeconfig (default: true)</span>
node
create NODENAME <span class="c1"># Create new nodes (and add them to existing clusters)</span>
-c, --cluster <span class="c1"># specify the cluster that the node shall connect to</span>
-i, --image <span class="c1"># specify which k3s image should be used for the node(s)</span>
--replicas <span class="c1"># specify how many replicas you want to create with this spec</span>
--role <span class="c1"># specify the node role</span>
--wait <span class="c1"># wait for the node to be up and running before returning</span>
--timeout <span class="c1"># specify a timeout duration, after which the node creation will be interrupted, if not done yet</span>
-c, --cluster <span class="c1"># specify the cluster that the node shall connect to (string, default: k3s-default)</span>
-i, --image <span class="c1"># specify which k3s image should be used for the node(s) (string, default: &#39;docker.io/rancher/k3s:v1.20.0-k3s2&#39;, tag changes per build)</span>
--replicas <span class="c1"># specify how many replicas you want to create with this spec (integer, default: 1)</span>
--role <span class="c1"># specify the node role (string, format: &#39;agent|server&#39;, default: agent)</span>
--timeout <span class="c1"># specify a timeout duration, after which the node creation will be interrupted, if not done yet (duration, e.g. &#39;10s&#39;)</span>
--wait <span class="c1"># wait for the node to be up and running before returning (default: true)</span>
start NODENAME <span class="c1"># start a (stopped) node</span>
stop NODENAME <span class="c1"># stop a node</span>
delete NODENAME <span class="c1"># delete an existing node</span>
-a, --all <span class="c1"># delete all existing nodes</span>
-a, --all <span class="c1"># delete all existing nodes (default: false)</span>
list NODENAME
--no-headers <span class="c1"># do not print headers</span>
kubeconfig
get <span class="o">(</span>CLUSTERNAME <span class="o">[</span>CLUSTERNAME ...<span class="o">]</span> <span class="p">|</span> --all<span class="o">)</span> <span class="c1"># get kubeconfig from cluster(s) and write it to stdout</span>
-a, --all <span class="c1"># get kubeconfigs from all clusters</span>
merge <span class="p">|</span> write <span class="o">(</span>CLUSTERNAME <span class="o">[</span>CLUSTERNAME ...<span class="o">]</span> <span class="p">|</span> --all<span class="o">)</span> <span class="c1"># get kubeconfig from cluster(s) and merge it/them into into a file in $HOME/.k3d (or whatever you specify via the flags)</span>
-a, --all <span class="c1"># get kubeconfigs from all clusters</span>
--output <span class="c1"># specify the output file where the kubeconfig should be written to</span>
--overwrite <span class="c1"># [Careful!] forcefully overwrite the output file, ignoring existing contents</span>
-s, --switch-context <span class="c1"># switch current-context in kubeconfig to the new context</span>
-u, --update <span class="c1"># update conflicting fields in existing kubeconfig (default: true)</span>
-d, --merge-default-kubeconfig <span class="c1"># update the default kubeconfig (usually $KUBECONFIG or $HOME/.kube/config)</span>
image
import <span class="o">[</span>IMAGE <span class="p">|</span> ARCHIVE <span class="o">[</span>IMAGE <span class="p">|</span> ARCHIVE ...<span class="o">]]</span> <span class="c1"># Load one or more images from the local runtime environment or tar-archives into k3d clusters</span>
-c, --cluster <span class="c1"># clusters to load the image into</span>
-k, --keep-tarball <span class="c1"># do not delete the image tarball from the shared volume after completion</span>
--no-headers <span class="c1"># do not print headers (default: false)</span>
registry
create REGISTRYNAME
-i, --image <span class="c1"># specify image used for the registry (string, default: &quot;docker.io/library/registry:2&quot;)</span>
-p, --port <span class="c1"># select host port to map to (format: &#39;[HOST:]HOSTPORT&#39;, default: &#39;random&#39;)</span>
delete REGISTRYNAME
-a, --all <span class="c1"># delete all existing registries (default: false)</span>
list <span class="o">[</span>NAME <span class="o">[</span>NAME...<span class="o">]]</span>
--no-headers <span class="c1"># disable table headers (default: false)</span>
version <span class="c1"># show k3d and k3s version</span>
</code></pre></div>
@ -591,7 +611,7 @@
<div class="md-source-date">
<small>
Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">November 23, 2020</span>
Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">January 5, 2021</span>
</small>
</div>

@ -1,7 +1,7 @@
#!/bin/bash
set -e
cd $(dirname $0)
K3S_TAG="${1:-v1.18.10+k3s1}"
IMAGE_TAG="${K3S_TAG/+/-}"

@ -442,7 +442,7 @@
<li class="md-nav__item">
<a href="#acknowledgements" class="md-nav__link">
Acknowledgements:
Acknowledgements
</a>
</li>
@ -662,7 +662,7 @@
<li class="md-nav__item">
<a href="#acknowledgements" class="md-nav__link">
Acknowledgements:
Acknowledgements
</a>
</li>
@ -691,7 +691,7 @@ The K3S container itself also needs to run with this runtime. If you are using D
<h2 id="building-a-customized-k3s-image">Building a customized K3S image<a class="headerlink" href="#building-a-customized-k3s-image" title="Permanent link">&para;</a></h2>
<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>
<h3 id="adapt-the-dockerfile">Adapt the Dockerfile<a class="headerlink" href="#adapt-the-dockerfile" title="Permanent link">&para;</a></h3>
<p><div class="highlight"><pre><span></span><code><span class="k">FROM</span> <span class="s">ubuntu:18.04</span> <span class="k">as</span> <span class="s">base</span>
<div class="highlight"><pre><span></span><code><span class="k">FROM</span> <span class="s">ubuntu:18.04</span> <span class="k">as</span> <span class="s">base</span>
<span class="k">RUN</span> apt-get update -y <span class="o">&amp;&amp;</span> apt-get install -y ca-certificates
<span class="k">ADD</span> k3s/build/out/data.tar.gz /image
<span class="k">RUN</span> mkdir -p /image/etc/ssl/certs /image/run /image/var/run /image/tmp /image/lib/modules /image/lib/firmware <span class="o">&amp;&amp;</span> <span class="se">\</span>
@ -730,11 +730,13 @@ The K3S container itself also needs to run with this runtime. If you are using D
<span class="k">ENTRYPOINT</span> <span class="p">[</span><span class="s2">&quot;/bin/k3s&quot;</span><span class="p">]</span>
<span class="k">CMD</span> <span class="p">[</span><span class="s2">&quot;agent&quot;</span><span class="p">]</span>
</code></pre></div>
This <a href="cuda/Dockerfile">Dockerfile</a> is based on the <a href="https://github.com/rancher/k3s/blob/master/package/Dockerfile">K3S Dockerfile</a>.
The following changes are applied:
1. Change the base images to Ubuntu 18.04 so the NVIDIA Container Runtime can be installed
2. Add a custom containerd <code>config.toml</code> template to add the NVIDIA Container Runtime. This replaces the default <code>runc</code> runtime
3. Add a manifest for the NVIDIA driver plugin for Kubernetes</p>
<p>This <a href="cuda/Dockerfile">Dockerfile</a> is based on the <a href="https://github.com/rancher/k3s/blob/master/package/Dockerfile">K3S Dockerfile</a>.
The following changes are applied:</p>
<ol>
<li>Change the base images to Ubuntu 18.04 so the NVIDIA Container Runtime can be installed</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>
<h3 id="configure-containerd">Configure containerd<a class="headerlink" href="#configure-containerd" title="Permanent link">&para;</a></h3>
<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 <a href="config.toml.tmpl">config.toml.tmpl</a> file. More information can be found on the <a href="https://rancher.com/docs/k3s/latest/en/advanced/#configuring-containerd">K3S site</a>.</p>
<div class="highlight"><pre><span></span><code><span class="p">[</span><span class="nx">plugins</span><span class="p">.</span><span class="nx">opt</span><span class="p">]</span>
@ -794,10 +796,12 @@ The following changes are applied:
<span class="p">{{</span><span class="nx">end</span><span class="p">}}</span>
</code></pre></div>
<h3 id="the-nvidia-device-plugin">The NVIDIA device plugin<a class="headerlink" href="#the-nvidia-device-plugin" title="Permanent link">&para;</a></h3>
<p>To enable NVIDIA GPU support on Kubernetes you also need to install the <a href="https://github.com/NVIDIA/k8s-device-plugin">NVIDIA device plugin</a>. The device plugin is a daemonset and allows you to automatically:
* Expose the number of GPUs on each nodes of your cluster
* Keep track of the health of your GPUs
* Run GPU enabled containers in your Kubernetes cluster.</p>
<p>To enable NVIDIA GPU support on Kubernetes you also need to install the <a href="https://github.com/NVIDIA/k8s-device-plugin">NVIDIA device plugin</a>. 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>
<div class="highlight"><pre><span></span><code><span class="nt">apiVersion</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">apps/v1</span>
<span class="nt">kind</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">DaemonSet</span>
<span class="nt">metadata</span><span class="p">:</span>
@ -842,18 +846,22 @@ The following changes are applied:
</code></pre></div>
<h3 id="build-the-k3s-image">Build the K3S image<a class="headerlink" href="#build-the-k3s-image" title="Permanent link">&para;</a></h3>
<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:
* <a href="cuda/Dockerfile">Dockerfile</a>
* <a href="config.toml.tmpl">config.toml.tmpl</a>
* <a href="gpu.yaml">gpu.yaml</a>
* <a href="build.sh">build.sh</a>
* <a href="cuda-vector-add.yaml">cuda-vector-add.yaml</a></p>
<p>The <code>build.sh</code> files takes the K3S git tag as argument, it defaults to <code>v1.18.10+k3s1</code>. The script performs the following steps:
* pulls K3S
* builds K3S
* build the custom K3S Docker image</p>
<p>Put the following files in a directory:</p>
<ul>
<li><a href="cuda/Dockerfile">Dockerfile</a></li>
<li><a href="config.toml.tmpl">config.toml.tmpl</a></li>
<li><a href="gpu.yaml">gpu.yaml</a></li>
<li><a href="build.sh">build.sh</a></li>
<li><a href="cuda-vector-add.yaml">cuda-vector-add.yaml</a></li>
</ul>
<p>The <code>build.sh</code> files takes the K3S git tag as argument, it defaults to <code>v1.18.10+k3s1</code>. The script performs the following steps:</p>
<ul>
<li>pulls K3S</li>
<li>builds K3S</li>
<li>build the custom K3S Docker image</li>
</ul>
<p>The resulting image is tagged as k3s-gpu:&lt;version tag&gt;. The version tag is the git tag but the &lsquo;+&rsquo; sign is replaced with a &lsquo;-&lsquo;.</p>
<p><a href="build.sh">build.sh</a>:
<p><a href="build.sh">build.sh</a>:</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/bash</span>
<span class="nb">set</span> -e
<span class="nb">cd</span> <span class="k">$(</span>dirname <span class="nv">$0</span><span class="k">)</span>
@ -869,33 +877,35 @@ git clone --depth <span class="m">1</span> https://github.com/rancher/k3s.git -b
make
<span class="nb">cd</span> ..
docker build -t k3s-gpu:<span class="nv">$IMAGE_TAG</span> .
</code></pre></div></p>
</code></pre></div>
<h2 id="run-and-test-the-custom-image-with-docker">Run and test the custom image with Docker<a class="headerlink" href="#run-and-test-the-custom-image-with-docker" title="Permanent link">&para;</a></h2>
<p>You can run a container based on the new image with Docker:
<p>You can run a container based on the new image with Docker:</p>
<div class="highlight"><pre><span></span><code>docker run --name k3s-gpu -d --privileged --gpus all k3s-gpu:v1.18.10-k3s1
</code></pre></div>
Deploy a <a href="cuda-vector-add.yaml">test pod</a>:
<p>Deploy a <a href="cuda-vector-add.yaml">test pod</a>:</p>
<div class="highlight"><pre><span></span><code>docker cp cuda-vector-add.yaml k3s-gpu:/cuda-vector-add.yaml
docker exec k3s-gpu kubectl apply -f /cuda-vector-add.yaml
docker exec k3s-gpu kubectl logs cuda-vector-add
</code></pre></div></p>
docker <span class="nb">exec</span> k3s-gpu kubectl apply -f /cuda-vector-add.yaml
docker <span class="nb">exec</span> k3s-gpu kubectl logs cuda-vector-add
</code></pre></div>
<h2 id="run-and-test-the-custom-image-with-k3d">Run and test the custom image with k3d<a class="headerlink" href="#run-and-test-the-custom-image-with-k3d" title="Permanent link">&para;</a></h2>
<p>Tou can use the image with k3d:
<p>Tou can use the image with k3d:</p>
<div class="highlight"><pre><span></span><code>k3d cluster create --no-lb --image k3s-gpu:v1.18.10-k3s1 --gpus all
</code></pre></div>
Deploy a <a href="cuda-vector-add.yaml">test pod</a>:
<p>Deploy a <a href="cuda-vector-add.yaml">test pod</a>:</p>
<div class="highlight"><pre><span></span><code>kubectl apply -f cuda-vector-add.yaml
kubectl logs cuda-vector-add
</code></pre></div></p>
</code></pre></div>
<h2 id="known-issues">Known issues<a class="headerlink" href="#known-issues" title="Permanent link">&para;</a></h2>
<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 <a href="https://docs.nvidia.com/cuda/wsl-user-guide/index.html#known-limitations">CUDA on WSL User Guide</a>.</li>
</ul>
<h2 id="acknowledgements">Acknowledgements:<a class="headerlink" href="#acknowledgements" title="Permanent link">&para;</a></h2>
<p>Most of the information in this article was obtained from various sources:
* <a href="https://dev.to/mweibel/add-nvidia-gpu-support-to-k3s-with-containerd-4j17">Add NVIDIA GPU support to k3s with containerd</a>
* <a href="https://github.com/ubuntu/microk8s">microk8s</a>
* <a href="https://github.com/rancher/k3s">K3S</a></p>
<h2 id="acknowledgements">Acknowledgements<a class="headerlink" href="#acknowledgements" title="Permanent link">&para;</a></h2>
<p>Most of the information in this article was obtained from various sources:</p>
<ul>
<li><a href="https://dev.to/mweibel/add-nvidia-gpu-support-to-k3s-with-containerd-4j17">Add NVIDIA GPU support to k3s with containerd</a></li>
<li><a href="https://github.com/ubuntu/microk8s">microk8s</a></li>
<li><a href="https://github.com/rancher/k3s">K3S</a></li>
</ul>

@ -340,8 +340,8 @@
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="#1-via-ingress" class="md-nav__link">
1. via Ingress
<a href="#1-via-ingress-recommended" class="md-nav__link">
1. via Ingress (recommended)
</a>
</li>
@ -544,8 +544,8 @@
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="#1-via-ingress" class="md-nav__link">
1. via Ingress
<a href="#1-via-ingress-recommended" class="md-nav__link">
1. via Ingress (recommended)
</a>
</li>
@ -575,7 +575,7 @@
<h1 id="exposing-services">Exposing Services<a class="headerlink" href="#exposing-services" title="Permanent link">&para;</a></h1>
<h2 id="1-via-ingress">1. via Ingress<a class="headerlink" href="#1-via-ingress" title="Permanent link">&para;</a></h2>
<h2 id="1-via-ingress-recommended">1. via Ingress (recommended)<a class="headerlink" href="#1-via-ingress-recommended" title="Permanent link">&para;</a></h2>
<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>
@ -598,7 +598,7 @@ Therefore, we have to create the cluster in a way, that the internal port 80 (wh
</div>
</li>
<li>
<p>Get the kubeconfig file</p>
<p>Get the kubeconfig file (redundant, as <code>k3d cluster create</code> already merges it into your default kubeconfig file)</p>
<p><code class="highlight"><span class="nb">export</span> <span class="nv">KUBECONFIG</span><span class="o">=</span><span class="s2">&quot;</span><span class="k">$(</span>k3d kubeconfig write k3s-default<span class="k">)</span><span class="s2">&quot;</span></code></p>
</li>
<li>
@ -649,6 +649,7 @@ Therefore, we have to create the cluster in a way, that the internal port 80 (wh
<li>
<p><strong>Note</strong>: 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 <a href="https://www.youtube.com/watch?v=5HaU6338lAk">this video from @portainer</a>)</p>
</li>
<li><strong>Warning</strong>: 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>
</li>
</ol>
@ -687,7 +688,7 @@ Therefore, we have to create the cluster in a way, that the internal port 80 (wh
<div class="md-source-date">
<small>
Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">November 10, 2020</span>
Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">January 5, 2021</span>
</small>
</div>

@ -388,15 +388,35 @@
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#using-the-k3d-registry" class="md-nav__link">
Using the k3d registry
<a href="#using-k3d-managed-registries" class="md-nav__link">
Using k3d-managed registries
</a>
<nav class="md-nav" aria-label="Using k3d-managed registries">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#create-a-dedicated-registry-together-with-your-cluster" class="md-nav__link">
Create a dedicated registry together with your cluster
</a>
</li>
<li class="md-nav__item">
<a href="#using-your-own-local-registry" class="md-nav__link">
Using your own local registry
<a href="#create-a-customized-k3d-managed-registry" class="md-nav__link">
Create a customized k3d-managed registry
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#using-your-own-not-k3d-managed-local-registry" class="md-nav__link">
Using your own (not k3d-managed) local registry
</a>
</li>
@ -640,15 +660,35 @@
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#using-the-k3d-registry" class="md-nav__link">
Using the k3d registry
<a href="#using-k3d-managed-registries" class="md-nav__link">
Using k3d-managed registries
</a>
<nav class="md-nav" aria-label="Using k3d-managed registries">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#create-a-dedicated-registry-together-with-your-cluster" class="md-nav__link">
Create a dedicated registry together with your cluster
</a>
</li>
<li class="md-nav__item">
<a href="#using-your-own-local-registry" class="md-nav__link">
Using your own local registry
<a href="#create-a-customized-k3d-managed-registry" class="md-nav__link">
Create a customized k3d-managed registry
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#using-your-own-not-k3d-managed-local-registry" class="md-nav__link">
Using your own (not k3d-managed) local registry
</a>
</li>
@ -742,12 +782,29 @@ For example, if we mount the CA file in <code>/etc/ssl/certs/my-company-root.pem
<p>Finally, we can create the cluster, mounting the CA file in the path we specified in <code>ca_file</code>:</p>
<p><code class="highlight">k3d cluster create --volume <span class="s2">&quot;</span><span class="si">${</span><span class="nv">HOME</span><span class="si">}</span><span class="s2">/.k3d/my-registries.yaml:/etc/rancher/k3s/registries.yaml&quot;</span> --volume <span class="s2">&quot;</span><span class="si">${</span><span class="nv">HOME</span><span class="si">}</span><span class="s2">/.k3d/my-company-root.pem:/etc/ssl/certs/my-company-root.pem&quot;</span></code></p>
<h2 id="using-a-local-registry">Using a local registry<a class="headerlink" href="#using-a-local-registry" title="Permanent link">&para;</a></h2>
<h3 id="using-the-k3d-registry">Using the k3d registry<a class="headerlink" href="#using-the-k3d-registry" title="Permanent link">&para;</a></h3>
<h3 id="using-k3d-managed-registries">Using k3d-managed registries<a class="headerlink" href="#using-k3d-managed-registries" title="Permanent link">&para;</a></h3>
<div class="admonition info">
<p class="admonition-title">Not ported yet</p>
<p>The k3d-managed registry has not yet been ported from v1.x to v3.x</p>
<p class="admonition-title">Just ported!</p>
<p>The k3d-managed registry is available again as of k3d v4.0.0 (January 2021)</p>
</div>
<h3 id="using-your-own-local-registry">Using your own local registry<a class="headerlink" href="#using-your-own-local-registry" title="Permanent link">&para;</a></h3>
<h4 id="create-a-dedicated-registry-together-with-your-cluster">Create a dedicated registry together with your cluster<a class="headerlink" href="#create-a-dedicated-registry-together-with-your-cluster" title="Permanent link">&para;</a></h4>
<ol>
<li><code class="highlight">k3d cluster create mycluster --registry-create</code>: This creates your cluster <code>mycluster</code> together with a registry container called <code>k3d-mycluster-registry</code><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>Check the k3d command output or <code class="highlight">docker ps -f <span class="nv">name</span><span class="o">=</span>k3d-mycluster-registry</code> to find the exposed port (let&rsquo;s use <code>12345</code> here)</li>
<li>Pull some image (optional) <code class="highlight">docker pull alpine:latest</code>, re-tag it to reference your newly created registry <code class="highlight">docker tag alpine:latest k3d-mycluster-registry:12345/testimage:local</code> and push it <code class="highlight">docker push k3d-mycluster-registry: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 class="highlight">kubectl run --image k3d-mycluster-registry:12345/testimage:local testimage --command -- tail -f /dev/null</code> (creates a container that will not do anything but keep on running)</li>
</ol>
<h4 id="create-a-customized-k3d-managed-registry">Create a customized k3d-managed registry<a class="headerlink" href="#create-a-customized-k3d-managed-registry" title="Permanent link">&para;</a></h4>
<ol>
<li><code class="highlight">k3d registry create myregistry.localhost --port <span class="m">5111</span></code> creates a new registry called <code>myregistry.localhost</code> (could be used with automatic resolution of <code>*.localhost</code>, see next section)</li>
<li><code class="highlight">k3d cluster create newcluster --registry-use k3d-myregistry.localhost:5111</code> (make sure you use the <code>k3d-</code> prefix here) creates a new cluster set up to us that registry</li>
<li>continue with step 3 and 4 from the last section for testing</li>
</ol>
<h3 id="using-your-own-not-k3d-managed-local-registry">Using your own (not k3d-managed) local registry<a class="headerlink" href="#using-your-own-not-k3d-managed-local-registry" title="Permanent link">&para;</a></h3>
<p>You can start your own local registry it with some <code>docker</code> commands, like:</p>
<div class="highlight"><pre><span></span><code>docker volume create local_registry
docker container run -d --name registry.localhost -v local_registry:/var/lib/registry --restart always -p <span class="m">5000</span>:5000 registry:2
@ -772,37 +829,35 @@ Otherwise, it&rsquo;s installable using <code>sudo apt install libnss-myhostname
</ul>
<p>We will verify these two things for a local registry (located at <code>registry.localhost:5000</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&rsquo;s documentation for this).</p>
<p>First, we can download some image (like <code>nginx</code>) and push it to our local registry with:</p>
<p>```shell script
docker pull nginx:latest
<div class="highlight"><pre><span></span><code>docker pull nginx:latest
docker tag nginx:latest registry.localhost:5000/nginx:latest
docker push registry.localhost:5000/nginx:latest
<div class="highlight"><pre><span></span><code>Then we can deploy a pod referencing this image to your cluster:
```shell script
cat &lt;&lt;EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-test-registry
labels:
app: nginx-test-registry
spec:
replicas: 1
selector:
matchLabels:
app: nginx-test-registry
template:
metadata:
labels:
app: nginx-test-registry
spec:
containers:
- name: nginx-test-registry
image: registry.localhost:5000/nginx:latest
ports:
- containerPort: 80
EOF
</code></pre></div></p>
</code></pre></div>
<p>Then we can deploy a pod referencing this image to your cluster:</p>
<div class="highlight"><pre><span></span><code>cat <span class="s">&lt;&lt;EOF | kubectl apply -f -</span>
<span class="s">apiVersion: apps/v1</span>
<span class="s">kind: Deployment</span>
<span class="s">metadata:</span>
<span class="s"> name: nginx-test-registry</span>
<span class="s"> labels:</span>
<span class="s"> app: nginx-test-registry</span>
<span class="s">spec:</span>
<span class="s"> replicas: 1</span>
<span class="s"> selector:</span>
<span class="s"> matchLabels:</span>
<span class="s"> app: nginx-test-registry</span>
<span class="s"> template:</span>
<span class="s"> metadata:</span>
<span class="s"> labels:</span>
<span class="s"> app: nginx-test-registry</span>
<span class="s"> spec:</span>
<span class="s"> containers:</span>
<span class="s"> - name: nginx-test-registry</span>
<span class="s"> image: registry.localhost:5000/nginx:latest</span>
<span class="s"> ports:</span>
<span class="s"> - containerPort: 80</span>
<span class="s">EOF</span>
</code></pre></div>
<p>Then you should check that the pod is running with <code>kubectl get pods -l "app=nginx-test-registry"</code>.</p>
<h2 id="configuring-registries-for-k3s-v091">Configuring registries for k3s &lt;= v0.9.1<a class="headerlink" href="#configuring-registries-for-k3s-v091" title="Permanent link">&para;</a></h2>
<p>k3s servers below v0.9.1 do not recognize the <code>registries.yaml</code> file as described in
@ -847,7 +902,7 @@ sandbox_image = "{{ .NodeConfig.AgentConfig.PauseImage }}"
<div class="md-source-date">
<small>
Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">October 2, 2020</span>
Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">January 7, 2021</span>
</small>
</div>

@ -587,8 +587,8 @@
<h1 id="handling-kubeconfigs">Handling Kubeconfigs<a class="headerlink" href="#handling-kubeconfigs" title="Permanent link">&para;</a></h1>
<p>By default, k3d won&rsquo;t touch your kubeconfig without you telling it to do so.
To get a kubeconfig set up for you to connect to a k3d cluster, you can go different ways.</p>
<p>By default, k3d will update your default kubeconfig with your new cluster&rsquo;s 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>
<details class="question"><summary>What is the default kubeconfig?</summary><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 <em>exactly one</em> file</li>
@ -604,16 +604,16 @@ To get a kubeconfig set up for you to connect to a k3d cluster, you can go diffe
<li><em>Note 2</em>: alternatively you can use <code class="highlight">k3d kubeconfig get mycluster &gt; some-file.yaml</code></li>
</ul>
</li>
<li>Update your default kubeconfig <strong>upon</strong> cluster creation<ul>
<li><code class="highlight">k3d cluster create mycluster --update-kubeconfig</code><ul>
<li><em>Note:</em> this won&rsquo;t switch the current-context (append <code>--switch-context</code> to do so)</li>
<li>Update your default kubeconfig <strong>upon</strong> cluster creation (DEFAULT)<ul>
<li><code class="highlight">k3d cluster create mycluster --kubeconfig-update-default</code><ul>
<li><em>Note:</em> this won&rsquo;t switch the current-context (append <code>--kubeconfig-switch-context</code> to do so)</li>
</ul>
</li>
</ul>
</li>
<li>Update your default kubeconfig <strong>after</strong> cluster creation<ul>
<li><code class="highlight">k3d kubeconfig merge mycluster --merge-default-kubeconfig</code><ul>
<li><em>Note:</em> this won&rsquo;t switch the current-context (append <code>--switch-context</code> to do so)</li>
<li><code class="highlight">k3d kubeconfig merge mycluster --kubeconfig-merge-default</code><ul>
<li><em>Note:</em> this won&rsquo;t switch the current-context (append <code>--kubeconfig-switch-context</code> to do so)</li>
</ul>
</li>
</ul>
@ -631,16 +631,16 @@ To get a kubeconfig set up for you to connect to a k3d cluster, you can go diffe
<p class="admonition-title">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>--switch-context</code> flag.</p>
You can switch the current-context directly with the <code>kubeconfig merge</code> command by adding the <code>--kubeconfig-switch-context</code> flag.</p>
</div>
<h2 id="removing-cluster-details-from-the-kubeconfig">Removing cluster details from the kubeconfig<a class="headerlink" href="#removing-cluster-details-from-the-kubeconfig" title="Permanent link">&para;</a></h2>
<p><code class="highlight">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>
<h2 id="handling-multiple-clusters">Handling multiple clusters<a class="headerlink" href="#handling-multiple-clusters" title="Permanent link">&para;</a></h2>
<p><code>k3d kubeconfig merge</code> let&rsquo;s you specify one or more clusters via arguments <em>or</em> all via <code>--all</code>.
All kubeconfigs will then be merged into a single file if <code>--merge-default-kubeconfig</code> or <code>--output</code> is specified.
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>--switch-context</code> flag will change the current context to the cluster which was last in the list.</p>
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>
@ -649,7 +649,7 @@ Note, that with multiple cluster specified, the <code>--switch-context</code> fl
<div class="md-source-date">
<small>
Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">August 5, 2020</span>
Last update: <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">January 5, 2021</span>
</small>
</div>

Loading…
Cancel
Save