Kubernetes Task Plugin
Kubernetes plugin will allow you to create new pods remotely from a Clarive instance.
What is Kubernetes
Kubernetes is an open-source system for automating deployment, scaling and management of containerized applications. It groups containers that make up an application into logical units for easy management and discovery.
Requirements
This plugin requires Kubernetes to be installed in the destination server to work properly.
To install Kubernetes you need to click here and follow the instructions.
Installation
To install the plugin, place the cla-kubernetes-plugin folder inside the $CLARIVE_BASE/plugins
directory in a Clarive instance.
KubernetesPod Resource
To configurate the Kubernetes Pod Resource open:
In Clarive SE: Resources -> ClariveSE.
In Clarive EE: Resources -> Kubernetes.
You will be able to save your configuration code in this Resource. The main fields are:
- Pod configuration - Write the appropiate code for the pod creation.
Configuration example:
Pod configuration:
apiVersion: v1
kind: ReplicationController
metadata:
name: nginx
spec:
replicas: 2
selector:
app: nginx
template:
metadata:
name: nginx
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
Kubernetes task
The various parameters are:
- Server (variable name: server) - This option lets you choose the server where you wish to execute the command.
- User (user) - User which will be used to connect to the server.
- Command (command) - Via this parameter you can to build ("build") a pod in the remote server or delete it ("delete").
- Remote path (remote_path) - Full path where the configuration will be shipped.
- Creation mode (create_mode) - You can choose between creating the pod from an already existing file in the server ("File"), from a Resource ("Resource"), or create it in the rule ("Create").
- File path (config_file_path) - For create from file option, write the full path to the pod file in the server.
- Pod Resource (pod_resource) - For create option, select the Kubernetes Resource.
- Pod configuration (pod_config) - For create option, write the full pod configuration in this variable.
- Pod config path (delete_pod) - For delete option, write the full path to the pod file in the server.
Only Clarive EE
- Errors and Output - These two fields deal with managing control errors. The options are:
- Fail and Output Error - Search for the configured error pattern in the script output. If found, an error message is displayed in the monitor showing the match.
- Warning and Output warning - Search for the configured warning pattern in the script output. If found, an error message is displayed in the monitor showing the match.
- Custom - If combo box errors is set to custom, a new form is displayed to define the behavior with these fields:
- OK - Range of return code values for the script to have succeeded. No message will be displayed in the monitor.
- Warn - Range of return code values to warn the user. A warning will be displayed in the monitor.
- Error - Range of return code values for the script to have failed. An error message will be displayed in the monitor.
How to use
In Clarive EE
Once the plugin is placed in its folder, you can find this service in the palette in the section of generic service and can be used like any other palette op.
Op Name: Kubernetes task
Example:
Server: Remote_server
Command: Build
Creation mode: File
File path: /dir/seconfdir/podConfig.yaml
In Clarive SE
Rulebook
If you want to use the plugin through the Rulebook, in any do
block, use this ops as examples to configure the different parameters:
do:
- kubernetes_task:
server: 'kubernetes_server' # Required. Use the mid set to the resource you created
command: 'build' # Required
remote_path: '/tmp/'
create_mode: 'Create'
pod_config: |
apiVersion: v1
kind: ReplicationController
metadata:
name: nginx
spec:
replicas: 2
selector:
app: nginx
template:
metadata:
name: nginx
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
Outputs
Success
The plugin will return all the console output.
Possible configuration failures
Task failed
The plugin will return the error from the console output.
Variable required
Error in rulebook (compile): Required argument(s) missing for op "kubernetes_task": "server"
Make sure you have all required variables defined.
Not allowed variable
Error in rulebook (compile): Argument `Code` not available for op "kubernetes_task"
Make sure you are using the correct paramaters (make sure you are writing the variable names correctly).
More questions?
Feel free to join Clarive Community to resolve any of your doubts.