vscode-kubernetes-tools
Visual Studio Code Kubernetes Tools
The extension for developers building applications to run in Kubernetes clusters
and for DevOps staff troubleshooting Kubernetes applications.
Works with any Kubernetes anywhere (Azure, Minikube, AWS, GCP and more!).
Features include:
-
View your clusters in an explorer tree view, and drill into workloads, services,
pods and nodes. - Browse Helm repos and install charts into your Kubernetes cluster.
- Intellisense for Kubernetes resources and Helm charts and templates.
- Edit Kubernetes resource manifests and apply them to your cluster.
- Build and run containers in your cluster from Dockerfiles in your project.
-
View diffs of a resource’s current state against the resource manifest in your
Git repo - Easily check out the Git commit corresponding to a deployed application.
- Run commands or start a shell within your application’s pods.
- Get or follow logs and events from your clusters.
- Forward local ports to your application’s pods.
- Create Helm charts using scaffolding and snippets.
- Watch resources in the cluster explorer and get live updates as they change
What’s new in this version? See the change log to find out!
Getting started with the extension
Install
Open this extension in the Visual Studio Marketplace
Dependencies
The Kubernetes extension may need to invoke the following command line tools, depending on
which features you use. You will need kubectl
at minimum, and docker
or buildah
if you plan to
use the extension to build applications rather than only browse.
-
kubectl
-
docker
orbuildah
-
helm
Optional tools:
-
az
(Azure CLI – only if using the extension to create or register Azure clusters) -
minikube
(only if you want to use it) -
git
(only if using the ‘sync working copy to repository’ feature) -
buildah
(can be used as an alternative container image build tool)
We recommend you install these binaries on your system PATH before using the extension.
If these binaries aren’t on your system PATH, then some commands may not work. If the
extension needs one of the core Kubernetes tools and it’s missing, it will offer to
install it for you.
Configuration settings for building and running applications
If you want to use the Kubernetes: Run
and Kubernetes: Debug
features
then you need to configure a user and repository for your container
images. This is required because these commands need pushing an image of your application
for your cluster to run it. To do this, add the following to your VS Code preferences
(File > Preferences):
{ "vsdocker.imageUser": "<your-image-prefix-here>", }
where <your-image-prefix-here>
is something like docker.io/brendanburns
.
That’s it! You’re good to go.
Working with kubeconfigs
By default, the extension uses the active kubeconfig file — that is, the file
to which the KUBECONFIG environment variable points, or the default kubeconfig
if no KUBECONFIG environment variable exists. You can override this using the
vs-kubernetes.kubeconfig
setting in your user or workspace settings.
If you want to swap between multiple kubeconfig files, you can list them in the
vs-kubernetes.knownKubeconfigs
configuration setting and switch between them
using the Set Kubeconfig
command.
If you want to skip TLS verification for a particular cluster, you can edit your ~/.kube/config and set the insecure-skip-tls-verify: true
flag under the proper cluster:
- cluster:
insecure-skip-tls-verify: true
server: https://my-insecure-cluster:443
name: my-insecure-cluster:443
Commands and features
vs-kubernetes-tools
supports a number of commands for interacting with Kubernetes; these are accessible via the command menu (Ctrl+Shift+P
) and may be bound to keys in the normal way.
Kubernetes
General commands
-
Kubernetes: Load
– Load a resource from the Kubernetes API and create a new editor window. -
Kubernetes: Get
– Get the status for a specific resource. -
Kubernetes: Logs
– Open a view with a set of options to display/follow logs. -
Kubernetes: Follow Events
– Follow events on a selected namespace. -
Kubernetes: Show Events
– Show events on a selected namespace. -
Kubernetes: Watch
– Watch a specific resource or all resources of that object type, and update the cluster explorer as they change -
Kubernetes: Stop Watching
– Stop watching the specific resource
Commands while viewing a Kubernetes manifest file
-
Kubernetes: Explain
– Use thekubectl explain ...
tool to annotate Kubernetes API objects -
Kubernetes: Create
– Create an object using the current document -
Kubernetes: Delete
– Delete an object contained in the current document. -
Kubernetes: Apply
– Apply changes to an object contained in the current document. -
Kubernetes: Expose
– Expose the object in the current document as a service. -
Kubernetes: Describe
– Describe the object in a terminal window. -
Kubernetes: Diff
– Show the difference between a local copy of the object, and that which is deployed to the cluster.
Commands for application directories
-
Kubernetes: Run
– Run the current application as a Kubernetes Deployment -
Kubernetes: Terminal
– Open an interactive terminal session in a pod of the Kubernetes Deployment -
Kubernetes: Exec
– Run a command in a pod of the Kubernetes Deployment -
Kubernetes: Debug (Launch)
– Run the current application as a Kubernetes Deployment and attach a debugging session to it (currently works only for Java/Node.js deployments). See Debug support on Kubernetes cluster for more details. -
Kubernetes: Debug (Attach)
– Attach a debugging session to an existing Kubernetes Deployment (currently works only for Java deployments). See Debug support on Kubernetes cluster for more details. -
Kubernetes: Remove Debug
– Remove the deployment and/or service created for aKubernetes Debug (Launch)
session -
Kubernetes: Sync Working Copy to Cluster
– Checks out the version of the code that matches what is deployed in the cluster. (This relies on Docker image versions also being Git commit IDs, which the extension does if you use the Run command to build the container, but which typically doesn’t work for containers/deployments done by other means.)
Cluster creation commands
-
Kubernetes: Create Cluster
– Initiate the flow for creating a Kubernetes cluster with a selected cloud provider (eg: Azure), or creating a Minikube cluster locally.
Configuration commands
-
Kubernetes: Add Existing Cluster
– Install and configure the Kubernetes command line tool (kubectl) from a cloud cluster, such as an Azure Container Service (ACS) or Azure Kubernetes Service (AKS) cluster -
Kubernetes: Set as Current Cluster
– Select from a list of configured clusters to set the “current” cluster. Used for searching, displaying, and deploying Kubernetes resources. -
Kubernetes: Delete Context
– Remove a cluster’s configuration from the kubeconfig file. -
Kubernetes: Set Kubeconfig
– Select from a list of known kubeconfig files (for users who keep different kubeconfig files for different environments). -
Kubernetes: Show Cluster Info
– For a cluster, show the status of Kubernetes Components (API Server, etcd, KubeDNS, etc.) in a terminal window. -
Kubernetes: Use Namespace
– Select from a list of namespaces to set the “current” namespace. Used for searching, displaying, and deploying Kubernetes resources.
ConfigMap and Secret commands
-
Kubernetes: Add File
– Adds a file as a ConfigMap or a Secret -
Kubernetes: Delete File
– Deletes a file from a ConfigMap or a Secret
Miscellaneous commands
-
Kubernetes: Open Dashboard
– Opens the Kubernetes Dashboard in your browser. -
Kubernetes: Port Forward
– Prompts user for a local port and a remote port to bind to on a Pod. -
Kubernetes: Select Pod
– It allows to select a pod from a list of pods belonging to the “current” namespace. It can be invoked through command substitution${command:extension.vsKubernetesSelectPod}
. See Commands for debugging for more details.
Minikube
Minikube runs a local, single node Kubernetes cluster inside a VM. Support is currently experimental, and requires
Minikube tools to be installed and available on your PATH.
-
Kubernetes: Start minikube
– Starts Minikube -
Kubernetes: Stop minikube
– Stops Minikube
Helm
Helm is the package manager for Kubernetes and provides a way for you to define, install and upgrade applications using ‘charts.’ This extension provides a set of tools for creating and testing Helm charts:
- Syntax highlighting for YAML + Helm Templates
- Autocomplete for Helm, Sprig, and Go Tpl functions
- Help text (on hover) for Helm, Sprig, and Go Tpl functions
- Snippets for quickly scaffolding new charts and templates
-
Commands for…
-
Helm: Create Chart
– Create a new chart -
Helm: Get Release
– Get a helm release from the cluster -
Helm: Lint
– Lint your chart -
Helm: Preview Template
– Open a preview window and preview how your template will render -
Helm: Template
– Run your chart through the template engine -
Helm: Dry Run
– Run a helm install –dry-run –debug on a remote cluster and get the results (NOTE: requires Tiller on the remote cluster) -
Helm: Version
– Get the Helm version -
Helm: Insert Dependency
– Insert a dependency YAML fragment -
Helm: Dependency Update
– Update a chart’s dependencies -
Helm: Package
– Package a chart directory into a chart archive -
Helm: Convert to Template
– Create a template based on an existing resource or manifest -
Helm: Convert to Template Parameter
– Convert a fixed value in a template to a parameter in thevalues.yaml
file
-
-
Code lenses for:
- requirements.yaml (Add and update dependencies)
- Right-click on a chart .tgz file, and choose inspect chart to preview all configurable chart values.
Extension Settings
-
vs-kubernetes
– Parent for Kubernetes-related extension settings-
vs-kubernetes.namespace
– The namespace to use for all commands -
vs-kubernetes.kubectl-path
– File path to the kubectl binary. Note this is the binary file itself, not just the directory containing the file. On Windows, this must contain the.exe
extension. -
vs-kubernetes.helm-path
– File path to the helm binary….
-