Skip to content

Commit

Permalink
[cilium] Add support for choosing resources
Browse files Browse the repository at this point in the history
Cilium as a CNI is a critical component for cluster so it would be safe
to have some guaranteed resources as well as allowing the users to
define them based on their needs.

In this commit, we init default requested resources and add the
capability of user defined values.

Signed-off-by: dntosas <ntosas@gmail.com>
  • Loading branch information
dntosas committed Apr 17, 2021
1 parent 9786905 commit a13ae2a
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 2 deletions.
32 changes: 32 additions & 0 deletions k8s/crds/kops.k8s.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3398,6 +3398,22 @@ spec:
fetches information from the container runtime and this
field is ignored. Default: none'
type: string
cpuLimit:
anyOf:
- type: integer
- type: string
description: 'CPULimit CPU limit of Cilium agent + operator
container. (default: -)'
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
cpuRequest:
anyOf:
- type: integer
- type: string
description: 'CPURequest CPU request of Cilium agent + operator
container. (default: 25m)'
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
debug:
description: Debug runs Cilium in debug mode.
type: boolean
Expand Down Expand Up @@ -3588,6 +3604,22 @@ spec:
be removed in the future. Setting this has no effect.
format: int32
type: integer
memoryLimit:
anyOf:
- type: integer
- type: string
description: 'MemoryLimit memory limit of Cilium agent + operator
container. (default: -)'
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
memoryRequest:
anyOf:
- type: integer
- type: string
description: 'MemoryRequest memory request of Cilium agent
+ operator container. (default: 128Mi)'
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
monitorAggregation:
description: 'MonitorAggregation sets the level of packet
monitoring. Possible values are "low", "medium", or "maximum".
Expand Down
9 changes: 9 additions & 0 deletions pkg/apis/kops/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,15 @@ type CiliumNetworkingSpec struct {
// Version is the version of the Cilium agent and the Cilium Operator.
Version string `json:"version,omitempty"`

// MemoryRequest memory request of Cilium agent + operator container. (default: 128Mi)
MemoryRequest *resource.Quantity `json:"memoryRequest,omitempty"`
// CPURequest CPU request of Cilium agent + operator container. (default: 25m)
CPURequest *resource.Quantity `json:"cpuRequest,omitempty"`
// MemoryLimit memory limit of Cilium agent + operator container. (default: -)
MemoryLimit *resource.Quantity `json:"memoryLimit,omitempty"`
// CPULimit CPU limit of Cilium agent + operator container. (default: -)
CPULimit *resource.Quantity `json:"cpuLimit,omitempty"`

// AccessLog is not implemented and may be removed in the future.
// Setting this has no effect.
AccessLog string `json:"accessLog,omitempty"`
Expand Down
9 changes: 9 additions & 0 deletions pkg/apis/kops/v1alpha2/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,15 @@ type CiliumNetworkingSpec struct {
// Version is the version of the Cilium agent and the Cilium Operator.
Version string `json:"version,omitempty"`

// MemoryRequest memory request of Cilium agent + operator container. (default: 128Mi)
MemoryRequest *resource.Quantity `json:"memoryRequest,omitempty"`
// CPURequest CPU request of Cilium agent + operator container. (default: 25m)
CPURequest *resource.Quantity `json:"cpuRequest,omitempty"`
// MemoryLimit memory limit of Cilium agent + operator container. (default: -)
MemoryLimit *resource.Quantity `json:"memoryLimit,omitempty"`
// CPULimit CPU limit of Cilium agent + operator container. (default: -)
CPULimit *resource.Quantity `json:"cpuLimit,omitempty"`

// AccessLog is not implemented and may be removed in the future.
// Setting this has no effect.
AccessLog string `json:"accessLog,omitempty"`
Expand Down
8 changes: 8 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.

20 changes: 20 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.

20 changes: 20 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.

Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,17 @@ spec:
protocol: TCP
{{- end }}
{{ end }}

resources:
requests:
cpu: {{ or .Networking.Cilium.CPURequest "25m" }}
memory: {{ or .Networking.Cilium.MemoryRequest "128Mi" }}
limits:
{{- if .Networking.Cilium.CPULimit }}
cpu: {{ .Networking.Cilium.CPULimit }}
{{- end }}
{{- if .Networking.Cilium.MemoryLimit }}
memory: {{ .Networking.Cilium.MemoryLimit }}
{{- end }}
readinessProbe:
httpGet:
host: '127.0.0.1'
Expand Down Expand Up @@ -772,6 +782,17 @@ spec:
name: prometheus
protocol: TCP
{{ end }}
resources:
requests:
cpu: {{ or .Networking.Cilium.CPURequest "25m" }}
memory: {{ or .Networking.Cilium.MemoryRequest "128Mi" }}
limits:
{{- if .Networking.Cilium.CPULimit }}
cpu: {{ .Networking.Cilium.CPULimit }}
{{- end }}
{{- if .Networking.Cilium.MemoryLimit }}
memory: {{ .Networking.Cilium.MemoryLimit }}
{{- end }}
livenessProbe:
httpGet:
host: "127.0.0.1"
Expand Down Expand Up @@ -915,4 +936,4 @@ spec:
path: /var/run/cilium
type: Directory
name: hubble-sock-dir
{{ end }}
{{ end }}

0 comments on commit a13ae2a

Please sign in to comment.