Skip to content

Commit 0b1fcc5

Browse files
committed
adding feature flag NativeSidecar
1 parent 9473da4 commit 0b1fcc5

File tree

5 files changed

+75
-1
lines changed

5 files changed

+75
-1
lines changed

vertical-pod-autoscaler/docs/flags.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ This document is auto-generated from the flag definitions in the VPA admission-c
1414
| `address` | string | ":8944" | The address to expose Prometheus metrics. |
1515
| `alsologtostderr` | | | log to standard error as well as files (no effect when -logtostderr=true) |
1616
| `client-ca-file` | string | "/etc/tls-certs/caCert.pem" | Path to CA PEM file. |
17+
<<<<<<< HEAD
1718
| `feature-gates` | mapStringBool | | A set of key=value pairs that describe feature gates for alpha/experimental features. Options are:<br>AllAlpha=true\|false (ALPHA - default=false)<br>AllBeta=true\|false (BETA - default=false)<br>InPlaceOrRecreate=true\|false (BETA - default=true)<br>PerVPAConfig=true\|false (ALPHA - default=false) |
19+
=======
20+
| `feature-gates` | mapStringBool | | A set of key=value pairs that describe feature gates for alpha/experimental features. Options are:<br>AllAlpha=true\|false (ALPHA - default=false)<br>AllBeta=true\|false (BETA - default=false)<br>InPlaceOrRecreate=true\|false (BETA - default=true)<br>NativeSidecar=true\|false (ALPHA - default=false) |
21+
>>>>>>> a4748ee23 (adding feature flag `NativeSidecar`)
1822
| `ignored-vpa-object-namespaces` | string | | A comma-separated list of namespaces to ignore when searching for VPA objects. Leave empty to avoid ignoring any namespaces. These namespaces will not be cleaned by the garbage collector. |
1923
| `kube-api-burst` | float | 100 | QPS burst limit when making requests to Kubernetes apiserver |
2024
| `kube-api-qps` | float | 50 | QPS limit when making requests to Kubernetes apiserver |
@@ -68,7 +72,11 @@ This document is auto-generated from the flag definitions in the VPA recommender
6872
| `cpu-integer-post-processor-enabled` | | | Enable the cpu-integer recommendation post processor. The post processor will round up CPU recommendations to a whole CPU for pods which were opted in by setting an appropriate label on VPA object (experimental) |
6973
| `external-metrics-cpu-metric` | string | | ALPHA. Metric to use with external metrics provider for CPU usage. |
7074
| `external-metrics-memory-metric` | string | | ALPHA. Metric to use with external metrics provider for memory usage. |
75+
<<<<<<< HEAD
7176
| `feature-gates` | mapStringBool | | A set of key=value pairs that describe feature gates for alpha/experimental features. Options are:<br>AllAlpha=true\|false (ALPHA - default=false)<br>AllBeta=true\|false (BETA - default=false)<br>InPlaceOrRecreate=true\|false (BETA - default=true)<br>PerVPAConfig=true\|false (ALPHA - default=false) |
77+
=======
78+
| `feature-gates` | mapStringBool | | A set of key=value pairs that describe feature gates for alpha/experimental features. Options are:<br>AllAlpha=true\|false (ALPHA - default=false)<br>AllBeta=true\|false (BETA - default=false)<br>InPlaceOrRecreate=true\|false (BETA - default=true)<br>NativeSidecar=true\|false (ALPHA - default=false) |
79+
>>>>>>> a4748ee23 (adding feature flag `NativeSidecar`)
7280
| `history-length` | string | "8d" | How much time back prometheus have to be queried to get historical metrics |
7381
| `history-resolution` | string | "1h" | Resolution at which Prometheus is queried for historical metrics |
7482
| `humanize-memory` | | | DEPRECATED: Convert memory values in recommendations to the highest appropriate SI unit with up to 2 decimal places for better readability. This flag is deprecated and will be removed in a future version. Use --round-memory-bytes instead. |
@@ -144,7 +152,11 @@ This document is auto-generated from the flag definitions in the VPA updater cod
144152
| `eviction-rate-burst` | int | 1 | Burst of pods that can be evicted. |
145153
| `eviction-rate-limit` | float | | Number of pods that can be evicted per seconds. A rate limit set to 0 or -1 will disable<br>the rate limiter. (default -1) |
146154
| `eviction-tolerance` | float | 0.5 | Fraction of replica count that can be evicted for update, if more than one pod can be evicted. |
155+
<<<<<<< HEAD
147156
| `feature-gates` | mapStringBool | | A set of key=value pairs that describe feature gates for alpha/experimental features. Options are:<br>AllAlpha=true\|false (ALPHA - default=false)<br>AllBeta=true\|false (BETA - default=false)<br>InPlaceOrRecreate=true\|false (BETA - default=true)<br>PerVPAConfig=true\|false (ALPHA - default=false) |
157+
=======
158+
| `feature-gates` | mapStringBool | | A set of key=value pairs that describe feature gates for alpha/experimental features. Options are:<br>AllAlpha=true\|false (ALPHA - default=false)<br>AllBeta=true\|false (BETA - default=false)<br>InPlaceOrRecreate=true\|false (BETA - default=true)<br>NativeSidecar=true\|false (ALPHA - default=false) |
159+
>>>>>>> a4748ee23 (adding feature flag `NativeSidecar`)
148160
| `ignored-vpa-object-namespaces` | string | | A comma-separated list of namespaces to ignore when searching for VPA objects. Leave empty to avoid ignoring any namespaces. These namespaces will not be cleaned by the garbage collector. |
149161
| `in-recommendation-bounds-eviction-lifetime-threshold` | | 12h0m0s | duration Pods that live for at least that long can be evicted even if their request is within the [MinRecommended...MaxRecommended] range |
150162
| `kube-api-burst` | float | 100 | QPS burst limit when making requests to Kubernetes apiserver |

