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

[cilium] Add support for choosing resources #11248

Merged
merged 2 commits into from
Apr 19, 2021
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
2 changes: 2 additions & 0 deletions docs/contributing/adding_a_feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ Then we conditionally move cilium-operator to masters:
{{ '{{ end }}' }}
```

After changing manifest files remember to run `bash hack/update-expected.sh` in order to get updated [manifestHash](https://github.com/kubernetes/kops/blob/master/upup/pkg/fi/cloudup/tests/bootstrapchannelbuilder/cilium/manifest.yaml#L74) values.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this bit more clear. Note that not all manifests have tests that requires update-expected.

Perhaps split this to a dedicated commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


## Configuring kubelet

When Cilium is in ENI mode `kubelet` needs to be configured with the local IP address, so that it can distinguish it
Expand Down
10 changes: 10 additions & 0 deletions docs/networking/cilium.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ Once the secret has been created, encryption can be enabled by setting `enableEn
enableEncryption: true
```

#### Resources in Cilium
{{ kops_feature_table(kops_added_default='1.21', k8s_min='1.20') }}

As of kOps 1.20, it is possible to choose your own values for Cilium Agents + Operator. Example:
```yaml
networking:
cilium:
cpuRequest: "25m"
memoryRequest: "128Mi"
```

## Getting help

Expand Down
16 changes: 16 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,14 @@ spec:
fetches information from the container runtime and this
field is ignored. Default: none'
type: string
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 +3596,14 @@ spec:
be removed in the future. Setting this has no effect.
format: int32
type: integer
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
5 changes: 5 additions & 0 deletions pkg/apis/kops/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ 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"`

// AccessLog is not implemented and may be removed in the future.
// Setting this has no effect.
AccessLog string `json:"accessLog,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/kops/v1alpha2/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ 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"`

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

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

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

11 changes: 11 additions & 0 deletions pkg/model/components/cilium.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package components

import (
"github.com/blang/semver/v4"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/wellknownports"
"k8s.io/kops/upup/pkg/fi"
Expand Down Expand Up @@ -92,6 +93,16 @@ func (b *CiliumOptionsBuilder) BuildOptions(o interface{}) error {
c.EnableRemoteNodeIdentity = fi.Bool(true)
}

if c.CPURequest == nil {
defaultCPURequest := resource.MustParse("25m")
c.CPURequest = &defaultCPURequest
}

if c.MemoryRequest == nil {
defaultMemoryRequest := resource.MustParse("128Mi")
c.MemoryRequest = &defaultMemoryRequest
}

hubble := c.Hubble
if hubble != nil {
if hubble.Enabled == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,10 @@ spec:
protocol: TCP
{{- end }}
{{ end }}

resources:
requests:
cpu: {{ or .CPURequest "25m" }}
memory: {{ or .MemoryRequest "128Mi" }}
readinessProbe:
httpGet:
host: '127.0.0.1'
Expand Down Expand Up @@ -772,6 +775,10 @@ spec:
name: prometheus
protocol: TCP
{{ end }}
resources:
requests:
cpu: {{ or .CPURequest "25m" }}
memory: {{ or .MemoryRequest "128Mi" }}
livenessProbe:
httpGet:
host: "127.0.0.1"
Expand Down Expand Up @@ -915,4 +922,4 @@ spec:
path: /var/run/cilium
type: Directory
name: hubble-sock-dir
{{ end }}
{{ end }}
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,10 @@ spec:
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 5
resources:
requests:
cpu: {{ or .CPURequest "25m" }}
memory: {{ or .MemoryRequest "128Mi" }}
readinessProbe:
httpGet:
host: '127.0.0.1'
Expand Down Expand Up @@ -823,6 +827,10 @@ spec:
name: prometheus
protocol: TCP
{{ end }}
resources:
requests:
cpu: {{ or .CPURequest "25m" }}
memory: {{ or .MemoryRequest "128Mi" }}
livenessProbe:
httpGet:
host: '127.0.0.1'
Expand Down Expand Up @@ -891,7 +899,7 @@ spec:
strategy:
rollingUpdate:
maxUnavailable: 1
type: RollingUpdate
type: RollingUpdate
template:
metadata:
labels:
Expand Down Expand Up @@ -951,4 +959,4 @@ spec:
path: config.yaml
name: config
{{ end }}
{{ end }}
{{ end }}
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,10 @@ spec:
name: prometheus
protocol: TCP
{{ end }}
resources:
requests:
cpu: {{ or .CPURequest "25m" }}
memory: {{ or .MemoryRequest "128Mi" }}
readinessProbe:
exec:
command:
Expand Down Expand Up @@ -750,6 +754,10 @@ spec:
name: prometheus
protocol: TCP
{{ end }}
resources:
requests:
cpu: {{ or .CPURequest "25m" }}
memory: {{ or .MemoryRequest "128Mi" }}
livenessProbe:
httpGet:
host: "127.0.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ spec:
version: 1.17.0
- id: k8s-1.12
manifest: networking.cilium.io/k8s-1.12-v1.9.yaml
manifestHash: a1d86d4d8501a5f4adfc7e6c356377730a507c86
manifestHash: dea8534ba3aa267f877f7c2f68a1899fe869e1d3
name: networking.cilium.io
needsRollingUpdate: all
selector:
Expand Down