diff --git a/cloudbuild.yaml b/cloudbuild.yaml deleted file mode 100644 index 2d031ce..0000000 --- a/cloudbuild.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# This configuration file is used to build and deploy the app into a -# GKE cluster using Google Cloud Build. -# -# PREREQUISITES: -# - Cloud Build service account must have role: "Kubernetes Engine Developer" - -# USAGE: -# GCP zone and GKE target cluster must be specified as substitutions -# Example invocation: -# `gcloud builds submit --config=cloudbuild.yaml --substitutions=_ZONE=us-central1-b,_CLUSTER=demo-app-staging .` - -steps: -- id: 'Deploy application to cluster' - name: 'gcr.io/k8s-skaffold/skaffold:v0.20.0' - entrypoint: 'bash' - args: - - '-c' - - > - gcloud container clusters get-credentials --zone=$_ZONE $_CLUSTER; - skaffold run -f=skaffold.yaml --default-repo=gcr.io/$PROJECT_ID; - -# Add more power, and more time, for heavy Skaffold build -timeout: '3600s' -options: - machineType: 'N1_HIGHCPU_8' \ No newline at end of file diff --git a/docs/development-principles.md b/docs/development-principles.md deleted file mode 100644 index 2e840f2..0000000 --- a/docs/development-principles.md +++ /dev/null @@ -1,44 +0,0 @@ -# Development Principles - -> **Note:** This document outlines guidances behind some development decisions -> behind the Hipster Shop demo application. - -### Minimal configuration - -Running the demo locally or on GCP should require minimal to no -configuration unless absolutely necessary to run critical parts of the demo. - -Configuration that takes multiple steps, especially such as creating service -accounts should be avoided. - -### App must work well outside GCP - -Demo application should work reasonably well when it is not deployed to GCP -services. The experience of running the application locally or on GCP should -be close. - -For example: -- OpenCensus prints the traces to stdout when it cannot connect to GCP. -- Stackdriver Debugging tries connecting to GCP multiple times, eventually gives - up. - -### Running on GCP must not reduce functionality - -Running the demo on the GCP must not reduce/lose any of the capabilities -developers have when running locally. - -For example: Logs should still be printed to stdout/stderr even though logs are -uploaded to Stackdriver Logging when on GCP, so that developers can use "kubectl -logs" to diagnose each container. - -### Microservice implementations should not be complex - -Each service should provide a minimal implementation and try to avoid -unnecessary code and logic that's not executed. - -Keep in mind that any service implementation is a decent example of “a GRPC -application that runs on Kubernetes”. Keeping the source code short and -navigable will serve this purpose. - -It is okay to have intentional inefficiencies in the code as they help -illustrate the capabilities of profiling and diagnostics offerings. diff --git a/docs/img/architecture-diagram.png b/docs/img/architecture-diagram.png deleted file mode 100644 index c95d84b..0000000 Binary files a/docs/img/architecture-diagram.png and /dev/null differ diff --git a/docs/img/hipster-shop-frontend-1.png b/docs/img/hipster-shop-frontend-1.png deleted file mode 100644 index 8084e23..0000000 Binary files a/docs/img/hipster-shop-frontend-1.png and /dev/null differ diff --git a/docs/img/hipster-shop-frontend-2.png b/docs/img/hipster-shop-frontend-2.png deleted file mode 100644 index c5a686f..0000000 Binary files a/docs/img/hipster-shop-frontend-2.png and /dev/null differ diff --git a/hack/README.md b/hack/README.md deleted file mode 100755 index 41d89df..0000000 --- a/hack/README.md +++ /dev/null @@ -1,18 +0,0 @@ -## `hack/` - -This directory provides scripts for building and pushing Docker images, and tagging new demo -releases. - -### env variables - -- `TAG` - git release tag / Docker tag. -- `REPO_PREFIX` - Docker repo prefix to push images. Format: `$user/$project`. Resulting images will be of the - format `$user/$project/$svcname:$tag` (where `svcname` = `adservice`, `cartservice`, - etc.) - -### scripts - -1. `./make-docker-images.sh`: builds and pushes images to the specified Docker repository. -2. `./make-release-artifacts.sh`: generates a combined YAML file with image $TAG at: - `./release/kubernetes-manifests/demo.yaml`. -3. `./make-release.sh`: runs scripts 1 and 2, then runs `git tag` / pushes updated manifests to master. diff --git a/hack/license_header.txt b/hack/license_header.txt deleted file mode 100644 index 2e94f3e..0000000 --- a/hack/license_header.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/hack/make-docker-images.sh b/hack/make-docker-images.sh deleted file mode 100755 index 69afd0f..0000000 --- a/hack/make-docker-images.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Builds and pushes docker image for each demo microservice. - -set -euo pipefail -SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -log() { echo "$1" >&2; } - -TAG="${TAG:?TAG env variable must be specified}" -REPO_PREFIX="${REPO_PREFIX:?REPO_PREFIX env variable must be specified}" - -while IFS= read -d $'\0' -r dir; do - # build image - svcname="$(basename "${dir}")" - image="${REPO_PREFIX}/$svcname:$TAG" - ( - cd "${dir}" - log "Building: ${image}" - docker build -t "${image}" . - - log "Pushing: ${image}" - docker push "${image}" - ) -done < <(find "${SCRIPTDIR}/../src" -mindepth 1 -maxdepth 1 -type d -print0) - -log "Successfully built and pushed all images." diff --git a/hack/make-release-artifacts.sh b/hack/make-release-artifacts.sh deleted file mode 100755 index 10fcb25..0000000 --- a/hack/make-release-artifacts.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This script compiles manifest files with the image tags and places them in -# /release/... - -set -euo pipefail -SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[[ -n "${DEBUG:-}" ]] && set -x - -log() { echo "$1" >&2; } - -TAG="${TAG:?TAG env variable must be specified}" -REPO_PREFIX="${REPO_PREFIX:?REPO_PREFIX env variable must be specified}" -OUT_DIR="${OUT_DIR:-${SCRIPTDIR}/../release}" - -print_license_header() { - cat "${SCRIPTDIR}/license_header.txt" - echo -} - -print_autogenerated_warning() { - cat< "${k8s_manifests_file}" - log "Written ${k8s_manifests_file}" - - istio_manifests_file="${OUT_DIR}/istio-manifests.yaml" - mk_istio_manifests > "${istio_manifests_file}" - log "Written ${istio_manifests_file}" -} - -main diff --git a/hack/make-release.sh b/hack/make-release.sh deleted file mode 100755 index 04fb276..0000000 --- a/hack/make-release.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This script creates a new release by: -# - 1. building/pushing images -# - 2. injecting tags into YAML manifests -# - 3. creating a new git tag -# - 4. pushing the tag/commit to master. - -set -euo pipefail -SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[[ -n "${DEBUG:-}" ]] && set -x - -log() { echo "$1" >&2; } -fail() { log "$1"; exit 1; } - -TAG="${TAG:?TAG env variable must be specified}" -REPO_PREFIX="${REPO_PREFIX:?REPO_PREFIX env variable must be specified e.g. gcr.io\/google-samples\/microservices-demo}" - -if [[ "$TAG" != v* ]]; then - fail "\$TAG must start with 'v', e.g. v0.1.0 (got: $TAG)" -fi - -# build and push images -"${SCRIPTDIR}"/make-docker-images.sh - -# update yaml -"${SCRIPTDIR}"/make-release-artifacts.sh - -# create git release / push to master -git add "${SCRIPTDIR}/../release/" -git commit --allow-empty -m "Release $TAG" -log "Pushing k8s manifests to master..." -git tag "$TAG" -git push --tags -git push origin master - -log "Successfully tagged release $TAG." diff --git a/istio-manifests/frontend-gateway.yaml b/istio-manifests/frontend-gateway.yaml deleted file mode 100644 index b3a1a64..0000000 --- a/istio-manifests/frontend-gateway.yaml +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: networking.istio.io/v1alpha3 -kind: Gateway -metadata: - name: frontend-gateway -spec: - selector: - istio: ingressgateway # use Istio default gateway implementation - servers: - - port: - number: 80 - name: http - protocol: HTTP - hosts: - - "*" ---- -apiVersion: networking.istio.io/v1alpha3 -kind: VirtualService -metadata: - name: frontend-ingress -spec: - hosts: - - "*" - gateways: - - frontend-gateway - http: - - route: - - destination: - host: frontend - port: - number: 80 diff --git a/istio-manifests/frontend.yaml b/istio-manifests/frontend.yaml deleted file mode 100644 index 23cd648..0000000 --- a/istio-manifests/frontend.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: networking.istio.io/v1alpha3 -kind: VirtualService -metadata: - name: frontend -spec: - hosts: - - "frontend.default.svc.cluster.local" - http: - - route: - - destination: - host: frontend - port: - number: 80 diff --git a/istio-manifests/whitelist-egress-googleapis.yaml b/istio-manifests/whitelist-egress-googleapis.yaml deleted file mode 100644 index 60e0221..0000000 --- a/istio-manifests/whitelist-egress-googleapis.yaml +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: networking.istio.io/v1alpha3 -kind: ServiceEntry -metadata: - name: whitelist-egress-googleapis -spec: - hosts: - - "accounts.google.com" # Used to get token - - "*.googleapis.com" - ports: - - number: 80 - protocol: HTTP - name: http - - number: 443 - protocol: HTTPS - name: https ---- -apiVersion: networking.istio.io/v1alpha3 -kind: ServiceEntry -metadata: - name: whitelist-egress-google-metadata -spec: - hosts: - - metadata.google.internal - addresses: - - 169.254.169.254 # GCE metadata server - ports: - - number: 80 - name: http - protocol: HTTP - - number: 443 - name: https - protocol: HTTPS diff --git a/kubernetes-manifests/adservice.yaml b/kubernetes-manifests/adservice.yaml index 713ebcd..3134ad8 100644 --- a/kubernetes-manifests/adservice.yaml +++ b/kubernetes-manifests/adservice.yaml @@ -28,7 +28,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: adservice + image: gcr.io/google-samples/microservices-demo/adservice:v0.1.2 ports: - containerPort: 9555 env: diff --git a/kubernetes-manifests/cartservice.yaml b/kubernetes-manifests/cartservice.yaml index 31175da..1a7b4d2 100644 --- a/kubernetes-manifests/cartservice.yaml +++ b/kubernetes-manifests/cartservice.yaml @@ -28,7 +28,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: cartservice + image: gcr.io/google-samples/microservices-demo/cartservice:v0.1.2 ports: - containerPort: 7070 env: diff --git a/kubernetes-manifests/checkoutservice.yaml b/kubernetes-manifests/checkoutservice.yaml index 501210a..609919f 100644 --- a/kubernetes-manifests/checkoutservice.yaml +++ b/kubernetes-manifests/checkoutservice.yaml @@ -27,7 +27,7 @@ spec: spec: containers: - name: server - image: checkoutservice + image: gcr.io/google-samples/microservices-demo/checkoutservice:v0.1.2 ports: - containerPort: 5050 readinessProbe: diff --git a/kubernetes-manifests/currencyservice.yaml b/kubernetes-manifests/currencyservice.yaml index 6d1b21a..cc1dd07 100644 --- a/kubernetes-manifests/currencyservice.yaml +++ b/kubernetes-manifests/currencyservice.yaml @@ -28,7 +28,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: currencyservice + image: gcr.io/google-samples/microservices-demo/currencyservice:v0.1.2 ports: - name: grpc containerPort: 7000 diff --git a/kubernetes-manifests/emailservice.yaml b/kubernetes-manifests/emailservice.yaml index 2ae3823..218cbb7 100644 --- a/kubernetes-manifests/emailservice.yaml +++ b/kubernetes-manifests/emailservice.yaml @@ -28,7 +28,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: emailservice + image: gcr.io/google-samples/microservices-demo/emailservice:v0.1.2 ports: - containerPort: 8080 env: diff --git a/kubernetes-manifests/frontend.yaml b/kubernetes-manifests/frontend.yaml index 5c5cd32..eea7f0a 100644 --- a/kubernetes-manifests/frontend.yaml +++ b/kubernetes-manifests/frontend.yaml @@ -27,7 +27,7 @@ spec: spec: containers: - name: server - image: frontend + image:gcr.io/google-samples/microservices-demo/frontend:v0.1.2 ports: - containerPort: 8080 readinessProbe: diff --git a/kubernetes-manifests/loadgenerator.yaml b/kubernetes-manifests/loadgenerator.yaml index c2aeb98..5ddb77c 100644 --- a/kubernetes-manifests/loadgenerator.yaml +++ b/kubernetes-manifests/loadgenerator.yaml @@ -41,7 +41,7 @@ spec: value: "frontend:80" containers: - name: main - image: loadgenerator + image: gcr.io/google-samples/microservices-demo/loadgenerator:v0.1.2 env: - name: FRONTEND_ADDR value: "frontend:80" diff --git a/kubernetes-manifests/paymentservice.yaml b/kubernetes-manifests/paymentservice.yaml index fa62c08..8e59544 100644 --- a/kubernetes-manifests/paymentservice.yaml +++ b/kubernetes-manifests/paymentservice.yaml @@ -28,7 +28,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: paymentservice + image: gcr.io/google-samples/microservices-demo/paymentservice:v0.1.2 ports: - containerPort: 50051 env: diff --git a/kubernetes-manifests/productcatalogservice.yaml b/kubernetes-manifests/productcatalogservice.yaml index b175856..129ef59 100644 --- a/kubernetes-manifests/productcatalogservice.yaml +++ b/kubernetes-manifests/productcatalogservice.yaml @@ -28,7 +28,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: productcatalogservice + image: gcr.io/google-samples/microservices-demo/productcatalogservice:v0.1.2 ports: - containerPort: 3550 env: diff --git a/kubernetes-manifests/recommendationservice.yaml b/kubernetes-manifests/recommendationservice.yaml index 1ccc4ab..aff1ef6 100644 --- a/kubernetes-manifests/recommendationservice.yaml +++ b/kubernetes-manifests/recommendationservice.yaml @@ -28,7 +28,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: recommendationservice + image: gcr.io/google-samples/microservices-demo/recommendationservice:v0.1.2 ports: - containerPort: 8080 readinessProbe: diff --git a/kubernetes-manifests/shippingservice.yaml b/kubernetes-manifests/shippingservice.yaml index d4049ad..35f1e22 100644 --- a/kubernetes-manifests/shippingservice.yaml +++ b/kubernetes-manifests/shippingservice.yaml @@ -27,7 +27,7 @@ spec: spec: containers: - name: server - image: shippingservice + image: gcr.io/google-samples/microservices-demo/shippingservice:v0.1.2 ports: - containerPort: 50051 env: diff --git a/pb/services/adservice.proto b/pb/services/adservice.proto deleted file mode 100644 index 2c6932c..0000000 --- a/pb/services/adservice.proto +++ /dev/null @@ -1,27 +0,0 @@ -syntax = "proto3"; - -package hipstershop; - - -// ------------Ad service------------------ - -service AdService { - rpc GetAds(AdRequest) returns (AdResponse) {} -} - -message AdRequest { - // List of important key words from the current page describing the context. - repeated string context_keys = 1; -} - -message AdResponse { - repeated Ad ads = 1; -} - -message Ad { - // url to redirect to when an ad is clicked. - string redirect_url = 1; - - // short advertisement text to display. - string text = 2; -} diff --git a/pb/services/cartservice.proto b/pb/services/cartservice.proto deleted file mode 100644 index e7b2ec9..0000000 --- a/pb/services/cartservice.proto +++ /dev/null @@ -1,37 +0,0 @@ -syntax = "proto3"; - -package hipstershop; - -// -----------------Cart service----------------- - -service CartService { - rpc AddItem(AddItemRequest) returns (Empty) {} - rpc GetCart(GetCartRequest) returns (Cart) {} - rpc EmptyCart(EmptyCartRequest) returns (Empty) {} -} - -message CartItem { - string product_id = 1; - int32 quantity = 2; -} - -message AddItemRequest { - string user_id = 1; - CartItem item = 2; -} - -message EmptyCartRequest { - string user_id = 1; -} - -message GetCartRequest { - string user_id = 1; -} - -message Cart { - string user_id = 1; - repeated CartItem items = 2; -} - -message Empty {} - diff --git a/pb/services/checkoutservice.proto b/pb/services/checkoutservice.proto deleted file mode 100644 index f6e00f4..0000000 --- a/pb/services/checkoutservice.proto +++ /dev/null @@ -1,24 +0,0 @@ -syntax = "proto3"; - -package hipstershop; - - -// -------------Checkout service----------------- - -service CheckoutService { - rpc PlaceOrder(PlaceOrderRequest) returns (PlaceOrderResponse) {} -} - -message PlaceOrderRequest { - string user_id = 1; - string user_currency = 2; - - Address address = 3; - string email = 5; - CreditCardInfo credit_card = 6; -} - -message PlaceOrderResponse { - OrderResult order = 1; -} - diff --git a/pb/services/currencyservice.proto b/pb/services/currencyservice.proto deleted file mode 100644 index 3d7da60..0000000 --- a/pb/services/currencyservice.proto +++ /dev/null @@ -1,42 +0,0 @@ -syntax = "proto3"; - -package hipstershop; - - -// -----------------Currency service----------------- - -service CurrencyService { - rpc GetSupportedCurrencies(Empty) returns (GetSupportedCurrenciesResponse) {} - rpc Convert(CurrencyConversionRequest) returns (Money) {} -} - -// Represents an amount of money with its currency type. -message Money { - // The 3-letter currency code defined in ISO 4217. - string currency_code = 1; - - // The whole units of the amount. - // For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar. - int64 units = 2; - - // Number of nano (10^-9) units of the amount. - // The value must be between -999,999,999 and +999,999,999 inclusive. - // If `units` is positive, `nanos` must be positive or zero. - // If `units` is zero, `nanos` can be positive, zero, or negative. - // If `units` is negative, `nanos` must be negative or zero. - // For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000. - int32 nanos = 3; -} - -message GetSupportedCurrenciesResponse { - // The 3-letter currency code defined in ISO 4217. - repeated string currency_codes = 1; -} - -message CurrencyConversionRequest { - Money from = 1; - - // The 3-letter currency code defined in ISO 4217. - string to_code = 2; -} - diff --git a/pb/services/emailservice.proto b/pb/services/emailservice.proto deleted file mode 100644 index 6576083..0000000 --- a/pb/services/emailservice.proto +++ /dev/null @@ -1,29 +0,0 @@ -syntax = "proto3"; - -package hipstershop; - -// -------------Email service----------------- - -service EmailService { - rpc SendOrderConfirmation(SendOrderConfirmationRequest) returns (Empty) {} -} - -message OrderItem { - CartItem item = 1; - Money cost = 2; -} - -message OrderResult { - string order_id = 1; - string shipping_tracking_id = 2; - Money shipping_cost = 3; - Address shipping_address = 4; - repeated OrderItem items = 5; -} - -message SendOrderConfirmationRequest { - string email = 1; - OrderResult order = 2; -} - - diff --git a/pb/services/paymentservice.proto b/pb/services/paymentservice.proto deleted file mode 100644 index d315b8d..0000000 --- a/pb/services/paymentservice.proto +++ /dev/null @@ -1,26 +0,0 @@ -syntax = "proto3"; - -package hipstershop; - -// -------------Payment service----------------- - -service PaymentService { - rpc Charge(ChargeRequest) returns (ChargeResponse) {} -} - -message CreditCardInfo { - string credit_card_number = 1; - int32 credit_card_cvv = 2; - int32 credit_card_expiration_year = 3; - int32 credit_card_expiration_month = 4; -} - -message ChargeRequest { - Money amount = 1; - CreditCardInfo credit_card = 2; -} - -message ChargeResponse { - string transaction_id = 1; -} - diff --git a/pb/services/productcatalogservice.proto b/pb/services/productcatalogservice.proto deleted file mode 100644 index a8a95a8..0000000 --- a/pb/services/productcatalogservice.proto +++ /dev/null @@ -1,61 +0,0 @@ -syntax = "proto3"; - -package hipstershop; - - -// ---------------Product Catalog---------------- - -service ProductCatalogService { - rpc ListProducts(Empty) returns (ListProductsResponse) {} - rpc GetProduct(GetProductRequest) returns (Product) {} - rpc SearchProducts(SearchProductsRequest) returns (SearchProductsResponse) {} -} - -// Represents an amount of money with its currency type. -message Money { - // The 3-letter currency code defined in ISO 4217. - string currency_code = 1; - - // The whole units of the amount. - // For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar. - int64 units = 2; - - // Number of nano (10^-9) units of the amount. - // The value must be between -999,999,999 and +999,999,999 inclusive. - // If `units` is positive, `nanos` must be positive or zero. - // If `units` is zero, `nanos` can be positive, zero, or negative. - // If `units` is negative, `nanos` must be negative or zero. - // For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000. - int32 nanos = 3; -} - -message Empty {} - -message Product { - string id = 1; - string name = 2; - string description = 3; - string picture = 4; - Money price_usd = 5; - - // Categories such as "vintage" or "gardening" that can be used to look up - // other related products. - repeated string categories = 6; -} - -message ListProductsResponse { - repeated Product products = 1; -} - -message GetProductRequest { - string id = 1; -} - -message SearchProductsRequest { - string query = 1; -} - -message SearchProductsResponse { - repeated Product results = 1; -} - diff --git a/pb/services/recommendationservice.proto b/pb/services/recommendationservice.proto deleted file mode 100644 index 078de34..0000000 --- a/pb/services/recommendationservice.proto +++ /dev/null @@ -1,20 +0,0 @@ -syntax = "proto3"; - -package hipstershop; - - -// ---------------Recommendation service---------- - -service RecommendationService { - rpc ListRecommendations(ListRecommendationsRequest) returns (ListRecommendationsResponse){} -} - -message ListRecommendationsRequest { - string user_id = 1; - repeated string product_ids = 2; -} - -message ListRecommendationsResponse { - repeated string product_ids = 1; -} - diff --git a/pb/services/shippingservice.proto b/pb/services/shippingservice.proto deleted file mode 100644 index 22cdc10..0000000 --- a/pb/services/shippingservice.proto +++ /dev/null @@ -1,65 +0,0 @@ -syntax = "proto3"; - -package hipstershop; - - - -// ---------------Shipping Service---------- - -service ShippingService { - rpc GetQuote(GetQuoteRequest) returns (GetQuoteResponse) {} - rpc ShipOrder(ShipOrderRequest) returns (ShipOrderResponse) {} -} - -message GetQuoteRequest { - Address address = 1; - repeated CartItem items = 2; -} - -message GetQuoteResponse { - Money cost_usd = 1; -} - -message ShipOrderRequest { - Address address = 1; - repeated CartItem items = 2; -} - -message ShipOrderResponse { - string tracking_id = 1; -} - -message Address { - string street_address = 1; - string city = 2; - string state = 3; - string country = 4; - int32 zip_code = 5; -} - - -// Represents an amount of money with its currency type. -message Money { - // The 3-letter currency code defined in ISO 4217. - string currency_code = 1; - - // The whole units of the amount. - // For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar. - int64 units = 2; - - // Number of nano (10^-9) units of the amount. - // The value must be between -999,999,999 and +999,999,999 inclusive. - // If `units` is positive, `nanos` must be positive or zero. - // If `units` is zero, `nanos` can be positive, zero, or negative. - // If `units` is negative, `nanos` must be negative or zero. - // For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000. - int32 nanos = 3; -} - -message CartItem { - string product_id = 1; - int32 quantity = 2; -} - - - diff --git a/release/istio-manifests.yaml b/release/istio-manifests.yaml deleted file mode 100644 index 57d669d..0000000 --- a/release/istio-manifests.yaml +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# ---------------------------------------------------------- -# WARNING: This file is autogenerated. Do not manually edit. -# ---------------------------------------------------------- - -apiVersion: networking.istio.io/v1alpha3 -kind: Gateway -metadata: - name: frontend-gateway -spec: - selector: - istio: ingressgateway # use Istio default gateway implementation - servers: - - port: - number: 80 - name: http - protocol: HTTP - hosts: - - "*" ---- -apiVersion: networking.istio.io/v1alpha3 -kind: VirtualService -metadata: - name: frontend-ingress -spec: - hosts: - - "*" - gateways: - - frontend-gateway - http: - - route: - - destination: - host: frontend - port: - number: 80 ---- -apiVersion: networking.istio.io/v1alpha3 -kind: VirtualService -metadata: - name: frontend -spec: - hosts: - - "frontend.default.svc.cluster.local" - http: - - route: - - destination: - host: frontend - port: - number: 80 ---- -apiVersion: networking.istio.io/v1alpha3 -kind: ServiceEntry -metadata: - name: whitelist-egress-googleapis -spec: - hosts: - - "accounts.google.com" # Used to get token - - "*.googleapis.com" - ports: - - number: 80 - protocol: HTTP - name: http - - number: 443 - protocol: HTTPS - name: https ---- -apiVersion: networking.istio.io/v1alpha3 -kind: ServiceEntry -metadata: - name: whitelist-egress-google-metadata -spec: - hosts: - - metadata.google.internal - addresses: - - 169.254.169.254 # GCE metadata server - ports: - - number: 80 - name: http - protocol: HTTP - - number: 443 - name: https - protocol: HTTPS ---- diff --git a/scripts/setup.bat b/scripts/setup.bat new file mode 100644 index 0000000..262d2b6 --- /dev/null +++ b/scripts/setup.bat @@ -0,0 +1,27 @@ +// other k8s artifacts +kubectl apply -f ./kubernetes-manifests/emailservice.yaml +kubectl apply -f ./kubernetes-manifests/frontend.yaml +kubectl apply -f ./kubernetes-manifests/loadgenerator.yaml +kubectl apply -f ./kubernetes-manifests/paymentservice.yaml +kubectl apply -f ./kubernetes-manifests/recommendationservice.yaml +kubectl apply -f ./kubernetes-manifests/redis.yaml +kubectl apply -f ./kubernetes-manifests/shippingservice.yaml + +// ballerina service k8s artifacts +kubectl apply -f ./src/recommendationservice_ballerina/target/kubernetes/recommendationservice_ballerina + +// challenges +kubectl apply -f ./kubernetes-manifests/currencyservice.yaml +# kubectl apply -f ./src/currencyservice_ballerina/target/kubernetes/currencyservice_ballerina + +kubectl apply -f ./kubernetes-manifests/productcatalogservice.yaml +# kubectl apply -f ./src/productcatalogservice_ballerina/target/kubernetes/productcatalogservice_ballerina + +kubectl apply -f ./kubernetes-manifests/cartservice.yaml +# kubectl apply -f ./src/cartservice_ballerina/target/kubernetes/cartservice_ballerina + +kubectl apply -f ./kubernetes-manifests/adservice.yaml +# kubectl apply -f ./src/adservice_ballerina/target/kubernetes/adservice_ballerina + +kubectl apply -f ./kubernetes-manifests/checkoutservice.yaml +# kubectl apply -f ./src/checkoutservice_ballerina/target/kubernetes/checkoutservice_ballerina \ No newline at end of file diff --git a/scripts/setup.sh b/scripts/setup.sh new file mode 100644 index 0000000..29049cd --- /dev/null +++ b/scripts/setup.sh @@ -0,0 +1,29 @@ +// other k8s artifacts +kubectl apply -f ./kubernetes-manifests/emailservice.yaml +kubectl apply -f ./kubernetes-manifests/frontend.yaml +kubectl apply -f ./kubernetes-manifests/loadgenerator.yaml +kubectl apply -f ./kubernetes-manifests/paymentservice.yaml +kubectl apply -f ./kubernetes-manifests/recommendationservice.yaml +kubectl apply -f ./kubernetes-manifests/redis.yaml +kubectl apply -f ./kubernetes-manifests/shippingservice.yaml + +// ballerina service k8s artifacts +kubectl apply -f ./src/recommendationservice_ballerina/target/kubernetes/recommendationservice_ballerina + +// challenges +kubectl apply -f ./kubernetes-manifests/currencyservice.yaml +# kubectl apply -f ./src/currencyservice_ballerina/target/kubernetes/currencyservice_ballerina + +kubectl apply -f ./kubernetes-manifests/productcatalogservice.yaml +#kubectl apply -f ./src/productcatalogservice_ballerina/target/kubernetes/productcatalogservice_ballerina + +kubectl apply -f ./kubernetes-manifests/cartservice.yaml +# kubectl apply -f ./src/cartservice_ballerina/target/kubernetes/cartservice_ballerina + +kubectl apply -f ./kubernetes-manifests/adservice.yaml +# kubectl apply -f ./src/adservice_ballerina/target/kubernetes/adservice_ballerina + +kubectl apply -f ./kubernetes-manifests/checkoutservice.yaml +# kubectl apply -f ./src/checkoutservice_ballerina/target/kubernetes/checkoutservice_ballerina + + diff --git a/scripts/shutdown.bat b/scripts/shutdown.bat new file mode 100644 index 0000000..809c0dd --- /dev/null +++ b/scripts/shutdown.bat @@ -0,0 +1,27 @@ +// other k8s artifacts +kubectl delete -f ./kubernetes-manifests/emailservice.yaml +kubectl delete -f ./kubernetes-manifests/frontend.yaml +kubectl delete -f ./kubernetes-manifests/loadgenerator.yaml +kubectl delete -f ./kubernetes-manifests/paymentservice.yaml +kubectl delete -f ./kubernetes-manifests/recommendationservice.yaml +kubectl delete -f ./kubernetes-manifests/redis.yaml +kubectl delete -f ./kubernetes-manifests/shippingservice.yaml + +// ballerina service k8s artifacts +kubectl delete -f ./src/recommendationservice_ballerina/target/kubernetes/recommendationservice_ballerina + +// challenges +kubectl delete -f ./kubernetes-manifests/currencyservice.yaml +# kubectl delete -f ./src/currencyservice_ballerina/target/kubernetes/currencyservice_ballerina + +kubectl delete -f ./kubernetes-manifests/productcatalogservice.yaml +#kubectl delete -f ./src/productcatalogservice_ballerina/target/kubernetes/productcatalogservice_ballerina + +kubectl delete -f ./kubernetes-manifests/cartservice.yaml +# kubectl delete -f ./src/cartservice_ballerina/target/kubernetes/cartservice_ballerina + +kubectl delete -f ./kubernetes-manifests/adservice.yaml +# kubectl delete -f ./src/adservice_ballerina/target/kubernetes/adservice_ballerina + +kubectl delete -f ./kubernetes-manifests/checkoutservice.yaml +# kubectl delete -f ./src/checkoutservice_ballerina/target/kubernetes/checkoutservice_ballerina \ No newline at end of file diff --git a/scripts/shutdown.sh b/scripts/shutdown.sh new file mode 100644 index 0000000..809c0dd --- /dev/null +++ b/scripts/shutdown.sh @@ -0,0 +1,27 @@ +// other k8s artifacts +kubectl delete -f ./kubernetes-manifests/emailservice.yaml +kubectl delete -f ./kubernetes-manifests/frontend.yaml +kubectl delete -f ./kubernetes-manifests/loadgenerator.yaml +kubectl delete -f ./kubernetes-manifests/paymentservice.yaml +kubectl delete -f ./kubernetes-manifests/recommendationservice.yaml +kubectl delete -f ./kubernetes-manifests/redis.yaml +kubectl delete -f ./kubernetes-manifests/shippingservice.yaml + +// ballerina service k8s artifacts +kubectl delete -f ./src/recommendationservice_ballerina/target/kubernetes/recommendationservice_ballerina + +// challenges +kubectl delete -f ./kubernetes-manifests/currencyservice.yaml +# kubectl delete -f ./src/currencyservice_ballerina/target/kubernetes/currencyservice_ballerina + +kubectl delete -f ./kubernetes-manifests/productcatalogservice.yaml +#kubectl delete -f ./src/productcatalogservice_ballerina/target/kubernetes/productcatalogservice_ballerina + +kubectl delete -f ./kubernetes-manifests/cartservice.yaml +# kubectl delete -f ./src/cartservice_ballerina/target/kubernetes/cartservice_ballerina + +kubectl delete -f ./kubernetes-manifests/adservice.yaml +# kubectl delete -f ./src/adservice_ballerina/target/kubernetes/adservice_ballerina + +kubectl delete -f ./kubernetes-manifests/checkoutservice.yaml +# kubectl delete -f ./src/checkoutservice_ballerina/target/kubernetes/checkoutservice_ballerina \ No newline at end of file diff --git a/setup.sh b/setup.sh deleted file mode 100644 index 6d6058e..0000000 --- a/setup.sh +++ /dev/null @@ -1,44 +0,0 @@ -kubectl apply -f HipsterShop/target/kubernetes/paymentservice -kubectl apply -f HipsterShop/target/kubernetes/shippingservice -kubectl apply -f HipsterShop/target/kubernetes/emailservice -kubectl apply -f k8s_manifests/frontend/frontend-kubernetes-manifests.yaml - -ballerina build --sourceroot src/recommendationservice_ballerina --all --skip-tests -kubectl apply -f src/recommendationservice/target/kubernetes/recommendationservice - -# Cart service -kubectl apply -f HipsterShop/target/kubernetes/adservice -# Replace above command with following command when you implemented the ad service in Ballerina. - -# ballerina build --sourceroot src/adservice_ballerina --all --skip-tests -# kubectl apply -f src/adservice_ballerina/target/kubernetes/adservice - -kubectl apply -f HipsterShop/target/kubernetes/currencyservice -# Replace above command with following command when you implemented the currency service in Ballerina. - -# ballerina build --sourceroot src/currencyservice_ballerina --all --skip-tests -# kubectl apply -f src/currencyservice_ballerina/target/kubernetes/currencyservice - -# Cart service -kubectl apply -f HipsterShop/target/kubernetes/cartservice -# Replace above command with following command when you implemented the cart service in Ballerina. - -# ballerina build --sourceroot src/cartservice_ballerina --all --skip-tests -# kubectl apply -f src/cartservice_ballerina/target/kubernetes/cartservice - -# Product Catalog Service -kubectl apply -f HipsterShop/target/kubernetes/productcatalogservice - -# Replace above with following command when you implemented the product catalog service in Ballerina. - -# ballerina build --sourceroot src/productcatalogservice_ballerina --all --skip-tests -# kubectl apply -f src/productcatalogservice_ballerina/target/kubernetes/productcatalogservice - -# Checkout service -kubectl apply -f HipsterShop/target/kubernetes/checkoutservice -# Replace above with following command when you implemented the checkout service in Ballerina. - -# ballerina build --sourceroot src/checkoutservice_ballerina --all --skip-tests -# kubectl apply -f src/checkoutservice_ballerina/target/kubernetes/checkoutservice - -kubectl get services diff --git a/shutdown.sh b/shutdown.sh deleted file mode 100644 index e69de29..0000000 diff --git a/skaffold.yaml b/skaffold.yaml deleted file mode 100644 index 665f80a..0000000 --- a/skaffold.yaml +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: skaffold/v1beta2 -kind: Config -build: - artifacts: - # image tags are relative; to specify an image repo (e.g. GCR), you - # must provide a "default repo" using one of the methods described - # here: - # https://skaffold.dev/docs/concepts/#image-repository-handling - - image: emailservice - context: src/emailservice - - image: productcatalogservice - context: src/productcatalogservice - - image: recommendationservice - context: src/recommendationservice - - image: shippingservice - context: src/shippingservice - - image: checkoutservice - context: src/checkoutservice - - image: paymentservice - context: src/paymentservice - - image: currencyservice - context: src/currencyservice - - image: cartservice - context: src/cartservice - - image: frontend - context: src/frontend - - image: loadgenerator - context: src/loadgenerator - - image: adservice - context: src/adservice - tagPolicy: - gitCommit: {} -deploy: - kubectl: - manifests: - - ./kubernetes-manifests/**.yaml -profiles: -# "travis-ci" profile is used to build the images without -# pushing them. -- name: travis-ci - build: - local: - push: false -# "gcb" profile allows building and pushing the images -# on Google Container Builder without requiring docker -# installed on the developer machine. However, note that -# since GCB does not cache the builds, each build will -# start from scratch and therefore take a long time. -# -# This is not used by default. To use it, run: -# skaffold run -p gcb -- name: gcb - build: - googleCloudBuild: - diskSizeGb: 300 - machineType: N1_HIGHCPU_32 - timeout: 4000s diff --git a/tests/cartservice/.gitignore b/tests/cartservice/.gitignore deleted file mode 100644 index 61aadf7..0000000 --- a/tests/cartservice/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/bin/* -/obj/* -/.vs/* \ No newline at end of file diff --git a/tests/cartservice/CartServiceTests.cs b/tests/cartservice/CartServiceTests.cs deleted file mode 100644 index ed297bd..0000000 --- a/tests/cartservice/CartServiceTests.cs +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Threading.Tasks; -using Grpc.Core; -using Hipstershop; -using Xunit; -using static Hipstershop.CartService; - -namespace cartservice -{ - public class E2ETests - { - private static string serverHostName = "localhost"; - private static int port = 7070; - - [Fact] - public async Task GetItem_NoAddItemBefore_EmptyCartReturned() - { - string userId = Guid.NewGuid().ToString(); - - // Construct server's Uri - string targetUri = $"{serverHostName}:{port}"; - - // Create a GRPC communication channel between the client and the server - var channel = new Channel(targetUri, ChannelCredentials.Insecure); - - var client = new CartServiceClient(channel); - - var request = new GetCartRequest - { - UserId = userId, - }; - - var cart = await client.GetCartAsync(request); - Assert.NotNull(cart); - - // All grpc objects implement IEquitable, so we can compare equality with by-value semantics - Assert.Equal(new Cart(), cart); - } - - [Fact] - public async Task AddItem_ItemExists_Updated() - { - string userId = Guid.NewGuid().ToString(); - - // Construct server's Uri - string targetUri = $"{serverHostName}:{port}"; - - // Create a GRPC communication channel between the client and the server - var channel = new Channel(targetUri, ChannelCredentials.Insecure); - - var client = new CartServiceClient(channel); - var request = new AddItemRequest - { - UserId = userId, - Item = new CartItem - { - ProductId = "1", - Quantity = 1 - } - }; - - // First add - nothing should fail - await client.AddItemAsync(request); - - // Second add of existing product - quantity should be updated - await client.AddItemAsync(request); - - var getCartRequest = new GetCartRequest - { - UserId = userId - }; - var cart = await client.GetCartAsync(getCartRequest); - Assert.NotNull(cart); - Assert.Equal(userId, cart.UserId); - Assert.Single(cart.Items); - Assert.Equal(2, cart.Items[0].Quantity); - - // Cleanup - await client.EmptyCartAsync(new EmptyCartRequest{ UserId = userId }); - } - - [Fact] - public async Task AddItem_New_Inserted() - { - string userId = Guid.NewGuid().ToString(); - - // Construct server's Uri - string targetUri = $"{serverHostName}:{port}"; - - // Create a GRPC communication channel between the client and the server - var channel = new Channel(targetUri, ChannelCredentials.Insecure); - - // Create a proxy object to work with the server - var client = new CartServiceClient(channel); - - var request = new AddItemRequest - { - UserId = userId, - Item = new CartItem - { - ProductId = "1", - Quantity = 1 - } - }; - - await client.AddItemAsync(request); - - var getCartRequest = new GetCartRequest - { - UserId = userId - }; - var cart = await client.GetCartAsync(getCartRequest); - Assert.NotNull(cart); - Assert.Equal(userId, cart.UserId); - Assert.Single(cart.Items); - - await client.EmptyCartAsync(new EmptyCartRequest{ UserId = userId }); - cart = await client.GetCartAsync(getCartRequest); - Assert.Empty(cart.Items); - } - } -} diff --git a/tests/cartservice/cartservice.tests.csproj b/tests/cartservice/cartservice.tests.csproj deleted file mode 100644 index 4ada297..0000000 --- a/tests/cartservice/cartservice.tests.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - netcoreapp2.0 - - false - - - - - - - - - - - - - - - - - - - - Always - - - - diff --git a/tests/cartservice/cartservice.tests.csproj.user b/tests/cartservice/cartservice.tests.csproj.user deleted file mode 100644 index 0b0f24d..0000000 --- a/tests/cartservice/cartservice.tests.csproj.user +++ /dev/null @@ -1,6 +0,0 @@ - - - - true - - \ No newline at end of file