Skip to content

Instantly share code, notes, and snippets.

@blues-man
Created February 8, 2022 18:40
Show Gist options
  • Save blues-man/de5c9b957cc3e7b9942603a0196d2feb to your computer and use it in GitHub Desktop.
Save blues-man/de5c9b957cc3e7b9942603a0196d2feb to your computer and use it in GitHub Desktop.
#!/bin/bash
# Project
oc new-project workshop
# Parksmap
oc policy add-role-to-user view -z default
oc new-app quay.io/openshiftroadshow/parksmap:latest --name=parksmap -l 'app=workshop,component=parksmap,role=frontend,app.kubernetes.io/part-of=workshop'
oc create route edge parksmap --service=parksmap
# Nationalparks
oc new-app java:openjdk-11-ubi8~https://github.com/openshift-roadshow/nationalparks.git --name nationalparks -l 'app=workshop,component=nationalparks,role=backend,app.kubernetes.io/part-of=workshop,app.kubernetes.io/name=java' --allow-missing-images=true
oc expose svc nationalparks
# MongoDB
oc create -f https://raw.githubusercontent.com/openshift-labs/starter-guides/ocp-4.8/mongodb-template.yaml -n workshop
oc new-app --template=mongodb-ephemeral -p DATABASE_SERVICE_NAME=mongodb-nationalparks -p MONGODB_USER=mongodb -p MONGODB_PASSWORD=mongodb -p MONGODB_DATABASE=mongodb -p MONGODB_ADMIN_PASSWORD=mongodb -l 'app.kubernetes.io/part-of=workshop'
oc label dc/mongodb-nationalparks svc/mongodb-nationalparks app=workshop component=nationalparks role=database --overwrite
oc create secret generic nationalparks-mongodb-parameters --from-literal=DATABASE_SERVICE_NAME=mongodb-nationalparks --from-literal=MONGODB_USER=mongodb --from-literal=MONGODB_PASSWORD=mongodb --from-literal=MONGODB_DATABASE=mongodb --from-literal=MONGODB_ADMIN_PASSWORD=mongodb
oc rollout status deployment nationalparks
oc rollout status deploymentconfig mongodb-nationalparks
# Add secret to workload
oc set env --from=secret/nationalparks-mongodb-parameters deploy/nationalparks
# /ws/data/load
# Wait for Nationalparks and MongoDB
# Load Data
oc exec $(oc get pods -l component=nationalparks | tail -n 1 | awk '{print $1;}') -- curl -s http://localhost:8080/ws/data/load
# Verify
oc exec $(oc get pods -l component=nationalparks | tail -n 1 | awk '{print $1;}') -- curl -s http://localhost:8080/ws/data/all
# Label Route
oc label route nationalparks type=parksmap-backend
# Health checks
oc set probe deploy/nationalparks --readiness --liveness --get-url=http://:8080/ws/healthz/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment