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

Enable ExperimentalCriticalPodAnnotation feature gate #3345

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
6 changes: 4 additions & 2 deletions docs/cluster_spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,13 @@ Will result in the flag `--resolv-conf=` being built.
spec:
kubelet:
featureGates:
ExperimentalCriticalPodAnnotation: "true"
Accelerators: "true"
AllowExtTrafficLocalEndpoints: "false"
```

Will result in the flag `--feature-gates=ExperimentalCriticalPodAnnotation=true,AllowExtTrafficLocalEndpoints=false`
Will result in the flag `--feature-gates=Accelerators=true,AllowExtTrafficLocalEndpoints=false`

NOTE: Feature gate `ExperimentalCriticalPodAnnotation` is enabled by default because some critical components like `kube-proxy` depend on its presence.

#### Compute Resources Reservation

Expand Down
4 changes: 4 additions & 0 deletions docs/releases/1.8-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ _This is a WIP document describing changes to the upcoming kops 1.8 release_
is not recommended, but will be the default value for existing clusters or clusters created via manifests.
`kops create cluster` with `--networking flannel` will use `vxlan`, `--networking flannel-vxlan`
or `--networking flannel-udp` can be specified to explicitly choose a backend mode.

# Full changelist

* ExperimentalCriticalPodAnnotation feature gate is now enabled by default in kubelet [@andreychernih](https://github.com/andreychernih) [#3345](https://github.com/kubernetes/kops/pull/3345)
25 changes: 5 additions & 20 deletions pkg/apis/kops/util/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,10 @@ func ParseKubernetesVersion(version string) (*semver.Version, error) {
// TODO: Convert to our own KubernetesVersion type?

func IsKubernetesGTE(version string, k8sVersion semver.Version) bool {
// The string-arg is a little annoying, but simplifies the calling code!
switch version {
case "1.2":
return k8sVersion.Major > 1 || (k8sVersion.Major == 1 && k8sVersion.Minor >= 2)
case "1.3":
return k8sVersion.Major > 1 || (k8sVersion.Major == 1 && k8sVersion.Minor >= 3)
case "1.4":
return k8sVersion.Major > 1 || (k8sVersion.Major == 1 && k8sVersion.Minor >= 4)
case "1.5":
return k8sVersion.Major > 1 || (k8sVersion.Major == 1 && k8sVersion.Minor >= 5)
case "1.6":
return k8sVersion.Major > 1 || (k8sVersion.Major == 1 && k8sVersion.Minor >= 6)
case "1.7":
return k8sVersion.Major > 1 || (k8sVersion.Major == 1 && k8sVersion.Minor >= 7)
case "1.8":
return k8sVersion.Major > 1 || (k8sVersion.Major == 1 && k8sVersion.Minor >= 8)
case "1.9":
return k8sVersion.Major > 1 || (k8sVersion.Major == 1 && k8sVersion.Minor >= 9)
default:
panic(fmt.Sprintf("IsKubernetesGTE not supported with version %q", version))
parsedVersion, err := ParseKubernetesVersion(version)
if err != nil {
panic(fmt.Sprintf("Error parsing version %s: %v", version, err))
}

return k8sVersion.GTE(*parsedVersion)
Copy link
Member

Choose a reason for hiding this comment

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

Ah - so this is annoying...

The problem is that 1.8.0-alpha.1 is considered to be less than 1.8.0. So 1.8.0-alpha.1 wouldn't match "1.8".

That said, we could just mask out the alpha.1 version before the comparison - I do like this approach!

}
43 changes: 43 additions & 0 deletions pkg/apis/kops/util/versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,46 @@ func Test_ParseKubernetesVersion(t *testing.T) {
}

}

func Test_IsKubernetesGTEWithPatch(t *testing.T) {
currentVersion, err := ParseKubernetesVersion("1.6.2")
if err != nil {
t.Fatalf("Error parsing version: %v", err)
}

grid := map[string]bool{
"1.5.2": true,
"1.6.2": true,
"1.6.5": false,
"1.7.8": false,
}

for v, expected := range grid {
actual := IsKubernetesGTE(v, *currentVersion)
if actual != expected {
t.Errorf("expected %s to be >= than %s", v, currentVersion)
}
}
}

func Test_IsKubernetesGTEWithoutPatch(t *testing.T) {
currentVersion, err := ParseKubernetesVersion("1.6")
if err != nil {
t.Fatalf("Error parsing version: %v", err)
}

grid := map[string]bool{
"1.1": true,
"1.2": true,
"1.3": true,
"1.6": true,
"1.7": false,
}

for v, expected := range grid {
actual := IsKubernetesGTE(v, *currentVersion)
if actual != expected {
t.Errorf("expected %s to be >= than %s", v, currentVersion)
}
}
}
12 changes: 11 additions & 1 deletion pkg/model/components/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ limitations under the License.
package components

import (
"strings"

"github.com/golang/glog"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/loader"
"strings"
)

// KubeletOptionsBuilder adds options for kubelets
Expand Down Expand Up @@ -191,5 +192,14 @@ func (b *KubeletOptionsBuilder) BuildOptions(o interface{}) error {
}
clusterSpec.Kubelet.PodInfraContainerImage = image

if clusterSpec.Kubelet.FeatureGates == nil {
clusterSpec.Kubelet.FeatureGates = make(map[string]string)
}
if _, found := clusterSpec.Kubelet.FeatureGates["ExperimentalCriticalPodAnnotation"]; !found {
if b.Context.IsKubernetesGTE("1.5.2") {
clusterSpec.Kubelet.FeatureGates["ExperimentalCriticalPodAnnotation"] = "true"
}
}

return nil
}
101 changes: 101 additions & 0 deletions pkg/model/components/kubelet_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
Copyright 2016 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package components

import (
"testing"

"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/assets"
)

func buildSpec() *kops.ClusterSpec {
spec := kops.ClusterSpec{
KubernetesVersion: "1.6.2",
ServiceClusterIPRange: "10.10.0.0/16",
Kubelet: &kops.KubeletConfigSpec{},
}

return &spec
}

func buildOptions(spec *kops.ClusterSpec) error {
ab := assets.NewAssetBuilder(nil)

ver, err := KubernetesVersion(spec)
if err != nil {
return err
}

builder := KubeletOptionsBuilder{
Context: &OptionsContext{
AssetBuilder: ab,
KubernetesVersion: *ver,
},
}

err = builder.BuildOptions(spec)
if err != nil {
return nil
}

return nil
}

func TestFeatureGates(t *testing.T) {
spec := buildSpec()
err := buildOptions(spec)
if err != nil {
t.Fatal(err)
}

gates := spec.Kubelet.FeatureGates
if gates["ExperimentalCriticalPodAnnotation"] != "true" {
t.Errorf("ExperimentalCriticalPodAnnotation feature gate should be enabled by default")
}
}

func TestFeatureGatesKubernetesVersion(t *testing.T) {
spec := buildSpec()
spec.KubernetesVersion = "1.4.0"
err := buildOptions(spec)
if err != nil {
t.Fatal(err)
}

gates := spec.Kubelet.FeatureGates
if _, found := gates["ExperimentalCriticalPodAnnotation"]; found {
t.Errorf("ExperimentalCriticalPodAnnotation feature gate should not be added on Kubernetes < 1.5.2")
}
}

func TestFeatureGatesOverride(t *testing.T) {
spec := buildSpec()
spec.Kubelet.FeatureGates = map[string]string{
"ExperimentalCriticalPodAnnotation": "false",
}

err := buildOptions(spec)
if err != nil {
t.Fatal(err)
}

gates := spec.Kubelet.FeatureGates
if gates["ExperimentalCriticalPodAnnotation"] != "false" {
t.Errorf("ExperimentalCriticalPodAnnotation feature should be disalbled")
}
}