The cloud-native rolling update model cannot meet the requirement for application updates in cloud-edge collaboration scenarios. For example, when the edge network disconnects from the cloud, DaemonSet rolling updates may become stuck due to nodes in the NotReady state. You may also need to trigger rolling updates on edge nodes in scenarios such as over-the-air (OTA) updates for green vehicles. To address the preceding issues, the AdvancedRollingUpdate and OTA update models are introduced.
Prerequisites
The DaemonSet update models are supported by ACK Edge clusters that run Kubernetes 1.26.3-aliyun.1.
DaemonSet update models
AdvancedRollingUpdate
You can use this update model to address the issue that DaemonSet updates become stuck due to nodes in the NotReady state. During the update process, this model updates nodes in the Ready state first and skips nodes in the NotReady state. After the status of a node changes from NotReady to Ready, DaemonSet pods on the node are automatically updated.
OTA
This update model allows you to call REST APIs on edge nodes to check whether the pods are updatable and trigger pod updates.
Configure update models
apiVersion: apps/v1
kind: DaemonSet
metadata:
annotations:
apps.openyurt.io/update-strategy: AdvancedRollingUpdate
apps.openyurt.io/max-unavailable: 30%
spec:
updateStrategy:
type: OnDelete
Parameter | Description |
apps.openyurt.io/update-strategy | Enable update model extensions. Valid values: AdvancedRollingUpdate and OTA. |
apps.openyurt.io/max-unavailable | This parameter takes effect only when you enable the |
DaemonSet.spec.updateStrategy.type | Set the value to |
Use the update models
AdvancedRollingUpdate
The following code block provides an example on how to create a DaemonSet named nginx-daemonset
and enable the AdvancedRollingUpdate
update model for the DaemonSet. During a rolling update, at most 30%
of the DaemonSet pods can be unavailable. The following code is an example:
cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: nginx-daemonset
annotations:
apps.openyurt.io/update-strategy: AdvancedRollingUpdate
apps.openyurt.io/max-unavailable: 30%
spec:
selector:
matchLabels:
app: nginx
updateStrategy:
type: OnDelete
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.19.4
EOF
OTA
REST APIs for OTA updates
The edge-hub components on an edge node can call the following REST APIs to enable OTA updates:
GET /pods
This REST API is used to query information about pods on the node. The
PodNeedUpgrade
parameter in thePod.status.conditions
section of the response indicates whether the pods are updatable.POST /openyurt.io/v1/namespaces/{ns}/pods/{podname}/upgrade
This REST API is used to trigger an update for a specified DaemonSet pod. You can configure the
{ns}
and{podname}
parameters to specify the pod that you want to update. This allows you to update individual pods based on your business requirements.
Use case of the OTA update model
Create a DaemonSet named
nginx-daemonset
and enable the OTA update model for the DaemonSet. When the image used by the DaemonSet is updated, the DaemonSet pods are not automatically updated. You need to call REST APIs on edge nodes to check whether the pods are updatable and trigger updates.cat <<EOF | kubectl apply -f - apiVersion: apps/v1 kind: DaemonSet metadata: name: nginx-daemonset annotations: apps.openyurt.io/update-strategy: OTA spec: selector: matchLabels: app: nginx updateStrategy: type: OnDelete template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.19.4 EOF
Use case of the OTA update model
Log on to an edge node and run the following command to to check for any pods that require updates on the node:
curl http://127.0.0.1:10267/pods
If
`PodNeedUpgrade=true`
is displayed in thedefault/nginx-daemonset-bwzss pod.Status.Conditions
field in the output, the pod requires an update.Run the following command to update the pod:
curl -X POST http://127.0.0.1:10267/openyurt.io/v1/namespaces/default/pods/nginx-daemonset-bwzss/upgrade
Run the following command to update the DaemonSet configuration:
Start updating pod default/nginx-daemonset-bwzss
References
For more information about how to check the pod status, see Manage pods.