pia-1.4.0
3 minute read
KOSI Plugin Pia Version 1.4.0
Summary
The cmd command calls either the bash plugin (the plugin that executes commands in the bash terminal in linux), or if not available the sh plugin (the plugin that executes commands in the sh terminal in linux) and passes the parameters through.
This plugin also supports chaining of multiple commands with the semicolon ;
as a divider.
Keys
Key | Description | |
---|---|---|
mode | Mandatory | set mode which pia will user. Available modes are “ssh” and “k8s” |
nodes | Mandatory/Optional | set nodes which pia will use. You have to set either nodes or labels. |
labels | Mandatory/Optional | set labels which pia will use. You have to set either nodes or labels. |
files | - | set the files which will be uploaded and used by pia. |
command | Mandatory | set this to a command which pia will executed on the node. |
user | Mandatory/Optional | have to be set if you use the mode ssh |
Note: user key is only needed if you use the mode “ssh”
usage
Example 1 - SSH-Mode
languageversion = "0.1.0";
apiversion = "kubernative/kubeops/sina/user/v3";
name = "kosi-example-packagev3";
description = "kosi-example-package";
version = "0.1.0";
docs = "docs.tgz";
logo = "logo.png";
files =
{
input="template.yaml";
}
containers =
{
example=["docker.io", "nginx", "latest"];
}
install
{
pia(mode='"ssh"';nodes='["cluster2master1","cluster2master2"]';files='["template.yaml"]';command='"echo Hello World"';user='"root"');
cmd(command='"echo Hello World"');
}
Result
This package will send you a Hello World to each node, which is set. The template.yaml will be uploaded to the nodes and the connection is under the root user.
Note: It is recommended that the user have root privileges
Example 2 - k8s Mode
languageversion = "0.1.0";
apiversion = "kubernative/kubeops/sina/user/v3";
name = "kosi-example-packagev3";
description = "kosi-example-package";
version = "0.1.0";
docs = "docs.tgz";
logo = "logo.png";
files =
{
input="template.yaml";
}
containers =
{
example=["docker.io", "nginx", "latest"];
}
install
{
cmd(command='"echo Using the cmd-plugin"');
pia(mode='"k8s"';nodes='["cluster2master1","cluster2master2"]';files='["template.yaml"]';command='"echo Hello World"');
}
Result
The plugin creates a customressource.yaml in the KUBEOPSROOT/pia directory. The plugin uploads the files and deployes the customressource.yaml for the pia-operator.
[root@cluster2admin1 Test_Pia-Plugin]# kosi install -p package.tgz
2024-01-24 12:12:03 Info: KOSI version: 2.9.0_Beta0_1704450448
2024-01-24 12:12:05 Info: template.yaml start uploading to webserver.
2024-01-24 12:12:05 Info: template.yaml successfully uploaded to webserver.
pia.kubeops.net/example-pia created
2024-01-24 12:12:08 Info: Installation successful
Pia-Operator (Plugin based Infrastructure Administrator)
Installation
- create values.yaml with pullsecret
pullsecretRegistry: "https://registry.preprod.kubernative.net"
pullsecretUser: "<username>"
pullsecretPassword: "<userpassword>"
piaWebserverNodePort: 31213
- install the pia -operator package
kosi install --hub public kubeops/piaoperator:0.1.0 -f values.yaml
Use of the pia-operator
There are two ways to use the operator. First way is to use the pia-plugin like the example above. The second way ist to deploy a custom ressource.
Pia custom resource example
apiVersion: kubeops.net/v1alpha1
kind: Pia
metadata:
name: hello-world
namespace: pia-test
spec:
command: "echo Hello world; sleep 60;"
jobId: abcdef
nodes:
- cluster2worker1
- cluster2worker3
labels:
#- kubeops-zone=zone2
files:
#- file1