Bug 1281926

Summary: [DOCS] Information on how to deploying a App to a set nodes
Product: OpenShift Container Platform Reporter: Ryan Howe <rhowe>
Component: DocumentationAssignee: Ashley Hardin <ahardin>
Status: CLOSED CURRENTRELEASE QA Contact: XiuJuan Wang <xiuwang>
Severity: medium Docs Contact: Vikram Goyal <vigoyal>
Priority: low    
Version: 3.1.0CC: amelicha, aos-bugs, jokerman, mmccomas, tnguyen, xiuwang, yinzhou
Target Milestone: ---Flags: xiuwang: needinfo-
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 21:59:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ryan Howe 2015-11-13 20:38:42 UTC
Document URL: https://docs.openshift.com/enterprise/3.1/dev_guide/new_app.html

Describe the issue: 

How to deploying a App to a set nodes just as we did with the integrated registry and router.


Suggestions for improvement: 

Include information on where and how to add "nodeSelector" value in the podspec. Also editing namespace to specify where the pods land. 
~~~
# oc edit namespace <name>

 annotations:    
   openshift.io/node-selector: region=example
~~~

Lastly publish is the scheduler priority flow.  What i mean is that if you set the selectnode filter at the project namespace anything below it is denied.

Comment 2 Thien-Thi Nguyen 2016-06-06 11:06:14 UTC
(WIP) PR: https://github.com/openshift/openshift-docs/pull/2219

Doc plan: 
- Convert example in section "Output Without Creation" from JSON to YAML.
- Expand section "Output Without Creation" to include node-selection setting as an example of what to do in the "vi myapp.yaml" step.

Comment 4 XiuJuan Wang 2016-06-07 06:25:02 UTC
This docs makes me confused.
Which part need I edit to add node-selector, in myapp project or the myapp.yaml get from 'oc new-app https://github.com/openshift/ruby-hello-world -o yaml > myapp.yaml'

