diff --git a/.env.example b/.env.example index f78920c1ac..bdd7e5d318 100644 --- a/.env.example +++ b/.env.example @@ -163,6 +163,10 @@ export BOOKWAREHOUSE_NAMESPACE=bookwarehouse ### optional: Name of the Vault role dedicated to OSM #export VAULT_ROLE=openservicemesh +### optional: Whether to configure the demo to run on an OpenShift cluster +# Default: false +#export DEPLOY_ON_OPENSHIFT=false + # See ./demo/deploy-vault.sh script on an example of how to deploy Hashicorp Vault # to your Kubernetes cluster. #-------------------------------------------------------------------------------- diff --git a/DESIGN.md b/DESIGN.md index 391be4ff89..ac3ecaf7cb 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -137,8 +137,8 @@ metadata: app: bookstore spec: ports: - - port: 80 - targetPort: 80 + - port: 14001 + targetPort: 14001 name: web-port selector: app: bookstore diff --git a/demo/README.md b/demo/README.md index 76dbcb31c5..03e69eeb2b 100644 --- a/demo/README.md +++ b/demo/README.md @@ -14,10 +14,10 @@ ## Prerequisites 1. Clone this repo on your workstation -2. Setup `.env` environment variable file +1. Setup `.env` environment variable file - From the root of the repository run `make .env` - It is already listed in `.gitignore` so that anything you put in it would not accidentally leak into a public git repo. Refer to `.env.example` in the root of this repo for the mandatory and optional environment variables. -2. Provision access to a Kubernetes cluster. Any certified conformant Kubernetes cluster (version 1.15 or higher) can be used. Here are a couple of options: +1. Provision access to a Kubernetes cluster. Any certified conformant Kubernetes cluster (version 1.15 or higher) can be used. Here are a couple of options: - **Option 1:** Local [kind](https://kind.sigs.k8s.io/) cluster - [Install kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation) - `brew install kind` on macOS @@ -26,6 +26,13 @@ We will use images from [Docker Hub](https://hub.docker.com/r/openservicemesh/osm-controller). Ensure you can pull these containers using: `docker pull openservicemesh/osm-controller` +### OpenShift + +If you are running the demo on an OpenShift cluster, there are additional prerequisites. + +1. Set `DEPLOY_ON_OPENSHIFT=true` in your `.env` file. +1. Install the [oc CLI](https://docs.openshift.com/container-platform/4.7/cli_reference/openshift_cli/getting-started-cli.html). + ## Run the Demo From the root of this repository execute: ```shell diff --git a/demo/cmd/bookbuyer/bookbuyer.go b/demo/cmd/bookbuyer/bookbuyer.go index 5523c92c35..b8301fcccb 100644 --- a/demo/cmd/bookbuyer/bookbuyer.go +++ b/demo/cmd/bookbuyer/bookbuyer.go @@ -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", 14001, "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") ) diff --git a/demo/cmd/bookstore/bookstore.go b/demo/cmd/bookstore/bookstore.go index 7ff3e8a253..6492ecdb0b 100644 --- a/demo/cmd/bookstore/bookstore.go +++ b/demo/cmd/bookstore/bookstore.go @@ -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", 14001, "port on which this app is listening for incoming HTTP") path = flag.String("path", ".", "path to the HTML template") ) diff --git a/demo/cmd/bookthief/bookthief.go b/demo/cmd/bookthief/bookthief.go index e4bbd09bbc..e066398f8a 100644 --- a/demo/cmd/bookthief/bookthief.go +++ b/demo/cmd/bookthief/bookthief.go @@ -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", 14001, "port on which this app is listening for incoming HTTP") path = flag.String("path", ".", "path to the HTML template") ) diff --git a/demo/cmd/bookwarehouse/bookwarehouse.go b/demo/cmd/bookwarehouse/bookwarehouse.go index 214ea2dfca..7ff37e82a5 100644 --- a/demo/cmd/bookwarehouse/bookwarehouse.go +++ b/demo/cmd/bookwarehouse/bookwarehouse.go @@ -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", 14001, "port on which this app is listening for incoming HTTP") totalBooks = 0 ) diff --git a/demo/cmd/common/books.go b/demo/cmd/common/books.go index ca6eb2eb86..3083b7c52f 100644 --- a/demo/cmd/common/books.go +++ b/demo/cmd/common/books.go @@ -19,7 +19,10 @@ const ( RestockWarehouseURL = "restock-books" // bookstorePort is the bookstore service's port - bookstorePort = 80 + bookstorePort = 14001 + + // bookwarehousePort is the bookwarehouse service's port + bookwarehousePort = 14001 httpPrefix = "http://" @@ -38,8 +41,8 @@ var ( warehouseServiceName = "bookwarehouse" bookwarehouseNamespace = os.Getenv(BookwarehouseNamespaceEnvVar) - bookstoreService = fmt.Sprintf("%s.%s:%d", bookstoreServiceName, bookstoreNamespace, bookstorePort) // FQDN - warehouseService = fmt.Sprintf("%s.%s", warehouseServiceName, bookwarehouseNamespace) // FQDN + bookstoreService = fmt.Sprintf("%s.%s:%d", bookstoreServiceName, bookstoreNamespace, bookstorePort) // FQDN + warehouseService = fmt.Sprintf("%s.%s:%d", warehouseServiceName, bookwarehouseNamespace, bookwarehousePort) // FQDN booksBought = fmt.Sprintf("http://%s/books-bought", bookstoreService) buyBook = fmt.Sprintf("http://%s/buy-a-book/new", bookstoreService) chargeAccountURL = fmt.Sprintf("http://%s/%s", warehouseService, RestockWarehouseURL) diff --git a/demo/deploy-bookbuyer.sh b/demo/deploy-bookbuyer.sh index 15ee266bd4..b7231f266d 100755 --- a/demo/deploy-bookbuyer.sh +++ b/demo/deploy-bookbuyer.sh @@ -9,6 +9,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_ON_OPENSHIFT="${DEPLOY_ON_OPENSHIFT:-false}" kubectl delete deployment bookbuyer -n "$BOOKBUYER_NAMESPACE" --ignore-not-found @@ -21,6 +22,11 @@ metadata: namespace: $BOOKBUYER_NAMESPACE EOF +if [ "$DEPLOY_ON_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 Deployment" kubectl apply -f - <