Chapter 3. Deploying applications with OpenShift Client
You can use OpenShift Client (oc) for application deployment. You can deploy applications from source or from binary artifacts.
3.1. Deploying applications from source using oc Copy linkLink copied to clipboard!
The following example demonstrates how to deploy the example-app application using oc, which is in the app folder on the dotnet-8.0 branch of the redhat-developer/s2i-dotnetcore-ex GitHub repository:
Procedure
Create a new OpenShift project:
oc new-project sample-project
$ oc new-project sample-projectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the ASP.NET Core application:
oc new-app --name=example-app 'dotnet:8.0-ubi8~https://github.com/redhat-developer/s2i-dotnetcore-ex#dotnet-8.0' --build-env DOTNET_STARTUP_PROJECT=app
$ oc new-app --name=example-app 'dotnet:8.0-ubi8~https://github.com/redhat-developer/s2i-dotnetcore-ex#dotnet-8.0' --build-env DOTNET_STARTUP_PROJECT=appCopy to Clipboard Copied! Toggle word wrap Toggle overflow Track the progress of the build:
oc logs -f bc/example-app
$ oc logs -f bc/example-appCopy to Clipboard Copied! Toggle word wrap Toggle overflow View the deployed application once the build is finished:
oc logs -f dc/example-app
$ oc logs -f dc/example-appCopy to Clipboard Copied! Toggle word wrap Toggle overflow The application is now accessible within the project.
Optional: Make the project accessible externally:
oc expose svc/example-app
$ oc expose svc/example-appCopy to Clipboard Copied! Toggle word wrap Toggle overflow Obtain the shareable URL:
oc get routes
$ oc get routesCopy to Clipboard Copied! Toggle word wrap Toggle overflow
3.2. Deploying applications from binary artifacts using oc Copy linkLink copied to clipboard!
You can use .NET Source-to-Image (S2I) builder image to build applications using binary artifacts that you provide.
Prerequisites
Published application.
For more information, see
Procedure
Create a new binary build:
oc new-build --name=my-web-app dotnet:8.0-ubi8 --binary=true
$ oc new-build --name=my-web-app dotnet:8.0-ubi8 --binary=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow Start the build and specify the path to the binary artifacts on your local machine:
oc start-build my-web-app --from-dir=bin/Release/net8.0/publish
$ oc start-build my-web-app --from-dir=bin/Release/net8.0/publishCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new application:
oc new-app my-web-app
$ oc new-app my-web-appCopy to Clipboard Copied! Toggle word wrap Toggle overflow