### Install k3d with arkade Source: https://k3d.io/stable Installs k3d using the arkade tool. Ensure arkade is installed. ```bash arkade get k3d ``` -------------------------------- ### k3d Cluster Start Options Source: https://k3d.io/stable/usage/commands/k3d_cluster_start Options for the 'k3d cluster start' command, including starting all clusters, help, timeout, and waiting for server readiness. ```bash -a, --all Start all existing clusters -h, --help help for start --timeout duration Maximum waiting time for '--wait' before canceling/returning. --wait Wait for the server(s) (and loadbalancer) to be ready before returning. (default true) ``` -------------------------------- ### Install k3d with Scoop Source: https://k3d.io/stable Installs k3d on Windows using the Scoop package manager. Ensure Scoop is installed. ```powershell scoop install k3d ``` -------------------------------- ### Install k3d using wget Source: https://k3d.io/stable Installs the current latest release of k3d using wget. Ensure Docker is installed and meets version requirements. ```bash wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash ``` -------------------------------- ### Install k3d with asdf Source: https://k3d.io/stable Installs k3d using the asdf version manager. First, add the plugin, then install the latest version or a specific tag. ```bash asdf plugin-add k3d && asdf install k3d latest ``` -------------------------------- ### k3d node start Command Synopsis Source: https://k3d.io/stable/usage/commands/k3d_node_start The basic syntax for starting an existing k3d node. Specify the node name and any desired flags. ```bash k3d node start NODE [flags] ``` -------------------------------- ### k3d Cluster Start Synopsis Source: https://k3d.io/stable/usage/commands/k3d_cluster_start The basic syntax for starting k3d cluster(s). You can specify cluster names or use the --all flag. ```bash k3d cluster start [NAME [NAME...] | --all] [flags] ``` -------------------------------- ### Example k3d Config File with All Options Source: https://k3d.io/stable/usage/configfile This example demonstrates a comprehensive k3d configuration file, showcasing all available options as of the time of writing. It covers various settings for cluster creation and management. ```yaml apiVersion: k3d.io/v1alpha5 kind: Simple metadata: name: mycluster labels: purpose: testing owner: me annotations: description: "My awesome k3d cluster" config: env: - MY_VAR=my_value - ANOTHER_VAR=another_value volumes: - /path/on/host:/path/in/cluster - /local/path:/path/in/cluster:ro ports: - host: "8080" container: 80 - host: "8443" container: 443 kubeAPI: host: "127.0.0.1" hostPort: "6443" loadBalancer: config: extraRoutes: - "192.168.1.0/24" hostPort: "80" ingress: - name: "ingress-nginx" controller: image: "ingress-nginx/controller:v1.0.0" ports: http: 80 https: 443 extraArgs: - publish-service=ingress-nginx/ingress-nginx-controller cluster: loadBalancer: mode: "auto" portMappings: - container: 80 host: 8080 protocol: http - container: 443 host: 8443 protocol: https network: "k3d-net" disableLoadBalancer: false disableRollback: false kubeAPI: loadBalancer: true accessInternal: false token: "my-secret-token" runtime: "docker" cgroup: cpu: "1000" memory: "1024" registry: disable: false image: "docker.io/rancher/k3s:v1.21.3-k3s1" config: | { ``` -------------------------------- ### Install k3d with Homebrew Source: https://k3d.io/stable Installs k3d on macOS or Linux using the Homebrew package manager. Ensure Homebrew is installed. ```bash brew install k3d ``` -------------------------------- ### Enable and Start User Podman Socket (Rootless) Source: https://k3d.io/stable/usage/advanced/podman For rootless Podman, ensure the user Podman socket is available. Enable and start the user socket service or run the Podman system service daemonless. ```bash systemctl --user enable --now podman.socket # or podman system service --time=0 & ``` -------------------------------- ### Install k3d with AUR Source: https://k3d.io/stable Installs k3d on Arch Linux using the AUR helper 'yay'. Ensure yay is installed. ```bash yay -S rancher-k3d-bin ``` -------------------------------- ### Start Podman Machine on macOS Source: https://k3d.io/stable/usage/advanced/podman Start an existing Podman machine on macOS. This command ensures the Podman environment is running and accessible. ```bash podman machine start ``` -------------------------------- ### k3d node start Help Flag Source: https://k3d.io/stable/usage/commands/k3d_node_start Use the -h or --help flag to display help information for the k3d node start command. ```bash -h, --help help for start ``` -------------------------------- ### Install k3d using curl Source: https://k3d.io/stable Installs the current latest release of k3d using curl. Ensure Docker is installed and meets version requirements. ```bash curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash ``` -------------------------------- ### Install k3d with go Source: https://k3d.io/stable Installs the latest bleeding-edge version of k3d using go. This may include unreleased changes. ```bash go install github.com/k3d-io/k3d/v5@latest ``` -------------------------------- ### Install specific k3d release using wget Source: https://k3d.io/stable Installs a specific release of k3d by setting the TAG environment variable with wget. Ensure Docker is installed and meets version requirements. ```bash wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=v5.0.0 bash ``` -------------------------------- ### Enable and Start Podman Socket Source: https://k3d.io/stable/usage/advanced/podman Ensure the Podman system socket is available and running. This can be done by enabling and starting the socket service or by running the Podman service daemonless. ```bash sudo systemctl enable --now podman.socket # or to start the socket daemonless # sudo podman system service --time=0 & ``` -------------------------------- ### Install specific k3d release using curl Source: https://k3d.io/stable Installs a specific release of k3d by setting the TAG environment variable with curl. Ensure Docker is installed and meets version requirements. ```bash curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=v5.0.0 bash ``` -------------------------------- ### k3d kubeconfig get Command Synopsis Source: https://k3d.io/stable/usage/commands/k3d_kubeconfig_get This is the basic syntax for the k3d kubeconfig get command. It shows how to specify clusters or use the --all flag. ```bash k3d kubeconfig get [CLUSTER [CLUSTER [...]] | --all] [flags] ``` -------------------------------- ### k3d version Synopsis Source: https://k3d.io/stable/usage/commands/k3d_version Displays the k3d and default k3s version. This is the basic command to check installed versions. ```bash k3d version [flags] ``` -------------------------------- ### Run a Self-Hosted Local Registry Source: https://k3d.io/stable/usage/registries Starts a local registry container using Docker. This involves creating a Docker volume for persistent storage and running the registry image, mapping host port 12345 to the container's 5000. ```bash docker volume create local_registry docker container run -d --name registry.localhost -v local_registry:/var/lib/registry --restart always -p 12345:5000 registry:2 ``` -------------------------------- ### k3d kubeconfig get Options Source: https://k3d.io/stable/usage/commands/k3d_kubeconfig_get These are the specific options available for the k3d kubeconfig get command, including the flag to get all cluster configurations. ```bash -a, --all Output kubeconfigs from all existing clusters -h, --help help for get ``` -------------------------------- ### k3d registry create with Custom Port Source: https://k3d.io/stable/usage/commands/k3d_registry_create Use this command to create a registry and specify a particular host port for it to listen on. The example shows binding to all interfaces on port 5111. ```bash k3d registry create --port 0.0.0.0:5111 ``` -------------------------------- ### k3d Cluster Creation with Mounted Registries and Certificates Source: https://k3d.io/stable/usage/registries Command to create a k3d cluster, mounting both the registries configuration file and the CA certificate for secure registries. Ensure the paths match your setup. ```bash k3d cluster create \ --volume "${HOME}/.k3d/my-registries.yaml:/etc/rancher/k3s/registries.yaml" \ --volume "${HOME}/.k3d/my-company-root.pem:/etc/ssl/certs/my-company-root.pem" ``` -------------------------------- ### Create Calico Custom Resources Source: https://k3d.io/stable/usage/advanced/calico Apply this manifest to instruct the Tigera Operator to install Calico with its default configurations. ```bash kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.29.0/manifests/custom-resources.yaml ``` -------------------------------- ### Define Registry Proxy via k3d Configuration File Source: https://k3d.io/stable/usage/registries This YAML configuration file defines a simple k3d cluster setup, including a registry proxy for Docker Hub and its mirror configuration. ```yaml apiVersion: k3d.io/v1alpha5 kind: Simple metadata: name: test-regcache registries: create: name: docker-io # name of the registry container proxy: remoteURL: https://registry-1.docker.io # proxy DockerHub volumes: - /tmp/reg:/var/lib/registry # persist data locally in /tmp/reg config: | mirrors: "docker.io": endpoint: - http://docker-io:5000 ``` -------------------------------- ### Mounting /dev/mapper for BTRFS Source: https://k3d.io/stable/faq/faq When using k3d on a system with BTRFS, you may need to mount `/dev/mapper` into the nodes for the setup to work correctly. ```bash k3d cluster create CLUSTER_NAME -v /dev/mapper:/dev/mapper ``` -------------------------------- ### K3s ZFS Initialization Error Source: https://k3d.io/stable/faq/faq This log indicates an issue with ZFS support in k3s, preventing multi-server setups from initializing. ```log starting kubernetes: preparing server: start cluster and https: raft_init(): io: create I/O capabilities probe file: posix_allocate: operation not supported on socket ``` -------------------------------- ### Verify Calico Installation Status Source: https://k3d.io/stable/usage/advanced/calico Check the status of the Calico components after installation. The output should indicate that components like 'apiserver' and 'calico' are available and not progressing or degraded. ```bash kubectl get tigerastatus ``` -------------------------------- ### CUDA Vector Addition Test Output Source: https://k3d.io/stable/usage/advanced/cuda Example output from the 'kubectl logs cuda-vector-add' command, indicating a successful vector addition test on the CUDA device. ```text [Vector addition of 50000 elements] Copy input data from the host memory to the CUDA device CUDA kernel launch with 196 blocks of 256 threads Copy output data from the CUDA device to the host memory Test PASSED Done ``` -------------------------------- ### Mapping Ports with k3d node edit Source: https://k3d.io/stable/usage/commands/k3d_node_edit Use the --port-add flag to map ports from a node container to the host. This is experimental and primarily for serverlb nodes. Example shows mapping host port 8080 to container port 80. ```bash -h, --help help for edit --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]) - Example: `k3d node edit k3d-mycluster-serverlb --port-add 8080:80` ``` -------------------------------- ### Custom K3s Dockerfile for CUDA Support Source: https://k3d.io/stable/usage/advanced/cuda This Dockerfile builds a custom K3s image using an Ubuntu-based NVIDIA CUDA image as the base. It installs the NVIDIA Container Toolkit and configures containerd to use it. The NVIDIA device plugin manifest is also copied into the image. ```dockerfile ARG K3S_TAG="v1.28.8-k3s1" ARG CUDA_TAG="12.4.1-base-ubuntu22.04" FROM rancher/k3s:$K3S_TAG as k3s FROM nvcr.io/nvidia/cuda:$CUDA_TAG # Install the NVIDIA container toolkit RUN apt-get update && apt-get install -y curl \ && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \ && curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \ sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \ tee /etc/apt/sources.list.d/nvidia-container-toolkit.list \ && apt-get update && apt-get install -y nvidia-container-toolkit \ && nvidia-ctk runtime configure --runtime=containerd COPY --from=k3s / / --exclude=/bin COPY --from=k3s /bin /bin # Deploy the nvidia driver plugin on startup COPY device-plugin-daemonset.yaml /var/lib/rancher/k3s/server/manifests/nvidia-device-plugin-daemonset.yaml VOLUME /var/lib/kubelet VOLUME /var/lib/rancher/k3s VOLUME /var/lib/cni VOLUME /var/log ENV PATH="$PATH:/bin/aux" ENTRYPOINT ["/bin/k3s"] CMD ["agent"] ``` -------------------------------- ### Install Tigera Operator for Calico Source: https://k3d.io/stable/usage/advanced/calico This command installs the Tigera Operator, which is used to manage the installation and configuration of Calico within the Kubernetes cluster. ```bash kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.29.0/manifests/tigera-operator.yaml ``` -------------------------------- ### Create a Local Registry with Podman Source: https://k3d.io/stable/usage/advanced/podman When using Podman, specify the network with `--default-network` for registry creation. ```bash k3d registry create --default-network podman mycluster-registry ``` -------------------------------- ### k3d config init Command Options Source: https://k3d.io/stable/usage/commands/k3d_config_init Available options for the k3d config init command, including force overwrite and output file specification. ```bash -f, --force Force overwrite of target file -h, --help help for init -o, --output string Write a default k3d config (default "k3d-default.yaml") ``` -------------------------------- ### k3d config init Command Usage Source: https://k3d.io/stable/usage/commands/k3d_config_init Basic usage of the k3d config init command. ```bash k3d config init [flags] ``` -------------------------------- ### Create Cluster from Configuration File Source: https://k3d.io/stable/usage/registries Create a k3d cluster using a configuration file that specifies registry settings, including a pull-through cache. ```bash k3d cluster create -c /home/me/test-regcache.yaml ``` -------------------------------- ### k3d node Help Options Source: https://k3d.io/stable/usage/commands/k3d_node Displays help information for the k3d node command. ```bash -h, --help help for node ``` -------------------------------- ### k3d registry Help Options Source: https://k3d.io/stable/usage/commands/k3d_registry Shows the help flag for the k3d registry command. ```bash -h, --help help for registry ``` -------------------------------- ### Initialize Podman Machine on macOS Source: https://k3d.io/stable/usage/advanced/podman On macOS, initialize a Podman machine if one does not already exist. This command sets up a new virtual machine for Podman. ```bash podman machine init ``` -------------------------------- ### Enable Container IP Forwarding in Calico Source: https://k3d.io/stable/usage/advanced/calico Patch the Calico installation to enable container IP forwarding, which can resolve issues with load balancers. This setting is applied to the default installation. ```bash kubectl patch installation default --type=merge --patch='{"spec":{"calicoNetwork":{"containerIPForwarding":"Enabled"}}}' ``` -------------------------------- ### Mounting volumes with k3d cluster create Source: https://k3d.io/stable/usage/commands/k3d_cluster_create Demonstrates how to mount volumes into k3d cluster nodes using the -v or --volume flag. It shows specifying source and destination paths, and optionally filtering nodes by role and index. ```bash k3d cluster create --agents 2 -v /my/path@agent:0,1 -v /tmp/test:/tmp/other@server:0 ``` -------------------------------- ### k3d cluster Command Options Source: https://k3d.io/stable/usage/commands/k3d_cluster Provides help for the 'k3d cluster' command. Use the --help flag to see available options. ```bash -h, --help help for cluster ``` -------------------------------- ### Get Kubeconfig for a Specific Cluster to a File Source: https://k3d.io/stable/usage/kubeconfig Retrieves the kubeconfig for a specific k3d cluster and redirects its output to a specified YAML file. ```bash k3d kubeconfig get mycluster > some-file.yaml ``` -------------------------------- ### Create Another Cluster with the Same Registry Source: https://k3d.io/stable/usage/registries Demonstrates that subsequent cluster creations using the same registry configuration will benefit from the existing local cache. ```bash k3d cluster create cluster02 --registry-use k3d-docker-io:5000 --registry-config registry.yml ``` -------------------------------- ### Curl Nginx via NodePort Source: https://k3d.io/stable/usage/exposing_services Tests the NodePort setup by curling the Nginx service through the host's mapped port 8082. ```bash curl localhost:8082/ ``` -------------------------------- ### k3d registry create Command Synopsis Source: https://k3d.io/stable/usage/commands/k3d_registry_create This is the basic command structure for creating a new registry. Replace NAME with your desired registry name. ```bash k3d registry create NAME [flags] ``` -------------------------------- ### K3d Image Command Help Option Source: https://k3d.io/stable/usage/commands/k3d_image Use the help flag to display information about the image command and its available options. ```bash k3d image --help ``` -------------------------------- ### Curl Nginx via Ingress Source: https://k3d.io/stable/usage/exposing_services Tests the Ingress setup by curling the Nginx service through the host's mapped port 8081. ```bash curl localhost:8081/ ``` -------------------------------- ### Create Cluster, Update Default Kubeconfig, and Switch Context Source: https://k3d.io/stable/usage/kubeconfig Creates a new k3d cluster, updates the default kubeconfig, and switches the current context to the newly created cluster. ```bash k3d cluster create mycluster --kubeconfig-update-default --kubeconfig-switch-context ``` -------------------------------- ### Get k3d cluster nodes Source: https://k3d.io/stable Retrieves the list of nodes in the currently active k3d cluster using kubectl. This command verifies cluster status. ```bash kubectl get nodes ``` -------------------------------- ### K3d Config Command Synopsis Source: https://k3d.io/stable/usage/commands/k3d_config This is the basic syntax for the k3d config command. Use this to understand the command's structure. ```bash k3d config [flags] ``` -------------------------------- ### Get k3d kubeconfig Source: https://k3d.io/stable/usage/exposing_services Exports the kubeconfig for the k3d cluster, allowing kubectl commands to interact with the cluster. This is often redundant as cluster creation usually merges it. ```bash export KUBECONFIG="$(k3d kubeconfig write k3s-default)" ``` -------------------------------- ### k3d registry create with Proxy Configuration Source: https://k3d.io/stable/usage/commands/k3d_registry_create Configure the registry to act as a proxy for a remote registry, providing authentication details if required. ```bash k3d registry create --proxy-remote-url https://my.remote.registry.com --proxy-username myuser --proxy-password mypassword ``` -------------------------------- ### k3d CLI Synopsis Source: https://k3d.io/stable/usage/commands/k3d The basic syntax for using the k3d command-line tool. This shows the general structure for invoking k3d commands and flags. ```bash k3d [flags] ``` -------------------------------- ### Create a k3d Cluster with IPAM Enabled Source: https://k3d.io/stable/usage/multiserver When restarting a cluster, node IPs might change, causing startup failures. Enable the experimental IPAM feature by specifying a subnet (e.g., `--subnet auto` or `--subnet 172.45.0.0/16`) to assign static IPs to containers. ```bash k3d cluster create multiserver --servers 3 --subnet auto ``` -------------------------------- ### Set DOCKER_HOST for Podman Source: https://k3d.io/stable/usage/advanced/podman Alternatively, point k3d to the Podman socket by setting the DOCKER_HOST and DOCKER_SOCK environment variables. Use sudo with --preserve-env to pass these variables to the k3d command. ```bash export DOCKER_HOST=unix:///run/podman/podman.sock export DOCKER_SOCK=/run/podman/podman.sock sudo --preserve-env=DOCKER_HOST --preserve-env=DOCKER_SOCK k3d cluster create ``` -------------------------------- ### Set DOCKER_HOST for Remote Podman Source: https://k3d.io/stable/usage/advanced/podman To use a remote Podman instance, start the Podman service on the remote host and set the DOCKER_HOST environment variable to the SSH connection string. The DOCKER_SOCK should point to the user's Podman socket on the remote host. ```bash export DOCKER_HOST=ssh://username@hostname export DOCKER_SOCK=/run/user/1000/podman/podman.sock k3d cluster create ``` -------------------------------- ### Use a Local Registry with a k3d Cluster Source: https://k3d.io/stable/usage/advanced/podman Integrate a previously created local registry with a k3d cluster using the `--registry-use` flag. ```bash k3d cluster create --registry-use mycluster-registry mycluster ``` -------------------------------- ### Load k3d completion for Fish (current session) Source: https://k3d.io/stable/usage/commands/k3d_completion Generates and loads fish completion scripts for the current k3d session. ```fish k3d completion fish | source ``` -------------------------------- ### Manually Apply Device Plugin DaemonSet Source: https://k3d.io/stable/usage/advanced/cuda This command applies the device plugin daemonset manually if the pod remains in a 'Pending' state, which can occur if auto-deployment fails. ```bash kubectl apply -f device-plugin-daemonset.yaml ``` -------------------------------- ### Deploy and Test CUDA Vector Addition Source: https://k3d.io/stable/usage/advanced/cuda Deploys a sample CUDA vector addition application to the cluster and retrieves its logs for verification. This confirms the GPU functionality. ```bash kubectl apply -f cuda-vector-add.yaml kubectl logs cuda-vector-add ``` -------------------------------- ### Run Pod using Image from Local Registry Source: https://k3d.io/stable/usage/registries Creates a Kubernetes pod named 'testimage' that uses the 'alpine:latest' image from the local registry 'k3d-registry.localhost:12345'. The pod is configured to run 'tail -f /dev/null' to keep it running. ```bash kubectl run --image k3d-registry.localhost:12345/testimage:local testimage --command -- tail -f /dev/null ``` -------------------------------- ### Push Alpine Image to Local Registry Source: https://k3d.io/stable/usage/registries Pulls the 'alpine:latest' image, tags it for the local registry 'k3d-registry.localhost:12345' with the name 'testimage:local', and then pushes it to the registry. ```bash docker pull alpine:latest docker tag alpine:latest k3d-registry.localhost:12345/testimage:local docker push k3d-registry.localhost:12345/testimage:local ``` -------------------------------- ### k3d registry list Command Options Source: https://k3d.io/stable/usage/commands/k3d_registry_list These are the specific options available for the 'k3d registry list' command, including help and output formatting. ```bash -h, --help help for list --no-headers Disable headers -o, --output string Output format. One of: json|yaml ``` -------------------------------- ### k3d cluster create Synopsis Source: https://k3d.io/stable/usage/commands/k3d_cluster_create The basic synopsis for creating a k3d cluster. Use this command to initiate a new k3s cluster with containerized nodes. ```bash k3d cluster create NAME [flags] ``` -------------------------------- ### k3d completion command usage Source: https://k3d.io/stable/usage/commands/k3d_completion Shows the general syntax for generating k3d completion scripts for a specified shell. ```bash k3d completion SHELL ``` -------------------------------- ### k3d registry create with Network Specification Source: https://k3d.io/stable/usage/commands/k3d_registry_create Connect the registry to a specific Docker network. The default is 'bridge'. ```bash k3d registry create --default-network my-custom-network ``` -------------------------------- ### Configure cgroup v2 Delegation for Rootless Podman Source: https://k3d.io/stable/usage/advanced/podman For rootless Podman to run properly, enable CPU, CPUSET, and I/O delegation for cgroup v2. This involves creating a configuration file within systemd's user service directory. ```bash mkdir -p /etc/systemd/system/user@.service.d cat > /etc/systemd/system/user@.service.d/delegate.conf < k3d completion powershell | Out-String | Invoke-Expression ``` -------------------------------- ### Create Cluster and Update Default Kubeconfig Source: https://k3d.io/stable/usage/kubeconfig Creates a new k3d cluster and automatically updates the default kubeconfig file. The current context is not switched by default. ```bash k3d cluster create mycluster --kubeconfig-update-default ``` -------------------------------- ### Basic Registries Configuration File Source: https://k3d.io/stable/usage/registries Defines mirrors for a remote registry. Use this when you need to pull images from a specific registry mirror. ```yaml mirrors: "my.company.registry:5000": endpoint: - http://my.company.registry:5000 ``` -------------------------------- ### Set DOCKER_HOST for Rootless Podman Source: https://k3d.io/stable/usage/advanced/podman When using rootless Podman, set the DOCKER_HOST and DOCKER_SOCK environment variables to point to the user's Podman socket. Ensure XDG_RUNTIME_DIR is correctly set. ```bash XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/run/user/$(id -u)} export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/podman/podman.sock export DOCKER_SOCK=$XDG_RUNTIME_DIR/podman/podman.sock k3d cluster create ``` -------------------------------- ### Create k3d cluster for Ingress Source: https://k3d.io/stable/usage/exposing_services Creates a k3d cluster with the ingress controller's port 80 mapped to host port 8081. This is the recommended approach for exposing services. ```bash k3d cluster create --api-port 6550 -p "8081:80@loadbalancer" --agents 2 ``` -------------------------------- ### Deploy Nginx using Image from Local Registry Source: https://k3d.io/stable/usage/registries Applies a Kubernetes Deployment manifest to create a pod that uses the 'nginx:latest' image from the local registry 'k3d-registry.localhost:12345'. ```yaml 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: k3d-registry.localhost:12345/nginx:latest ports: - containerPort: 80 ``` -------------------------------- ### K3d Image Command Synopsis Source: https://k3d.io/stable/usage/commands/k3d_image This is the main command for handling container images in k3d. Use this to access subcommands like import. ```bash k3d image [flags] ``` -------------------------------- ### List k3d Clusters with JSON Output Source: https://k3d.io/stable/usage/commands/k3d_cluster_list Lists k3d clusters and formats the output as JSON. This is useful for programmatic processing of cluster information. ```bash k3d cluster list -o json ``` -------------------------------- ### k3d node stop Help Flag Source: https://k3d.io/stable/usage/commands/k3d_node_stop Use the --help flag to display help information for the 'k3d node stop' command. ```bash -h, --help help for stop ``` -------------------------------- ### k3d version list Command Options Source: https://k3d.io/stable/usage/commands/k3d_version_list Available options for filtering and controlling the output of the k3d version list command, including exclusion, inclusion, limiting, and sorting. ```bash -e, --exclude string Exclude Regexp (default excludes pre-releases and arch-specific tags) (default ".+(rc|engine|alpha|beta|dev|test|arm|arm64|amd64|s390x).*") ``` ```bash -f, --format string [DEPRECATED] Use --output instead (default "raw") ``` ```bash -h, --help help for list ``` ```bash -i, --include string Include Regexp (default includes everything (default ".*") ``` ```bash -l, --limit int Limit number of tags in output (0 = unlimited) ``` ```bash -o, --output string Output Format [raw | repo] (default "raw") ``` ```bash -s, --sort string Sort Mode (asc | desc | off) (default "desc") ``` -------------------------------- ### k3d node create Inherited Options Source: https://k3d.io/stable/usage/commands/k3d_node_create These options are inherited from parent commands and can be used with k3d node create to control logging verbosity and timestamps. ```bash --timestamps Enable Log timestamps --trace Enable super verbose output (trace logging) --verbose Enable verbose output (debug logging) ``` -------------------------------- ### Volume and Port Mapping Configuration Source: https://k3d.io/stable/usage/configfile Configures volume mounts and port mappings for k3d cluster nodes. Volumes can be mapped from the host to the node, and host ports can be exposed through the load balancer. ```yaml volumes: - volume: /my/host/path:/path/in/node nodeFilters: - server:0 - agent:* ports: - port: 8080:80 nodeFilters: - loadbalancer ``` -------------------------------- ### Set DOCKER_HOST for Rootful Podman on macOS Source: https://k3d.io/stable/usage/advanced/podman For rootful Podman connections on macOS, export the appropriate DOCKER_HOST and DOCKER_SOCK environment variables and then create the k3d cluster. ```bash export DOCKER_HOST=ssh://root@localhost:53685 export DOCKER_SOCK=/run/podman/podman.sock k3d cluster create ```