IntelliJ IDEA 2018.1: Kubernetes support
The upcoming IntelliJ IDEA 2018.1 Ultimate Edition introduces initial support for Kubernetes via a brand new Kubernetes plugin. The new plugin supports the Kubernetes resource files from v1.5 up to the recently released v1.9.
The IntelliJ IDEA enhancements for Kubernetes include: code completion, inspections, quick-fixes for Kubernetes resource files, icons in the gutter for easier navigation, pop-up documentation, and live templates. Read on for more details and screenshots.
Please note that the Kubernetes plugin is not bundled, so before using this new functionality you need to install the plugin. Go to Preferences | Plugins | Kubernetes plugin, or download the plugin from the website.
The new Kubernetes plugin is compatible with all paid JetBrains IDEs: PhpStorm, WebStorm, PyCharm Professional, RubyMine, AppCode, CLion, GoLand, and DataGrip.
Once the Kubernetes plugin is installed, you can create and edit the YAML and JSON Kubernetes resource files in IntelliJ IDEA. The new plugin will look for the presence of apiVersion and kind fields in the files, and if these are present it will consider such files as Kubernetes resource files.
Working with Kubernetes resource files can be challenging as you need to include all the mandatory fields, and those fields differ depending on the applied Kubernetes API version and the kind type. This means having to consult the Kubernetes documentation often as you create Kubernetes resource files. To make it easier for you to work with Kubernetes, the new plugin has a full bag of improvements.
For a start, the Kubernetes plugin has a built-in Live Template that allows you to quickly create the type of YAML Kubernetes resource file that you need:
The new plugin now contains several predefined Kubernetes templates, and you can invoke the necessary Live Template by typing its abbreviation.
If you want to add your own Live Template or to customize an existing one, go to Preferences | Live Templates | Kubernetes.
Code completion now works for YAML Kubernetes resource files. The Kubernetes plugin offers the correct values you can use within the resources.
To help you really quickly create the required YAML definition file for Kubernetes, start typing the required key and invoke Smart Completion. The new plugin will auto-complete all the required keys from all the levels below.
For YAML Kubernetes resource files, the plugin provides an ability to navigate between a label definition and a label selector. Use the icons in the gutter.
You can also navigate and jump from a label selector to a label definition inside the editor if there is a direct match for a label, both for the key and for the value.
When you rename a key or a value in YAML Kubernetes files, the plugin will also rename all their usages.
The Kubernetes plugin will alert you whenever you select deprecated Kubernetes properties (available for the YAML files only).
In addition to this, you’ll get a warning for the YAML files if you try to use properties that are not applicable for the specified elements with the applied apiVersion and kind.
The plugin highlights elements with missing keys in YAML Kubernetes resource definition files and provides a quick-fix to add the required keys.
Another enhancement in this area is that IntelliJ IDEA will now warn you about redundant keys. Use the provided quick-fix to remove redundant keys in YAML Kubernetes resource files.
Our new plugin also detects non-editable keys in YAML Kubernetes resource files and highlights them in the editor. Note that there’s an easy way to remove all such read-only keys from the current YAML file via a handy quick-fix.
The IDE previews the important information from the folded area in YAML Kubernetes files.
You can also invoke the documentation for any keys in YAML or Kubernetes resource files by simply pressing ^J (macOS) or Ctrl + Q (Windows and Linux). Click the hyperlink in the Quick Documentation Lookup to navigate to more detailed information.
Support for JSON Kubernetes resource files
Although the JSON format is not recommended for Kubernetes resource files, it is still supported by Kubernetes. The new plugin provides some limited support for JSON Kubernetes resource files based on the JSON schema functionality.
Currently, only code completion is available for JSON Kubernetes resource files.
The new plugin validates the current keys according to the JSON schema and alerts you when incorrect properties or values are used.
Also, the plugin highlights elements with any missing required properties and then advises you about the appropriate properties that should be added.
Duplicated properties are also detected in JSON Kubernetes files.
The Quick Documentation Lookup is also available for JSON Kubernetes resource files.
We would like to learn more about your experience with Kubernetes and IntelliJ IDEA. Please share your experience with us. Feature requests and improvement suggestions are very welcome! We are currently actively working to support Kubernetes even better, and your feedback can influence the roadmap for Kubernetes support a lot. Add a comment here, tweet at us or create an issue in YouTrack.
Subscribe to Blog updates
Thanks, we've got you!