This repository has been archived by the owner on Mar 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 741
cluster: add option to specify busybox repository #1928
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d0a2037
cluster: add option to specify busybox repository
yehiyam 18735ab
cluster: add option to specify busybox repository
yehiyam 0454a55
cluster: add option to specify busybox repository
yehiyam adcdead
cluster: add option to specify busybox repository
yehiyam f91c3a3
change busybox repository and tag to one property
yehiyam d760038
cluster: add option to specify busybox repository
yehiyam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,8 @@ const ( | |
|
||
defaultKubeAPIRequestTimeout = 30 * time.Second | ||
|
||
defaultBusyboxImage = "busybox:1.28.0-glibc" | ||
|
||
// AnnotationScope annotation name for defining instance scope. Used for specifing cluster wide clusters. | ||
AnnotationScope = "etcd.database.coreos.com/scope" | ||
//AnnotationClusterWide annotation value for cluster wide clusters. | ||
|
@@ -134,6 +136,16 @@ func ImageName(repo, version string) string { | |
return fmt.Sprintf("%s:v%v", repo, version) | ||
} | ||
|
||
func imageNameBusybox(policy *api.PodPolicy) string { | ||
// set defaults for busybox init container | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move the comment on top of |
||
image := defaultBusyboxImage | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to have a newline here. if policy != nil && len(policy.BusyboxImage) > 0 {
return policy.BusyboxImage
}
return defaultBusyboxImage |
||
if policy != nil && len(policy.BusyboxImage) > 0 { | ||
image = policy.BusyboxImage | ||
} | ||
return image | ||
} | ||
|
||
func PodWithNodeSelector(p *v1.Pod, ns map[string]string) *v1.Pod { | ||
p.Spec.NodeSelector = ns | ||
return p | ||
|
@@ -355,7 +367,8 @@ func newEtcdPod(m *etcdutil.Member, initialCluster []string, clusterName, state, | |
InitContainers: []v1.Container{{ | ||
// busybox:latest uses uclibc which contains a bug that sometimes prevents name resolution | ||
// More info: https://github.com/docker-library/busybox/issues/27 | ||
Image: "busybox:1.28.0-glibc", | ||
//Image default: "busybox:1.28.0-glibc", | ||
Image: imageNameBusybox(cs.Pod), | ||
Name: "check-dns", | ||
// In etcd 3.2, TLS listener will do a reverse-DNS lookup for pod IP -> hostname. | ||
// If DNS entry is not warmed up, it will return empty result and peer connection will be rejected. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2017 The etcd-operator 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 k8sutil | ||
|
||
import ( | ||
"testing" | ||
|
||
api "github.com/coreos/etcd-operator/pkg/apis/etcd/v1beta2" | ||
) | ||
|
||
func TestDefaultBusyboxImageName(t *testing.T) { | ||
policy := &api.PodPolicy{} | ||
image := imageNameBusybox(policy) | ||
expected := defaultBusyboxImage | ||
if image != expected { | ||
t.Errorf("expect image=%s, get=%s", expected, image) | ||
} | ||
} | ||
|
||
func TestDefaultNilBusyboxImageName(t *testing.T) { | ||
image := imageNameBusybox(nil) | ||
expected := defaultBusyboxImage | ||
if image != expected { | ||
t.Errorf("expect image=%s, get=%s", expected, image) | ||
} | ||
} | ||
|
||
func TestSetBusyboxImageName(t *testing.T) { | ||
policy := &api.PodPolicy{ | ||
BusyboxImage: "myRepo/busybox:1.3.2", | ||
} | ||
image := imageNameBusybox(policy) | ||
expected := "myRepo/busybox:1.3.2" | ||
if image != expected { | ||
t.Errorf("expect image=%s, get=%s", expected, image) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put these comment below on the BusyboxVersion comment? They are more related there.