Welcome to the IBM Community, a place to collaborate, share knowledge, & support one another in everyday challenges. Connect with your fellow members through forums, blogs, files, & face-to-face networking.
Log in
Search Options
Search Options
Skip to main content (Press Enter).
Sign in
Skip auxiliary navigation (Press Enter).
Hybrid Data Management
Topic groups
HDM Global
Db2 (On Premises and Cloud)
Db2 Analytics Accelerator for z/OS
Db2 Early Access Program (EAP) Forum
Db2 for z/OS
Db2 Tools for z/OS
IBM Data Virtualization Manager for z/OS
IBM Query Management Facility (QMF)
Informix
Integrated Analytics Systems
Netezza Performance Server
Open Source Offerings
User groups
Events
Upcoming Hybrid Data Management Events
On Demand Webinars
IBM Expert TV
Virtual Community Events
All IBM Community Events
Participate
Gamification Program
Post to Forum
Share a Resource
Blogging on the Community
Connect with Hybrid Data Management Users
All IBM Community Users
Resources
Community Front Porch
IBM Champions
IBM Cloud Support
IBM Documentation
IBM Support
IBM Technology Zone
IBM Training
Marketplace
Marketplace
IBM Hybrid Data Management Community
Connect with Db2, Informix, Netezza, open source, and other data experts to gain value
from your data, share insights, and solve problems
Join / Log in
Skip main navigation (Press Enter).
Toggle navigation
Search Options
User Groups
User Group Tag Test
IBM Data Server Drivers (Db2 Connect Client)
View Only
Group Home
Discussion
88
Library
3
Blogs
24
Events
0
Members
116
Back to Blog List
Deploying Db2 .NET Core application on Red Hat Openshift environment
By
Hosathota Vishwanatha
posted
Thu December 02, 2021 05:38 AM
0
Like
By following few simple steps as detailed below, a simple Db2 .NET Core application can be deployed on Red Hat Openshift environment.
1. First create a simple .NET Core 3.1 Console application in Visual Studio and name it as DockerTester
2. Set the project configuration to x64.
3. Using Manage Nuget Packages option in the project, add IBM.Data.DB2.Core-lnx, the Db2 .NET Core package for linux
4. Next add a docker file into the project and include following code in it
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/runtime:3.1 AS base
WORKDIR /app
#Setting LD_LIBRARY_PATH is critical for Db2 .NET driver to work and setting it like below works for normal docker scenario
#but it has to be set through Build Configs in Openshift environment as detailed later
#ENV LD_LIBRARY_PATH="/app/clidriver/lib"
#ENV LD_LIBRARY_PATH="/app/bin/x64/Debug/netcoreapp3.1/clidriver/lib"
RUN apt-get -y update && apt-get install -y libxml2
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["DockerTester.csproj", "."]
RUN dotnet restore "./DockerTester.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "DockerTester.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "DockerTester.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
#Env PATH=$PATH:"/app/bin/x64/Debug/net5.0/clidriver/bin:/app/bin/x64/Debug/net5.0/clidriver/lib"
Env PATH=$PATH:"/app/bin/x64/Debug/netcoreapp3.1/clidriver/lib:/app/bin/x64/Debug/netcoreapp3.1/clidriver/lib"
ENTRYPOINT ["dotnet", "DockerTester.dll"]
5. As indicated in the comment section in the above docker file, setting of LD_LIBRARY_PATH has no effect on Openshift containers and it has to be set through Build Config inside Openshift project.
6. Put the above code into a git repository. As an example the following public git repository has a simple console application
https://github.com/hosathota/db2dotnetdocker
7. Now login to AWS Openshift cluster and Add an application. For this example since we have already created a project in git, lets choose the git option as shown below
8. Specify the Git repository and choose .NET as the template to create application. The example uses the sample repository https://github.com/hosathota/db2dotnetdocker. Ideally the code should come from a local repository and it should have appropriate code.
9. Select .NET Core 3.1 RHEL image and specify an application name.
10. We need to provide one critical configuration at this stage and that is to make a build configuration entry to set the LD_LIBRARY_PATH.
11. Click on the Build configuration to open the Build Configuration dialog.
The value specified for LD_LIBRARY_PATH is based on the location of the clidriver inside the deployed container. If it is different from the above, please specify the appropriate path. Click on the Create option to create the application.
12. The created application will be visible in the Topology view with three circles to build/edit code/see the output
13. Click on the application at the center of the above screen to see further options for this application. Use the Start Build option to build the image anytime. The image will be built using the code from the specified repository. In case of any build error it will be displayed at the right hand side.
14. If a build is successful, the build status and Pod status will be displayed above the Start Build option.
15. In case of any Pod error, click on the View Logs option to open the log file
16. Since the code is in public git, the actual server details are missing and it is resulting in a Pod crash.
At Step 8 above, by providing a correct repository with working code in it, the steps detailed above can be followed to deploy a Db2 .NET Core application into Red Hat Openshift environment.
The above steps are for detailing the minimum configuration needed to deploy a sample db2 .NET Core application to Openshift environment. Further configuration or deployment options are not covered in this example.
#Openshift
#.net
#dotnetcore
#AWS
#RedHat
0 comments
5 views
Permalink
Hybrid Data Management
Topic groups
HDM Global
Db2 (On Premises and Cloud)
Db2 Analytics Accelerator for z/OS
Db2 Early Access Program (EAP) Forum
Db2 for z/OS
Db2 Tools for z/OS
IBM Data Virtualization Manager for z/OS
IBM Query Management Facility (QMF)
Informix
Integrated Analytics Systems
Netezza Performance Server
Open Source Offerings
User groups
Events
Upcoming Hybrid Data Management Events
On Demand Webinars
IBM Expert TV
Virtual Community Events
All IBM Community Events
Participate
Gamification Program
Post to Forum
Share a Resource
Blogging on the Community
Connect with Hybrid Data Management Users
All IBM Community Users
Resources
Community Front Porch
IBM Champions
IBM Cloud Support
IBM Documentation
IBM Support
IBM Technology Zone
IBM Training
Marketplace
Marketplace
Copyright © 2020 IBM Data Science Community. All rights reserved.
Powered by Higher Logic