Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 7ab7a07

Browse files
committed
CRD Spec: add option to configure HostNetwork and DNSPolicy
this allows the network plugins like CNI to use etcd-cluster as kv when bootstrapping the cluster fixes #1929
1 parent 8347d27 commit 7ab7a07

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

Gopkg.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/etcd/v1beta2/cluster.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"errors"
1919
"strings"
2020

21-
"k8s.io/api/core/v1"
21+
v1 "k8s.io/api/core/v1"
2222
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2323
)
2424

@@ -162,6 +162,12 @@ type PodPolicy struct {
162162
// '.cluster.local'.
163163
// The default is to not set a cluster domain explicitly.
164164
ClusterDomain string `json:"ClusterDomain"`
165+
166+
// hostNetwork will set HostNetwork: true in podspec
167+
HostNetwork bool `json:"hostNetwork,omitempty"`
168+
169+
// dnsPolicy will set dnsPolicy: <whatever> in podspec
170+
DNSPolicy v1.DNSPolicy `json:"dnsPolicy,omitempty"`
165171
}
166172

167173
// TODO: move this to initializer

pkg/util/k8sutil/k8sutil.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"github.com/pborman/uuid"
3131

3232
appsv1beta1 "k8s.io/api/apps/v1beta1"
33-
"k8s.io/api/core/v1"
33+
v1 "k8s.io/api/core/v1"
3434
apierrors "k8s.io/apimachinery/pkg/api/errors"
3535
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3636
"k8s.io/apimachinery/pkg/labels"
@@ -402,6 +402,15 @@ func newEtcdPod(m *etcdutil.Member, initialCluster []string, clusterName, state,
402402
SecurityContext: podSecurityContext(cs.Pod),
403403
},
404404
}
405+
406+
if cs.Pod.DNSPolicy != "" {
407+
pod.Spec.DNSPolicy = cs.Pod.DNSPolicy
408+
}
409+
410+
if cs.Pod.HostNetwork {
411+
pod.Spec.HostNetwork = true
412+
}
413+
405414
SetEtcdVersion(pod, cs.Version)
406415
return pod
407416
}

0 commit comments

Comments
 (0)