Comment 5 Thien-Thi Nguyen 2016-06-22 18:40:43 UTC
(In reply to XiuJuan Wang from comment #4)
> This docs makes me confused.
> Which part need I edit to add node-selector, in myapp project or the
> myapp.yaml get from 'oc new-app
> https://github.com/openshift/ruby-hello-world -o yaml > myapp.yaml'

Thanks for the review.

Does this change help?
https://github.com/openshift/openshift-docs/pull/2219/commits/9b20c23416a060e1cc45e27e9a5692327f2b2f0b

Comment 6 XiuJuan Wang 2016-06-23 03:10:27 UTC
@Thien
Did I get your point? My understand as below, but when replaced this yaml, got error

$oc new-project myapp

$oc get namespace myapp -o yaml > myapp.yaml

$vi myapp.yaml
apiVersion: v1
kind: Namespace
metadata:
  annotations:
    openshift.io/description: ""
    openshift.io/display-name: ""
    openshift.io/requester: xiuwang
    openshift.io/sa.scc.mcs: s0:c9,c4
    openshift.io/sa.scc.supplemental-groups: 1000080000/10000
    openshift.io/sa.scc.uid-range: 1000080000/10000
    openshift.io/node-selector: region=west
  creationTimestamp: 2016-06-23T03:02:19Z
  name: myapp
  resourceVersion: "71878"
  selfLink: /api/v1/namespaces/myapp

$oc replace -f myapp.yaml
Error from server: error when replacing "myapp.yaml": User "xiuwang" cannot update namespaces in project "myapp"

Comment 7 Thien-Thi Nguyen 2016-06-23 10:28:54 UTC
(In reply to XiuJuan Wang from comment #6)
> Did I get your point?

I think there is a misunderstanding.

> My understand as below, but when replaced this yaml, got error
>
> $oc new-project myapp
>
> $oc get namespace myapp -o yaml > myapp.yaml

In the beginning of the "Useful Edits" section, there is a link (with text "edits to make") that points to a sequence of commands:

$ oc new-app https://github.com/openshift/ruby-hello-world -o yaml > myapp.yaml
$ vi myapp.yaml
$ oc create -f myapp.yaml

In this sequence, the command that creates the myapp.yaml file is "oc new-app ... -o yaml", which differs from the command you gave above (using "oc get namespace").  In myapp.yaml created from "oc new-app", there are many objects, one of which is the "kind: Project" that the example in the "Useful Edits" section talks about.

To make this clearer, i've installed the change:
https://github.com/openshift/openshift-docs/pull/2219/commits/8764fe6f78116919453132d733dd27ce223326ae

Does that help?

Comment 8 XiuJuan Wang 2016-06-24 09:01:32 UTC
My bad, so I need add the following code to myapp.yaml which comes from 'oc new-app https://github.com/openshift/ruby-hello-world -o yaml > myapp.yaml'

- apiVersion: v1
  kind: Project
  metadata:
    name: myapp
    annotations:
      openshift.io/node-selector: region=west

Unfortunately, I met error again.

$ oc create  -f  myapp.yaml 
imagestream "ruby-22-centos7" created
imagestream "ruby-hello-world" created
buildconfig "ruby-hello-world" created
deploymentconfig "ruby-hello-world" created
service "ruby-hello-world" created
Error from server: User "xiuwang" cannot create projects at the cluster scope

Comment 9 XiuJuan Wang 2016-07-12 02:50:48 UTC
(In reply to XiuJuan Wang from comment #8)
1. create the myapp project.
2.Get the myapp.yaml
oc new-app https://github.com/openshift/ruby-hello-world -o yaml > myapp.yaml
3.Add below code to myapp.yaml
- apiVersion: v1
  kind: Project
  metadata:
    name: myapp
    annotations:
      openshift.io/node-selector: region=infra
4.Create resources via myapp.yaml
$oc  create -f myapp.yaml 
imagestream "ruby-22-centos7" created
imagestream "ruby-hello-world" created
buildconfig "ruby-hello-world" created
deploymentconfig "ruby-hello-world" created
service "ruby-hello-world" created
Error from server: User "xiuwang" cannot create projects at the cluster scope
5.Check if the pod is created in region=infra node
 oc get pods  -o wide 
NAME                       READY     STATUS    RESTARTS   AGE       NODE
ruby-hello-world-1-build   1/1       Running   0          5m        openshift-108.lab.sjc.redhat.com


@Thien-Thi
You can see the pod is be assigeed to related node, but has a error in the step 4.

Comment 10 XiuJuan Wang 2016-07-13 05:36:38 UTC
(In reply to XiuJuan Wang from comment #9)
 My apology, I add the below code to wrong code level.
 Should add in the first code level, before I add it to the second level.No error in the comment #9 when create myapp.yaml now

apiVersion: v1
kind: Project
metadata:
  name: myapp
  annotations:
    openshift.io/node-selector: region=infra

Comment 11 Thien-Thi Nguyen 2016-07-14 14:04:32 UTC
(In reply to XiuJuan Wang from comment #10)
> (In reply to XiuJuan Wang from comment #9)
>  My apology, I add the below code to wrong code level.
>  Should add in the first code level, before I add it to the second level.No
> error in the comment #9 when create myapp.yaml now
>
> apiVersion: v1
> kind: Project
> metadata:
>   name: myapp
>   annotations:
>     openshift.io/node-selector: region=infra

Thank-you for the update.  Based on this feedback
(and on playing w/ the docs team ose v3 test instance)
i have installed:
https://github.com/openshift/openshift-docs/pull/2219/commits/486405a9ccbc6b14e307f2506d43c2c5ff728532

Do you think this would have helped initially?

Comment 12 Thien-Thi Nguyen 2016-07-14 14:51:42 UTC
PR has been rebased.  Pretty rendering here:
http://file.brq.redhat.com/~tnguyen/bz1281926/new_app.html

Comment 13 openshift-github-bot 2016-07-14 17:20:48 UTC
Commit pushed to master at https://github.com/openshift/openshift-docs

https://github.com/openshift/openshift-docs/commit/6eac8f9f85c0b8fcead0a0810f311125b9c75948
Merge pull request #2219 from tnguyen-rh/bz1281926

Fixes bug 1281926 -- add node placement info to 'oc new-app' description.

Comment 14 Thien-Thi Nguyen 2016-07-14 17:25:11 UTC
> Do you think this would have helped initially?

PR merged; if there are any problems, we can open a new BZ.
Moving status to RELEASE_PENDING.

Comment 15 XiuJuan Wang 2016-07-15 01:53:28 UTC
@Thien Acctually we need the project code to the first level(not the second level) in the myapp.yaml, otherwise will met error in comment #9.

Comment 16 Thien-Thi Nguyen 2016-07-15 09:17:46 UTC
(In reply to XiuJuan Wang from comment #15)
> Acctually we need the project code to the first level(not the second
> level) in the myapp.yaml, otherwise will met error in comment #9.

I think "first" and "second" are confusing terms, because it depends where you start to count (from one or from zero).  Most non-programmers count from one (thus "first" means 1).  Some programmers count from zero (thus "first" means 0).

In this case, putting on my programmer hat, level 0 defines a single field ‘items’ (of ‘kind: List’), level 1 defines several objects of ‘kind: ImageStream’.  The new ‘kind: Project’ object should be added at level 1 (and not level 2), as you correctly noted in your feedback.

The reason i say "second" in the documentation is because the audience is more likely to be non-programmers than programmers.  In any case, i added the qualifier "peer to ImageStream"  to clarify further, and expanded the fragment to show the relationship between the new Project and the existing ImageStream definitions.

I'll leave the text as-is for now.  Thanks very much for your reviews.

(BTW, my given name is "Thien-Thi", not "Thien".  Do you prefer "Xiu" or "XiuJuan" or something else?)

Comment 18 XiuJuan Wang 2016-07-15 10:14:07 UTC
@Thien-Thi you can call me Xiujuan :)
More clear now, thanks your detailed feedback. :)

Comment 19 Thien-Thi Nguyen 2016-07-27 21:59:25 UTC
Docs live:
https://docs.openshift.com/enterprise/3.2/dev_guide/new_app.html#useful-edits

Moving status to CLOSED CURRENTRELEASE.