Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ability to configure resources for weave (#8113) #8216

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions k8s/crds/kops.k8s.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2769,6 +2769,21 @@ spec:
connLimit:
format: int32
type: integer
cpuLimit:
description: CPULimit CPU limit of weave container.
type: string
cpuRequest:
description: CPURequest CPU request of weave container. Default
50m
type: string
memoryLimit:
description: MemoryLimit memory limit of weave container. Default
200Mi
type: string
memoryRequest:
description: MemoryRequest memory request of weave container.
Default 200Mi
type: string
mtu:
format: int32
type: integer
Expand All @@ -2777,6 +2792,21 @@ spec:
noMasqLocal:
format: int32
type: integer
npcCPULimit:
description: NPCCPULimit CPU limit of weave npc container
type: string
npcCPURequest:
description: NPCCPURequest CPU request of weave npc container.
Default 50m
type: string
npcMemoryLimit:
description: NPCMemoryLimit memory limit of weave npc container.
Default 200Mi
type: string
npcMemoryRequest:
description: NPCMemoryRequest memory request of weave npc container.
Default 200Mi
type: string
type: object
type: object
nodeAuthorization:
Expand Down
19 changes: 19 additions & 0 deletions pkg/apis/kops/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ limitations under the License.

package kops

import "k8s.io/apimachinery/pkg/api/resource"

// NetworkingSpec allows selection and configuration of a networking plugin
type NetworkingSpec struct {
Classic *ClassicNetworkingSpec `json:"classic,omitempty"`
Expand Down Expand Up @@ -65,6 +67,23 @@ type WeaveNetworkingSpec struct {
ConnLimit *int32 `json:"connLimit,omitempty"`
NoMasqLocal *int32 `json:"noMasqLocal,omitempty"`
NetExtraArgs string `json:"netExtraArgs,omitempty"`

// MemoryRequest memory request of weave container. Default 200Mi
MemoryRequest *resource.Quantity `json:"memoryRequest,omitempty"`
// CPURequest CPU request of weave container. Default 50m
CPURequest *resource.Quantity `json:"cpuRequest,omitempty"`
// MemoryLimit memory limit of weave container. Default 200Mi
MemoryLimit *resource.Quantity `json:"memoryLimit,omitempty"`
// CPULimit CPU limit of weave container.
CPULimit *resource.Quantity `json:"cpuLimit,omitempty"`
// NPCMemoryRequest memory request of weave npc container. Default 200Mi
NPCMemoryRequest *resource.Quantity `json:"npcMemoryRequest,omitempty"`
// NPCCPURequest CPU request of weave npc container. Default 50m
NPCCPURequest *resource.Quantity `json:"npcCPURequest,omitempty"`
// NPCMemoryLimit memory limit of weave npc container. Default 200Mi
NPCMemoryLimit *resource.Quantity `json:"npcMemoryLimit,omitempty"`
// NPCCPULimit CPU limit of weave npc container
NPCCPULimit *resource.Quantity `json:"npcCPULimit,omitempty"`
}

// FlannelNetworkingSpec declares that we want Flannel networking
Expand Down
45 changes: 45 additions & 0 deletions pkg/apis/kops/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,48 @@ func TestParseConfigYAML(t *testing.T) {
})
}
}

func TestWeaveParseConfigYAML(t *testing.T) {
grid := []struct {
Config string
ExpectedValue string
}{
{
Config: "networking: { weave: { memoryRequest: 500Mi, cpuRequest: 100m, npcMemoryRequest: 100Mi, npcCPURequest: 50m} }",
ExpectedValue: "50m",
},
{
Config: "networking: {}",
ExpectedValue: "",
},
}
for i := range grid {
g := grid[i]
t.Run(fmt.Sprintf("%q", g.Config), func(t *testing.T) {
config := ClusterSpec{}
err := utils.YamlUnmarshal([]byte(g.Config), &config)
if err != nil {
t.Errorf("error parsing configuration %q: %v", g.Config, err)
return
}
var actual string
if nil != config.Networking.Weave {
actual = config.Networking.Weave.NPCCPURequest.String()
}
if g.ExpectedValue == "" {
if actual != "" {
t.Errorf("expected empty value for Networking.Weave.NPCCPURequest.String(), got %v", actual)
return
}
} else {
if actual == "" {
t.Errorf("expected %v value for Networking.Weave.NPCCPURequest.String(), got empty string", g.ExpectedValue)
return
} else if actual != g.ExpectedValue {
t.Errorf("expected %v value for Networking.Weave.NPCCPURequest.String(), got %v", g.ExpectedValue, actual)
return
}
}
})
}
}
19 changes: 19 additions & 0 deletions pkg/apis/kops/v1alpha1/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ limitations under the License.

