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

patch coreDNS deployment for external cloud provider #362

Merged
merged 1 commit into from
Apr 24, 2019
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
64 changes: 64 additions & 0 deletions pkg/installer/installation/coredns.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
Copyright 2019 The KubeOne 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 installation

import (
"context"

"github.com/pkg/errors"

"github.com/kubermatic/kubeone/pkg/util"

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

func patchCoreDNS(ctx *util.Context) error {
if !ctx.Cluster.Provider.External {
return nil
}

ctx.Logger.Infoln("Patching coreDNS with uninitialized toleration…")

if ctx.DynamicClient == nil {
return errors.New("kubernetes client not initialized")
}

bgCtx := context.Background()
dep := &appsv1.Deployment{}
key := client.ObjectKey{
Name: "coredns",
Namespace: metav1.NamespaceSystem,
}

err := ctx.DynamicClient.Get(bgCtx, key, dep)
if err != nil {
return errors.Wrap(err, "failed to get coredns deployment")
}

dep.Spec.Template.Spec.Tolerations = append(dep.Spec.Template.Spec.Tolerations,
corev1.Toleration{
Key: "node.cloudprovider.kubernetes.io/uninitialized",
Value: "true",
Effect: corev1.TaintEffectNoSchedule,
},
)

return errors.Wrap(ctx.DynamicClient.Update(bgCtx, dep), "failed to update coredns deployment")
}
1 change: 1 addition & 0 deletions pkg/installer/installation/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func Install(ctx *util.Context) error {
{Fn: util.BuildKubernetesClientset, ErrMsg: "unable to build kubernetes clientset", Retries: 3},
{Fn: features.Activate, ErrMsg: "unable to activate features"},
{Fn: applyCanalCNI, ErrMsg: "failed to install cni plugin canal", Retries: 3},
{Fn: patchCoreDNS, ErrMsg: "failed to patch CoreDNS", Retries: 3},
{Fn: machinecontroller.EnsureMachineController, ErrMsg: "failed to install machine-controller", Retries: 3},
{Fn: machinecontroller.WaitReady, ErrMsg: "failed to wait for machine-controller", Retries: 3},
{Fn: createWorkerMachines, ErrMsg: "failed to create worker machines", Retries: 3},
Expand Down