Skip to content

Commit

Permalink
Merge pull request #11412 from johngmyers/remove-unsupported
Browse files Browse the repository at this point in the history
Remove code for no-longer-supported k8s versions
  • Loading branch information
k8s-ci-robot committed May 8, 2021
2 parents 261a2e9 + 36f93d0 commit 1761076
Show file tree
Hide file tree
Showing 53 changed files with 133 additions and 4,360 deletions.
2 changes: 1 addition & 1 deletion cmd/kops/create_cluster_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ var MagicTimestamp = metav1.Time{Time: time.Date(2017, 1, 1, 0, 0, 0, 0, time.UT

// TestCreateClusterMinimal runs kops create cluster minimal.example.com --zones us-test-1a
func TestCreateClusterMinimal(t *testing.T) {
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.16", "v1alpha2")
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.17", "v1alpha2")
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.18", "v1alpha2")
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.19", "v1alpha2")
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.20", "v1alpha2")
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.21", "v1alpha2")
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.22", "v1alpha2")
}

// TestCreateClusterOverride tests the override flag
Expand Down
1 change: 0 additions & 1 deletion nodeup/pkg/model/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 8 additions & 16 deletions nodeup/pkg/model/kube_apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks"
"k8s.io/kops/util/pkg/architectures"
"k8s.io/kops/util/pkg/exec"
"k8s.io/kops/util/pkg/proxy"

v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -498,21 +497,14 @@ func (b *KubeAPIServerBuilder) buildPod() (*v1.Pod, error) {

// Log both to docker and to the logfile
addHostPathMapping(pod, container, "logfile", "/var/log/kube-apiserver.log").ReadOnly = false
if b.IsKubernetesGTE("1.15") {
// From k8s 1.15, we use lighter containers that don't include shells
// But they have richer logging support via klog
container.Command = []string{"/usr/local/bin/kube-apiserver"}
container.Args = append(
sortedStrings(flags),
"--logtostderr=false", //https://github.com/kubernetes/klog/issues/60
"--alsologtostderr",
"--log-file=/var/log/kube-apiserver.log")
} else {
container.Command = exec.WithTee(
"/usr/local/bin/kube-apiserver",
sortedStrings(flags),
"/var/log/kube-apiserver.log")
}
// We use lighter containers that don't include shells
// But they have richer logging support via klog
container.Command = []string{"/usr/local/bin/kube-apiserver"}
container.Args = append(
sortedStrings(flags),
"--logtostderr=false", //https://github.com/kubernetes/klog/issues/60
"--alsologtostderr",
"--log-file=/var/log/kube-apiserver.log")

for _, path := range b.SSLHostPaths() {
name := strings.Replace(path, "/", "", -1)
Expand Down
24 changes: 8 additions & 16 deletions nodeup/pkg/model/kube_controller_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks"
"k8s.io/kops/util/pkg/architectures"
"k8s.io/kops/util/pkg/distributions"
"k8s.io/kops/util/pkg/exec"
"k8s.io/kops/util/pkg/proxy"

v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -191,21 +190,14 @@ func (b *KubeControllerManagerBuilder) buildPod() (*v1.Pod, error) {

// Log both to docker and to the logfile
addHostPathMapping(pod, container, "logfile", "/var/log/kube-controller-manager.log").ReadOnly = false
if b.IsKubernetesGTE("1.15") {
// From k8s 1.15, we use lighter containers that don't include shells
// But they have richer logging support via klog
container.Command = []string{"/usr/local/bin/kube-controller-manager"}
container.Args = append(
sortedStrings(flags),
"--logtostderr=false", //https://github.com/kubernetes/klog/issues/60
"--alsologtostderr",
"--log-file=/var/log/kube-controller-manager.log")
} else {
container.Command = exec.WithTee(
"/usr/local/bin/kube-controller-manager",
sortedStrings(flags),
"/var/log/kube-controller-manager.log")
}
// We use lighter containers that don't include shells
// But they have richer logging support via klog
container.Command = []string{"/usr/local/bin/kube-controller-manager"}
container.Args = append(
sortedStrings(flags),
"--logtostderr=false", //https://github.com/kubernetes/klog/issues/60
"--alsologtostderr",
"--log-file=/var/log/kube-controller-manager.log")

for _, path := range b.SSLHostPaths() {
name := strings.Replace(path, "/", "", -1)
Expand Down
38 changes: 12 additions & 26 deletions nodeup/pkg/model/kube_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import (
"fmt"
"strings"

v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog/v2"
"k8s.io/kops/pkg/dns"
"k8s.io/kops/pkg/flagbuilder"
"k8s.io/kops/pkg/k8scodecs"
Expand All @@ -28,12 +32,6 @@ import (
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks"
"k8s.io/kops/util/pkg/architectures"
"k8s.io/kops/util/pkg/exec"

v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog/v2"
)

// KubeProxyBuilder installs kube-proxy
Expand Down Expand Up @@ -182,11 +180,6 @@ func (b *KubeProxyBuilder) buildPod() (*v1.Pod, error) {
"--kubeconfig=/var/lib/kube-proxy/kubeconfig",
"--oom-score-adj=-998"}...)

if !b.IsKubernetesGTE("1.16") {
// Removed in 1.16: https://github.com/kubernetes/kubernetes/pull/78294
flags = append(flags, `--resource-container=""`)
}

image := kubeProxyImage(b.NodeupModelContext)
container := &v1.Container{
Name: "kube-proxy",
Expand Down Expand Up @@ -217,21 +210,14 @@ func (b *KubeProxyBuilder) buildPod() (*v1.Pod, error) {

// Log both to docker and to the logfile
addHostPathMapping(pod, container, "logfile", "/var/log/kube-proxy.log").ReadOnly = false
if b.IsKubernetesGTE("1.15") {
// From k8s 1.15, we use lighter containers that don't include shells
// But they have richer logging support via klog
container.Command = []string{"/usr/local/bin/kube-proxy"}
container.Args = append(
sortedStrings(flags),
"--logtostderr=false", //https://github.com/kubernetes/klog/issues/60
"--alsologtostderr",
"--log-file=/var/log/kube-proxy.log")
} else {
container.Command = exec.WithTee(
"/usr/local/bin/kube-proxy",
sortedStrings(flags),
"/var/log/kube-proxy.log")
}
// We use lighter containers that don't include shells
// But they have richer logging support via klog
container.Command = []string{"/usr/local/bin/kube-proxy"}
container.Args = append(
sortedStrings(flags),
"--logtostderr=false", //https://github.com/kubernetes/klog/issues/60
"--alsologtostderr",
"--log-file=/var/log/kube-proxy.log")

{
addHostPathMapping(pod, container, "kubeconfig", "/var/lib/kube-proxy/kubeconfig")
Expand Down
11 changes: 2 additions & 9 deletions nodeup/pkg/model/kube_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package model

import (
"reflect"
"strings"
"testing"

"k8s.io/kops/pkg/apis/kops"
Expand Down Expand Up @@ -63,11 +62,11 @@ func TestKubeProxyBuilder_buildPod(t *testing.T) {
wantErr bool
}{
{
"Setup KubeProxy for kubernetes version 1.10",
"Setup KubeProxy for kubernetes version 1.20",
fields{
&NodeupModelContext{
Cluster: cluster,
kubernetesVersion: semver.Version{Major: 1, Minor: 10},
kubernetesVersion: semver.Version{Major: 1, Minor: 20},
},
},
&v1.Pod{
Expand Down Expand Up @@ -146,12 +145,6 @@ func TestKubeProxyBuilder_buildPod(t *testing.T) {
t.Errorf("KubeProxyBuilder.buildPod() Resources = %v, want %v", got.Spec.Containers[0].Resources, tt.want.Spec.Containers[0].Resources)
}

// compare pod spec container command should contain --oom-score-adj=-998
gotcommand := got.Spec.Containers[0].Command[2]
if !strings.Contains(gotcommand, "--oom-score-adj=-998") {
t.Errorf("KubeProxyBuilder.buildPod() Command = %v, want %v", got.Spec.Containers[0].Command, tt.want.Spec.Containers[0].Command)
}

})
}
}
Expand Down
24 changes: 8 additions & 16 deletions nodeup/pkg/model/kube_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks"
"k8s.io/kops/util/pkg/architectures"
"k8s.io/kops/util/pkg/exec"
"k8s.io/kops/util/pkg/proxy"

v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -202,21 +201,14 @@ func (b *KubeSchedulerBuilder) buildPod() (*v1.Pod, error) {

// Log both to docker and to the logfile
addHostPathMapping(pod, container, "logfile", "/var/log/kube-scheduler.log").ReadOnly = false
if b.IsKubernetesGTE("1.15") {
// From k8s 1.15, we use lighter containers that don't include shells
// But they have richer logging support via klog
container.Command = []string{"/usr/local/bin/kube-scheduler"}
container.Args = append(
sortedStrings(flags),
"--logtostderr=false", //https://github.com/kubernetes/klog/issues/60
"--alsologtostderr",
"--log-file=/var/log/kube-scheduler.log")
} else {
container.Command = exec.WithTee(
"/usr/local/bin/kube-scheduler",
sortedStrings(flags),
"/var/log/kube-scheduler.log")
}
// We use lighter containers that don't include shells
// But they have richer logging support via klog
container.Command = []string{"/usr/local/bin/kube-scheduler"}
container.Args = append(
sortedStrings(flags),
"--logtostderr=false", //https://github.com/kubernetes/klog/issues/60
"--alsologtostderr",
"--log-file=/var/log/kube-scheduler.log")

if c.MaxPersistentVolumes != nil {
maxPDV := v1.EnvVar{
Expand Down
4 changes: 1 addition & 3 deletions nodeup/pkg/model/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,7 @@ func (b *KubeletBuilder) buildKubeletConfigSpec() (*kops.KubeletConfigSpec, erro
// As of 1.16 we can no longer set critical labels.
// kops-controller will set these labels.
// For bootstrapping reasons, protokube sets the critical labels for kops-controller to run.
if b.Cluster.IsKubernetesGTE("1.16") {
c.NodeLabels = nil
}
c.NodeLabels = nil

if c.AuthorizationMode == "" && b.Cluster.IsKubernetesGTE("1.19") {
c.AuthorizationMode = "Webhook"
Expand Down
12 changes: 4 additions & 8 deletions nodeup/pkg/model/networking/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,10 @@ func (b *CommonBuilder) Build(c *fi.ModelBuilderContext) error {
"ptp",
"tuning",
"vlan",
}

// Additions in https://github.com/containernetworking/plugins/releases/tag/v0.8.6
if b.IsKubernetesGTE("1.15") {
assets = append(assets, "bandwidth")
assets = append(assets, "firewall")
assets = append(assets, "sbr")
assets = append(assets, "static")
"bandwidth",
"firewall",
"sbr",
"static",
}

if err := b.AddCNIBinAssets(c, assets); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion nodeup/pkg/model/tests/dockerbuilder/logflags/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
- instanceGroup: master-us-test-1a
name: master-us-test-1a
name: events
kubernetesVersion: v1.16.0
kubernetesVersion: v1.17.0
masterInternalName: api.internal.logflags.example.com
masterPublicName: api.logflags.example.com
networkCIDR: 172.20.0.0/16
Expand Down
2 changes: 1 addition & 1 deletion nodeup/pkg/model/tests/kubelet/featuregates/tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ path: /etc/kubernetes/manifests
type: directory
---
contents: |
DAEMON_ARGS="--client-ca-file=/srv/kubernetes/ca.crt --feature-gates=AllowExtTrafficLocalEndpoints=false,ExperimentalCriticalPodAnnotation=true --node-labels=kubernetes.io/role=node,node-role.kubernetes.io/node= --pod-manifest-path=/etc/kubernetes/manifests --register-schedulable=true --volume-plugin-dir=/usr/libexec/kubernetes/kubelet-plugins/volume/exec/ --cni-bin-dir=/opt/cni/bin/ --cni-conf-dir=/etc/cni/net.d/"
DAEMON_ARGS="--client-ca-file=/srv/kubernetes/ca.crt --feature-gates=AllowExtTrafficLocalEndpoints=false,ExperimentalCriticalPodAnnotation=true --pod-manifest-path=/etc/kubernetes/manifests --register-schedulable=true --volume-plugin-dir=/usr/libexec/kubernetes/kubelet-plugins/volume/exec/ --cni-bin-dir=/opt/cni/bin/ --cni-conf-dir=/etc/cni/net.d/"
HOME="/root"
path: /etc/sysconfig/kubelet
type: file
Expand Down
21 changes: 3 additions & 18 deletions pkg/apis/kops/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,29 +777,14 @@ func validateNetworkingCilium(cluster *kops.Cluster, v *kops.CiliumNetworkingSpe
allErrs = append(allErrs, field.Invalid(versionFld, v.Version, "Could not parse as semantic version"))
}

if !(version.Minor >= 6 && version.Minor <= 10) {
allErrs = append(allErrs, field.Invalid(versionFld, v.Version, "Only versions 1.6 through 1.10 are supported"))
}

if version.Minor == 6 && cluster.IsKubernetesGTE("1.16") {
allErrs = append(allErrs, field.Forbidden(versionFld, "Version 1.6 requires kubernetesVersion before 1.16"))
}

if version.Minor == 7 && cluster.IsKubernetesGTE("1.17") {
allErrs = append(allErrs, field.Forbidden(versionFld, "Version 1.7 requires kubernetesVersion before 1.17"))
}

if version.Minor == 10 && cluster.IsKubernetesLT("1.16") {
allErrs = append(allErrs, field.Forbidden(versionFld, "Version 1.10 requires kubernetesVersion 1.16 or newer"))
if !(version.Minor >= 8 && version.Minor <= 10) {
allErrs = append(allErrs, field.Invalid(versionFld, v.Version, "Only versions 1.8 through 1.10 are supported"))
}

if v.Hubble != nil && fi.BoolValue(v.Hubble.Enabled) {
if !components.IsCertManagerEnabled(cluster) {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("hubble", "enabled"), "Hubble requires that cert manager is enabled"))
}
if version.Minor < 8 {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("hubble", "enabled"), "Hubble requires Cilium 1.8 or newer"))
}
}
}

Expand Down Expand Up @@ -997,7 +982,7 @@ func validateEtcdVersion(spec kops.EtcdClusterSpec, fieldPath *field.Path, minim

version := spec.Version
if spec.Version == "" {
version = components.DefaultEtcd3Version_1_14
version = components.DefaultEtcd3Version_1_17
}

sem, err := semver.Parse(strings.TrimPrefix(version, "v"))
Expand Down
27 changes: 2 additions & 25 deletions pkg/apis/kops/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func TestValidateKubeAPIServer(t *testing.T) {
if g.Cluster == nil {
g.Cluster = &kops.Cluster{
Spec: kops.ClusterSpec{
KubernetesVersion: "1.16.0",
KubernetesVersion: "1.20.0",
},
}
}
Expand Down Expand Up @@ -807,35 +807,12 @@ func Test_Validate_Cilium(t *testing.T) {
},
ExpectedErrors: []string{"Invalid value::cilium.version"},
},
{
Cilium: kops.CiliumNetworkingSpec{
Version: "v1.7.0",
},
Spec: kops.ClusterSpec{
KubernetesVersion: "1.18.0",
},
ExpectedErrors: []string{"Forbidden::cilium.version"},
},
{
Cilium: kops.CiliumNetworkingSpec{
Version: "v1.7.0",
},
},
{
Cilium: kops.CiliumNetworkingSpec{
Version: "1.7.0",
},
ExpectedErrors: []string{"Invalid value::cilium.version"},
},
{
Cilium: kops.CiliumNetworkingSpec{
Version: "v1.7.0",
Hubble: &kops.HubbleSpec{
Enabled: fi.Bool(true),
},
},
ExpectedErrors: []string{"Forbidden::cilium.hubble.enabled"},
},
{
Cilium: kops.CiliumNetworkingSpec{
Version: "v1.8.0",
Expand Down Expand Up @@ -864,7 +841,7 @@ func Test_Validate_Cilium(t *testing.T) {
Cilium: &g.Cilium,
}
if g.Spec.KubernetesVersion == "" {
g.Spec.KubernetesVersion = "1.15.0"
g.Spec.KubernetesVersion = "1.17.0"
}
cluster := &kops.Cluster{
Spec: g.Spec,
Expand Down
12 changes: 3 additions & 9 deletions pkg/model/components/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,9 @@ func (b *KubeAPIServerOptionsBuilder) BuildOptions(o interface{}) error {
// We make sure to disable AnonymousAuth
c.AnonymousAuth = fi.Bool(false)

if b.IsKubernetesGTE("1.17") {
// We query via the kube-apiserver-healthcheck proxy, which listens on port 3990
c.InsecureBindAddress = ""
c.InsecurePort = 0
} else {
// Older versions of kubernetes continue to rely on the insecure port: kubernetes issue #43784
c.InsecureBindAddress = "127.0.0.1"
c.InsecurePort = 8080
}
// We query via the kube-apiserver-healthcheck proxy, which listens on port 3990
c.InsecureBindAddress = ""
c.InsecurePort = 0

return nil
}
Expand Down
Loading

0 comments on commit 1761076

Please sign in to comment.