Class V1NeonNodeTask
Describes a task to be executed as a Bash script on a node by the neon-node-agent pod running on the target cluster node.
note
The node agent currently executes one node task at a time in no guaranteed order.
Namespace: Neon.Kube.Resources.Cluster
Assembly: Neon.Kube.Resources.dll
Syntax
[KubernetesEntity(Group = "neonkube.io", ApiVersion = "v1alpha1", Kind = "NeonNodeTask", PluralName = "neonnodetasks")]
[EntityScope(EntityScope.Cluster)]
public class V1NeonNodeTask
Remarks
NEONKUBE clusters deploy the neon-node-agent as a daemonset such that this is running on every node in the cluster. This runs as a privileged pod and has full access to the host node's file system, network, and processes and is typically used for low-level node maintainance activities.
NODETASK SCRIPTS
Node tasks are simply Bash scripts executed on the node by the neon-node-agent daemon running on the node. These scripts will be written to the node's file system like:
/var/run/neonkube/node-agent/nodetasks/GUID/task.sh
where GUID is a base-36 encoded GUID generated and assigned to the task by the agent.
neon-node-agent adds some variable assignments to the beginning of the deployed script before executing it:
$NODE_ROOT |
Identifies where the host node's file system is mounted to the neon-node-agent container. Since the script is executing in the context of the container, your script will need to use this to reference files and directories on the host node. This currently returns /mnt/host but you should always use this variable instead of hardcoding the path. noteThis does not include a terminating "/" |
$SCRIPT_DIR |
Set to the directory where the script is executing (like /var/run/neonkube/node-agent/nodetasks/GUID. Your scripts should generally store any temporary files here so they will be removed automaticaly by the node agent. noteThis does not include a terminating "/" |
LIFECYCLE
Here is the description of a NodeTask lifecycle:
- neon-cluster-operator or other entity determines that a script needs to be run on a specific node and creates a V1NeonNodeTask specifiying the name of the target node as well as the Bash script to be executed.
- neon-node-agent is running as a daemonset on all cluster nodes and each instance is watching for node tasks assigned to its node.
- When a neon-node-agent sees a pending V1NeonNodeTask assigned to the node it's managing, the agent will assign its unique ID to the task status, set the StartTimestamp to the current time and change the state to Running.
- The agent will assign a new UUID to the task and save this in the node task status. This UUID will be used to name the script file persisted to the host and will also be used to identify the The agent will then execute the script on the node, persisting the process ID to the node task status along with the command line used to execute the script. When the script finishes, the agent will capture its exit code and standard output and error streams as text. The command execution time will be limited by TimeoutSeconds.
- When the command completes without timing out, the agent will set its state to Success, set FinishTimestamp to the current time and ExitCode, Output and Error to the command results.
- When the command execution timesout, the agent will kill the process and set the node task state to Timeout and set FinishTimestamp to the time when the timeout was detected.
- neon-node-agents also look for running tasks that are assigned to its node but include a AgentId that doesn't match the current agent's ID. This can happen when the previous agent pod started executing the command and then was terminated before the command completed. The agent will attempt to locate the running pod by its command line and process ID and terminate when it exists and then set the state to Orphaned and FinishTimestamp to the current time.
- Finally, neon-node-agent periodically looks for Bash scripts that don't have corresponding node tasks and will delete these so they don't accumulate. This means the a task's script will typically be deleted shortly after the task retention period has been exceeded.
- neon-cluster-operator also monitors these tasks. It will remove tasks assigned to nodes that don't exist.
Constructors
V1NeonNodeTask()
Default constructor.
Declaration
public V1NeonNodeTask()
Fields
KubeApiVersion
Object API version.
Declaration
public const string KubeApiVersion = "v1alpha1"
Field Value
Type | Description |
---|---|
string |
KubeGroup
Object API group.
Declaration
public const string KubeGroup = "neonkube.io"
Field Value
Type | Description |
---|---|
string |
KubeKind
Object API kind.
Declaration
public const string KubeKind = "NeonNodeTask"
Field Value
Type | Description |
---|---|
string |
KubePlural
Object plural name.
Declaration
public const string KubePlural = "neonnodetasks"
Field Value
Type | Description |
---|---|
string |
Properties
ApiVersion
Gets or sets APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
Declaration
public string ApiVersion { get; set; }
Property Value
Type | Description |
---|---|
string |
Kind
Gets or sets kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
Declaration
public string Kind { get; set; }
Property Value
Type | Description |
---|---|
string |
Metadata
Gets or sets standard object metadata.
Declaration
public V1ObjectMeta Metadata { get; set; }
Property Value
Type | Description |
---|---|
V1ObjectMeta |
Spec
The spec.
Declaration
public V1NeonNodeTask.TaskSpec Spec { get; set; }
Property Value
Type | Description |
---|---|
V1NeonNodeTask.TaskSpec |
Status
The spec.
Declaration
public V1NeonNodeTask.TaskStatus Status { get; set; }
Property Value
Type | Description |
---|---|
V1NeonNodeTask.TaskStatus |
Methods
Validate()
Verifies that the resource properties are valid.
Declaration
public void Validate()
Exceptions
Type | Condition |
---|---|
CustomResourceException | Thrown when the resource is not valid. |