Skip to content

Commit

Permalink
Make the events etcd cluster optional
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed May 14, 2021
1 parent d8b4cae commit 4b4bfc9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion nodeup/pkg/model/etcd_manager_tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ func (b *EtcdManagerTLSBuilder) Build(ctx *fi.ModelBuilderContext) error {
return err
}

for _, k := range []string{"main", "events"} {
for _, etcdCluster := range b.Cluster.Spec.EtcdClusters {
k := etcdCluster.Name
d := "/etc/kubernetes/pki/etcd-manager-" + k

keys := make(map[string]string)
Expand Down
15 changes: 13 additions & 2 deletions nodeup/pkg/model/kube_apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ func (b *KubeAPIServerBuilder) buildPod() (*v1.Pod, error) {
}
}

hasEventsEtcdCluster := false
for _, etcdCluster := range b.Cluster.Spec.EtcdClusters {
if etcdCluster.Name == "events" {
hasEventsEtcdCluster = true
}
}

var mainEtcdCluster, eventsEtcdCluster string
if b.IsMaster {
mainEtcdCluster = "https://127.0.0.1:4001"
Expand All @@ -328,13 +335,17 @@ func (b *KubeAPIServerBuilder) buildPod() (*v1.Pod, error) {
kubeAPIServer.EtcdCertFile = filepath.Join(basedir, "etcd-client.crt")
kubeAPIServer.EtcdKeyFile = filepath.Join(basedir, "etcd-client.key")
kubeAPIServer.EtcdServers = []string{mainEtcdCluster}
kubeAPIServer.EtcdServersOverrides = []string{"/events#" + eventsEtcdCluster}
if hasEventsEtcdCluster {
kubeAPIServer.EtcdServersOverrides = []string{"/events#" + eventsEtcdCluster}
}
} else if b.UseEtcdTLS() {
kubeAPIServer.EtcdCAFile = filepath.Join(b.PathSrvKubernetes(), "ca.crt")
kubeAPIServer.EtcdCertFile = filepath.Join(b.PathSrvKubernetes(), "etcd-client.pem")
kubeAPIServer.EtcdKeyFile = filepath.Join(b.PathSrvKubernetes(), "etcd-client-key.pem")
kubeAPIServer.EtcdServers = []string{mainEtcdCluster}
kubeAPIServer.EtcdServersOverrides = []string{"/events#" + eventsEtcdCluster}
if hasEventsEtcdCluster {
kubeAPIServer.EtcdServersOverrides = []string{"/events#" + eventsEtcdCluster}
}
}

// @note we are making assumption were using the ones created by the pki model, not custom defined ones
Expand Down
2 changes: 0 additions & 2 deletions pkg/model/components/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ func (b *KubeAPIServerOptionsBuilder) BuildOptions(o interface{}) error {

c.AllowPrivileged = fi.Bool(true)
c.ServiceClusterIPRange = clusterSpec.ServiceClusterIPRange
c.EtcdServers = []string{"http://127.0.0.1:4001"}
c.EtcdServersOverrides = []string{"/events#http://127.0.0.1:4002"}

// TODO: We can probably rewrite these more clearly in descending order
// Based on recommendations from:
Expand Down

0 comments on commit 4b4bfc9

Please sign in to comment.