k3d-io / vscode-k3d

Kubernetes k3d extension for Visual Studio Code
MIT License
116 stars 8 forks source link
k3d kubernetes vscode

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.

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

Option Description Default value
k3d.updateChannel Update channel for downloading k3d binaries: stable/all "all"
k3d.paths paths for different tools. [see following settings] {}
k3d.paths.k3d this 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.updateKubeconfig update the kubeconfig after creating/destroying a cluster. It can be always, never or onCreate. "always"
k3d.kubeconfig use 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.defaults defaults for different parameters used for new K3D clusters. [see following settings] {}
k3d.defaults.image default image for creating the Docker nodes in new K3D clusters. ""
k3d.defaults.network default existing network to join all the new K3D clusters. ""
k3d.defaults.numServers default number of server nodes for new K3D clusters. 1
k3d.defaults.numAgents default number of agent nodes for new K3D clusters. 0
k3d.defaults.serverArgs default K3S server arguments for new K3D clusters. ""
k3d.images images used for creating nodes in new K3D cluster. {}
k3d.images.proposalsRegistry registry used for looking for images for the cluster (defaults to the Docker Hub). https://registry.hub.docker.com
k3d.images.proposalsRepo image repository used for proposing images for nodes, including the namespace (ie, rancher/k3s) rancher/k3s
k3d.images.proposalsTagRegex filter 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: