# Kubernetes Plugins

# Overview

Process Automation integrates with Kubernetes through a variety of plugins listed below. By integrating Process Automation with Kubernetes, users can automate and provide self-service interfaces for operations in their Kubernetes Clusters. These integrations allow operations teams to provide self-service mechanisms to users throughout the business, as well as setup event-driven automation for workflows with Kubernetes.

Kubernetes Plugins
Plugin Name Plugin Type Description
Create Deployment Node Step Create a new deployment.
Delete Deployment Node Step Delete an existing deployment.
Deployment Status Node Step Get the status of an existing deployment.
Update Deployment Node Step Update an existing deployment.
Waitfor Deployment Node Step Pause workflow until deployment is complete.
Create Job Node Step Create a new Kubernetes job.
Delete Job Node Step Delete an existing Kubernetes job.
Re-run Job Node Step Re-runs an existing Kubernetes job.
Waitfor Job Node Step Pause workflow until Kubernetes job is complete.
Create Service Node Step Create a new Kubernetes service.
Update Service Node Step Update an existing Kubernetes service.
Delete Service Node Step Delete an existing Kubernetes service.
Pods Node Source Resource Model Populates node inventory with Kubernetes pods.
Create Pod Node Step Create a new Kubernetes pod.
Delete Pod Node Step Delete an existing Kubernetes pod.
Describe Pod Node Step Describe a running Kubernetes pod.
Execute Command Node Step Execute a command inside a container in a running pod.
Execute Script Node Step Execute a script inside a container in a running pod.
Pod Logs Node Step View the logs of a running pod.
Waitfor Pod Node Step Pause workflow until pod is in "ready" state.
Debug Pod Node Step Debug a running container inside an existing pod using an ephemeral container.
Waitfor StatefulSet Node Step Pause workflow until StatefulSet has been successfully deployed.

Click to expand to see the full list of Process Automation plugins for Kubernetes.

# Setup

# Python Dependencies

In order to use the Kubernetes python must be installed on the Process Automation cluster-members or on the Enterprise Runner - depending on where the connection to Kubernetes is going to originate.

The Kubernetes plugins will work with both Python 2.7.x and Python 3.x.x.

Once python is installed, download and install the kubernetes python client. For Python 2.7.x this can be done with pip install kubernetes and for Python 3.x.x this can be done with pip3 install kubernetes.

Optionally test that the Kubernetes client has been installed successfully by executing the following at the command-line: python followed by from kubernetes import client, config:

ubuntu@ip-172-31-13-91:~$ python
Python 2.7.17 (default, Mar  8 2023, 18:40:28) 
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from kubernetes import client, config

# Kubernetes Authentication

By default, the Kubernetes plugins look for a Kube Config file at $RDECK_BASE/.kube/config. For Deb and RPM this would translate to /var/lib/rundeck/.kube/config. The Kube Config file can be saved to a different location, just be sure to take note of where it is saved for later steps.

If it is preferred to use a Kubernetes API Token, then follow the instructions outlined here (opens new window) to generate the Service Account Token. Once created, save the Token to Key Storage as a Password secret type.

# Upload Kubernetes Plugins (Rundeck OSS Only)

Rundeck OSS does not come preloaded with the Kubernetes plugins. To install the Kubernetes plugins, use the following steps:

  1. Navigate to the latest plugin release (opens new window) on Github and download the kubernetes-X.X.XX.zip file.

  2. In Rundeck, click the Gear Icon and then click the Plugins > Upload Plugin: Upload Plugins Menu
  3. Click Browse and select the downloaded .zip file from Step 2.
  4. Click Install: Upload Kubernetes Plugins

# Test Kubernetes Plugins

To test that the dependencies and authentication have been configured correctly, use a Kubernetes Node Step plugin - as this will provide the option to easily execute the plugin in debug mode.

  1. Create a new Job.
  2. Navigate to the Workflow tab.
  3. Click + Add a step.
  4. In the Search step field type Kubernetes.
  5. Select the Kubernetes / Pod / Describe plugin from the list.
  6. Type in a pod name into the Name field. K8s Describe Pod
  7. Type in the namespace of the pod in the Namespace field.
  8. If the Kube Config file is saved in the directory $RDECK_BASE/.kube/config (/var/lib/rundeck/.kube/configfor RPM and Deb), then the authentication fields can be left blank.
    • Otherwise, specify the custom Kube Config location.
  9. Optionally chance the Python Interpreter if python scripts are not invoked using python my_script.py but rather python2 my_script.py or python3 my_script.py.
  10. Click Save on the Job Step and then Save to save the Job.
  11. Click Run Job Now to test that the configuration is correct.

Now that configuration is complete, take a look at use-cases for Process Automation with Kubernetes such as Capturing Debug Data from Apps in Kubernetes or Managing Kubernetes with Rundeck.