Exercise 2 - Change code, build, save and deploy the Authors Microservice
Step 1: Open the server.xml
file
server.xml
fileStep 2: Change following source code
Replace the [keycloakurl]
with the value, you got before for in and save the file.
Step 3: Open the microprofile-config.properties
file
microprofile-config.properties
fileStep 4: Change following source code
Replace the [keycloakurl]
with the value, you got before for in Step 1 and save the file.
Step 5: Insert the RS256 JWT key in the file keycloak-public-key.pem
keycloak-public-key.pem
The file is saved in that folder src/main/webapp/META-INF/keycloak-public-key.pem
.
Get the key using the URL http://[keycloakurl]/auth/admin/master/console/#/realms/cloudnativestarter/keys
and then press public key. The following image shows the invocation.
Step 6: Build and save the "Authors" container image in the IBM Cloud Container Registry
Step 7: List the container images to verify the upload.
Step 8: Apply the deployment of the Authors service
Ensure you are in the
$ROOT_FOLDER/web-app-cloud/deployment
Open the
../authors-java-jee-cloud/deployment/kubernetes.yaml
file 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 theauthors:1
text, and add following statementimagePullPolicy: Always
and save the file.
Note: With the specification imagePullPolicy: Always
we force that the image is pulled from the IBM Cloud Container Registry and not cashed image in Kubernetes is possible used, when we change our container image IBM Cloud Container Registry.
Before:
Example for the change:
Now we apply the yaml to create the Authors Pod.
Insert this command and verify the output.
Sample output:
Cluster/Workernode IP
authors
NodePort
Open the service in a browser
Last updated
Was this helpful?