package v1alpha1

import "k8s.io/apimachinery/pkg/api/resource"

// NetworkingSpec allows selection and configuration of a networking plugin
type NetworkingSpec struct {
Classic *ClassicNetworkingSpec `json:"classic,omitempty"`
Expand Down Expand Up @@ -65,6 +67,23 @@ type WeaveNetworkingSpec struct {
ConnLimit *int32 `json:"connLimit,omitempty"`
NoMasqLocal *int32 `json:"noMasqLocal,omitempty"`
NetExtraArgs string `json:"netExtraArgs,omitempty"`

// MemoryRequest memory request of weave container. Default 200Mi
MemoryRequest *resource.Quantity `json:"memoryRequest,omitempty"`
// CPURequest CPU request of weave container. Default 50m
CPURequest *resource.Quantity `json:"cpuRequest,omitempty"`
// MemoryLimit memory limit of weave container. Default 200Mi
MemoryLimit *resource.Quantity `json:"memoryLimit,omitempty"`
// CPULimit CPU limit of weave container.
CPULimit *resource.Quantity `json:"cpuLimit,omitempty"`
// NPCMemoryRequest memory request of weave npc container. Default 200Mi
NPCMemoryRequest *resource.Quantity `json:"npcMemoryRequest,omitempty"`
// NPCCPURequest CPU request of weave npc container. Default 50m
NPCCPURequest *resource.Quantity `json:"npcCPURequest,omitempty"`
// NPCMemoryLimit memory limit of weave npc container. Default 200Mi
NPCMemoryLimit *resource.Quantity `json:"npcMemoryLimit,omitempty"`
// NPCCPULimit CPU limit of weave npc container
NPCCPULimit *resource.Quantity `json:"npcCPULimit,omitempty"`
}

// FlannelNetworkingSpec declares that we want Flannel networking
Expand Down
16 changes: 16 additions & 0 deletions pkg/apis/kops/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions pkg/apis/kops/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions pkg/apis/kops/v1alpha2/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ limitations under the License.

package v1alpha2

import "k8s.io/apimachinery/pkg/api/resource"

// NetworkingSpec allows selection and configuration of a networking plugin
type NetworkingSpec struct {
Classic *ClassicNetworkingSpec `json:"classic,omitempty"`
Expand Down Expand Up @@ -65,6 +67,23 @@ type WeaveNetworkingSpec struct {
ConnLimit *int32 `json:"connLimit,omitempty"`
NoMasqLocal *int32 `json:"noMasqLocal,omitempty"`
NetExtraArgs string `json:"netExtraArgs,omitempty"`

// MemoryRequest memory request of weave container. Default 200Mi
MemoryRequest *resource.Quantity `json:"memoryRequest,omitempty"`
// CPURequest CPU request of weave container. Default 50m
CPURequest *resource.Quantity `json:"cpuRequest,omitempty"`
// MemoryLimit memory limit of weave container. Default 200Mi
MemoryLimit *resource.Quantity `json:"memoryLimit,omitempty"`
// CPULimit CPU limit of weave container.
CPULimit *resource.Quantity `json:"cpuLimit,omitempty"`
// NPCMemoryRequest memory request of weave npc container. Default 200Mi
NPCMemoryRequest *resource.Quantity `json:"npcMemoryRequest,omitempty"`
// NPCCPURequest CPU request of weave npc container. Default 50m
NPCCPURequest *resource.Quantity `json:"npcCPURequest,omitempty"`
// NPCMemoryLimit memory limit of weave npc container. Default 200Mi
NPCMemoryLimit *resource.Quantity `json:"npcMemoryLimit,omitempty"`
// NPCCPULimit CPU limit of weave npc container
NPCCPULimit *resource.Quantity `json:"npcCPULimit,omitempty"`
}

// FlannelNetworkingSpec declares that we want Flannel networking
Expand Down
16 changes: 16 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions pkg/apis/kops/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading