https://github.com/freedomben/basic-ocp-demo
Sample app that can be easily deployed to OpenShift either as a training exercise or demonstration.
https://github.com/freedomben/basic-ocp-demo
Last synced: 8 months ago
JSON representation
Sample app that can be easily deployed to OpenShift either as a training exercise or demonstration.
- Host: GitHub
- URL: https://github.com/freedomben/basic-ocp-demo
- Owner: FreedomBen
- Created: 2020-10-05T15:46:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-25T22:59:48.000Z (about 5 years ago)
- Last Synced: 2025-08-18T04:30:29.826Z (10 months ago)
- Language: Shell
- Homepage:
- Size: 71.3 KB
- Stars: 1
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sample Demo app for OpenShift
_For an introduction to `oc` and a detailed walk through of deploying this application, see [Introduction to “oc” — the OpenShift Command Line Power Tool](https://freedomben.medium.com/introduction-to-oc-the-openshift-command-line-power-tool-cdcd399b4048?sk=125cc573ea371d91b7eb922cf3193f57). If Medium's paywall blocks the article for you, make sure you use **the exact link provided** and it will get you around the paywall. (Often people go to share the article with others and will copy/paste from their browser. Don't do that because medium will redirect away from the paywall-skipping link above. If you're sharing the link with other, use [this one (same as above)](https://freedomben.medium.com/introduction-to-oc-the-openshift-command-line-power-tool-cdcd399b4048?sk=125cc573ea371d91b7eb922cf3193f57))_
## Using s2i / oc new-app
```bash
# Development environment
oc new-project basic-ocp-demo-development
oc new-app https://github.com/FreedomBen/basic-ocp-demo#development
oc expose svc basic-ocp-demo
# Production environment
oc new-project basic-ocp-demo-production
oc new-app https://github.com/FreedomBen/basic-ocp-demo#production
oc expose svc basic-ocp-demo
```
## Deploying from YAML
There are YAML files available in the `deploy` directory that can be used to deploy.
```bash
oc new-project basic-ocp-demo-project
# Create (deploy) resources
oc apply -f deploy/basic-ocp-demo.yaml
# To delete resources
oc delete all -l app=basic-ocp-demo
```
Some things you can do to get familiar:
```bash
# Let's look at the pods that got created
oc get pods
# Using the pod name above, let's get a human readable description
# Your pod name will vary a bit from mine
oc describe pods basic-ocp-demo-554ddd794f-9zwnw
# Let's see that pod in YAML form
oc get pods basic-ocp-demo-554ddd794f-9zwnw -o yaml
# You can save this off for later use
oc get pods basic-ocp-demo-554ddd794f-9zwnw -o yaml | tee basic-ocp-demo-pod.yaml
# Tweak the deployment YAML somehow and redeploy it
# This is idempotent (Only things that changed will be updated)
oc apply -f deploy/basic-ocp-demo.yaml
# Edit a resource directly and see the change take effect
# If you need a usggestion try deleting the `tls` key section and see
# that the route turns HTTP only (load balancers on your cluster must
# support this for it to work)
oc edit route basic-ocp-demo
# Now undo your chagne by redeploying. Note that only the resource you
# changed gets updated
oc apply -f deploy/basic-ocp-demo.yaml
# rsh into the pod and curl it locally
oc rsh basic-ocp-demo-554ddd794f-9zwnw
sh-4.4$ curl localhost:4567/healthz
{"ok":true,"datetime":"2021-01-04 22:36:28 UTC"}
# Get a debug shell in a Pod. Your pod name will be slightly different
oc debug basic-ocp-demo-554ddd794f-9zwnw
# Try out oc explain
oc explain deployment.spec.template.spec.containers.ports
```