|
| 1 | +:_mod-docs-content-type: ASSEMBLY |
| 2 | +[id="cloud-experts-deploying-application-deployment"] |
| 3 | += Tutorial: Deploying an application |
| 4 | +include::_attributes/attributes-openshift-dedicated.adoc[] |
| 5 | +:context: cloud-experts-deploying-application-deployment |
| 6 | + |
| 7 | +toc::[] |
| 8 | + |
| 9 | +//rosaworkshop.io content metadata |
| 10 | +//Brought into ROSA product docs 23-JAN-2024 |
| 11 | + |
| 12 | +== Deploying the OSToy application with Kubernetes |
| 13 | + |
| 14 | +You can deploy the OSToy application by creating and storing the images for the front-end and back-end microservice containers in an image repository. You can then create Kubernetes deployments to deploy the application. |
| 15 | + |
| 16 | +=== Retrieving the login command |
| 17 | + |
| 18 | +. If you are not logged in to the CLI, access your cluster with the web console. |
| 19 | + |
| 20 | +. Click the dropdown arrow next to your login name in the upper right, and select *Copy Login Command*. |
| 21 | ++ |
| 22 | +image::4-cli-login.png[CLI login screen] |
| 23 | ++ |
| 24 | +A new tab opens. |
| 25 | + |
| 26 | +. Select your authentication method. |
| 27 | + |
| 28 | +. Click *Display Token*. |
| 29 | + |
| 30 | +. Copy the command under *Log in with this token*. |
| 31 | + |
| 32 | +. From your terminal, paste and run the copied command. If the login is successful, you will see the following confirmation message: |
| 33 | ++ |
| 34 | +[source,terminal] |
| 35 | +---- |
| 36 | +$ oc login --token=<your_token> --server=https://api.osd4-demo.abc1.p1.openshiftapps.com:6443 |
| 37 | +Logged into "https://api.myrosacluster.abcd.p1.openshiftapps.com:6443" as "rosa-user" using the token provided. |
| 38 | +
|
| 39 | +You don't have any projects. You can try to create a new project, by running |
| 40 | +
|
| 41 | +oc new-project <project name> |
| 42 | +---- |
| 43 | + |
| 44 | +=== Creating a new project |
| 45 | + |
| 46 | +==== Using the CLI |
| 47 | + |
| 48 | +. Create a new project named `ostoy` in your cluster by running following command: |
| 49 | ++ |
| 50 | +[source,terminal] |
| 51 | +---- |
| 52 | +$ oc new-project ostoy |
| 53 | +---- |
| 54 | ++ |
| 55 | +.Example output |
| 56 | +[source,terminal] |
| 57 | +---- |
| 58 | +Now using project "ostoy" on server "https://api.myrosacluster.abcd.p1.openshiftapps.com:6443". |
| 59 | +---- |
| 60 | + |
| 61 | +. *Optional*: Alternatively, create a unique project name by running the following command: |
| 62 | ++ |
| 63 | +[source,terminal] |
| 64 | +---- |
| 65 | +$ oc new-project ostoy-$(uuidgen | cut -d - -f 2 | tr '[:upper:]' '[:lower:]') |
| 66 | +---- |
| 67 | + |
| 68 | +==== Using the web console |
| 69 | + |
| 70 | +. From the web console, click *Home -> Projects*. |
| 71 | + |
| 72 | +. On the *Projects* page, click create *Create Project*. |
| 73 | ++ |
| 74 | +image::4-createnewproj.png[The project creation screen] |
| 75 | + |
| 76 | +=== Deploying the back-end microservice |
| 77 | + |
| 78 | +The microservice serves internal web requests and returns a JSON object containing the current hostname and a randomly generated color string. |
| 79 | + |
| 80 | +* Deploy the microservice by running the following command from your terminal: |
| 81 | ++ |
| 82 | +[source,terminal] |
| 83 | +---- |
| 84 | +$ oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-microservice-deployment.yaml |
| 85 | +---- |
| 86 | ++ |
| 87 | +.Example output |
| 88 | +[source,terminal] |
| 89 | +---- |
| 90 | +$ oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-microservice-deployment.yaml |
| 91 | +deployment.apps/ostoy-microservice created |
| 92 | +service/ostoy-microservice-svc created |
| 93 | +---- |
| 94 | + |
| 95 | +=== Deploying the front-end service |
| 96 | + |
| 97 | +The front-end deployment uses the Node.js front-end for the application and additional Kubernetes objects. |
| 98 | + |
| 99 | +The `ostoy-frontend-deployment.yaml` file shows that front-end deployment defines the following features: |
| 100 | + |
| 101 | +- Persistent volume claim |
| 102 | +- Deployment object |
| 103 | +- Service |
| 104 | +- Route |
| 105 | +- Configmaps |
| 106 | +- Secrets |
| 107 | + |
| 108 | +* Deploy the application front-end and create all of the objects by entering the following command: |
| 109 | ++ |
| 110 | +[source,terminal] |
| 111 | +---- |
| 112 | +$ oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-frontend-deployment.yaml |
| 113 | +---- |
| 114 | ++ |
| 115 | +.Example output |
| 116 | +[source,terminal] |
| 117 | +---- |
| 118 | +persistentvolumeclaim/ostoy-pvc created |
| 119 | +deployment.apps/ostoy-frontend created |
| 120 | +service/ostoy-frontend-svc created |
| 121 | +route.route.openshift.io/ostoy-route created |
| 122 | +configmap/ostoy-configmap-env created |
| 123 | +secret/ostoy-secret-env created |
| 124 | +configmap/ostoy-configmap-files created |
| 125 | +secret/ostoy-secret created |
| 126 | +---- |
| 127 | ++ |
| 128 | +You should see all objects created successfully. |
| 129 | + |
| 130 | +=== Getting the route |
| 131 | + |
| 132 | +You must get the route to access the application. |
| 133 | + |
| 134 | +* Get the route to your application by running the following command: |
| 135 | ++ |
| 136 | +[source,terminal] |
| 137 | +---- |
| 138 | +$ oc get route |
| 139 | +---- |
| 140 | ++ |
| 141 | +.Example output |
| 142 | +[source,terminal] |
| 143 | +---- |
| 144 | +NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD |
| 145 | +ostoy-route ostoy-route-ostoy.apps.<your-rosa-cluster>.abcd.p1.openshiftapps.com ostoy-frontend-svc <all> None |
| 146 | +---- |
| 147 | + |
| 148 | +=== Viewing the application |
| 149 | + |
| 150 | +. Copy the `ostoy-route-ostoy.apps.<your-rosa-cluster>.abcd.p1.openshiftapps.com` URL output from the previous step. |
| 151 | +. Paste the copied URL into your web browser and press enter. You should see the homepage of your application. If the page does not load, make sure you use `http` and not `https`. |
| 152 | ++ |
| 153 | +image::4-ostoy-homepage.png[OStoy application homepage] |
0 commit comments