Exercise 3 - Change code, build, save and deploy the Web-App
Step 1: Open the main.js file
main.js fileecho $keycloakurl
echo $authorsurl
echo
cd $ROOT_FOLDER/web-app-cloud/src
nano main.jsStep 2: Change following source code
cd $ROOT_FOLDER/web-app-cloud/src
nano main.jsReplace the [keycloakurl] with the value, you got before for in Step 1 and save the file. The authors url is only available after the deploment of the Authors service.
let initOptions = {
url: '[keycloakurl]/auth', realm: 'cloudnativestarter', clientId: 'frontend', onLoad: 'login-required'
}
let urls = {
api: 'http://[authorsurl]/api/v1/'
}
store.commit("setAPI", urls);Step 3: Build and save the "Web-App" container image in the IBM Cloud Container Registry
Now we want to build and save the container image "Web-APP" in the IBM Cloud Container Registry.
Ensure you logon on to IBM Cloud.
REMEMBER: You should know this from the prerequisites.
You can follow the steps in the Access tab, by starting from After your cluster provision .. and inserting the commands into your terminal session.

Logon to the IBM Cloud Container Registry (Ensure you are in the right folders)
Web-APP
List you namespaces inside the IBM Cloud Container Registry
Example output:
Now upload the code and build the container image inside IBM Cloud Container Registry. We use the information from step 2, where we got the list of namespaces.
Web-APP
Step 4: List the container images to verify the upload.
Step 5: Apply the deployment of the Web-App
Ensure you are in the
$ROOT_FOLDER/web-app-cloud/deploymentOpen the
../web-app-cloud/deployment/kubernetes.yamlfile with a editor and replace the value for the container image location with the path we got from the IBM Container Registry and just replace theweb-app:1text, and add following statementimagePullPolicy: Alwaysand save the file.
Before:
Example after the change:
Now we apply the yaml to create the web-app Pod.
Insert this command and verify the output.
Example output:
Cluster/Workernode IP
Web-APP
NodePortOpen the Web-APP in a browser
Step 6: Configure the redirect URL in Keycloak
Get the Keycloak URL in your terminal session:
Open Keycloak your browser
Login admin/admin and open the Cloud Native Starter realm
Select Clients
Open the
authors-client-cloud-native-starterclientGet the
redirecturlin your terminal session and copy the URLInsert the
[redirecturl]Root URL:
[redirecturl]Valid Redirect URIs:
[redirecturl]/*[redirecturl]//
Configure the
Web OriginsWeb Origins:
'*'
*
Step 7: Open the Web-App again
Step 8: Logon as user author-cloud-native-starter and password 1234.
author-cloud-native-starter and password 1234.Last updated
Was this helpful?