Skip to content

Commit ca220f0

Browse files
committed
add option to skip kubelet update
1 parent 9f0523d commit ca220f0

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

cluster.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ type KubeletParams struct {
234234
CNIConfFile CNIConfFile `json:"cni_conf_file"`
235235
Config *unstructured.Unstructured `json:"config,omitempty"`
236236
CRIEndpoint string `json:"cri_endpoint"`
237+
SkipUpdate bool `json:"skip_update"`
237238
}
238239

239240
// MergeConfig merges the input struct with `base`.

docs/cluster.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Changing `KubeProxyConfiguration.Mode` requires full node restarts.
230230

231231
### KubeletParams
232232

233-
| Name | Required | Type | Description |
233+
| Name | Required | Type | Description |
234234
| --------------- | -------- | ------------------------------- | ----------------------------------------------------------------------- |
235235
| `boot_taints` | false | `[]Taint` | Bootstrap node taints. |
236236
| `cni_conf_file` | false | `CNIConfFile` | CNI configuration file. |
@@ -239,6 +239,7 @@ Changing `KubeProxyConfiguration.Mode` requires full node restarts.
239239
| `extra_args` | false | array | Extra command-line arguments. List of strings. |
240240
| `extra_binds` | false | array | Extra bind mounts. List of `Mount`. |
241241
| `extra_env` | false | object | Extra environment variables. |
242+
| `skip_update` | false | bool | Skip update of the outdated kubelet. |
242243

243244
#### Boot taints
244245

server/node_filter.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,11 @@ func (nf *NodeFilter) RegisteredNodes(target []*cke.Node) (nodes []*cke.Node) {
446446
return nodes
447447
}
448448

449+
func (nf *NodeFilter) KubeletNeedUpgrade(node *cke.Node) bool {
450+
st := nf.nodeStatus(node).Kubelet
451+
return cke.KubernetesImage.Name() != st.Image
452+
}
453+
449454
// KubeletOutdatedNodes returns nodes that are running kubelet with outdated image or params.
450455
func (nf *NodeFilter) KubeletOutdatedNodes() (nodes []*cke.Node) {
451456
currentOpts := nf.cluster.Options.Kubelet

server/strategy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func k8sOps(c *cke.Cluster, nf *NodeFilter, cs *cke.ClusterStatus, maxConcurrent
186186
}
187187
ops = append(ops, k8s.KubeletBootOp(nodes[:max], nf.RegisteredNodes(nodes[:max]), apiServer, c.Name, c.Options.Kubelet, cs.NodeStatuses))
188188
}
189-
if nodes := nf.SSHConnectedNodes(nf.KubeletOutdatedNodes(), true, true); len(nodes) > 0 {
189+
if nodes := nf.SSHConnectedNodes(nf.KubeletOutdatedNodes(), true, true); len(nodes) > 0 && !c.Options.Kubelet.SkipUpdate {
190190
max := maxConcurrentUpdates
191191
if len(nodes) < max {
192192
max = len(nodes)

server/strategy_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,15 @@ func TestDecideOps(t *testing.T) {
10121012
{"kubelet-restart", 2},
10131013
},
10141014
},
1015+
{
1016+
Name: "RestartKubelet10",
1017+
Input: newData().withAllServices().withKubelet("foo.local", "10.0.0.53", false).with(func(d testData) {
1018+
d.Cluster.Options.Kubelet.SkipUpdate = true
1019+
}).withSSHNotConnectedNodes(),
1020+
ExpectedOps: []opData{
1021+
{"wait-kubernetes", 1},
1022+
},
1023+
},
10151024
{
10161025
Name: "RestartProxy",
10171026
Input: newData().withAllServices().with(func(d testData) {

0 commit comments

Comments
 (0)