Community
Search Options
Search Options
Log in
Skip to main content (Press Enter).
Sign in
Skip auxiliary navigation (Press Enter).
Data Management
Topic areas
Data Management Global
Db2
Db2 for z/OS and its ecosystem
Db2 Tools for z/OS
Informix
Integrated Analytics Systems
Netezza Performance Server
Open Source Offerings
Champions
User groups
Data management user groups
All user groups
Events
TechXchange Conference
Upcoming Data Management Events
IBM TechXchange Webinars
All IBM TechXchange Community Events
Participate
Gamification Program
Post to Forum
Share a Resource
Share Your Expertise
Blogging on the Community
All IBM TechXchange Community Users
Resources
IBM TechXchange Group
IBM Cloud Support
IBM Documentation
IBM Support
IBM Support 101
IBM Technology Zone
IBM Training
TechXchange Conference
Marketplace
Marketplace
IBM 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.
Ask a question
Nominate for the IBM Champions program by 15 November!
Skip main navigation (Press Enter).
Toggle navigation
Search Options
Data Management User Groups
Data Management Global
View Only
Group Home
Discussion
455
Library
59
Blogs
146
Events
1
Members
6.3K
Share
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.
#AWS
#DataManagementGlobal
#DataServerDrivers
#Openshift
#RedHat
2 comments
35 views
Permalink
Comments
Srihari Varma Mudunuru
Fri January 06, 2023 05:47 AM
Can we use the driver IBM Data Server Driver for ODBC and CLI (Linux AMD64 and Intel EM64T) - in the docker container for our Dot Net Core application to connect connect DB2 v11.5 Database on ZOS . If yes, can you please provide steps or sample docker file to use it?
Ashok Shettigar
Wed September 14, 2022 12:42 AM
If we are using S2I for build, how will we update the PATH?
IBM Community Home
Browse
Discussions
Resources
Groups
Events
IBM TechXchange Conference 2023
IBM Community Webinars
All IBM Community Events
Participate
Gamification Program
Community Manager's Welcome
Post to Forum
Share a Resource
Blogging on the Community
All IBM Community Users
Resources
Community Front Porch
IBM Champions
IBM Cloud Support
IBM Documentation
IBM Support
IBM Technology Zone
IBM Training
Marketplace
Marketplace
Data Management
Topic areas
Data Management Global
Db2
Db2 for z/OS and its ecosystem
Db2 Tools for z/OS
Informix
Integrated Analytics Systems
Netezza Performance Server
Open Source Offerings
Champions
User groups
Data management user groups
All user groups
Events
TechXchange Conference
Upcoming Data Management Events
IBM TechXchange Webinars
All IBM TechXchange Community Events
Participate
Gamification Program
Post to Forum
Share a Resource
Share Your Expertise
Blogging on the Community
All IBM TechXchange Community Users
Resources
IBM TechXchange Group
IBM Cloud Support
IBM Documentation
IBM Support
IBM Support 101
IBM Technology Zone
IBM Training
TechXchange Conference
Marketplace
Marketplace
Powered by Higher Logic