Project: OpenYurt (Provisioning / Automation & Configuration)
File: 20220718-workload-update-model.md

title: Daemonset Update Model authors: "@hxcGit" reviewers: "@rambohe-ch" creation-date: 20220719 last-updated: 20220719 status: provisional A table of contents is helpful for quickly jumping to sections of a proposal and for highlighting any additional information provided beyond the standard proposal template. a table of contents from markdown are available. - - - - - - - - Refer to the . If this proposal adds new terms, or defines some, make the changes to the book's glossary when in PR stage. In this proposalwe hope to optimize the daemonset update model in cloud-edge collaboration scenarios. We consider two scenarios and propose different solutions for each of them. First, in order to optimize the user experience, we propose a way to implement update. In this mode, users can control the update or not of applications autonomously through the exposed API. Besides, we use a new controller with `OnDelete` update strategy to update the application, even if the cluster has `not ready` nodes. In Openyurt, we use a native Kubernetes workload where application updates are processed in bulk by administrators. However, in some scenarios, node-level users also would like to manage application updates. In cloud-edge collaboration scenario, the edge is connected to the cloud through the public network, and the edge nodes may be disconnected from the cloud due to various objective or subjective factors. The update of Workloads (Deployment, DaemonSet, etc.) in the native Kubernetes relies on the connectivity of the edge nodes to the cloud master nodes. Therefore, when the cloud-edge network is disconnected, we need to explore a suitable way to update the application. Provide OTA update: users can control the daemonset application updates through the API exposed on the edge nodes. Add a new controller: for `ready` nodes, execute the daemosnet application updates directly; for `not-ready` nodes, wait for nodes' status to turn ready before executing the update

In some node-independent scenarios, such as a user owning a node, for example, on a Tesla car, the owner wants to independently update his application, instead of being controlled by the cluster administrator. At this time, the user can complete the application update process through a two-step process. Check whether the latest version of the application is available. Confirm the execution of application update. In a openyurt cluster, there are some edge nodes, and some node's status are `not-ready` due to the network, when the administrator updates the application version, the administrator expects that for the `ready` edge nodes, the application can be updated to the latest version smoothly; for the `not-ready` edge nodes, they do not block the update process of other nodes. Note: No modification to Kubernetes, keeping it non-invasive, no modification to the native workload controllers. <div align="center"> <img src="../img/OTA.png" width=50% title="OTA"> </div> Pre-requisites: Set application's updateStrategy to `type: OnDelete`; add a new annotation(`apps.openyurt.io/upgrade-strategy: OTA`) for DaemonSet Users query whether a newer version of the application is available via OTA module's API. OTA module accesses Kubernetes APIServer through client-go library and get the current application's version. If update is available, users can choose to apply update. (This is only from the user's perspective) OTA module removes the selected pod from the current node.This step is achieved by calling the Kubernetes interface' Kubelet on this node will synchronize pods information from Kubernetes APIServer. Kubelet is responsible for creating the latest version of pod. <div align="center"> <img src="../img/process.png" width=40% title="OTA Process"> </div> get all pods on edge node ```text GET /pods HTTP/1.1 ``` upgrade specified pod on edge node ```text POST /openyurt.io/v1/namespaces/{ns}/pods/{podname}/upgrade HTTP/1.1 ```` <div align="center"> <img src="../img/xxx-controller.png" width=40% title="new-controller"> </div> Daemonset Node Pre-requisites: Set application's updateStrategy to `type: OnDelete`; add a new annotation(`apps.openyurt.io/upgrade-strategy: AdvancedRollingUpdate`) for DaemonSet New controller monitor daemonset's changes. When the daemonset is updated, check the status of all the nodes selected by this daemosnet and if it is ready, then delete pods.