Skip to content

Commit 64bc043

Browse files
authored
feat: Enable configurable parallel image pulls (#1306)
**What problem does this PR solve?**: Default behaviour is retained, that is serialized image pulls actually configured by disabling forced serialized image pulls and setting max parallel image pulls to 1. A value of zero means unlimited parallel image pulls. **Which issue(s) this PR fixes**: Fixes # **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. -->
1 parent 06520f8 commit 64bc043

13 files changed

+1284
-1
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ repos:
8181
- id: check-yaml
8282
args: ["-m", "--unsafe"]
8383
stages: [pre-commit]
84-
exclude: ^charts/.+/(templates|addons)/.+\.ya?ml$
84+
exclude: (embedded/kubeletconfigpatch.yaml|^charts/.+/(templates|addons)/.+\.ya?ml)$
8585
- id: mixed-line-ending
8686
args: ["-f", "lf"]
8787
exclude: \.bat$

api/v1alpha1/clusterconfig_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,13 @@ type KubeadmClusterConfigSpec struct {
246246
// KubeProxy defines the configuration for kube-proxy.
247247
// +kubebuilder:validation:Optional
248248
KubeProxy *KubeProxy `json:"kubeProxy,omitempty"`
249+
250+
// MaxParallelImagePullsPerNode defines the maximum number of parallel image pulls performed by each kubelet.
251+
// If not set, the default value of 1 will be used.
252+
// If set to 0, the maximum number of parallel image pulls will be unlimited.
253+
// +kubebuilder:validation:Optional
254+
// +kubebuilder:validation:Minimum=0
255+
MaxParallelImagePullsPerNode *int32 `json:"maxParallelImagePullsPerNode,omitempty"`
249256
}
250257

251258
// +kubebuilder:object:root=true

api/v1alpha1/crds/caren.nutanix.com_awsclusterconfigs.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,14 @@ spec:
636636
minLength: 1
637637
pattern: ^((?:[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*|\[(?:[a-fA-F0-9:]+)\])(:[0-9]+)?/)?[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*(/[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*)*$
638638
type: string
639+
maxParallelImagePullsPerNode:
640+
description: |-
641+
MaxParallelImagePullsPerNode defines the maximum number of parallel image pulls performed by each kubelet.
642+
If not set, the default value of 1 will be used.
643+
If set to 0, the maximum number of parallel image pulls will be unlimited.
644+
format: int32
645+
minimum: 0
646+
type: integer
639647
ntp:
640648
description: NTP defines the NTP configuration for the cluster.
641649
properties:

api/v1alpha1/crds/caren.nutanix.com_dockerclusterconfigs.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,14 @@ spec:
545545
minLength: 1
546546
pattern: ^((?:[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*|\[(?:[a-fA-F0-9:]+)\])(:[0-9]+)?/)?[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*(/[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*)*$
547547
type: string
548+
maxParallelImagePullsPerNode:
549+
description: |-
550+
MaxParallelImagePullsPerNode defines the maximum number of parallel image pulls performed by each kubelet.
551+
If not set, the default value of 1 will be used.
552+
If set to 0, the maximum number of parallel image pulls will be unlimited.
553+
format: int32
554+
minimum: 0
555+
type: integer
548556
ntp:
549557
description: NTP defines the NTP configuration for the cluster.
550558
properties:

api/v1alpha1/crds/caren.nutanix.com_kubeadmclusterconfigs.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ spec:
134134
minLength: 1
135135
pattern: ^((?:[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*|\[(?:[a-fA-F0-9:]+)\])(:[0-9]+)?/)?[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*(/[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*)*$
136136
type: string
137+
maxParallelImagePullsPerNode:
138+
description: |-
139+
MaxParallelImagePullsPerNode defines the maximum number of parallel image pulls performed by each kubelet.
140+
If not set, the default value of 1 will be used.
141+
If set to 0, the maximum number of parallel image pulls will be unlimited.
142+
format: int32
143+
minimum: 0
144+
type: integer
137145
type: object
138146
type: object
139147
served: true

api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,14 @@ spec:
733733
minLength: 1
734734
pattern: ^((?:[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*|\[(?:[a-fA-F0-9:]+)\])(:[0-9]+)?/)?[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*(/[a-z0-9]+((?:[._]|__|[-]+)[a-z0-9]+)*)*$
735735
type: string
736+
maxParallelImagePullsPerNode:
737+
description: |-
738+
MaxParallelImagePullsPerNode defines the maximum number of parallel image pulls performed by each kubelet.
739+
If not set, the default value of 1 will be used.
740+
If set to 0, the maximum number of parallel image pulls will be unlimited.
741+
format: int32
742+
minimum: 0
743+
type: integer
736744
ntp:
737745
description: NTP defines the NTP configuration for the cluster.
738746
properties:

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
+++
2+
title = "Parallel Image Pulls"
3+
+++
4+
5+
This customization will be available when the
6+
[provider-specific cluster configuration patch]({{< ref "..">}}) is included in the `ClusterClass`.
7+
8+
The parallel image pull configuration can then be manipulated via the cluster variables.
9+
If the `maxParallelImagePullsPerNode` property is not specified, then the default value of `1` will be used
10+
which is equivalent to serialized image pulls.
11+
12+
Setting this value to `0` results in unlimited parallel image pulls.
13+
14+
### Example
15+
16+
```yaml
17+
apiVersion: cluster.x-k8s.io/v1beta1
18+
kind: Cluster
19+
metadata:
20+
name: <NAME>
21+
spec:
22+
topology:
23+
variables:
24+
- name: clusterConfig
25+
value:
26+
maxParallelImagePullsPerNodePerNode: 10
27+
```
28+
29+
Applying this configuration will result in a `KubeletConfiguration` patch being added which will be
30+
applied by `kubeadm` on `init` and `join`:
31+
32+
- `KubeadmControlPlaneTemplate`:
33+
34+
- ```yaml
35+
spec:
36+
template:
37+
spec:
38+
kubeadmConfigSpec:
39+
files:
40+
- path: "/etc/kubernetes/patches/kubeletconfigurationmaxparallelimagepulls+strategic.json"
41+
owner: "root:root"
42+
permissions: "0644"
43+
content: |-
44+
---
45+
apiVersion: kubelet.config.k8s.io/v1beta1
46+
kind: KubeletConfiguration
47+
serializeImagePulls: false
48+
maxParallelImagePulls: 10
49+
```
50+
51+
- `KubeadmConfigTemplate`
52+
53+
- ```yaml
54+
spec:
55+
kubeadmConfigSpec:
56+
files:
57+
- path: "/etc/kubernetes/patches/kubeletconfigurationmaxparallelimagepulls+strategic.json"
58+
owner: "root:root"
59+
permissions: "0644"
60+
content: |-
61+
---
62+
apiVersion: kubelet.config.k8s.io/v1beta1
63+
kind: KubeletConfiguration
64+
serializeImagePulls: false
65+
maxParallelImagePulls: 10
66+
```

pkg/handlers/generic/mutation/handlers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/mirrors"
2626
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/noderegistration"
2727
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/ntp"
28+
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/parallelimagepulls"
2829
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/taints"
2930
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation/users"
3031
)
@@ -48,6 +49,7 @@ func MetaMutators(mgr manager.Manager) []mutation.MetaMutator {
4849
autorenewcerts.NewPatch(),
4950
kubeproxymode.NewPatch(),
5051
ntp.NewPatch(),
52+
parallelimagepulls.NewPatch(),
5153

5254
// Some patches may have changed containerd configuration.
5355
// We write the configuration changes to disk, and must run a command
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
apiVersion: kubelet.config.k8s.io/v1beta1
3+
kind: KubeletConfiguration
4+
serializeImagePulls: false
5+
{{- if gt .MaxParallelImagePullsPerNode 0 }}
6+
maxParallelImagePulls: {{ .MaxParallelImagePullsPerNode }}
7+
{{- end }}

0 commit comments

Comments
 (0)