Early Access Program

Docker and Kubernetes Updates in IntelliJ IDEA 2021.1

IntelliJ IDEA 2021.1 brings some handy updates for Kubernetes and Docker. In this blog post, we’ll describe them in detail.

Kubernetes

Quickly delete resources

You can now delete all the cluster resources in the current context right from the editor – just click the Run icon in the gutter and select Delete.

Delete resources

Support for Kustomize 3.7.0 components

We’ve added support for the new Kustomize 3.7.0 components. You can choose this new option in the Kustomize version drop-down list in Settings/Preference | Languages & Frameworks | Kubernetes.

Kustomize 3.7.0

Support for kind: List

If you want to work with what the ‘kubectl get <resource type> -o yaml command returns, or if you’d like to apply lists of resources, we have good news for you: your IDE now supports kind: List!

In each resource from the list, you can rename labels, use code assistance and navigation via the gutter icons. You can also convert a List to a multi-document YAML file, and vice-versa, by clicking Alt+Enter and selecting the relevant intention action.

Support for Kind:List

Non-default values for Helm projects

A Helm chart is a set of parameterized Kubernetes resource descriptions. By default, parameters are specified in values.yaml, but Helm allows using an arbitrary number of non-default Values files. Until v2021.1, the default values.yaml was the only option available for both code insight and running Helm commands.

In IntelliJ IDEA 2021.1, we’ve made it possible to use custom Values files. The IDE now sees all the files with “values” in their names as values files.

To configure which values files the chart template will use, select Configure Helm Parameters or invoke Helm Lint or Helm Template from the context menu. A dialog will open where you can add the required Values file. If you want to skip this dialog when executing Helm commands, tick the checkbox at the bottom.

Helm

You can also manually add values by pasting them in the Additional values area.

Additional Values

Docker

Improved Run/Debug Configurations

We’ve given your Run/Debug Configuration dialog a makeover to make it neater and adjustable to your needs. To add all the necessary build options, click Modify options; to add run options, click Modify. The IDE now validates each option to make sure it is compatible.

For Docker Compose, we support all the existing options, including the one for declaring Environmental variables files (.env).

Docker Run/Debug Configurations

For Dockerfiles, you don’t have to remember all the run commands because code completion works in the Run Options field.

Completion for Run options

For Images, you can use code completion to enter the image name in the Image ID or name field.

Image completion in Run/Debug Configurations

BuildKit support

We’ve added experimental support for BuildKit, which makes building projects much faster. You can activate this option in Run/Debug Configurations by clicking Modify options and selecting Enable BuildKit (experimental).

BuildKit in Docker

Building named stages separately from the whole multi-stage Dockerfile is now easier and faster. Simply click the hammer icon next to the stage name, and the IDE will build the image using BuildKit. If you add the Run section in Run/Debug Configurations, the icon will change. When you click it, you will not only build an image but also run a container.

BuildKit for Docker

UI enhancements in multi-stage Dockerfiles

If you use multiple FROM statements in your Dockerfile, each FROM instruction starts a new stage. In v2021.1, you can now fold stages and see a distinct separator line between them.

Multi-stage enhancements

Cancel Docker run

If you decide to stop your running Dockerfile, you can easily do so in the Services tool window. Select the running item, call up the context menu, and click Stop Deploy.

Cancel run

Environment variables and macros for Docker mounts

When using bind mounts, you can now enter a path to a directory on the host machine faster. The completion mechanism allows you to select macros and environmental variables in the Bind mount option in Run/Debug Configurations.

Macros

Images completion in Dockerfiles

Adding image names has become easier because code completion now works for them. Have a look:

Image completion

We would appreciate your feedback on these updates so we can polish them before the major release. If you have any suggestions, please report them to our issue tracker or comment on this post.

Happy developing!

image description

Discover more