Skip to content

Commit

Permalink
Support configuring MaxPods (#167)
Browse files Browse the repository at this point in the history
* Support configuring MaxPods

Signed-off-by: Marko Mudrinić <[email protected]>

* Update OSPs

Signed-off-by: Marko Mudrinić <[email protected]>

* Update machine-controller to v1.51.0

Signed-off-by: Marko Mudrinić <[email protected]>

* Add maxPods to fixtures

Signed-off-by: Marko Mudrinić <[email protected]>
  • Loading branch information
xmudrii authored Jun 1, 2022
1 parent d3b2732 commit 57929a3
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 7 deletions.
3 changes: 3 additions & 0 deletions deploy/osps/default/osp-amzn2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,9 @@ spec:
nodefs.available: 10%
nodefs.inodesFree: 5%
{{- end }}
{{- if .MaxPods }}
maxPods: {{ .MaxPods }}
{{- end }}
tlsCipherSuites:
- TLS_AES_128_GCM_SHA256
- TLS_AES_256_GCM_SHA384
Expand Down
3 changes: 3 additions & 0 deletions deploy/osps/default/osp-centos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,9 @@ spec:
nodefs.available: 10%
nodefs.inodesFree: 5%
{{- end }}
{{- if .MaxPods }}
maxPods: {{ .MaxPods }}
{{- end }}
tlsCipherSuites:
- TLS_AES_128_GCM_SHA256
- TLS_AES_256_GCM_SHA384
Expand Down
3 changes: 3 additions & 0 deletions deploy/osps/default/osp-centos8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,9 @@ spec:
nodefs.available: 10%
nodefs.inodesFree: 5%
{{- end }}
{{- if .MaxPods }}
maxPods: {{ .MaxPods }}
{{- end }}
tlsCipherSuites:
- TLS_AES_128_GCM_SHA256
- TLS_AES_256_GCM_SHA384
Expand Down
3 changes: 3 additions & 0 deletions deploy/osps/default/osp-flatcar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,9 @@ spec:
nodefs.available: 10%
nodefs.inodesFree: 5%
{{- end }}
{{- if .MaxPods }}
maxPods: {{ .MaxPods }}
{{- end }}
tlsCipherSuites:
- TLS_AES_128_GCM_SHA256
- TLS_AES_256_GCM_SHA384
Expand Down
3 changes: 3 additions & 0 deletions deploy/osps/default/osp-rhel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,9 @@ spec:
nodefs.available: 10%
nodefs.inodesFree: 5%
{{- end }}
{{- if .MaxPods }}
maxPods: {{ .MaxPods }}
{{- end }}
tlsCipherSuites:
- TLS_AES_128_GCM_SHA256
- TLS_AES_256_GCM_SHA384
Expand Down
3 changes: 3 additions & 0 deletions deploy/osps/default/osp-sles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ spec:
nodefs.available: 10%
nodefs.inodesFree: 5%
{{- end }}
{{- if .MaxPods }}
maxPods: {{ .MaxPods }}
{{- end }}
tlsCipherSuites:
- TLS_AES_128_GCM_SHA256
- TLS_AES_256_GCM_SHA384
Expand Down
3 changes: 3 additions & 0 deletions deploy/osps/default/osp-ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,9 @@ spec:
nodefs.available: 10%
nodefs.inodesFree: 5%
{{- end }}
{{- if .MaxPods }}
maxPods: {{ .MaxPods }}
{{- end }}
tlsCipherSuites:
- TLS_AES_128_GCM_SHA256
- TLS_AES_256_GCM_SHA384
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/Masterminds/sprig/v3 v3.2.2
github.com/flatcar-linux/container-linux-config-transpiler v0.9.3
github.com/go-test/deep v1.0.7
github.com/kubermatic/machine-controller v1.50.1-0.20220524122024-10d35a0d7e24
github.com/kubermatic/machine-controller v1.51.0
github.com/onsi/ginkgo v1.16.5
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kubermatic/machine-controller v1.50.1-0.20220524122024-10d35a0d7e24 h1:UB7qb1AI+2NTt/REqwAUVs8RlKOwL/eLrE15WZ222NY=
github.com/kubermatic/machine-controller v1.50.1-0.20220524122024-10d35a0d7e24/go.mod h1:Ooaj2BieUTx8URH6Hgpt6UJ83gi2oTt9vd/6rk2TrpU=
github.com/kubermatic/machine-controller v1.51.0 h1:Vo1SAK9kt2DWPuPAhxzI8tSwK7eRvpSMfAkMlucr67A=
github.com/kubermatic/machine-controller v1.51.0/go.mod h1:b9NIu47nb0MwONTUtb3iCf2hfMfpnmy3Y9BIkR+J3ZQ=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
Expand Down
2 changes: 2 additions & 0 deletions pkg/controllers/osc/osc_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ func TestReconciler_Reconcile(t *testing.T) {
additionalAnnotations: map[string]string{
"v1.kubelet-config.machine-controller.kubermatic.io/ContainerLogMaxSize": "300Mi",
"v1.kubelet-config.machine-controller.kubermatic.io/ContainerLogMaxFiles": "30",
"v1.kubelet-config.machine-controller.kubermatic.io/MaxPods": "110",
"v1.kubelet-config.machine-controller.kubermatic.io/SystemReserved": "ephemeral-storage=30Gi,cpu=30m",
"v1.kubelet-config.machine-controller.kubermatic.io/KubeReserved": "ephemeral-storage=30Gi,cpu=30m",
"v1.kubelet-config.machine-controller.kubermatic.io/EvictionHard": "memory.available<30Mi",
Expand All @@ -266,6 +267,7 @@ func TestReconciler_Reconcile(t *testing.T) {
additionalAnnotations: map[string]string{
"v1.kubelet-config.machine-controller.kubermatic.io/ContainerLogMaxSize": "300Mi",
"v1.kubelet-config.machine-controller.kubermatic.io/ContainerLogMaxFiles": "30",
"v1.kubelet-config.machine-controller.kubermatic.io/MaxPods": "110",
"v1.kubelet-config.machine-controller.kubermatic.io/SystemReserved": "ephemeral-storage=30Gi,cpu=30m",
"v1.kubelet-config.machine-controller.kubermatic.io/KubeReserved": "ephemeral-storage=30Gi,cpu=30m",
"v1.kubelet-config.machine-controller.kubermatic.io/EvictionHard": "memory.available<30Mi",
Expand Down
22 changes: 18 additions & 4 deletions pkg/controllers/osc/resources/operating_system_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"errors"
"fmt"
"net"
"strconv"
"strings"
"text/template"

Expand All @@ -41,6 +42,7 @@ import (
"k8c.io/operating-system-manager/pkg/providerconfig/ubuntu"
jsonutil "k8c.io/operating-system-manager/pkg/util/json"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -118,7 +120,10 @@ func GenerateOperatingSystemConfig(
}

// Handling for kubelet configuration
kubeletConfigs := getKubeletConfigs(md.Annotations)
kubeletConfigs, err := getKubeletConfigs(md.Annotations)
if err != nil {
return nil, err
}
if kubeletConfigs.ContainerLogMaxSize != nil && len(*kubeletConfigs.ContainerLogMaxSize) > 0 {
containerRuntimeConfig.ContainerLogMaxSize = *kubeletConfigs.ContainerLogMaxSize
}
Expand Down Expand Up @@ -251,6 +256,7 @@ type kubeletConfig struct {
KubeReserved *map[string]string
SystemReserved *map[string]string
EvictionHard *map[string]string
MaxPods *int32
ContainerLogMaxSize *string
ContainerLogMaxFiles *string
}
Expand Down Expand Up @@ -386,11 +392,11 @@ func setOperatingSystemConfig(os providerconfigtypes.OperatingSystem, operatingS
return errors.New("unknown OperatingSystem")
}

func getKubeletConfigs(annotations map[string]string) kubeletConfig {
func getKubeletConfigs(annotations map[string]string) (kubeletConfig, error) {
var cfg kubeletConfig
kubeletConfigs := common.GetKubeletConfigs(annotations)
if len(kubeletConfigs) == 0 {
return cfg
return cfg, nil
}

if val, ok := kubeletConfigs[common.KubeReservedKubeletConfig]; ok {
Expand All @@ -405,14 +411,22 @@ func getKubeletConfigs(annotations map[string]string) kubeletConfig {
cfg.EvictionHard = getKeyValueMap(val, "<")
}

if val, ok := kubeletConfigs[common.MaxPodsKubeletConfig]; ok {
mp, err := strconv.ParseInt(val, 10, 32)
if err != nil {
return kubeletConfig{}, fmt.Errorf("failed to parse maxPods")
}
cfg.MaxPods = pointer.Int32Ptr(int32(mp))
}

if val, ok := kubeletConfigs[common.ContainerLogMaxSizeKubeletConfig]; ok {
cfg.ContainerLogMaxSize = &val
}

if val, ok := kubeletConfigs[common.ContainerLogMaxFilesKubeletConfig]; ok {
cfg.ContainerLogMaxFiles = &val
}
return cfg
return cfg, nil
}

func getKeyValueMap(value string, kvDelimeter string) *map[string]string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ spec:
ephemeral-storage: 30Gi
evictionHard:
memory.available: 30Mi
maxPods: 110
tlsCipherSuites:
- TLS_AES_128_GCM_SHA256
- TLS_AES_256_GCM_SHA384
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ spec:
ephemeral-storage: 30Gi
evictionHard:
memory.available: 30Mi
maxPods: 110
tlsCipherSuites:
- TLS_AES_128_GCM_SHA256
- TLS_AES_256_GCM_SHA384
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 57929a3

Please sign in to comment.