Update a Workload
When you update a workload, you can choose whether to deploy immediately or to stage the workload at the edge and apply it at a later time.
| Field | Option | Description |
|---|---|---|
| Standard | None | This will use the standard Kubernetes deployment process for workload containers and the workload will be automatically started after downloaded to the edge. |
| Staged | Stage Only | This will download the workload to the edge but will not start the workload. You will need to send an additional command to start the workload either through the Kelvin API or locally in the terminal of the edge computer |
| Staged | Stage and Apply | This will use the kelvin's deployment process for workload containers and the workload will be automatically started after downloaded to the edge. The difference to the Kubernetes deployment process is that Kelvin will download all workloads and stage them first. Only when all workloads have been successfully downloaded will the start command be given to the workloads. |
You can update any workload through the Orchestration page.
When you do an upgrade, you will have the option to stage the upgrade.
To start go to Orchestration menu, select a Cluster and find the Workload you want to upgrade. Then click on the dropdown menu on the Workload row.
The process is very similar to the Deploy Workload process.
In Step 1 you can select the version you want to upgrade to.
Click the Next button and choose what type of deploy you want to do.
For Standard mode, you do not have any other options.
For Staged mode, you have two options;
Click the Next button and check / edit the Workload yaml file.
Then you can click on the Save & Deploy button.
If you have selected to stage a Workload deploy, you can read more in the chapter above Staged Workload Deploy on how to activate the staged Workload.
To upgrade, simply select the same Workload name and cluster and do a normal /workloads/deploy API request.
The system will see the current version at the edge and will replace it with the new version dfined.
This example only does a standard Workload deploy. For staged workload documentation read more in the chapter above Staged Workload Deploy
curl -X "POST" \
"https://<url.kelvin.ai>/api/v4/workloads/deploy" \
-H "Authorization: Bearer <Your Current Token>" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"acp_name": "docs-demo-cluster-k3s",
"app_name": "esp-optimization",
"app_version": "2.0",
"cluster_name": "docs-demo-cluster-k3s",
"instantly_apply": true,
"name": "doc-demo-standard-deploy",
"payload": {
"app":{
"kelvin":{
"configuration":{
"recommendations":[
{
"description":"Water level increasing, higher pump speed will lead water level to return to optimal.",
"setpoint":{
"name":"speed_sp",
"variation_factor":0.1
},
"type":"increase_speed"
},
...
]
},
"inputs":[
{
"data_type":"number",
"name":"casing_pressure"
},
...
],
"language":{
"python":{
"entry_point":"kelvin_python_sdk"
},
"type":"python"
},
"outputs":[
{
"control_change":true,
"data_type":"number",
"name":"speed_sp"
}
]
},
"type":"kelvin"
},
"info":{
"description":"This application uses the values coming from the well control system such as flow rate, pressure, and motor speed, to optimize the speed of the ESP motor. As a byproduct we have a lower energy use by the equipment.",
"name":"esp-optimization",
"title":"ESP Optimization",
"version":"2.0"
},
"spec_version":"4.12.0",
"system":{
"environment_vars":[
{
"name":"KELVIN_GW_MODE",
"value":"SOCKETS"
}
],
"ports":[
],
"privileged":false,
"volumes":[
]
}
},
"staged": false,
"source": "krn:user:demo@kelvin.ai",
"title": "Motor Speed Control"
}'
You will get a response similar to this;
created=datetime.datetime(2024, 5, 23, 8, 52, 7, 803281, tzinfo=datetime.timezone.utc) name='doc_demo_asset_type' title='Documentation Demo Asset Type' updated=datetime.datetime(2024, 5, 23, 8, 52, 7, 803281, tzinfo=datetime.timezone.utc)
This example only does a standard Workload deploy. For staged workload documentation read more in the chapter above Staged Workload Deploy
from kelvin.api.client import Client
# Login
client = Client(config={"url": "https://<url.kelvin.ai>", "username": "<your_username>"})
client.login(password="<your_password>")
# Deploy Standard Workload
response = client.workload.deploy_workload(data={
"app_name":"esp-optimization",
"app_version":"2.0",
"cluster_name":"docs-demo-cluster-k3s",
"name":"doc-demo-standard-deploy",
"payload":{
"app":{
"kelvin":{
"configuration":{
"recommendations":[
{
"description":"Water level increasing, higher pump speed will lead water level to return to optimal.",
"setpoint":{
"name":"speed_sp",
"variation_factor":0.1
},
"type":"increase_speed"
},
...
]
},
"inputs":[
{
"data_type":"number",
"name":"casing_pressure"
},
...
],
"language":{
"python":{
"entry_point":"kelvin_python_sdk"
},
"type":"python"
},
"outputs":[
{
"control_change":True,
"data_type":"number",
"name":"speed_sp"
}
]
},
"type":"kelvin"
},
"info":{
"description":"This application uses the values coming from the well control system such as flow rate, pressure, and motor speed, to optimize the speed of the ESP motor. As a byproduct we have a lower energy use by the equipment.",
"name":"esp-optimization",
"title":"ESP Optimization",
"version":"2.0"
},
"spec_version":"4.12.0",
"system":{
"environment_vars":[
{
"name":"KELVIN_GW_MODE",
"value":"SOCKETS"
}
],
"ports":[
],
"privileged":False,
"volumes":[
]
}
},
"title":"Doc Demo Standard Deploy",
"staged":False
})
print(response)
You will get a response similar to this;
acp_name='docs-demo-cluster-k3s' app_name='esp-optimization' app_version='2.0' cluster_name='docs-demo-cluster-k3s' created=datetime.datetime(2024, 6, 17, 4, 53, 1, 165847, tzinfo=datetime.timezone.utc) download_status=<WorkloadDownloadStatus.pending: 'pending'> enabled=True instantly_apply=None name='doc-demo-standard-deploy' networking=[] node_name=None payload={'app': {'kelvin': {'configuration': {'recommendations': [{'description': 'Water level increasing, higher pump speed will lead water level to return to optimal.', 'setpoint': {'name': 'speed_sp', 'variation_factor': 0.1}, 'type': 'increase_speed'}, {'description': 'Production gain possible after step test, with higher pump speed', 'setpoint': {'name': 'speed_sp', 'variation_factor': 0.1}, 'type': 'increase_speed'}, {'description': 'Erratic Torque detected at this speed previously, lower pump speed will reduce vibrations', 'setpoint': {'name': 'speed_sp', 'variation_factor': -0.1}, 'type': 'decrease_speed'}, {'description': 'Reducing Speed will save energy and keep production levels constant', 'setpoint': {'name': 'speed_sp', 'variation_factor': -0.1}, 'type': 'decrease_speed'}, {'description': 'Above max Drawdown, parameters stable', 'setpoint': None, 'type': 'no_action'}, {'description': 'Casing Pressure Event Detected, no changes allowed', 'setpoint': None, 'type': 'no_action'}, {'description': 'No action - monitoring', 'setpoint': None, 'type': 'no_action'}]}, 'inputs': [{'data_type': 'number', 'name': 'casing_pressure'}, {'data_type': 'number', 'name': 'gas_flow_rate'}, {'data_type': 'number', 'name': 'speed'}, {'data_type': 'number', 'name': 'speed_sp'}], 'language': {'python': {'entry_point': 'kelvin_python_sdk'}, 'type': 'python'}, 'outputs': [{'control_change': True, 'data_type': 'number', 'name': 'speed_sp'}]}, 'type': 'kelvin'}, 'info': {'description': 'This application uses the values coming from the well control system such as flow rate, pressure, and motor speed, to optimize the speed of the ESP motor. As a byproduct we have a lower energy use by the equipment.', 'name': 'esp-optimization', 'title': 'ESP Optimization', 'version': '1.0.05221921'}, 'spec_version': '4.12.0', 'system': {'environment_vars': [{'name': 'KELVIN_GW_MODE', 'value': 'SOCKETS'}], 'ports': [], 'privileged': False, 'volumes': []}} pre_download=None status=WorkloadStatus(last_seen=datetime.datetime(2024, 6, 17, 4, 53, 1, 381101, tzinfo=datetime.timezone.utc), message='Pending for deploy', state=<WorkloadStatus.pending_deploy: 'pending_deploy'>, warnings=None) title='Doc Demo Standard Deploy' updated=datetime.datetime(2024, 6, 17, 4, 53, 1, 165847, tzinfo=datetime.timezone.utc) staged=None






