Skip to content

Commit

Permalink
Include custom sysctl parameters when running the sysctl builder
Browse files Browse the repository at this point in the history
  • Loading branch information
ripta committed Oct 10, 2019
1 parent a63b75e commit 6766f47
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions nodeup/pkg/model/sysctls.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package model

import (
"fmt"
"strings"

"k8s.io/kops/pkg/apis/kops"
Expand Down Expand Up @@ -129,6 +130,30 @@ func (b *SysctlBuilder) Build(c *fi.ModelBuilderContext) error {
"net.ipv4.ip_forward=1",
"")

if params := b.InstanceGroup.Spec.SysctlParameters; len(params) > 0 {
sysctls = append(sysctls,
"# Custom sysctl parameters from instance group spec",
"")
for _, param := range params {
if !strings.ContainsRune(param, '=') {
return fmt.Errorf("Invalid SysctlParameter: expected %q to contain '='", param)
}
sysctls = append(sysctls, param)
}
}

if params := b.Cluster.Spec.SysctlParameters; len(params) > 0 {
sysctls = append(sysctls,
"# Custom sysctl parameters from cluster spec",
"")
for _, param := range params {
if !strings.ContainsRune(param, '=') {
return fmt.Errorf("Invalid SysctlParameter: expected %q to contain '='", param)
}
sysctls = append(sysctls, param)
}
}

c.AddTask(&nodetasks.File{
Path: "/etc/sysctl.d/99-k8s-general.conf",
Contents: fi.NewStringResource(strings.Join(sysctls, "\n")),
Expand Down

0 comments on commit 6766f47

Please sign in to comment.