Demo .NET Core 2.1 generic host background application running in OpenShift. Application pulls messages from Azure Service Bus and writes them to the console log.
- .NET Core
- Generic Host
- Configuration
- Hosted Services
- OpenShift
- Config Map
- Secrets
- Deployment Config
- Namespaces/Projects
- OC CLI
- install Docker for Windows (use Linux containers)
- install Visual Studio Code
oc cluster up
- create Azure Service Bus Queue
- Configure
MessageProcessor.ConnectionString
in appsettings.Development.json - Configure
MessageProcessor.QueueName
in appsettings.json
- Configure
- (optional) install the dotnet-azsb (Azure Service Bus CLI). Provides the ability to create SaS tokens used to post http messages to the queue.
- dotnet azsb queue sas create -n -k /messages
- Get registry url:
- login to OpenShift CLI as admin:
oc login -u System:admin
oc get svc -n default | grep registry
- login to OpenShift CLI as admin:
- Get OpenShift access token:
- login to OpenShift CLI as developer:
oc login -u developer -p test
oc whoami -t
- login to OpenShift CLI as developer:
- Login to OpenShift registry:
docker login -u developer -p k5iGmgVEj_O3Rx9JYOLC2ivoFoK1uTtkC-rqg25RSWw 172.30.1.1:5000
- Create project:
oc new-project myproject
- Build image:
docker-compose build
- Tag image for OpenShift:
docker tag samplehosting:latest 172.30.1.1:5000/myproject/samplehosting:1.0.0
- Push to registry:
docker push 172.30.1.1:5000/myproject/samplehosting:1.0.0
- Apply config map:
oc apply -f secrets.yml
- Apply secrets:
oc apply -f configmap.yml
- Apply app
- via UI
- create OpenShift app from image:
oc new-app myproject/samplehosting --name=mysamplehosting
- create OpenShift app from image:
- via yaml
oc apply -f kubedeploy.yml -n myproject
- via UI
- Execute commands:
oc exec -it mysamplehosting-1-6mtlq /bin/bash
- Remote Shell:
oc rsh mysamplehosting-1-6mtlq
- Logs:
oc logs mysamplehosting-1-6mtlq