Quickly Deploy .NET Game on Power & x86 From the Same Source

Learn how to deploy a simple arcade-style game written for x86 with .NET using source code shared on GitHub. The same source code is used to deploy on Power with OpenShift, and Fedora on x86. Full guided instructions are provided.

Deploy .NET game on Power

Deploy .NET game on x86

Deploy on Power – GUI

Deploy .NET game using OpenShift Console – S2I & Docker file

Deploy on Power – CLI

Hands-on lab walkthrough

1. log in to OpenShift Environments

All Command Line Interfaces are expected to be on the Bastion node terminal with cecuser unless explicitly mentioned.

If you are a Windows user, Putty is a great terminal to use.
For Mac users iterm2 terminal is available to you.

Section 1. Login to OpenShift RHEL Bastion

Using your preferred terminal method (iterm2, xterm, Putty) connect to your environment via SSH using the appropriate IP, cecuser and password for your environment.

Section 2. Login to OpenShift Console

Point your browser to your OpenShift Console.

Click on the htpasswd option:

Add your user and password and Click login.

Section 3. Copy the login command for CLI use.

On the top right side, you will see the cecuser drop-down; click on it and then “Copy login command.”

Once again, click on the htpasswd option:

Add your user and password contained in step 1 and Click log in.

Click on Display Token on the top left.

You can use the oc login command whenever your Authorization is expired. You may need to use the API token to log in to the registry.

Copy the above “oc login” command and paste it into your Terminal (Putty, or iTerm)

Important: You may need these steps more than once during this training.

2. Deploy the .NET game, staying alive

This part of the demo will guide you through creating a new project, cloning the code hosted on GitHub, and building the .Net application using S2I via the command line interface. This part
of the demo will be completed using the cecuser user.

Section 1. Add the .Net Builder image.

Follow the below steps to add the .Net 7 builder image to OCP.

Log in to the OCP Bastion Server as the cecuser. Check you have the correct user. The whoami command should return cecuser.

whoami

Switch to the OpenShift project.

oc project openshift

Enable .Net S2I for ppc64le

oc create -f https://raw.githubusercontent.com/redhat-developer/s2i-dotnetcore/master/dotnet_imagestreams_ppc64le.json --as system:admin

Section 2. Deploy the application using Source to Image

Log into the OCP RHEL Bastion using cecuser credentials and install the git command line.

sudo dnf install git

Create a new OpenShift Project

oc new-project stayingalive --description="Simple Arcade Game using ASP.NET with Power" --display-name="stayingalive"

Creating the Application

oc new-app --image-stream="openshift/dotnet:7.0-ubi8"~https://github.com/paulchapmanibm/stayingalive.git
Staying Alive .NET Source Code shared publically via GitHub

Track the progress of the build

oc logs -f bc/stayingalive

Once the build is complete, you will see “Push successful”. At this point, the resulting image has successfully been pushed to your registry. Check the status of your application:

oc status

Create a Route. An OpenShift Container Platform route exposes a service at a hostname so external clients can reach it by name. To create an external route to your new application, expose the application service.

oc expose service stayingalive

View your new route

oc get route

3. Test the application

Section 1. Verify the application is running, browse the website and test the counters. Optionally, complete the survey.

Verify the Application is Running. To view your new application, paste the route location that you copied (in the previous section) into the address bar of your web browser and hit enter.

echo "The url to your new application is $(oc status | grep "http://stayingalive" | awk '{print $1}')"

Copy the above link to the game and paste it into your favourite browser to start playing the game.

Playing the .NET game

4. Wrap up

We believe in Sustainability and Cloud without lock-in. Customers may benefit from Cloud with greater sustainability, scale, security, performance, and economics when consolidating existing .NET applications from x86 to Power Systems.

You should now understand how ASP.Net Core is used to power many websites, even games. You have seen how easy it can be to deploy a basic arcade-style game on Power using the same source code written on and for the x86 platform.

Congratulations, you have added ppc64le S2I functionality to OCP and used this to simplify the deployment of an ASP.Net-based game that was written for x86 direct from GitHub to your OCP
using the command line interface.

This lesson plan takes 1 minute and 10 seconds to deploy the application when scripted.

============================================

Deploy on x86 – CLI

It’s assumed that dotnet is already installed for your Linux distribution. I have used RHEL and Fedora with the below.

Deploy .NET game from Source to x86

Change to your home directory

cd

Create build directory

mkdir build

Change to the newly created Directory

cd build

Install git

sudo dnf install git

Clone the application source from GitHub

git clone https://github.com/paulchapmanibm/stayingalive.git
The same Staying Alive .NET Source Code was used with Power

You should see a new folder created:

ls -la

Change to the new application directory

cd stayingalive

Copy the ppc64le docker file, which will be used to build the application container.

cp Dockerfile.x86 Dockerfile

Copy the ppc64le csproj file, which will be used to build the application container

cp ./stayingalive/stayingalive.csproj.x86 ./stayingalive/stayingalive.csproj

Build the application container using Podman

podman build . -t stayingalive

Confirm that both dotnet and application containers are available

podman images
podman run -p 8080:80 stayingalive

Get in touch using social media

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *