... | ... |
@@ -76,6 +76,7 @@ func NewCmdIPFailoverConfig(f *clientcmd.Factory, parentName, name string, out i |
76 | 76 |
cmd.Flags().BoolVar(&options.ImageTemplate.Latest, "latest-images", options.ImageTemplate.Latest, "If true, attempt to use the latest images instead of the current release") |
77 | 77 |
cmd.Flags().StringVarP(&options.Selector, "selector", "l", options.Selector, "Selector (label query) to filter nodes on.") |
78 | 78 |
cmd.Flags().StringVar(&options.Credentials, "credentials", "", "Path to a .kubeconfig file that will contain the credentials the router should use to contact the master.") |
79 |
+ cmd.Flags().StringVar(&options.ServiceAccount, "service-account", options.ServiceAccount, "Name of the service account to use to run the ipfailover pod.") |
|
79 | 80 |
|
80 | 81 |
cmd.Flags().BoolVar(&options.Create, "create", options.Create, "Create the configuration if it does not exist.") |
81 | 82 |
|
... | ... |
@@ -155,10 +155,11 @@ func GenerateDeploymentConfig(name string, options *ipfailover.IPFailoverConfigC |
155 | 155 |
podTemplate := &kapi.PodTemplateSpec{ |
156 | 156 |
ObjectMeta: kapi.ObjectMeta{Labels: selector}, |
157 | 157 |
Spec: kapi.PodSpec{ |
158 |
- HostNetwork: true, |
|
159 |
- NodeSelector: generateNodeSelector(name, selector), |
|
160 |
- Containers: containers, |
|
161 |
- Volumes: generateVolumeConfig(), |
|
158 |
+ HostNetwork: true, |
|
159 |
+ NodeSelector: generateNodeSelector(name, selector), |
|
160 |
+ Containers: containers, |
|
161 |
+ Volumes: generateVolumeConfig(), |
|
162 |
+ ServiceAccount: options.ServiceAccount, |
|
162 | 163 |
}, |
163 | 164 |
} |
164 | 165 |
|
... | ... |
@@ -9,7 +9,7 @@ import ( |
9 | 9 |
"github.com/openshift/origin/pkg/ipfailover" |
10 | 10 |
) |
11 | 11 |
|
12 |
-func makeIPFailoverConfigOptions(selector string, replicas int) *ipfailover.IPFailoverConfigCmdOptions { |
|
12 |
+func makeIPFailoverConfigOptions(selector string, replicas int, serviceAccount string) *ipfailover.IPFailoverConfigCmdOptions { |
|
13 | 13 |
return &ipfailover.IPFailoverConfigCmdOptions{ |
14 | 14 |
ImageTemplate: variable.NewDefaultImageTemplate(), |
15 | 15 |
Selector: selector, |
... | ... |
@@ -17,6 +17,7 @@ func makeIPFailoverConfigOptions(selector string, replicas int) *ipfailover.IPFa |
17 | 17 |
WatchPort: 80, |
18 | 18 |
NetworkInterface: "eth0", |
19 | 19 |
Replicas: replicas, |
20 |
+ ServiceAccount: serviceAccount, |
|
20 | 21 |
} |
21 | 22 |
|
22 | 23 |
} |
... | ... |
@@ -36,6 +37,7 @@ func TestGenerateDeploymentConfig(t *testing.T) { |
36 | 36 |
Selector string |
37 | 37 |
Replicas int |
38 | 38 |
PodSelectorLength int |
39 |
+ ServiceAccount string |
|
39 | 40 |
}{ |
40 | 41 |
{ |
41 | 42 |
Name: "config-test-no-selector", |
... | ... |
@@ -73,10 +75,17 @@ func TestGenerateDeploymentConfig(t *testing.T) { |
73 | 73 |
Replicas: 42, |
74 | 74 |
PodSelectorLength: 4, |
75 | 75 |
}, |
76 |
+ { |
|
77 |
+ Name: "config-test-service-account", |
|
78 |
+ Selector: "router=geo-us-west", |
|
79 |
+ Replicas: 3, |
|
80 |
+ PodSelectorLength: 1, |
|
81 |
+ ServiceAccount: "foo", |
|
82 |
+ }, |
|
76 | 83 |
} |
77 | 84 |
|
78 | 85 |
for _, tc := range tests { |
79 |
- options := makeIPFailoverConfigOptions(tc.Selector, tc.Replicas) |
|
86 |
+ options := makeIPFailoverConfigOptions(tc.Selector, tc.Replicas, tc.ServiceAccount) |
|
80 | 87 |
selector := makeSelector(options) |
81 | 88 |
dc, err := GenerateDeploymentConfig(tc.Name, options, selector) |
82 | 89 |
if err != nil { |
... | ... |
@@ -96,6 +105,10 @@ func TestGenerateDeploymentConfig(t *testing.T) { |
96 | 96 |
t.Errorf("Test case for %s got HostNetwork disabled where HostNetwork was expected to be enabled", tc.Name) |
97 | 97 |
} |
98 | 98 |
|
99 |
+ if podSpec.ServiceAccount != tc.ServiceAccount { |
|
100 |
+ t.Errorf("Test case for %s got service account %s when expecting %s", tc.Name, podSpec.ServiceAccount, tc.ServiceAccount) |
|
101 |
+ } |
|
102 |
+ |
|
99 | 103 |
psLength := len(podSpec.NodeSelector) |
100 | 104 |
if tc.PodSelectorLength != psLength { |
101 | 105 |
t.Errorf("Test case for %s got pod spec NodeSelector length %v where %v was expected", |
... | ... |
@@ -26,12 +26,13 @@ const ( |
26 | 26 |
|
27 | 27 |
// IPFailoverConfigCmdOptions are options supported by the IP Failover admin command. |
28 | 28 |
type IPFailoverConfigCmdOptions struct { |
29 |
- Type string |
|
30 |
- ImageTemplate variable.ImageTemplate |
|
31 |
- Credentials string |
|
32 |
- ServicePort int |
|
33 |
- Selector string |
|
34 |
- Create bool |
|
29 |
+ Type string |
|
30 |
+ ImageTemplate variable.ImageTemplate |
|
31 |
+ Credentials string |
|
32 |
+ ServicePort int |
|
33 |
+ Selector string |
|
34 |
+ Create bool |
|
35 |
+ ServiceAccount string |
|
35 | 36 |
|
36 | 37 |
// Failover options. |
37 | 38 |
VirtualIPs string |