Skip to content

Commit

Permalink
Merge pull request #9057 from hakman/automated-cherry-pick-of-#8216-#…
Browse files Browse the repository at this point in the history
…8303-upstream-release-1.17

Automated cherry pick of #8216 #8303: Adding ability to configure resources for weave
  • Loading branch information
k8s-ci-robot committed May 4, 2020
2 parents 75819f0 + f495ddb commit 8d3c46d
Show file tree
Hide file tree
Showing 18 changed files with 362 additions and 43 deletions.
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 @@ -2657,6 +2657,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 @@ -2665,6 +2680,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

0 comments on commit 8d3c46d

Please sign in to comment.