Skip to content

Commit

Permalink
ovs: change update strategy to RollingUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed Mar 3, 2023
1 parent 9805070 commit b7bea91
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 7 deletions.
48 changes: 46 additions & 2 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,13 @@ rules:
- create
- patch
- update
- apiGroups:
- apps
resources:
- controllerrevisions
verbs:
- get
- list
- apiGroups:
- coordination.k8s.io
resources:
Expand Down Expand Up @@ -2141,7 +2148,10 @@ spec:
matchLabels:
app: ovs
updateStrategy:
type: OnDelete
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
Expand Down Expand Up @@ -2175,6 +2185,14 @@ spec:
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
Expand Down Expand Up @@ -2385,6 +2403,13 @@ rules:
- create
- patch
- update
- apiGroups:
- apps
resources:
- controllerrevisions
verbs:
- get
- list
- apiGroups:
- coordination.k8s.io
resources:
Expand Down Expand Up @@ -2639,7 +2664,10 @@ spec:
matchLabels:
app: ovs
updateStrategy:
type: OnDelete
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
Expand Down Expand Up @@ -2673,6 +2701,14 @@ spec:
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: HW_OFFLOAD
value: "$HW_OFFLOAD"
- name: TUNNEL_TYPE
Expand Down Expand Up @@ -2831,6 +2867,14 @@ spec:
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: HW_OFFLOAD
value: "$HW_OFFLOAD"
- name: TUNNEL_TYPE
Expand Down
13 changes: 11 additions & 2 deletions dist/images/start-ovs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,17 @@ function quit {
# Wait a while for prob ready.
# As the timeout has been increased existing entry will not change to stale or delay at the moment
sleep 5
/usr/share/ovn/scripts/grace_stop_ovn_controller
/usr/share/openvswitch/scripts/ovs-ctl stop

gen_name=$(kubectl -n $POD_NAMESPACE get pod $POD_NAME -o jsonpath='{.metadata.generateName}')
revision_hash=$(kubectl -n $POD_NAMESPACE get pod $POD_NAME -o jsonpath='{.metadata.labels.controller-revision-hash}')
revision=$(kubectl -n $POD_NAMESPACE get controllerrevision $gen_name$revision_hash -o jsonpath='{.revision}')
ds_name=${gen_name%-}
latest_revision=$(kubectl -n kube-system get controllerrevision --no-headers | awk '$2 == "daemonset.apps/'$ds_name'" {print $3}' | sort -nr | head -n1)
if [ "x$latest_revision" = "x$revision" ]; then
/usr/share/ovn/scripts/grace_stop_ovn_controller
/usr/share/openvswitch/scripts/ovs-ctl stop
fi

exit 0
}
trap quit EXIT
Expand Down
7 changes: 7 additions & 0 deletions kubeovn-helm/templates/ovn-CR.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ rules:
- create
- patch
- update
- apiGroups:
- apps
resources:
- controllerrevisions
verbs:
- get
- list
- apiGroups:
- coordination.k8s.io
resources:
Expand Down
5 changes: 4 additions & 1 deletion kubeovn-helm/templates/ovsovn-ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ spec:
matchLabels:
app: ovs
updateStrategy:
type: OnDelete
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
Expand Down
12 changes: 11 additions & 1 deletion yamls/ovn-ha.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ rules:
- create
- patch
- update
- apiGroups:
- apps
resources:
- controllerrevisions
verbs:
- get
- list
- apiGroups:
- coordination.k8s.io
resources:
Expand Down Expand Up @@ -331,7 +338,10 @@ spec:
matchLabels:
app: ovs
updateStrategy:
type: OnDelete
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
Expand Down
12 changes: 11 additions & 1 deletion yamls/ovn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ rules:
- create
- patch
- update
- apiGroups:
- apps
resources:
- controllerrevisions
verbs:
- get
- list
- apiGroups:
- coordination.k8s.io
resources:
Expand Down Expand Up @@ -347,7 +354,10 @@ spec:
matchLabels:
app: ovs
updateStrategy:
type: OnDelete
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
Expand Down

0 comments on commit b7bea91

Please sign in to comment.