... | ... |
@@ -5,6 +5,7 @@ import ( |
5 | 5 |
"io" |
6 | 6 |
|
7 | 7 |
"github.com/spf13/cobra" |
8 |
+ "k8s.io/kubernetes/pkg/kubectl/cmd/set" |
|
8 | 9 |
|
9 | 10 |
"github.com/openshift/origin/pkg/cmd/templates" |
10 | 11 |
cmdutil "github.com/openshift/origin/pkg/cmd/util" |
... | ... |
@@ -37,6 +38,7 @@ func NewCmdSet(fullName string, f *clientcmd.Factory, in io.Reader, out, errout |
37 | 37 |
NewCmdVolume(name, f, out, errout), |
38 | 38 |
NewCmdProbe(name, f, out, errout), |
39 | 39 |
NewCmdDeploymentHook(name, f, out, errout), |
40 |
+ NewCmdImage(name, f, out), |
|
40 | 41 |
}, |
41 | 42 |
}, |
42 | 43 |
{ |
... | ... |
@@ -57,3 +59,29 @@ func NewCmdSet(fullName string, f *clientcmd.Factory, in io.Reader, out, errout |
57 | 57 |
templates.ActsAsRootCommand(set, []string{"options"}, groups...) |
58 | 58 |
return set |
59 | 59 |
} |
60 |
+ |
|
61 |
+const ( |
|
62 |
+ setImageLong = ` |
|
63 |
+Update existing container image(s) of resources. |
|
64 |
+` |
|
65 |
+ |
|
66 |
+ setImageExample = ` # Set a deployment configs's nginx container image to 'nginx:1.9.1', and its busybox container image to 'busybox'. |
|
67 |
+ %[1]s image dc/nginx busybox=busybox nginx=nginx:1.9.1 |
|
68 |
+ |
|
69 |
+ # Update all deployments' and rc's nginx container's image to 'nginx:1.9.1' |
|
70 |
+ %[1]s image deployments,rc nginx=nginx:1.9.1 --all |
|
71 |
+ |
|
72 |
+ # Update image of all containers of daemonset abc to 'nginx:1.9.1' |
|
73 |
+ %[1]s image daemonset abc *=nginx:1.9.1 |
|
74 |
+ |
|
75 |
+ # Print result (in yaml format) of updating nginx container image from local file, without hitting the server |
|
76 |
+ %[1]s image -f path/to/file.yaml nginx=nginx:1.9.1 --local -o yaml` |
|
77 |
+) |
|
78 |
+ |
|
79 |
+// NewCmdImage is a wrapper for the Kubernetes CLI set image command |
|
80 |
+func NewCmdImage(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command { |
|
81 |
+ cmd := set.NewCmdImage(f.Factory, out) |
|
82 |
+ cmd.Long = setImageLong |
|
83 |
+ cmd.Example = fmt.Sprintf(setImageExample, fullName) |
|
84 |
+ return cmd |
|
85 |
+} |
... | ... |
@@ -132,6 +132,14 @@ os::cmd::expect_success 'oc delete hpa/test-deployment-config' |
132 | 132 |
echo "autoscale: ok" |
133 | 133 |
os::test::junit::declare_suite_end |
134 | 134 |
|
135 |
+os::test::junit::declare_suite_start "cmd/deployments/setimage" |
|
136 |
+os::cmd::expect_success 'oc create -f test/integration/testdata/test-deployment-config.yaml' |
|
137 |
+os::cmd::expect_success 'oc set image dc/test-deployment-config ruby-helloworld=myshinynewimage' |
|
138 |
+os::cmd::expect_success_and_text "oc get dc/test-deployment-config -o jsonpath='{.spec.template.spec.containers[0].image}'" "myshinynewimage" |
|
139 |
+os::cmd::expect_success 'oc delete dc/test-deployment-config' |
|
140 |
+echo "set image: ok" |
|
141 |
+os::test::junit::declare_suite_end |
|
142 |
+ |
|
135 | 143 |
os::test::junit::declare_suite_start "cmd/deployments/setdeploymenthook" |
136 | 144 |
# Validate the set deployment-hook command |
137 | 145 |
arg="-f test/integration/testdata/test-deployment-config.yaml" |