Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
feat(demo): Update demo to work on OpenShift
Browse files Browse the repository at this point in the history
Signed-off-by: Kalya Subramanian <kasubra@microsoft.com>
  • Loading branch information
ksubrmnn committed Feb 22, 2021
1 parent 90284b7 commit ebc0f1f
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 13 deletions.
2 changes: 1 addition & 1 deletion demo/cmd/bookbuyer/bookbuyer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (
booksBoughtV1 int64
booksBoughtV2 int64
log = logger.NewPretty(participantName)
port = flag.Int("port", 80, "port on which this app is listening for incoming HTTP")
port = flag.Int("port", 8080, "port on which this app is listening for incoming HTTP")
path = flag.String("path", ".", "path to the HTML template")
numConnectionsStr = utils.GetEnv("CI_CLIENT_CONCURRENT_CONNECTIONS", "1")
)
Expand Down
2 changes: 1 addition & 1 deletion demo/cmd/bookstore/bookstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (
booksSold int64 = 0
log = logger.NewPretty("bookstore")
identity = flag.String("ident", "unidentified", "the identity of the container where this demo app is running (VM, K8s, etc)")
port = flag.Int("port", 80, "port on which this app is listening for incoming HTTP")
port = flag.Int("port", 8080, "port on which this app is listening for incoming HTTP")
path = flag.String("path", ".", "path to the HTML template")
)

Expand Down
2 changes: 1 addition & 1 deletion demo/cmd/bookthief/bookthief.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
booksStolenV1 int64
booksStolenV2 int64
log = logger.NewPretty(participantName)
port = flag.Int("port", 80, "port on which this app is listening for incoming HTTP")
port = flag.Int("port", 8080, "port on which this app is listening for incoming HTTP")
path = flag.String("path", ".", "path to the HTML template")
)

Expand Down
2 changes: 1 addition & 1 deletion demo/cmd/bookwarehouse/bookwarehouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
var (
log = logger.NewPretty("bookwarehouse")
identity = flag.String("ident", "unidentified", "the identity of the container where this demo app is running (VM, K8s, etc)")
port = flag.Int("port", 80, "port on which this app is listening for incoming HTTP")
port = flag.Int("port", 8080, "port on which this app is listening for incoming HTTP")
totalBooks = 0
)

