Home

Awesome

Kubernetes k3d extension for Visual Studio Code

Visual Studio Marketplace Version Visual Studio Marketplace Installs Visual Studio Marketplace Rating

Overview

This extension displays your k3d local clusters in the Kubernetes extension's Cloud Explorer. You can use this to create and delete clusters, and to merge them into your kubeconfig.

IMPORTANT: This is an early stage preview. It's not feature complete! Feature requests welcome via the issues page. (And let us know about bugs too!)

This project was developed by @inercia and originally based on the KinD plugin for VSCode.

Features

Installation

You can find this plugin in the VSCode Marketplace. You will find detailed installation instructions there.

This extension will download the latest, stable version of k3d automatically, although you can force a specific instalation channel of k3d with some settings (see bellow).

Settings

This extension is controlled by a multitude of user settings. These settings can be changed from Preferences > Settings in Extensions > Kubernetes k3d or from settings JSON file.

<p><img src="images/demo-preferences.gif" width="700"/></p>

The following list contains all the options and their default values.:

OptionDescriptionDefault value
k3d.updateChannelUpdate channel for downloading k3d binaries: stable/all"all"
k3d.pathspaths for different tools. [see following settings]{}
k3d.paths.k3dthis extension will download a recent version of k3d automatically, but you can use your own binary by seting this parameter. You can use OS-specific binaries by using k3d.paths.k3d-{linux,mac,windows} instead.""
k3d.updateKubeconfigupdate the kubeconfig after creating/destroying a cluster. It can be always, never or onCreate."always"
k3d.kubeconfiguse this kubeconfig for making modificatios after creating/destroying clusters. Note well that this kubeconfig must be in the vs-kubernetes.knownKubeconfigs for being shown in the clusters view.""
k3d.defaultsdefaults for different parameters used for new K3D clusters. [see following settings]{}
k3d.defaults.imagedefault image for creating the Docker nodes in new K3D clusters.""
k3d.defaults.networkdefault existing network to join all the new K3D clusters.""
k3d.defaults.numServersdefault number of server nodes for new K3D clusters.1
k3d.defaults.numAgentsdefault number of agent nodes for new K3D clusters.0
k3d.defaults.serverArgsdefault K3S server arguments for new K3D clusters.""
k3d.imagesimages used for creating nodes in new K3D cluster.{}
k3d.images.proposalsRegistryregistry used for looking for images for the cluster (defaults to the Docker Hub).https://registry.hub.docker.com
k3d.images.proposalsRepoimage repository used for proposing images for nodes, including the namespace (ie, rancher/k3s)rancher/k3s
k3d.images.proposalsTagRegexfilter proposed images tags with a regex (ie, .*v1\\.19.* for filtering all the images with a 1.19 tag).""

Example configuration:

    "k3d.updateKubeconfig": "always",
    "k3d.paths": {
        "k3d.paths.k3d-linux": "/home/user/bin/k3d"
    },
    "k3d.defaults": {
        "k3d.defaults.image": "docker.io/rancher/k3s:v1.19.5-k3s1"
    }

Keyboard shortcuts

All the k3d extension commands can be accessed from the Visual Studio Code command palette. However, there are some global keyboard shortcuts pre-defined for running some of the most frequent actions:

You can redefine the keybindings or assign new keybindings to other k3d commands by following the official documentation.

Note well that, when using the "last settings", some settings will not be reused and a new random value will be generated, like the cluster name.

Development

The easiest way to start coding on the extension is by following these steps: