Migrate an Application to OCI with WebLogic Kubernetes Toolkit

6
0
Send lab feedback

Oracle WebLogic Kubernetes Toolkit

Introduction

Oracle WebLogic Kubernetes Toolkit is a collection of open-source tools that help you provision WebLogic-based applications to run in Linux containers on a Kubernetes cluster.

WKT includes the following tools:

  • WebLogic Deploy Tooling (WDT) - A set of single-purpose, lifecycle tools that operate off of a single metadata model representation of a WebLogic domain.

  • WebLogic Image Tool (WIT) - A tool for creating Linux container images for running WebLogic domains.

  • WebLogic Kubernetes Operator (WKO) - A Kubernetes operator that allows WebLogic domains to run natively in a Kubernetes cluster.

Lab Objectives

Upon completion of this Lab you will be able to:

  • Create a model of the WebLogic domain
  • Create a Linux container image to run the domain
  • Deploy the domain to the Kubernetes cluster
  • Scale the WebLogic cluster
  • Upgrade WebLogic Server version

Click the next button below to begin.

Task 1: Prepare the Environment

This lab will auto deploy the following OCI resources:

  • Compute instance with a custom image running WebLogic.
  • A simple Kubernetes cluster with 3 nodes.
  1. Start by "sign in" to the OCI Console.

    On the Oracle Linux desktop, open the html page for the sign in information and the credentials.

  2. Use the credentials provided on this page.

  3. Click OCI Console to sign in.

  4. Copy and paste the credentials and click Sign In.

  5. You have successfully signed in to the Oracle cloud.

  6. Check the status of the WebLogic compute instance.

    Go to Compute -> Instances -> Custom Images -> compartment.

    You should see the import image in the importing state.

  7. Let's check the status of the Kubernetes cluster.

    Go to Developer Services -> Kubernetes Clusters (OKE).

    Select the compartment and note the cluster status.

  8. Continue with the lab while the environment is creating.

    For your information:

    • The WebLogic image should take no longer than 10 minutes.

    • The Kubernetes cluster should take no longer than 15 minutes.

  9. Now we can create a document to store details of the environment to be used later in the lab.

    Create a text file using gedit.

    Copy the following text.

    Luna Environment Details:
    
    User Name: 
    
    Password: 				
    
    OCI Auth Token: 		
    
    OCI Region: 			
    
    Tenancy Name: 
    
    Compartment Name: 
    
    Region Endpoint:			
    
    Tenancy Namespace: 		
    
    Repository name: test-model-<YourFirstName>
    
    Image Registry Username:  <TenancyNamespace>/oracleidentitycloudservice/<UserName>
    
    Example: idzkpjbdj5lt/oracleidentitycloudservice/luna.user@750e741c-2268-47fe-8a3f-4ca094c66a76
    
    
    Auxiliary Image Tag: <Region Endpoint>/<Tenancy Namespace>/test-model-<YourFirstName>:v1
    
    Example: /idzkpjbdj5lt/test-model-ankit:v1
    
  10. Paste and save your text file.

    You will store the details from Luna and paste it in this text file to be used later in this lab.

  11. Go back to the Luna-Lab.html file to populate the text file.

    Here you will find the login tenant information required for this lab. Copy the values for:

    • Username
    • Password
    • OCI Auth Token

    Paste them to the text file you created earlier.

  12. Click the Oracle Cloud tab and copy the values for:

    • OCI Region
    • Tenancy Name
    • Compartment Name

    Paste them to the text file. Remember to save your text file.

  13. Obtain the Container Registry namespace.

    Go to the Container Registry.

    Copy the Namespace to the text file. This is your tenancy namespace.

    Note

    If you do not see your namespace. On the Container & Artifacts column, first click Kubernetes Cluster (OKE) and then click Container Registry. You should now see the namespace.

  14. Create a repository to store your new image later on the in the lab.

    Click Create repository.

    Enter the Repository name as test-model-<your-first-name> in lower case, Access select Public, then click Create repository.

    Replace <your-first-name> with your first name to make repository name unique.

  15. Copy the name of the repository, you just created, to your text file.

  16. We will need the WebLogic Server image from the Oracle container repository.

    First, you need to accept the license agreement in Oracle Container Registry.

    In the browser, open a new tab, copy and paste the following URL.

    https://container-registry.oracle.com/
  17. Click Sign In.

  18. Sign in using your own Oracle Account, not the Luna username and password.

    Enter your Oracle Account Credentials.

  19. In Oracle Container Registry, enter the search term weblogic.

    Scroll down the result and click Weblogic.

    Select your preferred language, and click Continue.

    Click Accept to accept the license agreement.

  20. Prepare the text file for the next task, find the endpoint for your region.

    In the browser, go to your OCI Console tab and find the home region name.

  21. Open a new tab with the following URL and scroll down to look for your region. Copy the endpoint to the text file.

    https://docs.oracle.com/en-us/iaas/Content/Registry/Concepts/registryprerequisites.htm#Availab

    In this example, US East (Ashburn) endpoint is iad.ocir.io.

  22. In the text file, create the Image Registry Username value.

    <TenancyNamespace>/oracleidentitycloudservice/<LunaUsername>

    Example

    idzkpjbdj5lt/oracleidentitycloudservice/luna.user@750e741c-2268-47fe-8a3f-4ca094c66a76

  23. In the text file, create the Auxiliary Image Tag value.

    <Region Endpoint>/<Tenancy Namespace>/test-model-<YourFirstName>:v1

    Example

    iad.ocir.io/idzkpjbdj5lt/test-model-johndoe:v1

  24. Let's remote login (VNC) to the compute running our WebLogic Server.

    Find the IP address of the compute instance.

    In the OCI console got to Compute -> Instances.

  25. Look for the weblogic instance, copy the Public IP and paste it to your text file.

    If you don't see the weblogic instance, wait for it to be created.

    You may click Custom Images to check the progress of the image upload. Should not take longer than 10 minutes.

  26. At this time, it maybe possible to see the Kubernetes cluster nodes, otherwise, continue with the lab.

    Kubernetes cluster will take up to 15 minutes to deploy.

  27. In the Linux desktop, open TigerVNC Viewer.

  28. Enter the IP address in the following format (Add port 5901) and click Connect.

    <PUBLIC_IP_ADDRESS>::5901

    NOTE

    The VNC server may takes some time to start, keep trying until you get a password prompt from the server. Try again after a minute.

    Copy and paste the following password and then click OK.

    LiveLabs.Rocks_99

    Successfully remote control the server.


Congratulations on completing this task!

Click Next to continue.


Task 2: Modifying a WKT UI Project and Creation of Model file

  1. Start the Admin Server and navigate through the resources using WebLogic Administration console.

    In TigerVNC, click Activities and select Terminal.

  2. Start the Admin Server with the following command.

    cd ~/Oracle/Middleware/Oracle_Home/user_projects/domains/test_domain/
    ./startWebLogic.sh

  3. Log in to the WebLogic Administration Console.

    Click Activities and open the Chrome browser. In Chrome go to the following URL.

    http://localhost:7001/console/login/LoginForm.jsp

    You can see the WebLogic Server version. Log in using the following credentials and click Login.

    Username:

    weblogic

    Password:

    Welcome1%

  4. To view available servers, expand Environment and click Servers. You can see one admin server, one dynamic cluster with 5 managed servers.

  5. To view the data sources, expand Services and click Data Sources.

  6. To view the deployed application, click Deployment. You can see opdemo as deployed application.

  7. Opening the base WKT UI Project.

    For simplicity of the lab, we created base_project.wktproj, which presets the location of Docker, Java, Oracle Home and the Primary Image Tag.

    Click Activities and then select WebLogic Kubernetes Toolkit UI.

  8. Check the box for stop showing this introduction at startup and click OK.

  9. To open base_project.wktproj project, click File -> Open Project.

  10. Select the base_project.wktproj inside the Downloads folder and then click Open Project.

  11. Enter welcome1 as password and then click Unlock.

  12. Perform introspection of an on-premises domain, which creates a model file consisting of the domain configuration.

    In WebLogic Kubernetes Toolkit UI, Click File -> Add Model -> Discover Model(offline).

  13. Click the folder icon to open the Domain Home.

  14. In the Home folder, navigate to /home/opc/Oracle/Middleware/Oracle_Home/user_projects/domains/ directory and select test-domain folder then click Select.

    Click OK.

    If you look in the console, you will see that this invokes WebLogic Deployer Tool to introspect the domain configuration in offline mode.

  15. Click Model to view the model.

    The result of this WDT introspection are model(a metadata representation of your domain configuration), placeholder, where you can specify the values (such as password for data source) and application in the application archive.

  16. Validate the model and prepare the model to be deployed on Oracle Kubernetes Cluster (OKE).

    To Validate the model, click Validate Model.

    NOTE

    Validate model invokes the WDT Validate Model Tool , which validates that the model and its related artifacts are well formed and provides help on the valid attributes and subfolder for a particular model location.

  17. Once you see Validate Model Complete window, click Ok.

  18. To prepare the model to be deployed on Kubernetes cluster, click Prepare Model.

    NOTE

    Prepare model invokes the WDT Prepare Model Tool to modify the model to work in a Kubernetes cluster with WebLogic Kubernetes Operator or Verrazzano installed.

  19. Once you see Prepare Model Complete window, click Ok.


Congratulations on completing this task!

Click Next to continue.


Task 3: Create Auxiliary Image and Push it to the Container Registry

Introduction

Primary Image - the image containing the Oracle Fusion Middleware software. It is used as the basis of all containers that run WebLogic Servers for the domain.

Auxiliary Image - the image that supplies the WebLogic Deploy Tooling software and the model files. At runtime, the auxiliary image’s content is merged with the primary image’s content.

In this task, we specify WebLogic server 12.2.1.4.0-ol8 image as Primary Image. Create an auxiliary image, and push it to Oracle Container Image Registry repository using the generated authentication token.

  1. Creating an Auxiliary image, which we will push to the Oracle Cloud Container Registry.

    In the WKT UI, click Image. We have already preset Image Tag with container-registry.oracle.com/middleware/weblogic:12.2.1.4-ol8.

    NOTE

    The primary image is the one used for running the domain. One primary image can be reused for hundreds of domains. The primary image contains the OS, JDK, and FMW software installations.

  2. Click the tab Auxiliary Image. From the text file, enter the value, all in lower case, of the following:

    Auxiliary ParameterValue from the text file
    Auxiliary Image TagAuxiliary Image Tag
    Auxiliary Image Registry Push UsernameImage Registry Username
    Auxiliary Image Registry Push PasswordOCI Auth Token

    Click Create Auxiliary Image when done.

    For example

    These values are for reference only and will not work for you.

    ParameterValue
    Auxiliary Image Tagiad.ocir.io/abcdefghi/test-model-ankit:v1
    Auxiliary Image Registry Push Usernameabcdefghi/oracleidentitycloudservice/luna.user@64ae32bc-abcde-abcd-abcd-abcdeabcde
    Auxiliary Image Registry Push Passwordabcdeabcdeabcdeabcde

    As we have already prepared the model, click No.

    Select Downloads folder where we want to save WebLogic Deployer and click Select.

    Once Auxiliary images is successfully created, click Ok.

  3. Click Push Auxiliary Image to push the image to your OCI Registry.

    Once the image is successfully pushed, click Ok.

    NOTE

    An auxiliary image is domain-specific and contains the data that defines the domain.


Congratulations on completing this task!

Click Next to continue.


Task 4: Deploy WebLogic Operator to Oracle Kubernetes Cluster (OKE)

We will use kubectl to manage the cluster remotely using the Local Access.

