6 Quick Start with OKE
Follow the instructions in this section to install Transaction Manager for Microservices (MicroTx) in Oracle Container Engine for Kubernetes (OKE) and run a sample application.
The script deploys the sample applications on a single node in the Kubernetes cluster on which you have deployed MicroTx.
In the test environment, create at least one node in the Kubernetes cluster to host MicroTx. MicroTx supports Kubernetes 1.21.x or later versions.
The runme.sh
script installs MicroTx, builds the Docker images, and then installs the sample application. You can also run the sample applications without automating these steps using the runme.sh
script file. See Deploy Sample Applications in Transaction Manager for Microservices Developer Guide.
- Set Up the Required Software
You must complete the following tasks before you begin running the sample applications in OKE. - Run XA Sample Applications
Run the XA sample application to transfer an amount from one department to another and to understand how you can use MicroTx to coordinate XA transactions. The MicroTx library files are already integrated with the sample application code. - Run Saga Sample Applications
Run the Saga sample application to book a trip and understand how you can use MicroTx to coordinate the transactions. The MicroTx library files are already integrated with the sample application code. - Run TCC Sample Applications
Run the TCC sample application to book a trip and understand how you can use MicroTx to coordinate the transactions. The MicroTx library files are already integrated with the sample application code.
6.1 Set Up the Required Software
You must complete the following tasks before you begin running the sample applications in OKE.
- Run the following command to download Istio.
curl -sL https://istio.io/downloadIstioctl | sh -
When you run the
runme.sh
script, it installs Istio. - Add the istioctl client tool to the
PATH
environment variable of your local system. The following example specifies the a sample value. Provide the path based on your environment.export PATH=$HOME/.istioctl/bin:$PATH
- Install the following required software.
- npm version 7.x or later. See https://nodejs.org/en/download/.
- Maven version 3.6 or later. See https://maven.apache.org/download.cgi.
- Java JDK version 11 or later. See https://www.oracle.com/java/technologies/downloads/.
- cURL. See https://curl.se/download.html.
- jq. See https://stedolan.github.io/jq/download/.
- OpenSSL. See https://www.openssl.org/.
- Install and configure Kubernetes command-line interface (Kubectl), 1.21.x or later versions, to work with your Kubernetes cluster. See https://kubernetes.io/docs/tasks/tools/.
Use
Kubectl
to create and manage your deployments.Kubectl
uses the Kubernetes APIs to interact with the cluster. - Install the latest version of Helm 3.x on your local machine. See https://helm.sh/docs/intro/install/.
- Install Oracle Cloud Infrastructure (OCI) CLI. Ensure that OCI CLI is configured to connect to the Kubernetes cluster. See https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/cliinstall.htm.
- Create a Kubernetes Cluster with OKE.
- Log in to the Oracle OCI cloud console. See https://www.oracle.com/in/cloud/sign-in.html.
- Create a Kubernetes cluster in the OKE environment. See Quick Create Workflow to Create a Cluster in Oracle Cloud Infrastructure documentation.
- Set up local access to the Kubernetes cluster that you have created so that you can access your OKE cluster environment from your local machine. See Setting Up Local Access to Clusters in Oracle Cloud Infrastructure documentation.
- Create an access token. To create an access token using Oracle IAM and Oracle IDCS, see Use Oracle Identity Providers and Create an Access Token. If you want to use Keycloak or Microsoft AD as the identity provider, refer to their product documentation for information about setting up the identity provider and creating an access token.
- Set up resource managers for the two transaction participant services to run the sample XA application. Set up Oracle Database as the resource manager. See Set Up XA-Compliant Resource Managers.
- Ensure that Java Development Kit (JDK) is installed on your local system, and then run the following commands in the Bash shell to set the following environment variables.
export JAVA_HOME=jdk-install-dir export PATH=$JAVA_HOME/bin:$PATH
The JDK contains keytool, a utility to create and manage certificates. The
runme.sh
script runs the keytool utility to generate a certificate to enable TLS to access MicroTx. - Ensure that you have sudo privileges to run commands in the Bash shell.
- Use Oracle Identity Providers
You can use Oracle Identity Cloud Service (IDCS) or Oracle IAM as an identity provider to manage access to your application. - Create an Access Token
This topic provides details to create an access token when you use Oracle IDCS or Oracle IAM as the identity provider.
Parent topic: Quick Start with OKE
6.1.1 Use Oracle Identity Providers
You can use Oracle Identity Cloud Service (IDCS) or Oracle IAM as an identity provider to manage access to your application.
If you want to use Keycloak or Microsoft AD as the identity provider, refer to their product documentation for information about setting up the identity provider and creating an access token.
Oracle Cloud Infrastructure previously used Oracle IDCS as the identity provider. Now, Oracle Cloud Infrastructure uses Oracle IAM as the identity provider.
- Use Oracle IAM as Identity Provider
You can use Oracle IAM as identity provider to manage access to your application. - Use Oracle IDCS as Identity Provider
You can use Oracle IDCS as identity provider to manage access to your application.
Parent topic: Set Up the Required Software
6.1.1.1 Use Oracle IAM as Identity Provider
You can use Oracle IAM as identity provider to manage access to your application.
Parent topic: Use Oracle Identity Providers
6.1.1.2 Use Oracle IDCS as Identity Provider
You can use Oracle IDCS as identity provider to manage access to your application.
Parent topic: Use Oracle Identity Providers
6.1.2 Create an Access Token
This topic provides details to create an access token when you use Oracle IDCS or Oracle IAM as the identity provider.
If you want to use Keycloak or Microsoft AD as the identity provider, refer to their product documentation for information about setting up the identity provider and creating an access token.
API calls to the service require a valid authentication token. Create an access token which you can specify in subsequent API calls to the service. In addition to the access token, you can also specify the refresh token in subsequent API calls to the service. MicroTx uses the refresh token to refresh an expired access token.
After you obtain the OAuth 2.0 tokens, use the tokens in the authorization
and refresh-token
headers while making subsequent API calls to the service.
Parent topic: Set Up the Required Software
6.2 Run XA Sample Applications
Run the XA sample application to transfer an amount from one department to another and to understand how you can use MicroTx to coordinate XA transactions. The MicroTx library files are already integrated with the sample application code.
The sample application demonstrates how you can develop microservices that participate in XA transactions while using MicroTx to coordinate the transactions. When you run the Teller application, it withdraws money from one department and deposits it to another department by creating an XA transaction. Within the XA transaction, all actions such as withdraw and deposit either succeed, or they all are rolled back in case of a failure of any one or more actions. For details about the sample XA application, see About the Sample XA Application in Transaction Manager for Microservices Developer Guide.
- Name of the Oracle Cloud Infrastructure Registry to which you want the script to push the Docker images of the sample applications.
- Details to connect to the database, such as credentials and connection string.
- Complete the prerequisites and set up the required software. See Prerequisites.
To run the sample XA application using the runme.sh
script file:
- Use the Kiali dashboard to view how the MicroTx handles the flow of requests between the sample microservices.
- Perform distributed tracing using Jaeger to trace the entire transaction. See Perform Distributed Tracing with Jaeger.
- Run another sample application.
- View the source files of the sample application.
- View the log files to find more details about the transactions.
- Create and run your own application using MicroTx.
Parent topic: Quick Start with OKE
6.3 Run Saga Sample Applications
Run the Saga sample application to book a trip and understand how you can use MicroTx to coordinate the transactions. The MicroTx library files are already integrated with the sample application code.
The sample application demonstrates how you can develop microservices that participate in Saga transactions while using MicroTx to coordinate the transactions. When you run the application, it makes a provisional booking by reserving a hotel room and flight ticket. Only when you provide approval to confirm the booking, the booking of the hotel room and flight ticket is confirmed. If you cancel the provisional booking, the hotel room and flight ticket that was blocked is released and the booking is canceled. By default, the hotel and flight service permits only three confirmed bookings. To enable you to test the failure scenario, the services reject any additional booking requests that are made after three confirmed bookings. This leads to the cancellation (compensation) of a provisionally booked hotel or flight within the trip and the trip is not booked. For details about the sample Saga application, see About the Sample Saga Application in Transaction Manager for Microservices Developer Guide.
To run the sample Saga application using the runme.sh
script file:
- Use the Kiali dashboard to view how the MicroTx handles the flow of requests between the sample microservices.
- Perform distributed tracing using Jaeger to trace the entire transaction. See Perform Distributed Tracing with Jaeger.
- Run another sample application.
- View the source files of the sample application.
- View the log files to find more details about the transactions.
- Create and run your own application using MicroTx.
Parent topic: Quick Start with OKE
6.4 Run TCC Sample Applications
Run the TCC sample application to book a trip and understand how you can use MicroTx to coordinate the transactions. The MicroTx library files are already integrated with the sample application code.
The sample TCC application implements a scenario where the travel agent microservice books a trip, flight booking service books a flight, and the hotel booking microservice books a hotel. The travel agent service accesses both the flight and hotel booking services. When a customer books a flight and a hotel, the booking is reserved until either the customer completes the payment and confirms the booking. In case of any failure, the reserved resources are canceled and the resources are returned back to the inventory. For details about the sample TCC application, see About the Sample TCC Application in Transaction Manager for Microservices Developer Guide.
To run the sample TCC application using the runme.sh
script file:
- Use the Kiali dashboard to view how the MicroTx handles the flow of requests between the sample microservices.
- Perform distributed tracing using Jaeger to trace the entire transaction. See Perform Distributed Tracing with Jaeger.
- Run another sample application.
- View the source files of the sample application.
- View the log files to find more details about the transactions.
- Create and run your own application using MicroTx.
Parent topic: Quick Start with OKE