| ... | ... |
@@ -122,24 +122,26 @@ This section covers how to perform all the steps of building, deploying, and upd |
| 122 | 122 |
need to accept the server certificates and present its own client |
| 123 | 123 |
certificate. These are generated as part of the `openshift start` |
| 124 | 124 |
command in whatever the current directory is at the time. You will |
| 125 |
- need to point osc and curl at the appropriate .kubeconfig in order |
|
| 125 |
+ need to point osc and curl at the appropriate certificates in order |
|
| 126 | 126 |
to connect to OpenShift. Assuming you are running as a user other |
| 127 | 127 |
than root, you will also need to make the .kubeconfig readable by |
| 128 | 128 |
that user. (Note: this is just for example purposes; in a real |
| 129 | 129 |
installation, users would generate their own keys and not have access |
| 130 | 130 |
to the system keys.) |
| 131 | 131 |
|
| 132 |
- $ export OPENSHIFTCONFIG=`pwd`/openshift.local.certificates/admin/.kubeconfig |
|
| 133 | 132 |
$ export CURL_CA_BUNDLE=`pwd`/openshift.local.certificates/ca/cert.crt |
| 134 |
- $ sudo chmod a+rwX "$OPENSHIFTCONFIG" |
|
| 133 |
+ $ sudo chmod a+rwX `pwd`/openshift.local.certificates/admin/.kubeconfig |
|
| 135 | 134 |
|
| 136 | 135 |
|
| 137 | 136 |
4. Bind a user names `test-admin` to the `view` role in the default namespace so you can observe progress in the web console |
| 138 | 137 |
|
| 139 |
- $ openshift ex policy add-role-to-user view test-admin |
|
| 138 |
+ $ osadm policy add-role-to-user view test-admin --config=openshift.local.certificates/admin/.kubeconfig |
|
| 140 | 139 |
|
| 140 |
+5. Login as `test-admin` using any password |
|
| 141 |
+ $ osc login --certificate-authority=`pwd`/openshift.local.certificates/ca/cert.crt |
|
| 141 | 142 |
|
| 142 |
-5. *Optional:* View the OpenShift web console in your browser by browsing to `https://<host>:8443/console`. Login using the user `test-admin` and any password. |
|
| 143 |
+ |
|
| 144 |
+6. *Optional:* View the OpenShift web console in your browser by browsing to `https://<host>:8443/console`. Login using the user `test-admin` and any password. |
|
| 143 | 145 |
|
| 144 | 146 |
* You will need to have the browser accept the certificate at |
| 145 | 147 |
`https://<host>:8443` before the console can consult the OpenShift |
| ... | ... |
@@ -150,10 +152,10 @@ This section covers how to perform all the steps of building, deploying, and upd |
| 150 | 150 |
and run builds. |
| 151 | 151 |
|
| 152 | 152 |
|
| 153 |
-6. Deploy a private docker registry within OpenShift with the certs necessary for access to master: |
|
| 153 |
+7. Deploy a private docker registry within OpenShift with the certs necessary for access to master: |
|
| 154 | 154 |
|
| 155 | 155 |
$ sudo chmod +r ./openshift.local.certificates/openshift-registry/.kubeconfig |
| 156 |
- $ openshift ex registry --create --credentials=./openshift.local.certificates/openshift-registry/.kubeconfig |
|
| 156 |
+ $ openshift ex registry --create --credentials=./openshift.local.certificates/openshift-registry/.kubeconfig --config=openshift.local.certificates/admin/.kubeconfig |
|
| 157 | 157 |
docker-registry # the service |
| 158 | 158 |
docker-registry # the deployment config |
| 159 | 159 |
|
| ... | ... |
@@ -163,7 +165,7 @@ This section covers how to perform all the steps of building, deploying, and upd |
| 163 | 163 |
of this tutorial. |
| 164 | 164 |
|
| 165 | 165 |
|
| 166 |
-7. Confirm the registry is started (this can take a few minutes): |
|
| 166 |
+8. Confirm the registry is started (this can take a few minutes): |
|
| 167 | 167 |
|
| 168 | 168 |
$ osc describe service docker-registry |
| 169 | 169 |
|
| ... | ... |
@@ -181,7 +183,7 @@ This section covers how to perform all the steps of building, deploying, and upd |
| 181 | 181 |
be added to the docker-registry service list so that it's reachable from other places. |
| 182 | 182 |
|
| 183 | 183 |
|
| 184 |
-8. Confirm the registry is accessible (you may need to run this more than once): |
|
| 184 |
+9. Confirm the registry is accessible (you may need to run this more than once): |
|
| 185 | 185 |
|
| 186 | 186 |
$ curl `osc get service docker-registry --template="{{ .spec.portalIP }}:{{ with index .spec.ports 0 }}{{ .port }}{{ end }}"`
|
| 187 | 187 |
|
| ... | ... |
@@ -190,12 +192,12 @@ This section covers how to perform all the steps of building, deploying, and upd |
| 190 | 190 |
"docker-registry server (dev) (v0.9.0)" |
| 191 | 191 |
|
| 192 | 192 |
|
| 193 |
-9. Create a new project in OpenShift. This creates a namespace `test` to contain the builds and app that we will generate below. |
|
| 193 |
+10. Create a new project in OpenShift. This creates a namespace `test` to contain the builds and app that we will generate below. |
|
| 194 | 194 |
|
| 195 |
- $ openshift ex new-project test --display-name="OpenShift 3 Sample" --description="This is an example project to demonstrate OpenShift v3" --admin=test-admin |
|
| 195 |
+ $ osc new-project test --display-name="OpenShift 3 Sample" --description="This is an example project to demonstrate OpenShift v3" |
|
| 196 | 196 |
|
| 197 | 197 |
|
| 198 |
-10. *Optional:* View the OpenShift web console in your browser by browsing to `https://<host>:8443/console`. Login using the user `test-admin` and any password. |
|
| 198 |
+11. *Optional:* View the OpenShift web console in your browser by browsing to `https://<host>:8443/console`. Login using the user `test-admin` and any password. |
|
| 199 | 199 |
|
| 200 | 200 |
* You will need to have the browser accept the certificate at |
| 201 | 201 |
`https://<host>:8443` before the console can consult the OpenShift |
| ... | ... |
@@ -206,7 +208,7 @@ This section covers how to perform all the steps of building, deploying, and upd |
| 206 | 206 |
and run builds. |
| 207 | 207 |
|
| 208 | 208 |
|
| 209 |
-11. *Optional:* Fork the [ruby sample repository](https://github.com/openshift/ruby-hello-world) |
|
| 209 |
+12. *Optional:* Fork the [ruby sample repository](https://github.com/openshift/ruby-hello-world) |
|
| 210 | 210 |
to an OpenShift-visible git account that you control, preferably |
| 211 | 211 |
somewhere that can also reach your OpenShift server with a webhook. |
| 212 | 212 |
A github.com account is an obvious place for this, but an in-house |
| ... | ... |
@@ -220,7 +222,7 @@ This section covers how to perform all the steps of building, deploying, and upd |
| 220 | 220 |
OpenShift's public repository, just not a changed build. |
| 221 | 221 |
|
| 222 | 222 |
|
| 223 |
-12. *Optional:* Add the following webhook under the settings in your new GitHub repository: |
|
| 223 |
+13. *Optional:* Add the following webhook under the settings in your new GitHub repository: |
|
| 224 | 224 |
|
| 225 | 225 |
$ https://<host>:8443/osapi/v1beta1/buildConfigHooks/ruby-sample-build/secret101/github?namespace=test |
| 226 | 226 |
|
| ... | ... |
@@ -230,20 +232,12 @@ This section covers how to perform all the steps of building, deploying, and upd |
| 230 | 230 |
instance as the certificate chain generated is not publicly verified. |
| 231 | 231 |
|
| 232 | 232 |
|
| 233 |
-13. Edit application-template-stibuild.json which will define the sample application |
|
| 233 |
+14. Edit application-template-stibuild.json which will define the sample application |
|
| 234 | 234 |
|
| 235 | 235 |
* Update the BuildConfig's sourceURI (git://github.com/openshift/ruby-hello-world.git) to point to your forked repository. |
| 236 | 236 |
*Note:* You can skip this step if you did not create a forked repository. |
| 237 | 237 |
|
| 238 | 238 |
|
| 239 |
-14. Log in with the "test-admin" user and switch to the "test" project which will be used by every command from now on. This |
|
| 240 |
- will update the file pointed by $OPENSHIFTCONFIG and will make it easy to switch betwen the "master" context and the |
|
| 241 |
- "test-admin" user: |
|
| 242 |
- |
|
| 243 |
- $ osc login -u test-admin -p pass |
|
| 244 |
- $ osc project test |
|
| 245 |
- |
|
| 246 |
- |
|
| 247 | 239 |
15. Submit the application template for processing (generating shared parameters requested in the template) |
| 248 | 240 |
and then request creation of the processed template: |
| 249 | 241 |
|
| ... | ... |
@@ -379,23 +373,26 @@ the ip address shown below with the correct one for your environment. |
| 379 | 379 |
$ docker pull openshift/origin-haproxy-router |
| 380 | 380 |
|
| 381 | 381 |
$ sudo chmod +r `pwd`/openshift.local.certificates/openshift-router/.kubeconfig |
| 382 |
- $ openshift ex router --create --credentials="`pwd`/openshift.local.certificates/openshift-router/.kubeconfig" |
|
| 382 |
+ $ openshift ex router --create --credentials="`pwd`/openshift.local.certificates/openshift-router/.kubeconfig" --config=openshift.local.certificates/admin/.kubeconfig |
|
| 383 | 383 |
router # the service |
| 384 | 384 |
router # the deployment config |
| 385 | 385 |
|
| 386 | 386 |
|
| 387 |
-3. Wait for the router to start. |
|
| 387 |
+3. Switch to the `default` project to watch for router to start |
|
| 388 |
+ $ osc project default |
|
| 389 |
+ |
|
| 390 |
+4. Wait for the router to start. |
|
| 388 | 391 |
|
| 389 | 392 |
$ osc describe dc router |
| 390 | 393 |
# watch for the number of deployed pods to go to 1 |
| 391 | 394 |
|
| 392 | 395 |
|
| 393 |
-4. *Optional:* View the logs of the router. |
|
| 396 |
+5. *Optional:* View the logs of the router. |
|
| 394 | 397 |
|
| 395 | 398 |
$ osc log router-1-<podrandom-suffix> |
| 396 | 399 |
|
| 397 | 400 |
|
| 398 |
-5. Curl the url, substituting the ip address shown for the correct value in your environment. |
|
| 401 |
+6. Curl the url, substituting the ip address shown for the correct value in your environment. |
|
| 399 | 402 |
|
| 400 | 403 |
$ curl -s -k --resolve www.example.com:443:10.0.2.15 https://www.example.com |
| 401 | 404 |
... removed for readability ... |
| ... | ... |
@@ -403,7 +400,7 @@ the ip address shown below with the correct one for your environment. |
| 403 | 403 |
... removed for readability ... |
| 404 | 404 |
|
| 405 | 405 |
|
| 406 |
-6. *Optional*: View the certificate being used for the secure route. |
|
| 406 |
+7. *Optional*: View the certificate being used for the secure route. |
|
| 407 | 407 |
|
| 408 | 408 |
$ openssl s_client -servername www.example.com -connect 10.0.2.15:443 |
| 409 | 409 |
... removed for readability ... |
| ... | ... |
@@ -123,7 +123,7 @@ if [[ "${API_SCHEME}" == "https" ]]; then
|
| 123 | 123 |
fi |
| 124 | 124 |
|
| 125 | 125 |
# set the home directory so we don't pick up the users .config |
| 126 |
-export HOME="${CERT_DIR}/admin"
|
|
| 126 |
+export HOME="${TEMP_DIR}/home"
|
|
| 127 | 127 |
|
| 128 | 128 |
wait_for_url "${KUBELET_SCHEME}://${KUBELET_HOST}:${KUBELET_PORT}/healthz" "kubelet: " 0.25 80
|
| 129 | 129 |
wait_for_url "${API_SCHEME}://${API_HOST}:${API_PORT}/healthz" "apiserver: " 0.25 80
|
| ... | ... |
@@ -146,11 +146,14 @@ export KUBERNETES_MASTER="${API_SCHEME}://${API_HOST}:${API_PORT}"
|
| 146 | 146 |
if [[ "${API_SCHEME}" == "https" ]]; then
|
| 147 | 147 |
# test bad certificate |
| 148 | 148 |
[ "$(osc get services 2>&1 | grep 'certificate signed by unknown authority')" ] |
| 149 |
- |
|
| 150 |
- # ignore anything in the running user's $HOME dir |
|
| 151 |
- export HOME="${CERT_DIR}/admin"
|
|
| 152 | 149 |
fi |
| 153 | 150 |
|
| 151 |
+ |
|
| 152 |
+osc login --server=${KUBERNETES_MASTER} --certificate-authority="${CERT_DIR}/ca/cert.crt" -u test-user -p anything
|
|
| 153 |
+osc new-project project-foo --display-name="my project" --description="boring project description" |
|
| 154 |
+[ "$(osc project | grep 'Using project "project-foo"')" ] |
|
| 155 |
+ |
|
| 156 |
+ |
|
| 154 | 157 |
# test config files from the --config flag |
| 155 | 158 |
osc get services --config="${CERT_DIR}/admin/.kubeconfig"
|
| 156 | 159 |
|
| ... | ... |
@@ -243,17 +243,11 @@ func (o *LoginOptions) gatherProjectInfo() error {
|
| 243 | 243 |
|
| 244 | 244 |
switch len(projectsItems) {
|
| 245 | 245 |
case 0: |
| 246 |
- // TODO most users will not be allowed to run the suggested commands below, so we should check it and/or |
|
| 247 |
- // have a server endpoint that allows an admin to describe to users how to request projects |
|
| 248 |
- fmt.Fprintf(o.Out, `You don't have any projects. If you have access to create a new project, run |
|
| 246 |
+ fmt.Fprintf(o.Out, `You don't have any projects. You can try to create a new project, by running |
|
| 249 | 247 |
|
| 250 |
- $ openshift ex new-project <projectname> --admin=%q |
|
| 248 |
+ $ osc new-project <projectname> |
|
| 251 | 249 |
|
| 252 |
-To be added as an admin to an existing project, run |
|
| 253 |
- |
|
| 254 |
- $ openshift ex policy add-role-to-user admin %q -n <projectname> |
|
| 255 |
- |
|
| 256 |
-`, o.Username, o.Username) |
|
| 250 |
+`) |
|
| 257 | 251 |
|
| 258 | 252 |
case 1: |
| 259 | 253 |
o.Project = projectsItems[0].Name |
| ... | ... |
@@ -1,13 +1,16 @@ |
| 1 | 1 |
package cmd |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
+ "errors" |
|
| 4 | 5 |
"fmt" |
| 5 | 6 |
"io" |
| 6 | 7 |
|
| 7 |
- "github.com/golang/glog" |
|
| 8 | 8 |
"github.com/spf13/cobra" |
| 9 | 9 |
|
| 10 |
+ kcmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util" |
|
| 11 |
+ |
|
| 10 | 12 |
"github.com/openshift/origin/pkg/client" |
| 13 |
+ cliconfig "github.com/openshift/origin/pkg/cmd/cli/config" |
|
| 11 | 14 |
"github.com/openshift/origin/pkg/cmd/util/clientcmd" |
| 12 | 15 |
projectapi "github.com/openshift/origin/pkg/project/api" |
| 13 | 16 |
) |
| ... | ... |
@@ -18,6 +21,9 @@ type NewProjectOptions struct {
|
| 18 | 18 |
Description string |
| 19 | 19 |
|
| 20 | 20 |
Client client.Interface |
| 21 |
+ |
|
| 22 |
+ ProjectOptions *ProjectOptions |
|
| 23 |
+ Out io.Writer |
|
| 21 | 24 |
} |
| 22 | 25 |
|
| 23 | 26 |
const requestProjectLongDesc = ` |
| ... | ... |
@@ -40,22 +46,23 @@ After your project is created you can switch to it using %[3]s <project name>. |
| 40 | 40 |
|
| 41 | 41 |
func NewCmdRequestProject(name, fullName, oscLoginName, oscProjectName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
|
| 42 | 42 |
options := &NewProjectOptions{}
|
| 43 |
+ options.Out = out |
|
| 43 | 44 |
|
| 44 | 45 |
cmd := &cobra.Command{
|
| 45 | 46 |
Use: fmt.Sprintf("%s <project-name> [--display-name=<your display name> --description=<your description]", name),
|
| 46 | 47 |
Short: "request a new project", |
| 47 | 48 |
Long: fmt.Sprintf(requestProjectLongDesc, fullName, oscLoginName, oscProjectName), |
| 48 | 49 |
Run: func(cmd *cobra.Command, args []string) {
|
| 49 |
- if !options.complete(cmd) {
|
|
| 50 |
- return |
|
| 50 |
+ if err := options.complete(cmd, f); err != nil {
|
|
| 51 |
+ kcmdutil.CheckErr(err) |
|
| 51 | 52 |
} |
| 52 | 53 |
|
| 53 | 54 |
var err error |
| 54 | 55 |
if options.Client, _, err = f.Clients(); err != nil {
|
| 55 |
- glog.Fatalf("Error getting client: %v", err)
|
|
| 56 |
+ kcmdutil.CheckErr(err) |
|
| 56 | 57 |
} |
| 57 | 58 |
if err := options.Run(); err != nil {
|
| 58 |
- glog.Fatal(err) |
|
| 59 |
+ kcmdutil.CheckErr(err) |
|
| 59 | 60 |
} |
| 60 | 61 |
}, |
| 61 | 62 |
} |
| ... | ... |
@@ -67,16 +74,22 @@ func NewCmdRequestProject(name, fullName, oscLoginName, oscProjectName string, f |
| 67 | 67 |
return cmd |
| 68 | 68 |
} |
| 69 | 69 |
|
| 70 |
-func (o *NewProjectOptions) complete(cmd *cobra.Command) bool {
|
|
| 70 |
+func (o *NewProjectOptions) complete(cmd *cobra.Command, f *clientcmd.Factory) error {
|
|
| 71 | 71 |
args := cmd.Flags().Args() |
| 72 | 72 |
if len(args) != 1 {
|
| 73 | 73 |
cmd.Help() |
| 74 |
- return false |
|
| 74 |
+ return errors.New("must have exactly one argument")
|
|
| 75 | 75 |
} |
| 76 | 76 |
|
| 77 | 77 |
o.ProjectName = args[0] |
| 78 | 78 |
|
| 79 |
- return true |
|
| 79 |
+ o.ProjectOptions = &ProjectOptions{}
|
|
| 80 |
+ o.ProjectOptions.PathOptions = cliconfig.NewPathOptions(cmd) |
|
| 81 |
+ if err := o.ProjectOptions.Complete(f, []string{""}, o.Out); err != nil {
|
|
| 82 |
+ return err |
|
| 83 |
+ } |
|
| 84 |
+ |
|
| 85 |
+ return nil |
|
| 80 | 86 |
} |
| 81 | 87 |
|
| 82 | 88 |
func (o *NewProjectOptions) Run() error {
|
| ... | ... |
@@ -85,9 +98,20 @@ func (o *NewProjectOptions) Run() error {
|
| 85 | 85 |
projectRequest.DisplayName = o.DisplayName |
| 86 | 86 |
projectRequest.Annotations = make(map[string]string) |
| 87 | 87 |
projectRequest.Annotations["description"] = o.Description |
| 88 |
- if _, err := o.Client.ProjectRequests().Create(projectRequest); err != nil {
|
|
| 88 |
+ |
|
| 89 |
+ project, err := o.Client.ProjectRequests().Create(projectRequest) |
|
| 90 |
+ if err != nil {
|
|
| 89 | 91 |
return err |
| 90 | 92 |
} |
| 91 | 93 |
|
| 94 |
+ if o.ProjectOptions != nil {
|
|
| 95 |
+ o.ProjectOptions.ProjectName = project.Name |
|
| 96 |
+ o.ProjectOptions.ProjectOnly = true |
|
| 97 |
+ |
|
| 98 |
+ if err := o.ProjectOptions.RunProject(); err != nil {
|
|
| 99 |
+ return err |
|
| 100 |
+ } |
|
| 101 |
+ } |
|
| 102 |
+ |
|
| 92 | 103 |
return nil |
| 93 | 104 |
} |
| ... | ... |
@@ -3,6 +3,7 @@ |
| 3 | 3 |
package integration |
| 4 | 4 |
|
| 5 | 5 |
import ( |
| 6 |
+ "io/ioutil" |
|
| 6 | 7 |
"testing" |
| 7 | 8 |
"time" |
| 8 | 9 |
|
| ... | ... |
@@ -50,6 +51,7 @@ func TestUnprivilegedNewProject(t *testing.T) {
|
| 50 | 50 |
Description: "the special description", |
| 51 | 51 |
|
| 52 | 52 |
Client: valerieOpenshiftClient, |
| 53 |
+ Out: ioutil.Discard, |
|
| 53 | 54 |
} |
| 54 | 55 |
|
| 55 | 56 |
if err := requestProject.Run(); err != nil {
|