Author: Kyle Bassett


This is Part 2 of my blog on the OpenShift CDK - You can find Part 1 here > Productive Developer Tools - Deploying OpenShift “Container Development Kit”. Now it’s time to start looking at some real application use cases that we can test inside our CDK environment. Let’s talk about ASP.NET and give it a test drive using the CDK.

So I know many people said this would never happen… back in the day we did some crazy stuff using WINE but let’s be honest it never really caught on. Personally I feel the recent announcement of being able to run your Microsoft Windows ASP.NET applications on RHEL inside OpenShift containers is going to be a real game changer for organizations. Arctiq plans to get ahead of this curve as we feel the business case is very strong and the timing is perfect.

Many customers we work with have lots of .NET applications they want to modernize and benefit from the same level of automation as their Linux based workloads. Most of those same customers also maintain lots of dedicated infrastructure for these applications. This not only requires lots of capital but also makes it very difficult to move those applications to cloud based services. The resource requirements are just too demanding to drive real cost efficiency, not to mention the Windows OS license requirements.

Since we can now deploy our ASP.NET applications inside OpenShift the game has changed. We can benefits for all the platform automation and integration that OpenShift provides. Continuous Delivery and Integration can be achieved with little effort and your perviously “Windows Only” based workloads can now be managed just like your Linux based applications.

Ok now let’s get into the technical aspect of this Blog post so you can try it yourself:

Go ahead and install Git command line tools, follow this guide :

https://github.com/blog/1510-installing-git-from-github-for-mac

https://desktop.github.com/

Let go into the same directory we used in the last blog:

pwd
/Users/kylebassett/openshift-cdk

Go ahead and run this command, if you don’t have xcode installed it will prompt you. Let’s run - git clone :

git clone https://github.com/openshift-s2i/s2i-aspnet-example
cloning into 's2i-aspnet-example'...
remote: Counting objects: 137, done.
remote: Total 137 (delta 0), reused 0 (delta 0), pack-reused 137
Receiving objects: 100% (137/137), 71.39 KiB | 0 bytes/s, done.
Resolving deltas: 100% (48/48), done.
Checking connectivity... done.
oc login 10.1.2.2:8443
Authentication required for https://10.1.2.2:8443 (openshift)
Username: admin
Password:
Login successful.
Create a new project:
oc create project dotnet
Change to your net project
oc project dotnet
Now using project "dotnet" on server "https://10.1.2.2:8443".

After logging into an OpenShift environment and creating or using an existing project, create a new application which combines the ASP.NET S2I builder and the sample application from this repository

oc new-app registry.access.redhat.com/dotnet/dotnetcore-10-rhel7~https://github.com/openshift-s2i/s2i-aspnet-example --context-dir=app --name=aspnet-app
--> Found Docker image 9610e47 (11 weeks old) from registry.access.redhat.com for "registry.access.redhat.com/dotnet/dotnetcore-10-rhel7"
 .NET Core 1.0   -------------
Platform for building and running .NET Core 1.0 applications
Tags: builder, .net, dotnet, dotnetcore, rh-dotnetcore10
   * An image stream will be created as "dotnetcore-10-rhel7:latest" that will track the source image
   * A source build using source code from https://github.com/openshift-s2i/s2i-aspnet-example will be created
   * The resulting image will be pushed to image stream "aspnet-app:latest"
   * Every time "dotnetcore-10-rhel7:latest" changes a new build will be triggered
   * This image will be deployed in deployment config "aspnet-app"
   * Ports 8080/tcp, 8081/tcp will be load balanced by service "aspnet-app"
   * Other containers can access this service through the hostname "aspnet-app"
--> Creating resources with label app=aspnet-app ...
   imagestream "dotnetcore-10-rhel7" created
   imagestream "aspnet-app" created
   buildconfig "aspnet-app" created
   deploymentconfig "aspnet-app" created
   service "aspnet-app" created
--> Success

Build scheduled, use ‘oc logs -f bc/aspnet-app’ to track its progress. Run ‘oc status’ to view your app. Create a new route so that the application is accessible outside the OpenShift environment

oc expose service aspnet-app
route "aspnet-app" exposed

Login to the OpenShift WebUi and have a look at your new project: Go into your dotnet project and you will see the build happening. You can also view the log.

Also have a look at the Events

Use a template to build and deploy a sample application

A template has been provided to simplify the build and deployment of a ASP.NET application on OpenShift. The template is located in the templates folder in a file called aspnet-s2i-template.json.

After logging into an OpenShift environment and creating or using an existing project, add the template to the project

oc create -f templates/aspnet-s2i-template.json
template "aspnet-s2i" created

Alternately, the template can be added to the openshift project so that it will be visible by all users. Using a user with permissions to modify resources in the openshift project, execute the following command:

oc create -f templates/aspnet-s2i-template.json -n openshift
template "aspnet-s2i" created

Have a look at your application (Note the service link provided in the UI)

You can go ahead and scale your “pods” to 3

You can also now see you aspnet application container part of your project list:

Have a look at your application (click on the link provided in the UI we noted above) WOW - You are running a .NET application inside a Linux Container

Let’s go ahead and create another project from your new template:

oc project dotdotnet

Now using project “dotdotnet” on server “https://10.1.2.2:8443”. Deploy your new application:

oc new-app --template=aspnet-s2i -p GIT_URI=https://github.com/openshift-s2i/s2i-aspnet-example,GIT_CONTEXT_DIR=app
--> Deploying template "aspnet-s2i" in project "openshift" for "aspnet-s2i"
    With parameters:
     Application Name=aspnet-app
     Git URI=https://github.com/openshift-s2i/s2i-aspnet-example
     Git Branch=master
     Git Context Directory=app
     Application hostname=
     Upstream S2I Image=registry.access.redhat.com/dotnet/dotnetcore-10-rhel7
     Upstream S2I Image Tag=latest
     GitHub Webhook Secret=8FFLgXmt # generated
     Generic Webhook Secret=ckCbVsfQ # generated
--> Creating resources with label app=aspnet-app ...
   imagestream "aspnet-app" created
   imagestream "s2i-aspnet" created
   service "aspnet-app" created
   buildconfig "aspnet-app" created
   deploymentconfig "aspnet-app" created
   route "aspnet-app" created
--> Success

Build scheduled, use ‘oc logs -f bc/aspnet-app’ to track its progress. Run ‘oc status’ to view your app.

You can see you new application in the OpenShift UI.

I hope you enjoyed seeing the possibilities of what you can now do containerizing you ASP.NET applications. If you experienced any issues just let me know.

Tagged:



//comments