Set container env var using services. (#573)

* Introduce service env vars.
This commit is contained in:
Yash Desai
2019-04-17 11:30:39 -07:00
committed by Brian Goff
parent 6cb323eec2
commit de32752395
10 changed files with 1389 additions and 5 deletions

View File

@@ -25,6 +25,8 @@ const (
// For each one of these strings, a container that uses the string as its image will be appended to the pod.
// This method DOES NOT create the pod in the Kubernetes API.
func (f *Framework) CreateDummyPodObjectWithPrefix(prefix string, images ...string) *corev1.Pod {
enableServiceLink := false
pod := &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
GenerateName: prefix,
@@ -41,6 +43,7 @@ func (f *Framework) CreateDummyPodObjectWithPrefix(prefix string, images ...stri
Effect: corev1.TaintEffect(f.TaintEffect),
},
},
EnableServiceLinks: &enableServiceLink,
},
}
for idx, img := range images {

View File

@@ -24,6 +24,8 @@ func FakeEventRecorder(bufferSize int) *record.FakeRecorder {
// FakePodWithSingleContainer returns a pod with the specified namespace and name, and having a single container with the specified image.
func FakePodWithSingleContainer(namespace, name, image string) *corev1.Pod {
enableServiceLink := corev1.DefaultEnableServiceLinks
return &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace,
@@ -36,6 +38,7 @@ func FakePodWithSingleContainer(namespace, name, image string) *corev1.Pod {
Image: image,
},
},
EnableServiceLinks: &enableServiceLink,
},
}
}
@@ -55,12 +58,19 @@ func FakeSecret(namespace, name string, data map[string]string) *corev1.Secret {
return res
}
// FakeService returns a service with the specified namespace and name.
func FakeService(namespace, name string) *corev1.Service {
// FakeService returns a service with the specified namespace and name and service info.
func FakeService(namespace, name, clusterIP, protocol string, port int32) *corev1.Service {
return &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace,
Name: name,
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{{
Protocol: corev1.Protocol(protocol),
Port: port,
}},
ClusterIP: clusterIP,
},
}
}