-
Use Set up your Azure Red Hat OpenShift dev environment tutorial to prepare your environment.
-
Use Create an Azure Red Hat OpenShift cluster tutorial to create your own OpenShift cluster in Azure.
-
Use Create a private container registry tutorial to create your own private container registry in Azure.
-
Enable Admin account and save its credentials for further use.
Using OpenShift CLI create a project and a service account in the cluster.
Before continue please ensure that you have successfully logged into your cluster (Get the sign in URL for your cluster):
oc login --server=[CLUSTER_URL]
After you logged in:
create_project_and_serviceaccount.sh
creates everything automatically.
Alternatively you can run the same manually:
- Create a project:
oc new-project openshifttestapp
- Create a service account for deployment:
oc create serviceaccount devops
oc policy add-role-to-user admin system:serviceaccount:openshifttestapp:devops
oc serviceaccounts get-token devops
Save the token you obtained after the last command. You will need it later.
The last part is to setup environment variables in your deployment pipelines.
Both Azure Pipelines Secrets and GitHub Actions Secrets use the same subset of environment variables:
VARIABLE NAME | VALUE |
---|---|
CONNECTIONSTRING | Server=localhost; Database=MvcOSTAContext; user id=sa; password=YOUR_DB_PASSWORD; |
DATABASENAME | MvcOSTAContext |
DATABASEPASSWORD | YOUR_DB_PASSWORD |
DATABASEUSER | sa |
REGISTRY_NAME | The private registry name you used here |
REGISTRY_USERNAME | Username of Admin account |
REGISTRY_PASSWORD | Password of Admin account |
OCTOKEN | Token of devops service account |
OCURL | Get the sign in URL for your cluster |
After all the environment variables are setted up, run the pipeline or just make a commit to the master brunch.
After the pipeline is successfully finished, run the below command to obtain a public facing URL of the application:
echo http://$(oc get route openshifttestapp-application-route -o jsonpath="{.status.ingress[0].host}")
This is a very basic example of ASP.NET Core MVC + EF Core application
runned on an OpenShift cluster along with a containerized MSSQL database.
It also demonstrates how to use both Azure Pipelines and GitHub Actions to build and deploy .NET Core applications directly to an OpenShift cluster.
🚨 IMPORTANT: This project is a Proof of Concept and provided AS IS. The only purpose this project is to demonstrate a working concept. PLEASE DO NOT USE THIS PROJECT IN YOUR PRODUCTION ENVIREMENT!
🚨 IMPORTANT: This project ships with many references to third party dependencies, verisons of wich are not controlled. Build and deployment pipelines may fail in many cases of backward compatibility breaks, network and other availability issues. PLEASE DO NOT USE THIS PROJECT IN YOUR PRODUCTION ENVIREMENT!
🚨 IMPORTANT: This example uses sa user (Server Administrator) to connect to a database. This is only on purpose to simplify the demo case. PLEASE DO NOT USE THE SA USER IN YOUR PRODUCTION ENVIREMENT!
- Azure Pipelines and GitHub Actions
- Docker and OpenShift
- Containerized MSSQL database
- EF Core Migrations
Contributions to the package are always welcome!
- Report any bugs or issues you find on the issue tracker.