Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
Fix controlplane running as DaemonSet on single node clusters
Browse files Browse the repository at this point in the history
This commit fixes passed 'control_plane_replicas' value to Kubernetes
Helm chart which caused kube-scheduler and kube-controller-manager to
run as DaemonSet on single controlplane node clusters, which breaks the
ability to update it gracefully.

It also adds tests that controlplane is using right resource type on
different controlplane sizes and that both can be gracefully updated
without breaking cluster functionality.

Closes #1097
Closes #90

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
  • Loading branch information
invidian committed Nov 18, 2020
1 parent 76d1d28 commit 7578210
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 73 deletions.
2 changes: 1 addition & 1 deletion assets/terraform-modules/bootkube/assets.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ resource "local_file" "kubernetes" {
kube_scheduler_image = var.container_images["kube_scheduler"]
kube_proxy_image = var.container_images["kube_proxy"]
coredns_image = "${var.container_images["coredns"]}${var.container_arch}"
control_plane_replicas = max(2, length(var.etcd_servers))
control_plane_replicas = length(var.etcd_servers)
cloud_provider = var.cloud_provider
pod_cidr = var.pod_cidr
service_cidr = var.service_cidr
Expand Down
4 changes: 2 additions & 2 deletions pkg/assets/generated_assets.go

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

35 changes: 0 additions & 35 deletions test/components/coredns/coredns_test.go

This file was deleted.

35 changes: 0 additions & 35 deletions test/components/kubernetes/controller-manager_test.go

This file was deleted.

73 changes: 73 additions & 0 deletions test/components/kubernetes/controlplane-multi-node_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright 2020 The Lokomotive 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.

// +build aws aws_edge
// +build disruptivee2e

package kubernetes_test

import (
"context"
"testing"
"time"

testutil "github.com/kinvolk/lokomotive/test/components/util"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func Test_Controlplane_components_are_DaemonSets_on_multi_controller_node_cluster(t *testing.T) {
client := testutil.CreateKubeClient(t)

for c := range components() {
c := c

t.Run(c, func(t *testing.T) {
t.Parallel()

testutil.WaitForDaemonSet(t, client, namespace, c, testutil.RetryInterval, testutil.Timeout)
})
}
}

func Test_Controlplane_components_DaemonSets_can_be_gracefully_updated(t *testing.T) {
client := testutil.CreateKubeClient(t)
deployClient := client.AppsV1().DaemonSets(namespace)

components := components()
components["kube-proxy"] = testutil.RetryInterval

for c, waitTime := range components {
c := c
waitTime := waitTime

t.Run(c, func(t *testing.T) {
deploy, err := deployClient.Get(context.TODO(), c, metav1.GetOptions{})
if err != nil {
t.Fatalf("Getting DaemonSet %q: %v", c, err)
}

// Use current time to have different value on each test run.
deploy.Spec.Template.Annotations["update-test"] = time.Now().String()

if _, err := deployClient.Update(context.TODO(), deploy, metav1.UpdateOptions{}); err != nil {
t.Fatalf("Updating DaemonSet %q: %v", c, err)
}

// Wait a bit to let Kubernetes trigger pod updates.
time.Sleep(waitTime)

testutil.WaitForDaemonSet(t, client, namespace, c, testutil.RetryInterval, testutil.Timeout)
})
}
}
Loading

0 comments on commit 7578210

Please sign in to comment.