Chapter 5. Creating sample applications with .NET 8.0
5.1. Creating the MVC sample application Copy linkLink copied to clipboard!
s2i-dotnetcore-ex is the default Model, View, Controller (MVC) template application for .NET.
This application is used as the example application by the .NET S2I image and can be created directly from the OpenShift UI using the Try Example link.
The application can also be created with the OpenShift client binary (oc).
Procedure
To create the sample application using oc:
Add the .NET application:
$ oc new-app dotnet:8.0-ubi8~https://github.com/redhat-developer/s2i-dotnetcore-ex#dotnet-8.0 --context-dir=appMake the application accessible externally:
$ oc expose service s2i-dotnetcore-exObtain the sharable URL:
$ oc get route s2i-dotnetcore-ex
5.2. Creating the CRUD sample application Copy linkLink copied to clipboard!
s2i-dotnetcore-persistent-ex is a simple Create, Read, Update, Delete (CRUD) .NET web application that stores data in a PostgreSQL database.
Procedure
To create the sample application using oc:
Add the database:
$ oc new-app postgresql-ephemeralAdd the .NET application:
$ oc new-app dotnet:8.0-ubi8~https://github.com/redhat-developer/s2i-dotnetcore-persistent-ex#dotnet-8.0 --context-dir appAdd environment variables from the
postgresqlsecret and database service name environment variable:$ oc set env dc/s2i-dotnetcore-persistent-ex --from=secret/postgresql -e database-service=postgresqlMake the application accessible externally:
$ oc expose service s2i-dotnetcore-persistent-exObtain the sharable URL:
$ oc get route s2i-dotnetcore-persistent-ex