PhpStorm 2018.3 Help

Kubernetes

Kubernetes enables deployment, scaling, and management of containerized applications. PhpStorm provides support for Kubernetes resource configuration files via the Kubernetes plugin.

The Kubernetes plugin supports Kubernetes API starting from version 1.5. It provides rich support for resource configuration files in YAML, and only basic support for the JSON format.

Feature

YAML

JSON

Auto-completion

Supported

Supported

Quick documentation

Supported

Supported

Inspections and quick fixes
  • Invalid, missing, and duplicated keys

  • Non-editable (read-only) keys and resources

  • Deprecated keys and resources

  • Invalid integer and enum key values

  • Invalid, missing, and duplicated properties

Live templates

Predefined templates for common configuration kinds:

  • kcm: ConfigMap

  • kdep: Deployment

  • kpod: Pod

  • kres: Generic resource

  • kser: Service

No predefined live templates

Smart completion

Supported

Not supported

Label definitions and selectors

Navigation using gutter icons, find usages, and renaming

Not supported

Enhancements of the original Kubernetes model

Enums instead of plain strings where applicable

None

Resource configuration files

PhpStorm recognizes Kubernetes resource configuration files using the following mandatory fields:

  • apiVersion: identifies the versioned schema of the object representation

  • kind: identifies the object kind (for example, Service, Pod, Deployment, etc.)

If both of the previous fields are present in a YAML or JSON file, PhpStorm will mark the file with the corresponding Kubernetes icon and enable all available features:

For YAML files, you can also use predefined Live Templates to create the necessary type of configuration:

To see available Live Templates and create new ones, open the Settings/Preferences dialog (Ctrl+Alt+S), click Editor, then click Live Templates, and expand the Kubernetes group in the list.

Helm support

Helm is a tool for managing Kubernetes applications. Helm charts are packages of pre-configured resource definitions that you run inside a Kubernetes cluster. A chart contains a description of the package (Chart.yaml) and one or more templates used to generate Kubernetes manifest files.

Coding assistance for Helm charts and templates includes code completion, refactorings, inspections, quick fixes, and quick documentation. Also, it is possible to use gutter icons for navigating between label definitions and label selectors, and between overridden and overriding values.

Create a new Helm chart

  • Right-click any directory in the Project tool window, point to Kubernetes, and click Helm Create Chart.

This runs the helm create command, which adds all the basic files required to get started:

  • .helmignore: Patterns to ignore when building packages

  • Chart.yaml: A basic chart description with metadata

  • values.yaml: Default values for chart templates

  • charts/: Directory for sub-charts

  • templates/: Directory for chart definitions

    • _helpers.tpl: Partials and functions for your templates

    • NOTES.txt: Information that is printed out after a chart is deployed

    • deployment.yaml: Example Kubernetes deployment definition

    • ingress.yaml: Example Kubernetes ingress definition

    • service.yaml: Example Kubernetes service definition

Preview the result of Helm template rendering

  • Right-click the template file, point to Kubernetes, and click Helm Template.

This runs the helm template command that renders a chart template. The rendered preview opens inside the diff viewer dialog to compare it with the original template file.

Update external dependencies

If the chart has a requirements.yaml file, you can update or download the appropriate tgz dependencies. This action also generates or updates requirements.lock.

  • Right-click the chart, point to Kubernetes, and click Helm Dependency Update.

This runs the helm dependency update command.

Examine a chart for possible issues

  • Right-click the chart, point to Kubernetes, and click Helm Lint.

This runs the helm lint command that executes a series of tests to discover possible problems without actually installing the chart.

Productivity tips

If you use the features described here frequently, the following tips may be helpful:

Assign shortcuts

You can assign a keyboard shortcut for any action in PhpStorm. In the Settings/Preferences dialog (Ctrl+Alt+S), select Keymap. Type kubernetes in the search field, then double click an action to set a shortcut for it.

Last modified: 18 March 2019