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.
If you are not logged in to the CLI, access your cluster with the web console.
Click the dropdown arrow next to your login name in the upper right, and select Copy Login Command.
A new tab opens.
Select your authentication method.
Click Display Token.
Copy the command under Log in with this token.
From your terminal, paste and run the copied command. If the login is successful, you will see the following confirmation message:
$ oc login --token=<your_token> --server=https://api.osd4-demo.abc1.p1.openshiftapps.com:6443
Logged into "https://api.myrosacluster.abcd.p1.openshiftapps.com:6443" as "rosa-user" using the token provided.
You don't have any projects. You can try to create a new project, by running
oc new-project <project name>
Create a new project named ostoy
in your cluster by running following command:
$ oc new-project ostoy
Now using project "ostoy" on server "https://api.myrosacluster.abcd.p1.openshiftapps.com:6443".
Optional: Alternatively, create a unique project name by running the following command:
$ oc new-project ostoy-$(uuidgen | cut -d - -f 2 | tr '[:upper:]' '[:lower:]')
The microservice serves internal web requests and returns a JSON object containing the current hostname and a randomly generated color string.
Deploy the microservice by running the following command from your terminal:
$ oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-microservice-deployment.yaml
$ oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-microservice-deployment.yaml
deployment.apps/ostoy-microservice created
service/ostoy-microservice-svc created
The front-end deployment uses the Node.js front-end for the application and additional Kubernetes objects.
The ostoy-frontend-deployment.yaml
file shows that front-end deployment defines the following features:
Persistent volume claim
Deployment object
Service
Route
Configmaps
Secrets
Deploy the application front-end and create all of the objects by entering the following command:
$ oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-frontend-deployment.yaml
persistentvolumeclaim/ostoy-pvc created
deployment.apps/ostoy-frontend created
service/ostoy-frontend-svc created
route.route.openshift.io/ostoy-route created
configmap/ostoy-configmap-env created
secret/ostoy-secret-env created
configmap/ostoy-configmap-files created
secret/ostoy-secret created
You should see all objects created successfully.
You must get the route to access the application.
Get the route to your application by running the following command:
$ oc get route
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
ostoy-route ostoy-route-ostoy.apps.<your-rosa-cluster>.abcd.p1.openshiftapps.com ostoy-frontend-svc <all> None
Copy the ostoy-route-ostoy.apps.<your-rosa-cluster>.abcd.p1.openshiftapps.com
URL output from the previous step.
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
.