Kubernetes
Required plugin: Kubernetes
Kubernetes is a container orchestration engine for the deployment, scaling, and management of containerized applications. Install and enable the Kubernetes plugin for PyCharm to add the following features for managing your Kubernetes cluster:
Coding assistance for Kubernetes resource configuration files.
Coding assistance for Helm charts and templates.
Validation of custom resources with custom resource definition (CRD) specifications.
Coding assistance for Kustomize files: field and local file path completion, quick documentation, and navigation between Kustomize files and patches. The list of related Kustomize files appears in the editor at the top of the open Kustomize patch.
Interaction with the cluster from PyCharm: use the Services tool window to see all resources of the Kubernetes cluster in the current context, jump to relevant resource definitions, view logs for containers running on pods, and much more.
note
The Kubernetes plugin is not bundled with PyCharm, and should be installed from the JetBrains plugin repository. For more information, see Install plugins.
Specify a custom path to kubectl and helm
PyCharm uses the default kubectl (and helm if you use it) executables as determined by the PATH
environment variable. If you install Kubernetes or Helm in custom directories, you can manually specify the path to them.
In the Settings/Preferences dialog (Ctrl+Alt+S), select Build, Execution, Deployment | Kubernetes.
In the Path to kubectl executable field, specify the path to the kubectl executable file.
In the Path to helm executable field, specify the path to the helm executable file.

Use multiple Kubernetes configuration files
PyCharm detects the default kubeconfig
file. You can use a different configuration file. You can either apply it globally or use a different file for each project.
In the Settings/Preferences dialog (Ctrl+Alt+S), select Build, Execution, Deployment | Kubernetes.
In the Path to kubeconfig file field, specify the path to a
kubeconfig
file.If you want to use different configuration files in different projects, clear the Set this kubeconfig file path globally for all projects checkbox.
Resource configuration files
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.
PyCharm recognizes Kubernetes resource configuration files using the following mandatory fields:
apiVersion
: identifies the versioned schema of the object representationkind
: identifies the object kind (for example,Service
,Pod
,Deployment
, and so on)
If both of the previous fields are present in a YAML or JSON file, PyCharm 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:
kcm
: Kubernetes ConfigMapkdep
: Kubernetes Deploymentkpod
: Kubernetes Podkres
: Kubernetes Generic Resourcekser
: Kubernetes Service

tip
To see all available live templates for Kubernetes resource configuration files and create new ones, open the Settings/Preferences dialog Ctrl+Alt+S, select Editor | Live Templates, and expand the Kubernetes group in the list.
Configure the Kubernetes API version
PyCharm provides completion for configuration key values, navigation to relevant selectors and definitions via gutter icons, specialized inspections that check for deprecated values and required keys, and other assistance features. These depend on the version of the API you are using. By default, PyCharm sets it to the latest version. However, if your resources use an earlier version of the API, you can change it.
In the Settings/Preferences dialog (Ctrl+Alt+S), select Languages & Frameworks | Kubernetes.
Change the Kubernetes API version and Kustomize version options as necessary.
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.
note
The Go Template plugin is required for Helm template syntax support.
Coding assistance for Helm charts and templates includes code completion, refactorings, inspections, quick-fixes, and quick documentation. Code completion includes values of dependencies from the specified repository (by default, from Helm Hub).
In Go template directives, PyCharm provides completion for Helm built-in objects and for values passed from a values.yaml
file. You can press Ctrl+B to navigate to a source of object values, for example, to a child chart value imported into a parent chart.
In template objects, you can use code folding: press Ctrl+NumPad + and Ctrl+NumPad - to toggle between values and directives. You can also hover over a value to expand and show the directive.

You can also use gutter icons for navigating between label definitions and label selectors, and between overridden and overriding values.
Custom resource definitions support
If you extend the Kubernetes cluster with custom resources, PyCharm can validate them with custom resource definition (CRD) specifications.
Specify the path to CRD specifications
Press Ctrl+Alt+S to open the IDE settings and select Languages & Frameworks | Kubernetes.
Click
and either select a local CRD file or specify a URL. Then click OK.
Use and
to rearrange the list of CRD files. This defines the priority for conflicting definitions: PyCharm will use the lowest one if it is defined in more than one file.
By default, CRDs are applied to the current project only. Change the Scope: option to IDE
if you want a certain CRD to be available for any project that you open with this IDE instance.
note
When you apply changes, PyCharm automatically downloads newly added CRDs from the specified URLs. It will download other modified CRDs only as the model reloads, which happens whenever you open the project or change other Kubernetes settings (for example, the order of CRDs), and it has been more than three hours since the last model reload. If it has been less than three hours since the last model reload, you can force a reload on the current model using the Reset schema cache button.
To load the CRD from the running Kubernetes cluster, enable Use API schema from the active cluster if available.
You can view CRDs for the current cluster, including all their applied resources, under the Kubernetes node of the Services tool window.
The Kubernetes plugin supports CRD files of the following types:
CRD validation restrictions
PyCharm does not support the following OpenAPI v3 schema features:
multipleOf
maximum
exclusiveMaximum
minimum
exclusiveMinimum
maxLength
minLength
pattern
maxItems
minItems
uniqueItems
maxProperties
minProperties
allOf
oneOf
anyOf
not
format
default
nullable
readOnly
writeOnly
xml
externalDocs
example
deprecated
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 Kubernetes actions.
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.
Alternatively, you can use the Find Action dialog Ctrl+Shift+A, type kubernetes
, select the necessary action, and press Alt+Enter.
Configure code folding
By default, PyCharm uses code folding to render value references in Helm templates and definitions in Kubernetes configuration files as the actual values. You can click the value to expand it or press Ctrl+NumPad + and Ctrl+NumPad - to toggle folding. If you want to see the references and definitions expanded by default, do the following:
In the Settings/Preferences dialog (Ctrl+Alt+S), select Editor | General | Code Folding.
On the Code Folding page, clear the necessary checkboxes:
Kubernetes: value references in Helm templates
Kubernetes: EnvVar definitions in YAML files
Kubernetes: ExecAction definitions in YAML files
Thanks for your feedback!