Skip to content

Commit

Permalink
Don't try to build etcd-manager secrets for cilium twice
Browse files Browse the repository at this point in the history
  • Loading branch information
Ole Markus With committed Jun 15, 2021
1 parent 9a5259c commit a3cfe8d
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 1 deletion.
6 changes: 6 additions & 0 deletions nodeup/pkg/model/etcd_manager_tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ func (b *EtcdManagerTLSBuilder) Build(ctx *fi.ModelBuilderContext) error {

for _, etcdCluster := range b.Cluster.Spec.EtcdClusters {
k := etcdCluster.Name

// The certs for cilium etcd is managed by CiliumBuilder
if k == "cilium" {
continue
}

d := "/etc/kubernetes/pki/etcd-manager-" + k

keys := make(map[string]string)
Expand Down
14 changes: 13 additions & 1 deletion nodeup/pkg/model/networking/BUILD.bazel

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

85 changes: 85 additions & 0 deletions nodeup/pkg/model/networking/cilium_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
Copyright 2021 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 networking

import (
"runtime"
"testing"

"k8s.io/kops/nodeup/pkg/model"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/pki"
"k8s.io/kops/upup/pkg/fi"
)

func TestCiliumBuilder(t *testing.T) {
if runtime.GOOS != "linux" {
t.Skipf("cilium nodeup test will only work on linux")
}
context := &model.NodeupModelContext{
Cluster: &kops.Cluster{
Spec: kops.ClusterSpec{
CloudProvider: "aws",
EtcdClusters: []kops.EtcdClusterSpec{
{
Name: "cilium",
Provider: kops.EtcdProviderTypeManager,
},
},
KubernetesVersion: "1.19.0",
Networking: &kops.NetworkingSpec{
Cilium: &kops.CiliumNetworkingSpec{
EtcdManaged: true,
},
},
},
},
HasAPIServer: true,
KeyStore: &fakeKeyStore{},
IsMaster: true,
}
etcdBuilder := &model.EtcdManagerTLSBuilder{
NodeupModelContext: context,
}
ciliumBuilder := &CiliumBuilder{
NodeupModelContext: context,
}

modelContext := &fi.ModelBuilderContext{
Tasks: make(map[string]fi.Task),
}

if err := etcdBuilder.Build(modelContext); err != nil {
t.Errorf("unexpected error building etcd: %v", err)
}

if err := ciliumBuilder.Build(modelContext); err != nil {
t.Errorf("unexpected error building cilium: %v", err)
}
}

type fakeKeyStore struct {
fi.CAStore
}

func (*fakeKeyStore) FindCert(name string) (*pki.Certificate, error) {
return &pki.Certificate{}, nil
}

func (*fakeKeyStore) FindPrivateKey(name string) (*pki.PrivateKey, error) {
return &pki.PrivateKey{}, nil
}

0 comments on commit a3cfe8d

Please sign in to comment.