Once we verify the connectivity to Kubernetes cluster from the WebLogic Kubernetes Toolkit UI, we will install the WebLogic Kubernetes Operator to Kubernetes cluster(OKE).

  1. Configure kubectl from the virtual machine.

    Create the configuration file .oci/config and .kube/config in /home/opc directory to access Oracle Kubernetes Cluster (OKE) from the virtual machine.

    In the virtual machine (Go to TigerVNC Viewer) open Chrome with the following URL.

    https://cloud.oracle.com/
  2. Enter the Luna tenancy name as Cloud Account Name.

    Note

    If the Next button is not enabled, remove the spaces from your Cloud Account Name.

  3. In single sign-on page, click Continue.

  4. Sign in using the username and password from the text file.

  5. Click User Icon -> User Settings.

  6. Scroll down, click API Keys and then click Add API Key.

  7. Select Generate API Key Pair and then click Download Private Key and Download Public Key. When done, click Add.

  8. Click Copy and paste it to your text file.

  9. Find the location of Private key and paste it in your text file.

    Go to the Terminal and click File -> New tab.

    In the terminal, list the Download folder to obtain the private key file name.

    ls Downloads

    Copy and paste the private key file name with the full path name in to your text file.

     /home/opc/Downloads/<keyfile name>

    Full path of the key file.

  10. Create the .oci/config file.

    In the terminal, go to the new tab and copy and paste the following command.

    mkdir .oci
    vi ~/.oci/config

    In command mode press i to insert text.

    Copy the content of the text (just the config part).

    Right-click vi and click paste.

    Press Escape key and enter :wq to save and exit vi.

  11. Copy and paste the following command to change the permission of oci/config and private key files.

    chmod 600 ./.oci/config 
    chmod 600 ./Downloads/*.pem
  12. In the Cloud console go to Kubernetes Clusters (OKE).

  13. Select the correct compartment name and then click cluster1.

  14. Click Access Cluster.

  15. Select Local Access, VCN-Native Public endpoint and click Copy.

  16. Paste this command in terminal to create the .kube/config file.

  17. Verify the connectivity to Oracle Kubernetes Cluster(OKE) from the WebLogic Kubernetes Toolkit UI application.

    Go to the WebLogic Kubernetes Tool Kit UI, click Kubernetes -> Client Configuration and then click Verify Connectivity.

    Once you see Verify Kubernetes Client Connectivity Success window, Click Ok.

  18. Install the WebLogic Kubernetes Operator to the Cluster.

    Click WebLogic Operator and click Install Operator leaving all the parameters the default value.

    Once you see WebLogic Kubernetes Operator Installation Complete, Click Ok.


Congratulations on completing this task!

Click Next to continue.


Task 5: Deploy WebLogic Domain to Oracle Kubernetes Cluster (OKE)

Deploy the Kubernetes custom resource for the WebLogic domain to Kubernetes Cluster.

  1. Go to the WebLogic Kubernetes Tool Kit UI, click WebLogic Domain and scroll to the Primary Image to Use for the Domain section.

    Use the same credentials used to accept license for weblogic images in Oracle Container Registry. Enter the following.

    1. Oracle account username (same as email address) in Image Registry Pull Username

    2. Your password in Image Registry Pull Password

    3. Your Oracle email address in Image Registry Pull Email Address

    NOTE

    We are pulling the image from the Oracle Container Registry, so we are specifying the credentials, which we used to accept the license agreement for WebLogic Server Images.

  2. In the section Auxiliary Image to Use for the Domain, uncheck Specify Auxiliary Image Pull Credentials.

  3. In the Clusters section, click Edit icon.

    Enter 2 as Replicas and then Click OK.

    NOTE

    The size of replica decides the number of managed server in the Running state after successful deployment of WebLogic Domain to Kubernetes cluster.

  4. In the Secrets section, enter the two passwords.

    Double-click each password box and enter tiger as the password for both data source entries. Click Deploy Domain when done.

    NOTE

    This will deploy the WebLogic Domain test-domain to Kubernetes namespace test-domain-ns.

  5. Click OK when WebLogic Domain Deployment to Kubernetes Complete window appears.

  6. Check the domain is running.

    Go to the terminal and run the following command.

    kubectl get pods -n test-domain-ns -w

    You should see the pod for introspectors in the Running status first, followed by the admin Servers, and then the managed servers.

    After a while the pods are in running status.

    Leave the command to continue to run as we will monitor the output from it later.

  7. You can also get the domain status through WebLogic Kubernetes Toolkit UI.

    Go to WebLogic Kubernetes Toolkit UI and click Get Domain Status. In Domain Status window, scroll down to see status of all server pods then click OK.


Congratulations on completing this task!

Click Next to continue.


Task 6: Deploy Ingress Controller to Oracle Kubernetes Cluster (OKE)

In this task, we install the Traefik Ingress Controller and updates the Ingress Routes to access the application and admin server.

  1. Install Ingress Controller to the Oracle Kubernetes Cluster.

    Go to the WebLogic Kubernetes Tool Kit UI, click Ingress Controller, leave the default values and click Install Ingress Controller.

    NOTE

    This successfully installs the traefik-operator ingress controller to Kubernetes namespace traefik-ns.

    Ingress Controller Installation was successful.

    Click Ok.

  2. Update the Ingress Routes to Access the application.

    In the Ingress Routes Configuration section click + and Edit.

  3. Enter the following details:

    ParameterValue
    Nameconsole
    Path Expression/console
    Target Service Namespacetest-domain-ns
    Target Servicetest-domain-admin-server
    Target Port7001

    When done click OK.

  4. Add another, enter the following details:

    ParameterValue
    Nameopdemo
    Path Expression/opdemo
    Target Service Namespacetest-domain-ns
    Target Servicetest-domain-cluster-cluster-1
    Target Port8001

    When done click OK.

  5. Add another for the remote-console. Enter the following details:

    ParameterValue
    Nameremote-console
    Path Expression/
    Target Service Namespacetest-domain-ns
    Target Servicetest-domain-admin-server
    Target Port7001

    When done click OK.

  6. Click Update Ingress Routes to update the Ingres Routes.

    Click Yes to overwrite.

    The Ingress Routes Update complete successfully.

    Click Ok.


Congratulations on completing this task!

Click Next to continue.


Task 7: Testing Application Deployment

This task will verify the successful migration of an offline on-premise domain and the application opdemo.

Also verify the load balancing between managed server pods, and use WebLogic Remote Console to verify the successful deployment of resources of test-domain in Kubernetes environment.

About WebLogic Remote Console

The WebLogic Remote Console is a lightweight, open-source console that you can use to manage your WebLogic Server domain running anywhere, such as on a physical or virtual machine, in a container, Kubernetes, or in the Oracle Cloud. The WebLogic Remote Console does not need to be co-located with the WebLogic Server domain.

You can install and run the WebLogic Remote Console anywhere, and connect to your domain using WebLogic REST APIs. You simply launch the desktop application and connect to the Administration Server of your domain. Or, you can start the console server, launch the console in a browser and then connect to the Administration Server.

The WebLogic Remote Console is fully supported with WebLogic Server 12.2.1.3, 12.2.1.4, and 14.1.1.0.

Key Features of the WebLogic Remote Console

  • Configure WebLogic Server instances and clusters
  • Create or modify WDT metadata models
  • Configure WebLogic Server services, such as database connectivity (JDBC), and messaging (JMS)
  • Deploy and undeploy applications
  • Start and stop servers and applications
  • Monitor server and application performance
  1. Verify the opdemo application.

    Go to the WebLogic Kubernetes Tool Kit UI, click Ingress Controller. In the Ingress Routes Configuration table click the URL for opdemo.

  2. Verify load balancing between the two managed server pods.

    In the browser append the following to the opdemo URL.

    ?dsname=testDatasource

    Click refresh and you will see the hostname change.

    Make a note of the IP address and paste it in the text file. Leave this page open, we will use it later.

  3. Verify the successful migration of an on-premise domain into the Oracle Kubernetes Cluster.

    Create connection to Admin Server in Remote Console and verify the resources in WebLogic Domain.

    To open WebLogic Remote Console, go to the VNC desktop, click Activities and select the WebLogic Remote Console.

  4. Click the Three dots in the Kiosk window and then Add Admin Server Connection Provider.

    Enter the following details:

    ParameterValue
    Connection Provider NameKubernetesEnv
    Usernameweblogic
    Passwordwelcome1
    URLhttp://<IP address of the opdemo URL>

    When done click OK.

  5. To display the list of Java EE application.

    Go to Configuration Tree --> Deployments --> App Deployments.

  6. To display the JDBC data source objects.

    Go to Configuration tree --> Services --> Data Sources.

  7. To display the WebLogic version.

    Go to Monitoring Tree --> Environment --> Servers.

    Note the Admin Server and the Managed Server are running.

    Now click admin-server, you can see version of the WebLogic.


Congratulations on completing this task!

Click Next to continue.


Task 8: Scaling a WebLogic Cluster

  1. Modify the Replica value from 2 to 3 and redeploy the domain again.

    Go back to WebLogic Kubernetes Toolkit UI, click WebLogic Domain. Go to Clusters section and click Edit icon.

  2. Change the Replicas from 2 to 3, and click OK.

  3. To Re-deploy the domain, click Deploy Domain. Once you see WebLogic Domain Deployment to Kubernetes Complete window, click Ok.

  4. Go back to Terminal window, Click Activities and select the Terminal window.

    As you can see, the redeployment of the domain starts the process of creating a pod for test-domain-managed-server3, then after a while, changes to the Running status.

  5. Go back to the browser where you have the application page opened. Click the browser Refresh button, you will see the load balancing between three managed server now.

  6. Go back to WebLogic Remote Console, click Monitoring Tree -> Running Servers. You will see the server managed-server3.


Congratulations on completing this task!

Click Next to continue.


Task 9: Making an upgrade in WebLogic Server Version

In this task you will upgrade the WebLogic version from 12.2.1.4-ol8 to 12.2.1.4-slim-ol8.

To modify the primary image, use WebLogic Server Image with 12.2.1.4-slim-ol8 tag. Then we re-deploy the domain using WebLogic Kubernetes Toolkit UI.

Lastly, we verify that newly managed server pods are using the updated WebLogic Server images through WebLogic Remote Console.

  1. Update the primary image.

    Go back to the WebLogic Kubernetes Toolkit UI, click WebLogic Domain. Change the Primary Image Tag to 12.2.1.4-slim-ol8.

    12.2.1.4-slim-ol8

    The Primary Image Tag is changed.

  2. Re-deploy the domain.

    Click WebLogic Domain -> Deploy Domain. This will re-deploy the domain.

    As we changed our primary image, we will notice rolling restart of all the servers, one by one.

    As you click Deploy Domain, it start an Introspector job. It terminates the running admin server pods, and creates a new pod for admin server.

    The introspector does the same process with both the managed servers.

  3. Once you see the WebLogic Domain Deployment to Kubernetes Complete window, click Ok.

  4. Monitor the progress of the deployment.

    Go back to the Terminal and execute the following command several times.

    kubectl get pods -n test-domain-ns -w

    You will notice the rolling restart of all the servers.

  5. Check the version of the deployed pods.

    In the Terminal execute the following command.

    kubectl describe pods test-domain-admin-server -n test-domain-ns | grep 'Image'

    The new image is being used.

  6. Verify the version of WebLogic.

    Click Monitoring Tree icon and then select Running Servers -> admin-server.

    The WebLogic version is displayed.


Congratulations on completing this task!

This is the end of the lab.


Before you close your browser completely, do tell us what you think about this lab.

  1. Firstly, click the End Session icon on the Luna tool bar.

  2. Then click this icon to send us your feedback. Thanks you!

2023-03-28T08:27:12.134Z