vertical-pod-autoscaler/pkg/features/features.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ const (
5757
// optimization strategies to be applied to different workloads within the
5858
// same cluster.
5959
PerVPAConfig featuregate.Feature = "PerVPAConfig"
60+
61+
62+
// alpha: v1.5.0
63+
// components: admission-controller, recommender, updater
64+
65+
// NativeSidecar enables support for native sidecars in VPA
66+
NativeSidecar featuregate.Feature = "NativeSidecar"
6067
)
6168

6269
// MutableFeatureGate is a mutable, versioned, global FeatureGate.

vertical-pod-autoscaler/pkg/features/versioned_features.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,7 @@ var defaultVersionedFeatureGates = map[featuregate.Feature]featuregate.Versioned
3434
PerVPAConfig: {
3535
{Version: version.MustParse("1.5"), Default: false, PreRelease: featuregate.Alpha},
3636
},
37+
NativeSidecar: {
38+
{Version: version.MustParse("1.5"), Default: false, PreRelease: featuregate.Alpha},
39+
},
3740
}

vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
vpa_types "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1"
3838
vpa_api "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1"
3939
vpa_lister "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1"
40+
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/features"
4041
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/input/history"
4142
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/input/metrics"
4243
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/input/oom"
@@ -492,7 +493,7 @@ func (feeder *clusterStateFeeder) LoadPods() {
492493
}
493494
}
494495
for _, initContainer := range pod.InitContainers {
495-
if initContainer.ContainerType == model.ContainerTypeInitSidecar {
496+
if features.Enabled(features.NativeSidecar) && initContainer.ContainerType == model.ContainerTypeInitSidecar {
496497
if err = feeder.clusterState.AddOrUpdateContainer(initContainer.ID, initContainer.Request, initContainer.ContainerType); err != nil {
497498
klog.V(0).InfoS("Failed to add initContainer", "container", initContainer.ID, "error", err)
498499
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: myapp-deployment
5+
labels:
6+
app.kubernetes.io/name: MyApp
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app.kubernetes.io/name: MyApp
12+
template:
13+
metadata:
14+
labels:
15+
app.kubernetes.io/name: MyApp
16+
spec:
17+
containers:
18+
- name: main
19+
image: busybox:1.28
20+
command: ['sh', '-c', "while true; do nslookup myservice.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; sleep 30; done"]
21+
resources:
22+
requests:
23+
cpu: 100m
24+
memory: 100Mi
25+
limits:
26+
cpu: 150m
27+
memory: 250Mi
28+
initContainers:
29+
- name: sidecar
30+
image: busybox:1.28
31+
command: ['sh', '-c', "while true; do nslookup myservice.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; sleep 30; done"]
32+
restartPolicy: Always
33+
resources:
34+
requests:
35+
cpu: 100m
36+
memory: 100Mi
37+
limits:
38+
cpu: 150m
39+
memory: 250Mi
40+
---
41+
apiVersion: autoscaling.k8s.io/v1
42+
kind: VerticalPodAutoscaler
43+
metadata:
44+
name: myapp-deployment
45+
spec:
46+
targetRef:
47+
apiVersion: apps/v1
48+
kind: Deployment
49+
name: myapp-deployment
50+
updatePolicy:
51+
updateMode: Recreate

0 commit comments

Comments
 (0)