Expand Down
2 changes: 1 addition & 1 deletion demo/cmd/common/books.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (
RestockWarehouseURL = "restock-books"

// bookstorePort is the bookstore service's port
bookstorePort = 80
bookstorePort = 8080

httpPrefix = "http://"

Expand Down
11 changes: 11 additions & 0 deletions demo/deploy-bookbuyer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ CI_MAX_ITERATIONS_THRESHOLD="${CI_MAX_ITERATIONS_THRESHOLD:-0}"
CI_CLIENT_CONCURRENT_CONNECTIONS="${CI_CLIENT_CONCURRENT_CONNECTIONS:-1}"
ENABLE_EGRESS="${ENABLE_EGRESS:-false}"
CI_SLEEP_BETWEEN_REQUESTS_SECONDS="${CI_SLEEP_BETWEEN_REQUESTS_SECONDS:-1}"
ROUTES_V2="${ROUTES_V2:-false}"
DEPLOY_FOR_OPENSHIFT="${DEPLOY_FOR_OPENSHIFT:-false}"

if [ "$ROUTES_V2" = "true" ]; then
BOOKSTORE_SVC=bookstore-v1
fi

kubectl delete deployment bookbuyer -n "$BOOKBUYER_NAMESPACE" --ignore-not-found

Expand All @@ -21,6 +27,11 @@ metadata:
namespace: $BOOKBUYER_NAMESPACE
EOF

if [ "$DEPLOY_FOR_OPENSHIFT" = true ] ; then
oc adm policy add-scc-to-user privileged -z bookbuyer -n $BOOKBUYER_NAMESPACE
oc secrets link bookbuyer $CTR_REGISTRY_CREDS_NAME --for=pull -n $BOOKBUYER_NAMESPACE
fi

echo -e "Deploy BookBuyer Service"
kubectl apply -f - <<EOF
apiVersion: v1
Expand Down
21 changes: 14 additions & 7 deletions demo/deploy-bookstore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ set -aueo pipefail
source .env
VERSION=${1:-v1}
SVC="bookstore-$VERSION"
ROUTES_V2="${ROUTES_V2:-false}"
DEPLOY_FOR_OPENSHIFT="${DEPLOY_FOR_OPENSHIFT:-false}"

kubectl delete deployment "$SVC" -n "$BOOKSTORE_NAMESPACE" --ignore-not-found

Expand All @@ -21,7 +23,7 @@ metadata:
app: bookstore
spec:
ports:
- port: 80
- port: 8080
name: bookstore-port
EOF

Expand All @@ -34,6 +36,11 @@ metadata:
namespace: $BOOKSTORE_NAMESPACE
EOF

if [ "$DEPLOY_FOR_OPENSHIFT" = true ] ; then
oc adm policy add-scc-to-user privileged -z $SVC -n $BOOKSTORE_NAMESPACE
oc secrets link $SVC $CTR_REGISTRY_CREDS_NAME --for=pull -n $BOOKSTORE_NAMESPACE
fi

echo -e "Deploy $SVC Service"
kubectl apply -f - <<EOF
apiVersion: v1
Expand All @@ -45,7 +52,7 @@ metadata:
app: $SVC
spec:
ports:
- port: 80
- port: 8080
name: bookstore-port
selector:
Expand Down Expand Up @@ -77,10 +84,10 @@ spec:
imagePullPolicy: Always
name: $SVC
ports:
- containerPort: 80
- containerPort: 8080
name: web
command: ["/bookstore"]
args: ["--path", "./", "--port", "80"]
args: ["--path", "./", "--port", "8080"]
env:
- name: IDENTITY
value: ${SVC}
Expand All @@ -92,7 +99,7 @@ spec:
livenessProbe:
httpGet:
path: /liveness
port: 80
port: 8080
initialDelaySeconds: 3
periodSeconds: 3
Expand All @@ -102,15 +109,15 @@ spec:
failureThreshold: 10
httpGet:
path: /readiness
port: 80
port: 8080
scheme: HTTP
# OSM's mutating webhook will rewrite this startup probe to /osm-startup-probe and
# Envoy will have a dedicated listener on port 15903 for this startup probe
startupProbe:
httpGet:
path: /startup
port: 80
port: 8080
failureThreshold: 30
periodSeconds: 5
Expand Down
8 changes: 7 additions & 1 deletion demo/deploy-bookthief.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CI_MAX_ITERATIONS_THRESHOLD="${CI_MAX_ITERATIONS_THRESHOLD:-0}"
CI_CLIENT_CONCURRENT_CONNECTIONS="${CI_CLIENT_CONCURRENT_CONNECTIONS:-1}"
ENABLE_EGRESS="${ENABLE_EGRESS:-false}"
CI_SLEEP_BETWEEN_REQUESTS_SECONDS="${CI_SLEEP_BETWEEN_REQUESTS_SECONDS:-1}"
DEPLOY_FOR_OPENSHIFT="${DEPLOY_FOR_OPENSHIFT:-false}"

kubectl delete deployment bookthief -n "$BOOKTHIEF_NAMESPACE" --ignore-not-found

Expand All @@ -21,9 +22,14 @@ kind: ServiceAccount
metadata:
name: bookthief
namespace: $BOOKTHIEF_NAMESPACE
EOF

---
if [ "$DEPLOY_FOR_OPENSHIFT" = true ] ; then
oc adm policy add-scc-to-user privileged -z bookthief -n $BOOKTHIEF_NAMESPACE
oc secrets link bookthief $CTR_REGISTRY_CREDS_NAME --for=pull -n $BOOKTHIEF_NAMESPACE
fi

kubectl apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
Expand Down
6 changes: 6 additions & 0 deletions demo/deploy-bookwarehouse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -aueo pipefail

# shellcheck disable=SC1091
source .env
DEPLOY_FOR_OPENSHIFT="${DEPLOY_FOR_OPENSHIFT:-false}"

kubectl delete deployment bookwarehouse -n "$BOOKWAREHOUSE_NAMESPACE" --ignore-not-found

Expand All @@ -16,6 +17,11 @@ metadata:
namespace: $BOOKWAREHOUSE_NAMESPACE
EOF

if [ "$DEPLOY_FOR_OPENSHIFT" = true ] ; then
oc adm policy add-scc-to-user privileged -z bookwarehouse -n $BOOKWAREHOUSE_NAMESPACE
oc secrets link bookwarehouse $CTR_REGISTRY_CREDS_NAME --for=pull -n $BOOKWAREHOUSE_NAMESPACE
fi

echo -e "Deploy Bookwarehouse Service"
kubectl apply -f - <<EOF
apiVersion: v1
Expand Down

0 comments on commit ebc0f1f

Please sign in to comment.