├── .env ├── .github └── workflows │ ├── cart.yaml │ ├── catalogue.yaml │ ├── dispatch.yaml │ ├── payment.yaml │ ├── push.yml │ ├── shipping.yaml │ └── user.yaml ├── .gitignore ├── AKS └── helm │ ├── Chart.yaml │ ├── README.md │ ├── ingress.yaml │ ├── templates │ ├── cart-deployment.yaml │ ├── cart-service.yaml │ ├── catalogue-deployment.yaml │ ├── catalogue-service.yaml │ ├── clusterrole.yaml │ ├── clusterrolebinding.yaml │ ├── dispatch-deployment.yaml │ ├── dispatch-service.yaml │ ├── mongodb-deployment.yaml │ ├── mongodb-service.yaml │ ├── mysql-deployment.yaml │ ├── mysql-service.yaml │ ├── payment-deployment.yaml │ ├── payment-service.yaml │ ├── podsecuritypolicy.yaml │ ├── rabbitmq-deployment.yaml │ ├── rabbitmq-service.yaml │ ├── ratings-deployment.yaml │ ├── ratings-service.yaml │ ├── redis-service.yaml │ ├── redis-statefulset.yaml │ ├── serviceaccount.yaml │ ├── shipping-deployment.yaml │ ├── shipping-service.yaml │ ├── user-deployment.yaml │ ├── user-service.yaml │ ├── web-deployment.yaml │ └── web-service.yaml │ └── values.yaml ├── DCOS ├── deploy.sh ├── destroy.sh └── manifest │ ├── cart.json │ ├── catalogue.json │ ├── dispatch.json │ ├── mongodb.json │ ├── mysql.json │ ├── payment.json │ ├── rabbitmq.json │ ├── redis.json │ ├── shipping.json │ ├── user.json │ └── web.json ├── EKS ├── 01-prerequisites.md ├── 02-eks-cluster-setup.md ├── 03-oidc-IAM.md ├── 04-alb-configuration.md ├── 05-ebs-csi-driver.md └── helm │ ├── Chart.yaml │ ├── README.md │ ├── ingress.yaml │ ├── templates │ ├── cart-deployment.yaml │ ├── cart-service.yaml │ ├── catalogue-deployment.yaml │ ├── catalogue-service.yaml │ ├── clusterrole.yaml │ ├── clusterrolebinding.yaml │ ├── dispatch-deployment.yaml │ ├── dispatch-service.yaml │ ├── mongodb-deployment.yaml │ ├── mongodb-service.yaml │ ├── mysql-deployment.yaml │ ├── mysql-service.yaml │ ├── payment-deployment.yaml │ ├── payment-service.yaml │ ├── podsecuritypolicy.yaml │ ├── rabbitmq-deployment.yaml │ ├── rabbitmq-service.yaml │ ├── ratings-deployment.yaml │ ├── ratings-service.yaml │ ├── redis-service.yaml │ ├── redis-statefulset.yaml │ ├── serviceaccount.yaml │ ├── shipping-deployment.yaml │ ├── shipping-service.yaml │ ├── user-deployment.yaml │ ├── user-service.yaml │ ├── web-deployment.yaml │ └── web-service.yaml │ └── values.yaml ├── GKE └── helm │ ├── Chart.yaml │ ├── gclb.yaml │ ├── ingress.yaml │ ├── templates │ ├── cart-deployment.yaml │ ├── cart-service.yaml │ ├── catalogue-deployment.yaml │ ├── catalogue-service.yaml │ ├── clusterrole.yaml │ ├── clusterrolebinding.yaml │ ├── dispatch-deployment.yaml │ ├── dispatch-service.yaml │ ├── mongodb-deployment.yaml │ ├── mongodb-service.yaml │ ├── mysql-deployment.yaml │ ├── mysql-service.yaml │ ├── payment-deployment.yaml │ ├── payment-service.yaml │ ├── podsecuritypolicy.yaml │ ├── rabbitmq-deployment.yaml │ ├── rabbitmq-service.yaml │ ├── ratings-deployment.yaml │ ├── ratings-service.yaml │ ├── redis-service.yaml │ ├── redis-statefulset.yaml │ ├── serviceaccount.yaml │ ├── shipping-deployment.yaml │ ├── shipping-service.yaml │ ├── user-deployment.yaml │ ├── user-service.yaml │ ├── web-deployment.yaml │ └── web-service.yaml │ └── values.yaml ├── K8s ├── Istio │ ├── canary.yaml │ ├── gateway.yaml │ └── payment-deployment-fix.yaml ├── README.md ├── autoscale.sh ├── helm │ ├── Chart.yaml │ ├── README.md │ ├── templates │ │ ├── cart-deployment.yaml │ │ ├── cart-service.yaml │ │ ├── catalogue-deployment.yaml │ │ ├── catalogue-service.yaml │ │ ├── clusterrole.yaml │ │ ├── clusterrolebinding.yaml │ │ ├── dispatch-deployment.yaml │ │ ├── dispatch-service.yaml │ │ ├── mongodb-deployment.yaml │ │ ├── mongodb-service.yaml │ │ ├── mysql-deployment.yaml │ │ ├── mysql-service.yaml │ │ ├── payment-deployment.yaml │ │ ├── payment-service.yaml │ │ ├── podsecuritypolicy.yaml │ │ ├── rabbitmq-deployment.yaml │ │ ├── rabbitmq-service.yaml │ │ ├── ratings-deployment.yaml │ │ ├── ratings-service.yaml │ │ ├── redis-service.yaml │ │ ├── redis-statefulset.yaml │ │ ├── serviceaccount.yaml │ │ ├── shipping-deployment.yaml │ │ ├── shipping-service.yaml │ │ ├── user-deployment.yaml │ │ ├── user-service.yaml │ │ ├── web-deployment.yaml │ │ └── web-service.yaml │ └── values.yaml ├── load-deployment.yaml └── resource-quota.yaml ├── LICENSE ├── OpenShift ├── README.md └── setup.sh ├── README.md ├── Swarm ├── create-swarm.sh ├── deploy.sh └── instana-agent.sh ├── cart ├── Dockerfile ├── package.json └── server.js ├── catalogue ├── Dockerfile ├── package.json └── server.js ├── dispatch ├── Dockerfile ├── docker-compose.yaml └── main.go ├── docker-compose-load.yaml ├── docker-compose.yaml ├── fluentd ├── Docker-Compose │ ├── README.md │ ├── fluent.conf │ └── run.sh ├── Dockerfile ├── Kubernetes │ ├── README.md │ └── fluentd.yaml ├── README.md └── build.sh ├── load-gen ├── Dockerfile ├── README.md ├── build.sh ├── entrypoint.sh ├── load-gen.sh ├── requirements.txt └── robot-shop.py ├── mongo ├── Dockerfile ├── catalogue.js └── users.js ├── mysql ├── Dockerfile ├── config.sh ├── convert.sh └── scripts │ ├── 10-dump.sql.gz │ ├── 20-ratings.sql │ └── 99-finished.sh ├── payment ├── Dockerfile ├── docker-compose.yaml ├── payment.ini ├── payment.py ├── rabbitmq.py └── requirements.txt ├── pullbaseimages.sh ├── ratings ├── Dockerfile ├── html │ ├── .htaccess │ ├── composer.json │ ├── index.php │ ├── info.php │ ├── src │ │ ├── Controller │ │ │ ├── HealthController.php │ │ │ └── RatingsApiController.php │ │ ├── Database.php │ │ ├── EventListener │ │ │ └── InstanaDataCenterListener.php │ │ ├── Integration │ │ │ └── InstanaHeadersLoggingProcessor.php │ │ ├── Kernel.php │ │ └── Service │ │ │ ├── CatalogueService.php │ │ │ ├── HealthCheckService.php │ │ │ └── RatingsService.php │ └── var │ │ ├── cache │ │ └── .gitkeep │ │ └── log │ │ └── .gitkeep └── status.conf ├── shipping ├── .gitignore ├── Dockerfile ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── instana │ │ └── robotshop │ │ └── shipping │ │ ├── Calculator.java │ │ ├── CartHelper.java │ │ ├── City.java │ │ ├── CityRepository.java │ │ ├── Code.java │ │ ├── CodeRepository.java │ │ ├── Controller.java │ │ ├── JpaConfig.java │ │ ├── RetryableDataSource.java │ │ ├── Ship.java │ │ └── ShippingServiceApplication.java │ └── resources │ └── application.properties ├── user ├── Dockerfile ├── package.json └── server.js └── web ├── Dockerfile ├── default.conf.template ├── entrypoint.sh └── static ├── cart.html ├── css ├── auto-complete.css └── style.css ├── empty.html ├── eum-tmpl.html ├── images ├── Aplha.png ├── CNA.png ├── EMM.png ├── EPE.png ├── Ewooid.png ├── HPTD.png ├── RED.png ├── RMC.png ├── SHCE.png ├── STAN-1.png ├── UHJ.png ├── Watson.png └── placeholder.png ├── index.html ├── js ├── auto-complete.js └── controller.js ├── login.html ├── media ├── graph.png ├── instana_icon_square.png └── stan.png ├── payment.html ├── product.html ├── search.html ├── shipping.html └── splash.html /.env: -------------------------------------------------------------------------------- 1 | # environment file for docker-compose 2 | REPO=robotshop 3 | TAG=2.1.0 4 | -------------------------------------------------------------------------------- /.github/workflows/cart.yaml: -------------------------------------------------------------------------------- 1 | name: Cart 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | paths: 8 | - '**.js' # Only trigger on changes to Python files (**.py) 9 | - '.github/workflows/cart.yaml' # Include workflow file changes 10 | 11 | pull_request: 12 | branches: 13 | - master 14 | paths: 15 | - '**.js' # Only trigger on changes to Python files (**.py) 16 | - '.github/workflows/cart.yaml' # Include workflow file changes 17 | 18 | jobs: 19 | payment: 20 | name: Build and deploy cart microservice 21 | runs-on: [self-hosted] # Use a standard runner instead of self-hosted 22 | 23 | steps: 24 | - name: Checkout code 25 | uses: actions/checkout@v2 26 | with: 27 | fetch-depth: 0 28 | 29 | - name: NPM install 30 | run: npm install 31 | 32 | - name: Build Docker image 33 | run: | 34 | docker build -t cart . # Build image tagged as 'payment' from current directory 35 | 36 | - name: Docker Login (use secrets) 37 | run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} 38 | 39 | - name: Docker Push 40 | run: | 41 | docker tag cart ${name}/cart:latest 42 | docker push ${name}/cart:latest -------------------------------------------------------------------------------- /.github/workflows/catalogue.yaml: -------------------------------------------------------------------------------- 1 | name: Catalogue 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | paths: 8 | - '**.js' # Only trigger on changes to Python files (**.py) 9 | - '.github/workflows/catalogue.yaml' # Include workflow file changes 10 | 11 | pull_request: 12 | branches: 13 | - master 14 | paths: 15 | - '**.js' # Only trigger on changes to Python files (**.py) 16 | - '.github/workflows/catalogue.yaml' # Include workflow file changes 17 | 18 | jobs: 19 | payment: 20 | name: Build and deploy catalogue microservice 21 | runs-on: [self-hosted] # Use a standard runner instead of self-hosted 22 | 23 | steps: 24 | - name: Checkout code 25 | uses: actions/checkout@v2 26 | with: 27 | fetch-depth: 0 28 | 29 | - name: NPM install 30 | run: npm install 31 | 32 | - name: Build Docker image 33 | run: | 34 | docker build -t catalogue . # Build image tagged as 'payment' from current directory 35 | 36 | - name: Docker Login (use secrets) 37 | run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} 38 | 39 | - name: Docker Push 40 | run: | 41 | docker tag catalogue ${name}/catalogue:latest 42 | docker catalogue ${name}/catalogue:latest -------------------------------------------------------------------------------- /.github/workflows/dispatch.yaml: -------------------------------------------------------------------------------- 1 | name: Dispatch 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | paths: 8 | - '**.go' # Only trigger on changes to Python files (**.py) 9 | - '.github/workflows/dispatch.yaml' # Include workflow file changes 10 | 11 | pull_request: 12 | branches: 13 | - master 14 | paths: 15 | - '**.go' # Only trigger on changes to Python files (**.py) 16 | - '.github/workflows/dispatch.yaml' # Include workflow file changes 17 | 18 | jobs: 19 | payment: 20 | name: Build and deploy dispatch microservice 21 | runs-on: [self-hosted] # Use a standard runner instead of self-hosted 22 | 23 | steps: 24 | - name: Checkout code 25 | uses: actions/checkout@v2 26 | with: 27 | fetch-depth: 0 28 | 29 | - name: Go install 30 | run: | 31 | curl -sL https://dl.google.com/go/go1.18.linux-amd64.tar.gz | 32 | export PATH=$PATH:/home/runner/go/bin 33 | 34 | - name: Build Docker image 35 | run: | 36 | docker build -t payment . # Build image tagged as 'payment' from current directory 37 | 38 | - name: Docker Login (use secrets) 39 | run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} 40 | 41 | - name: Docker Push 42 | run: | 43 | docker tag dispatch ${name}/dispatch:latest 44 | docker push ${name}/dispatch:latest -------------------------------------------------------------------------------- /.github/workflows/payment.yaml: -------------------------------------------------------------------------------- 1 | name: Payment 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | paths: 8 | - '**.py' # Only trigger on changes to Python files (**.py) 9 | - '.github/workflows/payment.yaml' # Include workflow file changes 10 | 11 | pull_request: 12 | branches: 13 | - master 14 | paths: 15 | - '**.py' # Only trigger on changes to Python files (**.py) 16 | - '.github/workflows/payment.yaml' # Include workflow file changes 17 | 18 | jobs: 19 | payment: 20 | name: Build and deploy payment microservice 21 | runs-on: [self-hosted] # Use a standard runner instead of self-hosted 22 | 23 | steps: 24 | - name: Checkout code 25 | uses: actions/checkout@v2 26 | with: 27 | fetch-depth: 0 28 | 29 | - name: Python install 30 | run: sudo apt-get install python3 31 | 32 | - name: Build Docker image 33 | run: | 34 | docker build -t payment . # Build image tagged as 'payment' from current directory 35 | 36 | - name: Docker Login (use secrets) 37 | run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} 38 | 39 | - name: Docker Push 40 | run: | 41 | docker tag payment ${name}/payment:latest 42 | docker push ${name}/payment:latest -------------------------------------------------------------------------------- /.github/workflows/push.yml: -------------------------------------------------------------------------------- 1 | name: docker-compose-actions-workflow 2 | on: 3 | push: 4 | branches: 5 | - 'master' 6 | paths-ignore: 7 | - 'DCOS/**' 8 | - 'K8s/**' 9 | - 'load-gen/**' 10 | - 'OpenShift/**' 11 | - 'Swarm/**' 12 | 13 | jobs: 14 | test: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v2 18 | - name: Build the stack 19 | run: docker-compose build 20 | -------------------------------------------------------------------------------- /.github/workflows/shipping.yaml: -------------------------------------------------------------------------------- 1 | name: Dispatch 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | paths: 8 | - '**.java' # Only trigger on changes to Python files (**.py) 9 | - '.github/workflows/shipping.yaml' # Include workflow file changes 10 | 11 | pull_request: 12 | branches: 13 | - master 14 | paths: 15 | - '**.java' # Only trigger on changes to Python files (**.py) 16 | - '.github/workflows/shipping.yaml' # Include workflow file changes 17 | 18 | jobs: 19 | payment: 20 | name: Build and deploy shipping microservice 21 | runs-on: [self-hosted] # Use a standard runner instead of self-hosted 22 | 23 | steps: 24 | - name: Checkout code 25 | uses: actions/checkout@v2 26 | with: 27 | fetch-depth: 0 28 | 29 | - name: Go install 30 | run: | 31 | sudo apt-get install openjdk 17 | 32 | java -version 33 | 34 | - name: Build Docker image 35 | run: | 36 | docker build -t shipping . 37 | 38 | - name: Docker Login (use secrets) 39 | run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} 40 | 41 | - name: Docker Push 42 | run: | 43 | docker tag shipping ${name}/shipping:latest 44 | docker push ${name}/shipping:latest -------------------------------------------------------------------------------- /.github/workflows/user.yaml: -------------------------------------------------------------------------------- 1 | name: User 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | paths: 8 | - '**.js' # Only trigger on changes to Python files (**.py) 9 | - '.github/workflows/user.yaml' # Include workflow file changes 10 | 11 | pull_request: 12 | branches: 13 | - master 14 | paths: 15 | - '**.js' # Only trigger on changes to Python files (**.py) 16 | - '.github/workflows/user.yaml' # Include workflow file changes 17 | 18 | jobs: 19 | payment: 20 | name: Build and deploy user microservice 21 | runs-on: [self-hosted] # Use a standard runner instead of self-hosted 22 | 23 | steps: 24 | - name: Checkout code 25 | uses: actions/checkout@v2 26 | with: 27 | fetch-depth: 0 28 | 29 | - name: NPM install 30 | run: npm install 31 | 32 | - name: Build Docker image 33 | run: | 34 | docker build -t user . # Build image tagged as 'payment' from current directory 35 | 36 | - name: Docker Login (use secrets) 37 | run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} 38 | 39 | - name: Docker Push 40 | run: | 41 | docker tag user ${name}/user:latest 42 | docker user ${name}/user:latest -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .*.swp 2 | .DS_Store 3 | *-private.* 4 | vendor/ 5 | Gopkg.lock -------------------------------------------------------------------------------- /AKS/helm/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | name: robot-shop 3 | version: 1.1.0 4 | home: https://github.com/instana/robot-shop 5 | description: Sample micoservices application 6 | 7 | -------------------------------------------------------------------------------- /AKS/helm/ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1 2 | kind: Ingress 3 | metadata: 4 | namespace: robot-shop 5 | name: robot-shop 6 | spec: 7 | ingressClassName: azure-application-gateway 8 | rules: 9 | - http: 10 | paths: 11 | - path: / 12 | pathType: Prefix 13 | backend: 14 | service: 15 | name: web 16 | port: 17 | number: 8080 18 | -------------------------------------------------------------------------------- /AKS/helm/templates/cart-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: cart 5 | labels: 6 | service: cart 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: cart 12 | template: 13 | metadata: 14 | labels: 15 | service: cart 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: cart 22 | image: {{ .Values.image.repo }}/rs-cart:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | # agent networking access 25 | env: 26 | - name: INSTANA_AGENT_HOST 27 | valueFrom: 28 | fieldRef: 29 | fieldPath: status.hostIP 30 | ports: 31 | - containerPort: 8080 32 | resources: 33 | limits: 34 | cpu: 200m 35 | memory: 100Mi 36 | requests: 37 | cpu: 100m 38 | memory: 50Mi 39 | {{- with .Values.cart.affinity }} 40 | affinity: 41 | {{- toYaml . | nindent 8 }} 42 | {{- end }} 43 | {{- with .Values.cart.nodeSelector }} 44 | nodeSelector: 45 | {{- toYaml . | nindent 8 }} 46 | {{- end }} 47 | {{- with .Values.cart.tolerations }} 48 | tolerations: 49 | {{- toYaml . | nindent 8 }} 50 | {{- end }} 51 | -------------------------------------------------------------------------------- /AKS/helm/templates/cart-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: cart 5 | spec: 6 | ports: 7 | - name: http 8 | port: 8080 9 | targetPort: 8080 10 | selector: 11 | service: cart 12 | -------------------------------------------------------------------------------- /AKS/helm/templates/catalogue-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: catalogue 5 | labels: 6 | service: catalogue 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: catalogue 12 | template: 13 | metadata: 14 | labels: 15 | service: catalogue 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: catalogue 22 | image: {{ .Values.image.repo }}/rs-catalogue:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | env: 25 | - name: INSTANA_AGENT_HOST 26 | valueFrom: 27 | fieldRef: 28 | fieldPath: status.hostIP 29 | ports: 30 | - containerPort: 8080 31 | resources: 32 | limits: 33 | cpu: 200m 34 | memory: 100Mi 35 | requests: 36 | cpu: 100m 37 | memory: 50Mi 38 | restartPolicy: Always 39 | {{- with .Values.catalogue.affinity }} 40 | affinity: 41 | {{- toYaml . | nindent 8 }} 42 | {{- end }} 43 | {{- with .Values.catalogue.nodeSelector }} 44 | nodeSelector: 45 | {{- toYaml . | nindent 8 }} 46 | {{- end }} 47 | {{- with .Values.catalogue.tolerations }} 48 | tolerations: 49 | {{- toYaml . | nindent 8 }} 50 | {{- end }} 51 | -------------------------------------------------------------------------------- /AKS/helm/templates/catalogue-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | service: catalogue 6 | name: catalogue 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: catalogue 14 | -------------------------------------------------------------------------------- /AKS/helm/templates/clusterrole.yaml: -------------------------------------------------------------------------------- 1 | {{ if .Values.psp.enabled }} 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRole 4 | metadata: 5 | name: robot-shop 6 | rules: 7 | - apiGroups: 8 | - policy 9 | resourceNames: 10 | - robot-shop 11 | resources: 12 | - podsecuritypolicies 13 | verbs: 14 | - use 15 | {{ end }} 16 | -------------------------------------------------------------------------------- /AKS/helm/templates/clusterrolebinding.yaml: -------------------------------------------------------------------------------- 1 | {{ if .Values.psp.enabled }} 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRoleBinding 4 | metadata: 5 | name: robot-shop 6 | roleRef: 7 | apiGroup: rbac.authorization.k8s.io 8 | kind: ClusterRole 9 | name: robot-shop 10 | subjects: 11 | - kind: ServiceAccount 12 | name: robot-shop 13 | namespace: robot-shop 14 | {{ end }} 15 | -------------------------------------------------------------------------------- /AKS/helm/templates/dispatch-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: dispatch 5 | labels: 6 | service: dispatch 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: dispatch 12 | template: 13 | metadata: 14 | labels: 15 | service: dispatch 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: dispatch 22 | image: {{ .Values.image.repo }}/rs-dispatch:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | env: 25 | # agent networking access 26 | - name: INSTANA_AGENT_HOST 27 | valueFrom: 28 | fieldRef: 29 | fieldPath: status.hostIP 30 | resources: 31 | limits: 32 | cpu: 200m 33 | memory: 100Mi 34 | requests: 35 | cpu: 100m 36 | memory: 50Mi 37 | restartPolicy: Always 38 | {{- with .Values.dispatch.affinity }} 39 | affinity: 40 | {{- toYaml . | nindent 8 }} 41 | {{- end }} 42 | {{- with .Values.dispatch.nodeSelector }} 43 | nodeSelector: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | {{- with .Values.dispatch.tolerations }} 47 | tolerations: 48 | {{- toYaml . | nindent 8 }} 49 | {{- end }} 50 | -------------------------------------------------------------------------------- /AKS/helm/templates/dispatch-service.yaml: -------------------------------------------------------------------------------- 1 | # dispatch just listens to a message queue 2 | # it does not expose any ports 3 | apiVersion: v1 4 | kind: Service 5 | metadata: 6 | name: dispatch 7 | labels: 8 | service: dispatch 9 | spec: 10 | clusterIP: None 11 | ports: 12 | - name: headless 13 | port: 55555 14 | targetPort: 0 15 | selector: 16 | service: dispatch 17 | -------------------------------------------------------------------------------- /AKS/helm/templates/mongodb-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: mongodb 5 | labels: 6 | service: mongodb 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: mongodb 12 | template: 13 | metadata: 14 | labels: 15 | service: mongodb 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: mongodb 22 | image: {{ .Values.image.repo }}/rs-mongodb:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | ports: 25 | - containerPort: 27017 26 | resources: 27 | limits: 28 | cpu: 200m 29 | memory: 200Mi 30 | requests: 31 | cpu: 100m 32 | memory: 100Mi 33 | restartPolicy: Always 34 | {{- with .Values.mongodb.affinity }} 35 | affinity: 36 | {{- toYaml . | nindent 8 }} 37 | {{- end }} 38 | {{- with .Values.mongodb.nodeSelector }} 39 | nodeSelector: 40 | {{- toYaml . | nindent 8 }} 41 | {{- end }} 42 | {{- with .Values.mongodb.tolerations }} 43 | tolerations: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | -------------------------------------------------------------------------------- /AKS/helm/templates/mongodb-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | service: mongodb 6 | name: mongodb 7 | spec: 8 | ports: 9 | - name: mongo 10 | port: 27017 11 | targetPort: 27017 12 | selector: 13 | service: mongodb 14 | -------------------------------------------------------------------------------- /AKS/helm/templates/mysql-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: mysql 5 | labels: 6 | service: mysql 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: mysql 12 | template: 13 | metadata: 14 | labels: 15 | service: mysql 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: mysql 22 | image: {{ .Values.image.repo }}/rs-mysql-db:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | # added for Istio 25 | securityContext: 26 | capabilities: 27 | add: ["NET_ADMIN"] 28 | ports: 29 | - containerPort: 3306 30 | resources: 31 | limits: 32 | cpu: 200m 33 | memory: 1024Mi 34 | requests: 35 | cpu: 100m 36 | memory: 700Mi 37 | restartPolicy: Always 38 | {{- with .Values.mysql.affinity }} 39 | affinity: 40 | {{- toYaml . | nindent 8 }} 41 | {{- end }} 42 | {{- with .Values.mysql.nodeSelector }} 43 | nodeSelector: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | {{- with .Values.mysql.tolerations }} 47 | tolerations: 48 | {{- toYaml . | nindent 8 }} 49 | {{- end }} 50 | -------------------------------------------------------------------------------- /AKS/helm/templates/mysql-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | service: mysql 6 | name: mysql 7 | spec: 8 | ports: 9 | - name: mysql 10 | port: 3306 11 | targetPort: 3306 12 | selector: 13 | service: mysql 14 | -------------------------------------------------------------------------------- /AKS/helm/templates/payment-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: payment 5 | labels: 6 | service: payment 7 | stage: prod 8 | spec: 9 | replicas: 1 10 | selector: 11 | matchLabels: 12 | service: payment 13 | stage: prod 14 | template: 15 | metadata: 16 | labels: 17 | service: payment 18 | stage: prod 19 | spec: 20 | {{ if .Values.psp.enabled }} 21 | serviceAccountName: robot-shop 22 | {{ end }} 23 | containers: 24 | - name: payment 25 | image: {{ .Values.image.repo }}/rs-payment:{{ .Values.image.version }} 26 | imagePullPolicy: {{ .Values.image.pullPolicy }} 27 | # agent networking access 28 | env: 29 | - name: INSTANA_AGENT_HOST 30 | valueFrom: 31 | fieldRef: 32 | fieldPath: status.hostIP 33 | {{- if .Values.payment.gateway }} 34 | - name: PAYMENT_GATEWAY 35 | value: {{ .Values.payment.gateway }} 36 | {{- end }} 37 | ports: 38 | - containerPort: 8080 39 | resources: 40 | limits: 41 | cpu: 200m 42 | memory: 100Mi 43 | requests: 44 | cpu: 100m 45 | memory: 50Mi 46 | restartPolicy: Always 47 | {{- with .Values.payment.affinity }} 48 | affinity: 49 | {{- toYaml . | nindent 8 }} 50 | {{- end }} 51 | {{- with .Values.payment.nodeSelector }} 52 | nodeSelector: 53 | {{- toYaml . | nindent 8 }} 54 | {{- end }} 55 | {{- with .Values.payment.tolerations }} 56 | tolerations: 57 | {{- toYaml . | nindent 8 }} 58 | {{- end }} 59 | -------------------------------------------------------------------------------- /AKS/helm/templates/payment-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: payment 5 | labels: 6 | service: payment 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: payment 14 | -------------------------------------------------------------------------------- /AKS/helm/templates/podsecuritypolicy.yaml: -------------------------------------------------------------------------------- 1 | {{ if .Values.psp.enabled }} 2 | apiVersion: policy/v1beta1 3 | kind: PodSecurityPolicy 4 | metadata: 5 | name: robot-shop 6 | spec: 7 | allowPrivilegeEscalation: false 8 | fsGroup: 9 | rule: RunAsAny 10 | privileged: false 11 | runAsUser: 12 | rule: RunAsAny 13 | seLinux: 14 | rule: RunAsAny 15 | supplementalGroups: 16 | rule: RunAsAny 17 | allowedCapabilities: 18 | - 'NET_ADMIN' 19 | volumes: 20 | - configMap 21 | - downwardAPI 22 | - emptyDir 23 | - persistentVolumeClaim 24 | - secret 25 | - projected 26 | {{ end }} 27 | -------------------------------------------------------------------------------- /AKS/helm/templates/rabbitmq-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: rabbitmq 5 | labels: 6 | service: rabbitmq 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: rabbitmq 12 | template: 13 | metadata: 14 | labels: 15 | service: rabbitmq 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: rabbitmq 22 | image: rabbitmq:3.7-management-alpine 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | ports: 25 | - containerPort: 5672 26 | - containerPort: 15672 27 | resources: 28 | limits: 29 | cpu: 200m 30 | memory: 512Mi 31 | requests: 32 | cpu: 100m 33 | memory: 256Mi 34 | restartPolicy: Always 35 | {{- with .Values.rabbitmq.affinity }} 36 | affinity: 37 | {{- toYaml . | nindent 8 }} 38 | {{- end }} 39 | {{- with .Values.rabbitmq.nodeSelector }} 40 | nodeSelector: 41 | {{- toYaml . | nindent 8 }} 42 | {{- end }} 43 | {{- with .Values.rabbitmq.tolerations }} 44 | tolerations: 45 | {{- toYaml . | nindent 8 }} 46 | {{- end }} 47 | -------------------------------------------------------------------------------- /AKS/helm/templates/rabbitmq-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: rabbitmq 5 | labels: 6 | service: rabbitmq 7 | spec: 8 | ports: 9 | - name: tcp-amqp 10 | port: 5672 11 | targetPort: 5672 12 | - name: http-management 13 | port: 15672 14 | targetPort: 15672 15 | - name: tcp-epmd 16 | port: 4369 17 | targetPort: 4369 18 | selector: 19 | service: rabbitmq 20 | -------------------------------------------------------------------------------- /AKS/helm/templates/ratings-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: ratings 5 | labels: 6 | service: ratings 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: ratings 12 | template: 13 | metadata: 14 | labels: 15 | service: ratings 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: ratings 22 | image: {{ .Values.image.repo }}/rs-ratings:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | ports: 25 | - containerPort: 80 26 | resources: 27 | limits: 28 | cpu: 200m 29 | memory: 100Mi 30 | requests: 31 | cpu: 100m 32 | memory: 50Mi 33 | readinessProbe: 34 | httpGet: 35 | path: /_health 36 | port: 80 37 | initialDelaySeconds: 5 38 | periodSeconds: 5 39 | failureThreshold: 30 40 | successThreshold: 1 41 | restartPolicy: Always 42 | {{- with .Values.ratings.affinity }} 43 | affinity: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | {{- with .Values.ratings.nodeSelector }} 47 | nodeSelector: 48 | {{- toYaml . | nindent 8 }} 49 | {{- end }} 50 | {{- with .Values.ratings.tolerations }} 51 | tolerations: 52 | {{- toYaml . | nindent 8 }} 53 | {{- end }} 54 | -------------------------------------------------------------------------------- /AKS/helm/templates/ratings-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: ratings 5 | labels: 6 | service: ratings 7 | spec: 8 | ports: 9 | - name: http 10 | port: 80 11 | targetPort: 80 12 | selector: 13 | service: ratings 14 | 15 | -------------------------------------------------------------------------------- /AKS/helm/templates/redis-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | service: redis 6 | name: redis 7 | spec: 8 | ports: 9 | - name: redis 10 | port: 6379 11 | targetPort: 6379 12 | selector: 13 | service: redis 14 | -------------------------------------------------------------------------------- /AKS/helm/templates/redis-statefulset.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: StatefulSet 3 | metadata: 4 | labels: 5 | service: redis 6 | name: redis 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: redis 12 | serviceName: redis 13 | template: 14 | metadata: 15 | labels: 16 | service: redis 17 | spec: 18 | {{ if .Values.psp.enabled }} 19 | serviceAccountName: robot-shop 20 | {{ end }} 21 | containers: 22 | - name: redis 23 | image: redis:4.0.6 24 | imagePullPolicy: {{ .Values.image.pullPolicy }} 25 | ports: 26 | - containerPort: 6379 27 | volumeMounts: 28 | - name: data 29 | mountPath: /mnt/redis 30 | resources: 31 | limits: 32 | cpu: 200m 33 | memory: 100Mi 34 | requests: 35 | cpu: 100m 36 | memory: 50Mi 37 | restartPolicy: Always 38 | {{- with .Values.redis.affinity }} 39 | affinity: 40 | {{- toYaml . | nindent 8 }} 41 | {{- end }} 42 | {{- with .Values.redis.nodeSelector }} 43 | nodeSelector: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | {{- with .Values.redis.tolerations }} 47 | tolerations: 48 | {{- toYaml . | nindent 8 }} 49 | {{- end }} 50 | volumeClaimTemplates: 51 | - metadata: 52 | name: data 53 | spec: 54 | accessModes: [ "ReadWriteOnce" ] 55 | {{ if not .Values.openshift }} 56 | storageClassName: default 57 | volumeMode: Filesystem 58 | {{ end }} 59 | resources: 60 | requests: 61 | storage: 1Gi 62 | 63 | -------------------------------------------------------------------------------- /AKS/helm/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | {{ if .Values.psp.enabled }} 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | name: robot-shop 6 | namespace: robot-shop 7 | {{ end }} 8 | -------------------------------------------------------------------------------- /AKS/helm/templates/shipping-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: shipping 5 | labels: 6 | service: shipping 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: shipping 12 | template: 13 | metadata: 14 | labels: 15 | service: shipping 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: shipping 22 | image: {{ .Values.image.repo }}/rs-shipping:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | ports: 25 | - containerPort: 8080 26 | # it's Java it needs lots of memory 27 | resources: 28 | limits: 29 | cpu: 200m 30 | memory: 1000Mi 31 | requests: 32 | cpu: 100m 33 | memory: 500Mi 34 | readinessProbe: 35 | httpGet: 36 | path: /health 37 | port: 8080 38 | initialDelaySeconds: 5 39 | periodSeconds: 5 40 | failureThreshold: 30 41 | successThreshold: 1 42 | restartPolicy: Always 43 | {{- with .Values.shipping.affinity }} 44 | affinity: 45 | {{- toYaml . | nindent 8 }} 46 | {{- end }} 47 | {{- with .Values.shipping.nodeSelector }} 48 | nodeSelector: 49 | {{- toYaml . | nindent 8 }} 50 | {{- end }} 51 | {{- with .Values.shipping.tolerations }} 52 | tolerations: 53 | {{- toYaml . | nindent 8 }} 54 | {{- end }} 55 | -------------------------------------------------------------------------------- /AKS/helm/templates/shipping-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: shipping 5 | labels: 6 | service: shipping 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: shipping 14 | -------------------------------------------------------------------------------- /AKS/helm/templates/user-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: user 5 | labels: 6 | service: user 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: user 12 | template: 13 | metadata: 14 | labels: 15 | service: user 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: user 22 | image: {{ .Values.image.repo }}/rs-user:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | env: 25 | # agent networking access 26 | - name: INSTANA_AGENT_HOST 27 | valueFrom: 28 | fieldRef: 29 | fieldPath: status.hostIP 30 | ports: 31 | - containerPort: 8080 32 | resources: 33 | limits: 34 | cpu: 200m 35 | memory: 100Mi 36 | requests: 37 | cpu: 100m 38 | memory: 50Mi 39 | restartPolicy: Always 40 | {{- with .Values.user.affinity }} 41 | affinity: 42 | {{- toYaml . | nindent 8 }} 43 | {{- end }} 44 | {{- with .Values.user.nodeSelector }} 45 | nodeSelector: 46 | {{- toYaml . | nindent 8 }} 47 | {{- end }} 48 | {{- with .Values.user.tolerations }} 49 | tolerations: 50 | {{- toYaml . | nindent 8 }} 51 | {{- end }} 52 | -------------------------------------------------------------------------------- /AKS/helm/templates/user-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: user 5 | labels: 6 | service: user 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: user 14 | -------------------------------------------------------------------------------- /AKS/helm/templates/web-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: web 5 | labels: 6 | service: web 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: web 12 | template: 13 | metadata: 14 | labels: 15 | service: web 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: web 22 | image: {{ .Values.image.repo }}/rs-web:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | {{- if .Values.eum.key }} 25 | env: 26 | - name: INSTANA_EUM_KEY 27 | value: {{ .Values.eum.key }} 28 | - name: INSTANA_EUM_REPORTING_URL 29 | value: {{ .Values.eum.url }} 30 | {{- end}} 31 | ports: 32 | - containerPort: 8080 33 | resources: 34 | limits: 35 | cpu: 200m 36 | memory: 100Mi 37 | requests: 38 | cpu: 100m 39 | memory: 50Mi 40 | restartPolicy: Always 41 | {{- with .Values.web.affinity }} 42 | affinity: 43 | {{- toYaml . | nindent 8 }} 44 | {{- end }} 45 | {{- with .Values.web.nodeSelector }} 46 | nodeSelector: 47 | {{- toYaml . | nindent 8 }} 48 | {{- end }} 49 | {{- with .Values.web.tolerations }} 50 | tolerations: 51 | {{- toYaml . | nindent 8 }} 52 | {{- end }} 53 | -------------------------------------------------------------------------------- /AKS/helm/templates/web-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: web 5 | labels: 6 | service: web 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: web 14 | {{ if .Values.nodeport }} 15 | type: NodePort 16 | {{ else }} 17 | type: LoadBalancer 18 | {{ end }} 19 | --- 20 | {{if .Values.ocCreateRoute}} 21 | apiVersion: route.openshift.io/v1 22 | kind: Route 23 | metadata: 24 | name: web 25 | spec: 26 | to: 27 | kind: Service 28 | name: web 29 | {{end}} -------------------------------------------------------------------------------- /AKS/helm/values.yaml: -------------------------------------------------------------------------------- 1 | # Registry and repository for Docker images 2 | # Default is docker/robotshop/image:latest 3 | image: 4 | repo: robotshop 5 | version: latest 6 | pullPolicy: IfNotPresent 7 | 8 | # EUM configuration 9 | # Provide your key and set the endpoint 10 | eum: 11 | key: null 12 | url: https://eum-eu-west-1.instana.io 13 | #url: https://eum-us-west-2.instana.io 14 | 15 | # Pod Security Policy 16 | psp: 17 | enabled: false 18 | 19 | # For the mini ones minikube, minishift set to true 20 | nodeport: false 21 | 22 | # "special" Openshift. Set to true when deploying to any openshift flavour 23 | openshift: false 24 | 25 | ocCreateRoute: false 26 | 27 | ###################################### 28 | # Affinities for individual workloads 29 | # set in the following way: 30 | # : 31 | # affinity: {} 32 | # nodeSelector: {} 33 | # tolerations: [] 34 | ###################################### 35 | 36 | cart: {} 37 | 38 | catalogue: {} 39 | 40 | dispatch: {} 41 | 42 | mongodb: {} 43 | 44 | mysql: {} 45 | 46 | payment: 47 | # Alternative payment gateway URL 48 | # Default is https://www.paypal.com 49 | gateway: null 50 | #gateway: https://www.worldpay.com 51 | 52 | rabbitmq: {} 53 | 54 | ratings: {} 55 | 56 | redis: 57 | # Storage class to use with redis statefulset. 58 | storageClassName: default 59 | 60 | shipping: {} 61 | 62 | user: {} 63 | 64 | web: {} 65 | -------------------------------------------------------------------------------- /DCOS/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd manifest && \ 4 | for i in *.json; do dcos marathon app add $i; done -------------------------------------------------------------------------------- /DCOS/destroy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dcos marathon app remove robotshop/cart 4 | dcos marathon app remove robotshop/catalogue 5 | dcos marathon app remove robotshop/dispatch 6 | dcos marathon app remove robotshop/mongodb 7 | dcos marathon app remove robotshop/mysql 8 | dcos marathon app remove robotshop/payment 9 | dcos marathon app remove robotshop/rabbitmq 10 | dcos marathon app remove robotshop/redis 11 | dcos marathon app remove robotshop/shipping 12 | dcos marathon app remove robotshop/user 13 | dcos marathon app remove robotshop/web 14 | -------------------------------------------------------------------------------- /DCOS/manifest/cart.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "/robotshop/cart", 3 | "backoffFactor": 1.15, 4 | "backoffSeconds": 30, 5 | "container": { 6 | "portMappings": [ 7 | { 8 | "containerPort": 0, 9 | "labels": { 10 | "VIP_0": "/robotshop/cart:8080" 11 | }, 12 | "servicePort": 10008 13 | } 14 | ], 15 | "type": "DOCKER", 16 | "volumes": [], 17 | "docker": { 18 | "image": "robotshop/rs-cart:latest", 19 | "forcePullImage": false, 20 | "privileged": false, 21 | "parameters": [] 22 | } 23 | }, 24 | "cpus": 0.2, 25 | "disk": 0, 26 | "env": { 27 | "REDIS_HOST": "robotshopredis.marathon.l4lb.thisdcos.directory", 28 | "CATALOGUE_HOST": "robotshopcatalogue.marathon.l4lb.thisdcos.directory" 29 | }, 30 | "instances": 1, 31 | "maxLaunchDelaySeconds": 900, 32 | "mem": 128, 33 | "gpus": 0, 34 | "networks": [ 35 | { 36 | "name": "dcos", 37 | "mode": "container" 38 | } 39 | ], 40 | "requirePorts": false, 41 | "upgradeStrategy": { 42 | "maximumOverCapacity": 1, 43 | "minimumHealthCapacity": 1 44 | }, 45 | "killSelection": "YOUNGEST_FIRST", 46 | "unreachableStrategy": { 47 | "inactiveAfterSeconds": 0, 48 | "expungeAfterSeconds": 0 49 | }, 50 | "healthChecks": [], 51 | "fetch": [], 52 | "constraints": [] 53 | } -------------------------------------------------------------------------------- /DCOS/manifest/catalogue.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "/robotshop/catalogue", 3 | "backoffFactor": 1.15, 4 | "backoffSeconds": 30, 5 | "container": { 6 | "portMappings": [ 7 | { 8 | "containerPort": 0, 9 | "labels": { 10 | "VIP_0": "/robotshop/catalogue:8080" 11 | }, 12 | "servicePort": 10006 13 | } 14 | ], 15 | "type": "DOCKER", 16 | "volumes": [], 17 | "docker": { 18 | "image": "robotshop/rs-catalogue:latest", 19 | "forcePullImage": false, 20 | "privileged": false, 21 | "parameters": [] 22 | } 23 | }, 24 | "cpus": 0.2, 25 | "disk": 0, 26 | "env": { 27 | "MONGO_URL": "mongodb://robotshopmongodb.marathon.l4lb.thisdcos.directory:27017/catalogue" 28 | }, 29 | "instances": 1, 30 | "maxLaunchDelaySeconds": 900, 31 | "mem": 256, 32 | "gpus": 0, 33 | "networks": [ 34 | { 35 | "name": "dcos", 36 | "mode": "container" 37 | } 38 | ], 39 | "requirePorts": false, 40 | "upgradeStrategy": { 41 | "maximumOverCapacity": 1, 42 | "minimumHealthCapacity": 1 43 | }, 44 | "killSelection": "YOUNGEST_FIRST", 45 | "unreachableStrategy": { 46 | "inactiveAfterSeconds": 0, 47 | "expungeAfterSeconds": 0 48 | }, 49 | "healthChecks": [], 50 | "fetch": [], 51 | "constraints": [] 52 | } -------------------------------------------------------------------------------- /DCOS/manifest/dispatch.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "/robotshop/dispatch", 3 | "backoffFactor": 1.15, 4 | "backoffSeconds": 30, 5 | "container": { 6 | "portMappings": [], 7 | "type": "DOCKER", 8 | "volumes": [], 9 | "docker": { 10 | "image": "robotshop/rs-dispatch:latest", 11 | "forcePullImage": false, 12 | "privileged": false, 13 | "parameters": [] 14 | } 15 | }, 16 | "cpus": 0.2, 17 | "disk": 0, 18 | "env": { 19 | "AMQP_HOST": "robotshoprabbitmq.marathon.l4lb.thisdcos.directory" 20 | }, 21 | "instances": 1, 22 | "maxLaunchDelaySeconds": 900, 23 | "mem": 128, 24 | "gpus": 0, 25 | "networks": [ 26 | { 27 | "name": "dcos", 28 | "mode": "container" 29 | } 30 | ], 31 | "requirePorts": false, 32 | "upgradeStrategy": { 33 | "maximumOverCapacity": 1, 34 | "minimumHealthCapacity": 1 35 | }, 36 | "killSelection": "YOUNGEST_FIRST", 37 | "unreachableStrategy": { 38 | "inactiveAfterSeconds": 0, 39 | "expungeAfterSeconds": 0 40 | }, 41 | "healthChecks": [], 42 | "fetch": [], 43 | "constraints": [] 44 | } -------------------------------------------------------------------------------- /DCOS/manifest/mongodb.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "/robotshop/mongodb", 3 | "backoffFactor": 1.15, 4 | "backoffSeconds": 30, 5 | "container": { 6 | "portMappings": [ 7 | { 8 | "containerPort": 0, 9 | "labels": { 10 | "VIP_0": "/robotshop/mongodb:27017" 11 | }, 12 | "servicePort": 10002 13 | } 14 | ], 15 | "type": "DOCKER", 16 | "volumes": [], 17 | "docker": { 18 | "image": "robotshop/rs-mongodb:latest", 19 | "forcePullImage": false, 20 | "privileged": false, 21 | "parameters": [] 22 | } 23 | }, 24 | "cpus": 0.2, 25 | "disk": 0, 26 | "instances": 1, 27 | "maxLaunchDelaySeconds": 900, 28 | "mem": 256, 29 | "gpus": 0, 30 | "networks": [ 31 | { 32 | "name": "dcos", 33 | "mode": "container" 34 | } 35 | ], 36 | "requirePorts": false, 37 | "upgradeStrategy": { 38 | "maximumOverCapacity": 1, 39 | "minimumHealthCapacity": 1 40 | }, 41 | "killSelection": "YOUNGEST_FIRST", 42 | "unreachableStrategy": { 43 | "inactiveAfterSeconds": 0, 44 | "expungeAfterSeconds": 0 45 | }, 46 | "healthChecks": [], 47 | "fetch": [], 48 | "constraints": [] 49 | } -------------------------------------------------------------------------------- /DCOS/manifest/mysql.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "/robotshop/mysql", 3 | "backoffFactor": 1.15, 4 | "backoffSeconds": 30, 5 | "container": { 6 | "portMappings": [ 7 | { 8 | "containerPort": 0, 9 | "labels": { 10 | "VIP_0": "/robotshop/mysql:3306" 11 | }, 12 | "servicePort": 10000 13 | } 14 | ], 15 | "type": "DOCKER", 16 | "volumes": [], 17 | "docker": { 18 | "image": "robotshop/rs-shipping-db:latest", 19 | "forcePullImage": false, 20 | "privileged": false, 21 | "parameters": [] 22 | } 23 | }, 24 | "cpus": 0.2, 25 | "disk": 0, 26 | "instances": 1, 27 | "maxLaunchDelaySeconds": 900, 28 | "mem": 512, 29 | "gpus": 0, 30 | "networks": [ 31 | { 32 | "name": "dcos", 33 | "mode": "container" 34 | } 35 | ], 36 | "requirePorts": false, 37 | "upgradeStrategy": { 38 | "maximumOverCapacity": 1, 39 | "minimumHealthCapacity": 1 40 | }, 41 | "killSelection": "YOUNGEST_FIRST", 42 | "unreachableStrategy": { 43 | "inactiveAfterSeconds": 0, 44 | "expungeAfterSeconds": 0 45 | }, 46 | "healthChecks": [], 47 | "fetch": [], 48 | "constraints": [] 49 | } -------------------------------------------------------------------------------- /DCOS/manifest/payment.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "/robotshop/payment", 3 | "backoffFactor": 1.15, 4 | "backoffSeconds": 30, 5 | "container": { 6 | "portMappings": [ 7 | { 8 | "containerPort": 0, 9 | "labels": { 10 | "VIP_0": "/robotshop/payment:8080" 11 | }, 12 | "servicePort": 10009 13 | } 14 | ], 15 | "type": "DOCKER", 16 | "volumes": [], 17 | "docker": { 18 | "image": "robotshop/rs-payment:latest", 19 | "forcePullImage": false, 20 | "privileged": false, 21 | "parameters": [] 22 | } 23 | }, 24 | "cpus": 0.2, 25 | "disk": 0, 26 | "env": { 27 | "AMQP_HOST": "robotshoprabbitmq.marathon.l4lb.thisdcos.directory" 28 | }, 29 | "instances": 1, 30 | "maxLaunchDelaySeconds": 900, 31 | "mem": 128, 32 | "gpus": 0, 33 | "networks": [ 34 | { 35 | "name": "dcos", 36 | "mode": "container" 37 | } 38 | ], 39 | "requirePorts": false, 40 | "upgradeStrategy": { 41 | "maximumOverCapacity": 1, 42 | "minimumHealthCapacity": 1 43 | }, 44 | "killSelection": "YOUNGEST_FIRST", 45 | "unreachableStrategy": { 46 | "inactiveAfterSeconds": 0, 47 | "expungeAfterSeconds": 0 48 | }, 49 | "healthChecks": [], 50 | "fetch": [], 51 | "constraints": [] 52 | } -------------------------------------------------------------------------------- /DCOS/manifest/rabbitmq.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "/robotshop/rabbitmq", 3 | "backoffFactor": 1.15, 4 | "backoffSeconds": 30, 5 | "container": { 6 | "portMappings": [ 7 | { 8 | "containerPort": 0, 9 | "labels": { 10 | "VIP_0": "/robotshop/rabbitmq:5672" 11 | }, 12 | "servicePort": 10004 13 | }, 14 | { 15 | "containerPort": 0, 16 | "labels": { 17 | "VIP_1": "/robotshop/rabbitmq:15672" 18 | }, 19 | "servicePort": 10005 20 | } 21 | ], 22 | "type": "DOCKER", 23 | "volumes": [], 24 | "docker": { 25 | "image": "rabbitmq:3.7-management-alpine", 26 | "forcePullImage": false, 27 | "privileged": false, 28 | "parameters": [] 29 | } 30 | }, 31 | "cpus": 0.2, 32 | "disk": 0, 33 | "instances": 1, 34 | "maxLaunchDelaySeconds": 900, 35 | "mem": 256, 36 | "gpus": 0, 37 | "networks": [ 38 | { 39 | "name": "dcos", 40 | "mode": "container" 41 | } 42 | ], 43 | "requirePorts": false, 44 | "upgradeStrategy": { 45 | "maximumOverCapacity": 1, 46 | "minimumHealthCapacity": 1 47 | }, 48 | "killSelection": "YOUNGEST_FIRST", 49 | "unreachableStrategy": { 50 | "inactiveAfterSeconds": 0, 51 | "expungeAfterSeconds": 0 52 | }, 53 | "healthChecks": [], 54 | "fetch": [], 55 | "constraints": [] 56 | } -------------------------------------------------------------------------------- /DCOS/manifest/redis.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "/robotshop/redis", 3 | "backoffFactor": 1.15, 4 | "backoffSeconds": 30, 5 | "container": { 6 | "portMappings": [ 7 | { 8 | "containerPort": 0, 9 | "labels": { 10 | "VIP_0": "/robotshop/redis:6379" 11 | }, 12 | "servicePort": 10003 13 | } 14 | ], 15 | "type": "DOCKER", 16 | "volumes": [], 17 | "docker": { 18 | "image": "redis:4.0.6", 19 | "forcePullImage": false, 20 | "privileged": false, 21 | "parameters": [] 22 | } 23 | }, 24 | "cpus": 0.2, 25 | "disk": 0, 26 | "instances": 1, 27 | "maxLaunchDelaySeconds": 900, 28 | "mem": 128, 29 | "gpus": 0, 30 | "networks": [ 31 | { 32 | "name": "dcos", 33 | "mode": "container" 34 | } 35 | ], 36 | "requirePorts": false, 37 | "upgradeStrategy": { 38 | "maximumOverCapacity": 1, 39 | "minimumHealthCapacity": 1 40 | }, 41 | "killSelection": "YOUNGEST_FIRST", 42 | "unreachableStrategy": { 43 | "inactiveAfterSeconds": 0, 44 | "expungeAfterSeconds": 0 45 | }, 46 | "healthChecks": [], 47 | "fetch": [], 48 | "constraints": [] 49 | } -------------------------------------------------------------------------------- /DCOS/manifest/shipping.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "/robotshop/shipping", 3 | "backoffFactor": 1.15, 4 | "backoffSeconds": 30, 5 | "container": { 6 | "portMappings": [ 7 | { 8 | "containerPort": 0, 9 | "labels": { 10 | "VIP_0": "/robotshop/shipping:8080" 11 | }, 12 | "servicePort": 10001 13 | } 14 | ], 15 | "type": "DOCKER", 16 | "volumes": [], 17 | "docker": { 18 | "image": "robotshop/rs-shipping:latest", 19 | "forcePullImage": false, 20 | "privileged": false, 21 | "parameters": [] 22 | } 23 | }, 24 | "cpus": 0.5, 25 | "disk": 0, 26 | "env": { 27 | "DB_HOST": "robotshopmysql.marathon.l4lb.thisdcos.directory", 28 | "CART_ENDPOINT": "robotshopcart.marathon.l4lb.thisdcos.directory:8080" 29 | }, 30 | "instances": 1, 31 | "maxLaunchDelaySeconds": 900, 32 | "mem": 512, 33 | "gpus": 0, 34 | "networks": [ 35 | { 36 | "name": "dcos", 37 | "mode": "container" 38 | } 39 | ], 40 | "requirePorts": false, 41 | "upgradeStrategy": { 42 | "maximumOverCapacity": 1, 43 | "minimumHealthCapacity": 1 44 | }, 45 | "killSelection": "YOUNGEST_FIRST", 46 | "unreachableStrategy": { 47 | "inactiveAfterSeconds": 0, 48 | "expungeAfterSeconds": 0 49 | }, 50 | "healthChecks": [], 51 | "fetch": [], 52 | "constraints": [] 53 | } -------------------------------------------------------------------------------- /DCOS/manifest/user.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "/robotshop/user", 3 | "backoffFactor": 1.15, 4 | "backoffSeconds": 30, 5 | "container": { 6 | "portMappings": [ 7 | { 8 | "containerPort": 0, 9 | "labels": { 10 | "VIP_0": "/robotshop/user:8080" 11 | }, 12 | "servicePort": 10007 13 | } 14 | ], 15 | "type": "DOCKER", 16 | "volumes": [], 17 | "docker": { 18 | "image": "robotshop/rs-user:latest", 19 | "forcePullImage": false, 20 | "privileged": false, 21 | "parameters": [] 22 | } 23 | }, 24 | "cpus": 0.2, 25 | "disk": 0, 26 | "env": { 27 | "REDIS_HOST": "robotshopredis.marathon.l4lb.thisdcos.directory", 28 | "MONGO_URL": "mongodb://robotshopmongodb.marathon.l4lb.thisdcos.directory:27017/users" 29 | }, 30 | "instances": 1, 31 | "maxLaunchDelaySeconds": 900, 32 | "mem": 128, 33 | "gpus": 0, 34 | "networks": [ 35 | { 36 | "name": "dcos", 37 | "mode": "container" 38 | } 39 | ], 40 | "requirePorts": false, 41 | "upgradeStrategy": { 42 | "maximumOverCapacity": 1, 43 | "minimumHealthCapacity": 1 44 | }, 45 | "killSelection": "YOUNGEST_FIRST", 46 | "unreachableStrategy": { 47 | "inactiveAfterSeconds": 0, 48 | "expungeAfterSeconds": 0 49 | }, 50 | "healthChecks": [], 51 | "fetch": [], 52 | "constraints": [] 53 | } -------------------------------------------------------------------------------- /DCOS/manifest/web.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "/robotshop/web", 3 | "backoffFactor": 1.15, 4 | "backoffSeconds": 30, 5 | "container": { 6 | "portMappings": [ 7 | { 8 | "containerPort": 8080, 9 | "hostPort": 0, 10 | "protocol": "tcp", 11 | "servicePort": 10010, 12 | "name": "web" 13 | } 14 | ], 15 | "type": "DOCKER", 16 | "volumes": [], 17 | "docker": { 18 | "image": "robotshop/rs-web:latest", 19 | "forcePullImage": false, 20 | "privileged": false, 21 | "parameters": [] 22 | } 23 | }, 24 | "cpus": 0.1, 25 | "disk": 0, 26 | "env": { 27 | "PAYMENT_HOST": "robotshoppayment.marathon.l4lb.thisdcos.directory", 28 | "USER_HOST": "robotshopuser.marathon.l4lb.thisdcos.directory", 29 | "CART_HOST": "robotshopcart.marathon.l4lb.thisdcos.directory", 30 | "CATALOGUE_HOST": "robotshopcatalogue.marathon.l4lb.thisdcos.directory", 31 | "SHIPPING_HOST": "robotshopshipping.marathon.l4lb.thisdcos.directory" 32 | }, 33 | "instances": 1, 34 | "maxLaunchDelaySeconds": 900, 35 | "mem": 128, 36 | "gpus": 0, 37 | "networks": [ 38 | { 39 | "name": "dcos", 40 | "mode": "container" 41 | } 42 | ], 43 | "requirePorts": false, 44 | "upgradeStrategy": { 45 | "maximumOverCapacity": 1, 46 | "minimumHealthCapacity": 1 47 | }, 48 | "killSelection": "YOUNGEST_FIRST", 49 | "unreachableStrategy": { 50 | "inactiveAfterSeconds": 0, 51 | "expungeAfterSeconds": 0 52 | }, 53 | "healthChecks": [], 54 | "fetch": [], 55 | "constraints": [] 56 | } -------------------------------------------------------------------------------- /EKS/01-prerequisites.md: -------------------------------------------------------------------------------- 1 | # prerequisites 2 | 3 | kubectl – A command line tool for working with Kubernetes clusters. For more information, see Installing or updating kubectl. 4 | https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html 5 | 6 | eksctl – A command line tool for working with EKS clusters that automates many individual tasks. For more information, see Installing or updating. 7 | https://docs.aws.amazon.com/eks/latest/userguide/eksctl.html 8 | 9 | AWS CLI – A command line tool for working with AWS services, including Amazon EKS. For more information, see Installing, updating, and uninstalling the AWS CLI 10 | https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html in the AWS Command Line Interface User Guide. 11 | 12 | After installing the AWS CLI, I recommend that you also configure it. For more information, see Quick configuration with aws configure in the AWS Command Line Interface User Guide. 13 | https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-config 14 | -------------------------------------------------------------------------------- /EKS/02-eks-cluster-setup.md: -------------------------------------------------------------------------------- 1 | # Install EKS 2 | 3 | Please follow the prerequisites doc before this. 4 | 5 | ## Install using Fargate 6 | 7 | ``` 8 | eksctl create cluster --name demo-cluster-three-tier-1 --region us-east-1 9 | ``` 10 | 11 | ## Delete the cluster 12 | 13 | ``` 14 | eksctl delete cluster --name demo-cluster-three-tier-1 --region us-east-1 15 | ``` 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /EKS/03-oidc-IAM.md: -------------------------------------------------------------------------------- 1 | # commands to configure IAM OIDC provider 2 | 3 | ``` 4 | export cluster_name= 5 | ``` 6 | 7 | ``` 8 | oidc_id=$(aws eks describe-cluster --name $cluster_name --query "cluster.identity.oidc.issuer" --output text | cut -d '/' -f 5) 9 | ``` 10 | 11 | ## Check if there is an IAM OIDC provider configured already 12 | 13 | ``` 14 | aws iam list-open-id-connect-providers | grep $oidc_id | cut -d "/" -f4 15 | ``` 16 | 17 | If not, run the below command 18 | 19 | ``` 20 | eksctl utils associate-iam-oidc-provider --cluster $cluster_name --approve 21 | ``` -------------------------------------------------------------------------------- /EKS/04-alb-configuration.md: -------------------------------------------------------------------------------- 1 | # How to setup alb add on 2 | 3 | Download IAM policy 4 | 5 | ``` 6 | curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.11.0/docs/install/iam_policy.json 7 | ``` 8 | 9 | Create IAM Policy 10 | 11 | ``` 12 | aws iam create-policy \ 13 | --policy-name AWSLoadBalancerControllerIAMPolicy \ 14 | --policy-document file://iam_policy.json 15 | ``` 16 | 17 | Create IAM Role 18 | 19 | ``` 20 | eksctl create iamserviceaccount \ 21 | --cluster= \ 22 | --namespace=kube-system \ 23 | --name=aws-load-balancer-controller \ 24 | --role-name AmazonEKSLoadBalancerControllerRole \ 25 | --attach-policy-arn=arn:aws:iam:::policy/AWSLoadBalancerControllerIAMPolicy \ 26 | --approve 27 | ``` 28 | 29 | ## Deploy ALB controller 30 | 31 | Add helm repo 32 | 33 | ``` 34 | helm repo add eks https://aws.github.io/eks-charts 35 | ``` 36 | 37 | Update the repo 38 | 39 | ``` 40 | helm repo update eks 41 | ``` 42 | 43 | Install 44 | 45 | ``` 46 | helm install aws-load-balancer-controller eks/aws-load-balancer-controller \ 47 | -n kube-system \ 48 | --set clusterName= \ 49 | --set serviceAccount.create=false \ 50 | --set serviceAccount.name=aws-load-balancer-controller \ 51 | --set region= \ 52 | --set vpcId= 53 | ``` 54 | 55 | Verify that the deployments are running. 56 | 57 | ``` 58 | kubectl get deployment -n kube-system aws-load-balancer-controller 59 | ``` 60 | -------------------------------------------------------------------------------- /EKS/05-ebs-csi-driver.md: -------------------------------------------------------------------------------- 1 | # EBS CSI Plugin configuration 2 | 3 | The Amazon EBS CSI plugin requires IAM permissions to make calls to AWS APIs on your behalf. 4 | 5 | Create an IAM role and attach a policy. AWS maintains an AWS managed policy or you can create your own custom policy. You can create an IAM role and attach the AWS managed policy with the following command. Replace my-cluster with the name of your cluster. The command deploys an AWS CloudFormation stack that creates an IAM role and attaches the IAM policy to it. 6 | 7 | ``` 8 | eksctl create iamserviceaccount \ 9 | --name ebs-csi-controller-sa \ 10 | --namespace kube-system \ 11 | --cluster \ 12 | --role-name AmazonEKS_EBS_CSI_DriverRole \ 13 | --role-only \ 14 | --attach-policy-arn arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy \ 15 | --approve 16 | ``` 17 | 18 | Run the following command. Replace with the name of your cluster, with your account ID. 19 | 20 | ``` 21 | eksctl create addon --name aws-ebs-csi-driver --cluster --service-account-role-arn arn:aws:iam:::role/AmazonEKS_EBS_CSI_DriverRole --force 22 | ``` 23 | 24 | **Note**: If your cluster is in the AWS GovCloud (US-East) or AWS GovCloud (US-West) AWS Regions, then replace arn:aws: with arn:aws-us-gov:. 25 | 26 | **References**: 27 | https://repost.aws/knowledge-center/eks-persistent-storage -------------------------------------------------------------------------------- /EKS/helm/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | name: robot-shop 3 | version: 1.1.0 4 | home: https://github.com/instana/robot-shop 5 | description: Sample micoservices application 6 | 7 | -------------------------------------------------------------------------------- /EKS/helm/ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1 2 | kind: Ingress 3 | metadata: 4 | namespace: robot-shop 5 | name: robot-shop 6 | annotations: 7 | kubernetes.io/ingress.class: alb 8 | alb.ingress.kubernetes.io/scheme: internet-facing 9 | alb.ingress.kubernetes.io/target-type: ip 10 | spec: 11 | rules: 12 | - http: 13 | paths: 14 | - path: / 15 | pathType: Prefix 16 | backend: 17 | service: 18 | name: web 19 | port: 20 | number: 8080 -------------------------------------------------------------------------------- /EKS/helm/templates/cart-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: cart 5 | labels: 6 | service: cart 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: cart 12 | template: 13 | metadata: 14 | labels: 15 | service: cart 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: cart 22 | image: {{ .Values.image.repo }}/rs-cart:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | # agent networking access 25 | env: 26 | - name: INSTANA_AGENT_HOST 27 | valueFrom: 28 | fieldRef: 29 | fieldPath: status.hostIP 30 | ports: 31 | - containerPort: 8080 32 | resources: 33 | limits: 34 | cpu: 200m 35 | memory: 100Mi 36 | requests: 37 | cpu: 100m 38 | memory: 50Mi 39 | {{- with .Values.cart.affinity }} 40 | affinity: 41 | {{- toYaml . | nindent 8 }} 42 | {{- end }} 43 | {{- with .Values.cart.nodeSelector }} 44 | nodeSelector: 45 | {{- toYaml . | nindent 8 }} 46 | {{- end }} 47 | {{- with .Values.cart.tolerations }} 48 | tolerations: 49 | {{- toYaml . | nindent 8 }} 50 | {{- end }} 51 | -------------------------------------------------------------------------------- /EKS/helm/templates/cart-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: cart 5 | spec: 6 | ports: 7 | - name: http 8 | port: 8080 9 | targetPort: 8080 10 | selector: 11 | service: cart 12 | -------------------------------------------------------------------------------- /EKS/helm/templates/catalogue-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: catalogue 5 | labels: 6 | service: catalogue 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: catalogue 12 | template: 13 | metadata: 14 | labels: 15 | service: catalogue 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: catalogue 22 | image: {{ .Values.image.repo }}/rs-catalogue:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | env: 25 | - name: INSTANA_AGENT_HOST 26 | valueFrom: 27 | fieldRef: 28 | fieldPath: status.hostIP 29 | ports: 30 | - containerPort: 8080 31 | resources: 32 | limits: 33 | cpu: 200m 34 | memory: 100Mi 35 | requests: 36 | cpu: 100m 37 | memory: 50Mi 38 | restartPolicy: Always 39 | {{- with .Values.catalogue.affinity }} 40 | affinity: 41 | {{- toYaml . | nindent 8 }} 42 | {{- end }} 43 | {{- with .Values.catalogue.nodeSelector }} 44 | nodeSelector: 45 | {{- toYaml . | nindent 8 }} 46 | {{- end }} 47 | {{- with .Values.catalogue.tolerations }} 48 | tolerations: 49 | {{- toYaml . | nindent 8 }} 50 | {{- end }} 51 | -------------------------------------------------------------------------------- /EKS/helm/templates/catalogue-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | service: catalogue 6 | name: catalogue 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: catalogue 14 | -------------------------------------------------------------------------------- /EKS/helm/templates/clusterrole.yaml: -------------------------------------------------------------------------------- 1 | {{ if .Values.psp.enabled }} 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRole 4 | metadata: 5 | name: robot-shop 6 | rules: 7 | - apiGroups: 8 | - policy 9 | resourceNames: 10 | - robot-shop 11 | resources: 12 | - podsecuritypolicies 13 | verbs: 14 | - use 15 | {{ end }} 16 | -------------------------------------------------------------------------------- /EKS/helm/templates/clusterrolebinding.yaml: -------------------------------------------------------------------------------- 1 | {{ if .Values.psp.enabled }} 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRoleBinding 4 | metadata: 5 | name: robot-shop 6 | roleRef: 7 | apiGroup: rbac.authorization.k8s.io 8 | kind: ClusterRole 9 | name: robot-shop 10 | subjects: 11 | - kind: ServiceAccount 12 | name: robot-shop 13 | namespace: robot-shop 14 | {{ end }} 15 | -------------------------------------------------------------------------------- /EKS/helm/templates/dispatch-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: dispatch 5 | labels: 6 | service: dispatch 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: dispatch 12 | template: 13 | metadata: 14 | labels: 15 | service: dispatch 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: dispatch 22 | image: {{ .Values.image.repo }}/rs-dispatch:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | env: 25 | # agent networking access 26 | - name: INSTANA_AGENT_HOST 27 | valueFrom: 28 | fieldRef: 29 | fieldPath: status.hostIP 30 | resources: 31 | limits: 32 | cpu: 200m 33 | memory: 100Mi 34 | requests: 35 | cpu: 100m 36 | memory: 50Mi 37 | restartPolicy: Always 38 | {{- with .Values.dispatch.affinity }} 39 | affinity: 40 | {{- toYaml . | nindent 8 }} 41 | {{- end }} 42 | {{- with .Values.dispatch.nodeSelector }} 43 | nodeSelector: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | {{- with .Values.dispatch.tolerations }} 47 | tolerations: 48 | {{- toYaml . | nindent 8 }} 49 | {{- end }} 50 | -------------------------------------------------------------------------------- /EKS/helm/templates/dispatch-service.yaml: -------------------------------------------------------------------------------- 1 | # dispatch just listens to a message queue 2 | # it does not expose any ports 3 | apiVersion: v1 4 | kind: Service 5 | metadata: 6 | name: dispatch 7 | labels: 8 | service: dispatch 9 | spec: 10 | clusterIP: None 11 | ports: 12 | - name: headless 13 | port: 55555 14 | targetPort: 0 15 | selector: 16 | service: dispatch 17 | -------------------------------------------------------------------------------- /EKS/helm/templates/mongodb-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: mongodb 5 | labels: 6 | service: mongodb 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: mongodb 12 | template: 13 | metadata: 14 | labels: 15 | service: mongodb 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: mongodb 22 | image: {{ .Values.image.repo }}/rs-mongodb:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | ports: 25 | - containerPort: 27017 26 | resources: 27 | limits: 28 | cpu: 200m 29 | memory: 200Mi 30 | requests: 31 | cpu: 100m 32 | memory: 100Mi 33 | restartPolicy: Always 34 | {{- with .Values.mongodb.affinity }} 35 | affinity: 36 | {{- toYaml . | nindent 8 }} 37 | {{- end }} 38 | {{- with .Values.mongodb.nodeSelector }} 39 | nodeSelector: 40 | {{- toYaml . | nindent 8 }} 41 | {{- end }} 42 | {{- with .Values.mongodb.tolerations }} 43 | tolerations: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | -------------------------------------------------------------------------------- /EKS/helm/templates/mongodb-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | service: mongodb 6 | name: mongodb 7 | spec: 8 | ports: 9 | - name: mongo 10 | port: 27017 11 | targetPort: 27017 12 | selector: 13 | service: mongodb 14 | -------------------------------------------------------------------------------- /EKS/helm/templates/mysql-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: mysql 5 | labels: 6 | service: mysql 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: mysql 12 | template: 13 | metadata: 14 | labels: 15 | service: mysql 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: mysql 22 | image: {{ .Values.image.repo }}/rs-mysql-db:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | # added for Istio 25 | securityContext: 26 | capabilities: 27 | add: ["NET_ADMIN"] 28 | ports: 29 | - containerPort: 3306 30 | resources: 31 | limits: 32 | cpu: 200m 33 | memory: 1024Mi 34 | requests: 35 | cpu: 100m 36 | memory: 700Mi 37 | restartPolicy: Always 38 | {{- with .Values.mysql.affinity }} 39 | affinity: 40 | {{- toYaml . | nindent 8 }} 41 | {{- end }} 42 | {{- with .Values.mysql.nodeSelector }} 43 | nodeSelector: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | {{- with .Values.mysql.tolerations }} 47 | tolerations: 48 | {{- toYaml . | nindent 8 }} 49 | {{- end }} 50 | -------------------------------------------------------------------------------- /EKS/helm/templates/mysql-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | service: mysql 6 | name: mysql 7 | spec: 8 | ports: 9 | - name: mysql 10 | port: 3306 11 | targetPort: 3306 12 | selector: 13 | service: mysql 14 | -------------------------------------------------------------------------------- /EKS/helm/templates/payment-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: payment 5 | labels: 6 | service: payment 7 | stage: prod 8 | spec: 9 | replicas: 1 10 | selector: 11 | matchLabels: 12 | service: payment 13 | stage: prod 14 | template: 15 | metadata: 16 | labels: 17 | service: payment 18 | stage: prod 19 | spec: 20 | {{ if .Values.psp.enabled }} 21 | serviceAccountName: robot-shop 22 | {{ end }} 23 | containers: 24 | - name: payment 25 | image: {{ .Values.image.repo }}/rs-payment:{{ .Values.image.version }} 26 | imagePullPolicy: {{ .Values.image.pullPolicy }} 27 | # agent networking access 28 | env: 29 | - name: INSTANA_AGENT_HOST 30 | valueFrom: 31 | fieldRef: 32 | fieldPath: status.hostIP 33 | {{- if .Values.payment.gateway }} 34 | - name: PAYMENT_GATEWAY 35 | value: {{ .Values.payment.gateway }} 36 | {{- end }} 37 | ports: 38 | - containerPort: 8080 39 | resources: 40 | limits: 41 | cpu: 200m 42 | memory: 100Mi 43 | requests: 44 | cpu: 100m 45 | memory: 50Mi 46 | restartPolicy: Always 47 | {{- with .Values.payment.affinity }} 48 | affinity: 49 | {{- toYaml . | nindent 8 }} 50 | {{- end }} 51 | {{- with .Values.payment.nodeSelector }} 52 | nodeSelector: 53 | {{- toYaml . | nindent 8 }} 54 | {{- end }} 55 | {{- with .Values.payment.tolerations }} 56 | tolerations: 57 | {{- toYaml . | nindent 8 }} 58 | {{- end }} 59 | -------------------------------------------------------------------------------- /EKS/helm/templates/payment-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: payment 5 | labels: 6 | service: payment 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: payment 14 | -------------------------------------------------------------------------------- /EKS/helm/templates/podsecuritypolicy.yaml: -------------------------------------------------------------------------------- 1 | {{ if .Values.psp.enabled }} 2 | apiVersion: policy/v1beta1 3 | kind: PodSecurityPolicy 4 | metadata: 5 | name: robot-shop 6 | spec: 7 | allowPrivilegeEscalation: false 8 | fsGroup: 9 | rule: RunAsAny 10 | privileged: false 11 | runAsUser: 12 | rule: RunAsAny 13 | seLinux: 14 | rule: RunAsAny 15 | supplementalGroups: 16 | rule: RunAsAny 17 | allowedCapabilities: 18 | - 'NET_ADMIN' 19 | volumes: 20 | - configMap 21 | - downwardAPI 22 | - emptyDir 23 | - persistentVolumeClaim 24 | - secret 25 | - projected 26 | {{ end }} 27 | -------------------------------------------------------------------------------- /EKS/helm/templates/rabbitmq-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: rabbitmq 5 | labels: 6 | service: rabbitmq 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: rabbitmq 12 | template: 13 | metadata: 14 | labels: 15 | service: rabbitmq 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: rabbitmq 22 | image: rabbitmq:3.7-management-alpine 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | ports: 25 | - containerPort: 5672 26 | - containerPort: 15672 27 | resources: 28 | limits: 29 | cpu: 200m 30 | memory: 512Mi 31 | requests: 32 | cpu: 100m 33 | memory: 256Mi 34 | restartPolicy: Always 35 | {{- with .Values.rabbitmq.affinity }} 36 | affinity: 37 | {{- toYaml . | nindent 8 }} 38 | {{- end }} 39 | {{- with .Values.rabbitmq.nodeSelector }} 40 | nodeSelector: 41 | {{- toYaml . | nindent 8 }} 42 | {{- end }} 43 | {{- with .Values.rabbitmq.tolerations }} 44 | tolerations: 45 | {{- toYaml . | nindent 8 }} 46 | {{- end }} 47 | -------------------------------------------------------------------------------- /EKS/helm/templates/rabbitmq-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: rabbitmq 5 | labels: 6 | service: rabbitmq 7 | spec: 8 | ports: 9 | - name: tcp-amqp 10 | port: 5672 11 | targetPort: 5672 12 | - name: http-management 13 | port: 15672 14 | targetPort: 15672 15 | - name: tcp-epmd 16 | port: 4369 17 | targetPort: 4369 18 | selector: 19 | service: rabbitmq 20 | -------------------------------------------------------------------------------- /EKS/helm/templates/ratings-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: ratings 5 | labels: 6 | service: ratings 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: ratings 12 | template: 13 | metadata: 14 | labels: 15 | service: ratings 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: ratings 22 | image: {{ .Values.image.repo }}/rs-ratings:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | ports: 25 | - containerPort: 80 26 | resources: 27 | limits: 28 | cpu: 200m 29 | memory: 100Mi 30 | requests: 31 | cpu: 100m 32 | memory: 50Mi 33 | readinessProbe: 34 | httpGet: 35 | path: /_health 36 | port: 80 37 | initialDelaySeconds: 5 38 | periodSeconds: 5 39 | failureThreshold: 30 40 | successThreshold: 1 41 | restartPolicy: Always 42 | {{- with .Values.ratings.affinity }} 43 | affinity: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | {{- with .Values.ratings.nodeSelector }} 47 | nodeSelector: 48 | {{- toYaml . | nindent 8 }} 49 | {{- end }} 50 | {{- with .Values.ratings.tolerations }} 51 | tolerations: 52 | {{- toYaml . | nindent 8 }} 53 | {{- end }} 54 | -------------------------------------------------------------------------------- /EKS/helm/templates/ratings-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: ratings 5 | labels: 6 | service: ratings 7 | spec: 8 | ports: 9 | - name: http 10 | port: 80 11 | targetPort: 80 12 | selector: 13 | service: ratings 14 | 15 | -------------------------------------------------------------------------------- /EKS/helm/templates/redis-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | service: redis 6 | name: redis 7 | spec: 8 | ports: 9 | - name: redis 10 | port: 6379 11 | targetPort: 6379 12 | selector: 13 | service: redis 14 | -------------------------------------------------------------------------------- /EKS/helm/templates/redis-statefulset.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: StatefulSet 3 | metadata: 4 | labels: 5 | service: redis 6 | name: redis 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: redis 12 | serviceName: redis 13 | template: 14 | metadata: 15 | labels: 16 | service: redis 17 | spec: 18 | {{ if .Values.psp.enabled }} 19 | serviceAccountName: robot-shop 20 | {{ end }} 21 | containers: 22 | - name: redis 23 | image: redis:4.0.6 24 | imagePullPolicy: {{ .Values.image.pullPolicy }} 25 | ports: 26 | - containerPort: 6379 27 | volumeMounts: 28 | - name: data 29 | mountPath: /mnt/redis 30 | resources: 31 | limits: 32 | cpu: 200m 33 | memory: 100Mi 34 | requests: 35 | cpu: 100m 36 | memory: 50Mi 37 | restartPolicy: Always 38 | {{- with .Values.redis.affinity }} 39 | affinity: 40 | {{- toYaml . | nindent 8 }} 41 | {{- end }} 42 | {{- with .Values.redis.nodeSelector }} 43 | nodeSelector: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | {{- with .Values.redis.tolerations }} 47 | tolerations: 48 | {{- toYaml . | nindent 8 }} 49 | {{- end }} 50 | volumeClaimTemplates: 51 | - metadata: 52 | name: data 53 | spec: 54 | accessModes: [ "ReadWriteOnce" ] 55 | {{ if not .Values.openshift }} 56 | storageClassName: gp2 57 | volumeMode: Filesystem 58 | {{ end }} 59 | resources: 60 | requests: 61 | storage: 1Gi 62 | 63 | -------------------------------------------------------------------------------- /EKS/helm/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | {{ if .Values.psp.enabled }} 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | name: robot-shop 6 | namespace: robot-shop 7 | {{ end }} 8 | -------------------------------------------------------------------------------- /EKS/helm/templates/shipping-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: shipping 5 | labels: 6 | service: shipping 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: shipping 12 | template: 13 | metadata: 14 | labels: 15 | service: shipping 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: shipping 22 | image: {{ .Values.image.repo }}/rs-shipping:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | ports: 25 | - containerPort: 8080 26 | # it's Java it needs lots of memory 27 | resources: 28 | limits: 29 | cpu: 200m 30 | memory: 1000Mi 31 | requests: 32 | cpu: 100m 33 | memory: 500Mi 34 | readinessProbe: 35 | httpGet: 36 | path: /health 37 | port: 8080 38 | initialDelaySeconds: 5 39 | periodSeconds: 5 40 | failureThreshold: 30 41 | successThreshold: 1 42 | restartPolicy: Always 43 | {{- with .Values.shipping.affinity }} 44 | affinity: 45 | {{- toYaml . | nindent 8 }} 46 | {{- end }} 47 | {{- with .Values.shipping.nodeSelector }} 48 | nodeSelector: 49 | {{- toYaml . | nindent 8 }} 50 | {{- end }} 51 | {{- with .Values.shipping.tolerations }} 52 | tolerations: 53 | {{- toYaml . | nindent 8 }} 54 | {{- end }} 55 | -------------------------------------------------------------------------------- /EKS/helm/templates/shipping-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: shipping 5 | labels: 6 | service: shipping 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: shipping 14 | -------------------------------------------------------------------------------- /EKS/helm/templates/user-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: user 5 | labels: 6 | service: user 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: user 12 | template: 13 | metadata: 14 | labels: 15 | service: user 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: user 22 | image: {{ .Values.image.repo }}/rs-user:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | env: 25 | # agent networking access 26 | - name: INSTANA_AGENT_HOST 27 | valueFrom: 28 | fieldRef: 29 | fieldPath: status.hostIP 30 | ports: 31 | - containerPort: 8080 32 | resources: 33 | limits: 34 | cpu: 200m 35 | memory: 100Mi 36 | requests: 37 | cpu: 100m 38 | memory: 50Mi 39 | restartPolicy: Always 40 | {{- with .Values.user.affinity }} 41 | affinity: 42 | {{- toYaml . | nindent 8 }} 43 | {{- end }} 44 | {{- with .Values.user.nodeSelector }} 45 | nodeSelector: 46 | {{- toYaml . | nindent 8 }} 47 | {{- end }} 48 | {{- with .Values.user.tolerations }} 49 | tolerations: 50 | {{- toYaml . | nindent 8 }} 51 | {{- end }} 52 | -------------------------------------------------------------------------------- /EKS/helm/templates/user-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: user 5 | labels: 6 | service: user 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: user 14 | -------------------------------------------------------------------------------- /EKS/helm/templates/web-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: web 5 | labels: 6 | service: web 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: web 12 | template: 13 | metadata: 14 | labels: 15 | service: web 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: web 22 | image: {{ .Values.image.repo }}/rs-web:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | {{- if .Values.eum.key }} 25 | env: 26 | - name: INSTANA_EUM_KEY 27 | value: {{ .Values.eum.key }} 28 | - name: INSTANA_EUM_REPORTING_URL 29 | value: {{ .Values.eum.url }} 30 | {{- end}} 31 | ports: 32 | - containerPort: 8080 33 | resources: 34 | limits: 35 | cpu: 200m 36 | memory: 100Mi 37 | requests: 38 | cpu: 100m 39 | memory: 50Mi 40 | restartPolicy: Always 41 | {{- with .Values.web.affinity }} 42 | affinity: 43 | {{- toYaml . | nindent 8 }} 44 | {{- end }} 45 | {{- with .Values.web.nodeSelector }} 46 | nodeSelector: 47 | {{- toYaml . | nindent 8 }} 48 | {{- end }} 49 | {{- with .Values.web.tolerations }} 50 | tolerations: 51 | {{- toYaml . | nindent 8 }} 52 | {{- end }} 53 | -------------------------------------------------------------------------------- /EKS/helm/templates/web-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: web 5 | labels: 6 | service: web 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: web 14 | {{ if .Values.nodeport }} 15 | type: NodePort 16 | {{ else }} 17 | type: LoadBalancer 18 | {{ end }} 19 | --- 20 | {{if .Values.ocCreateRoute}} 21 | apiVersion: route.openshift.io/v1 22 | kind: Route 23 | metadata: 24 | name: web 25 | spec: 26 | to: 27 | kind: Service 28 | name: web 29 | {{end}} -------------------------------------------------------------------------------- /EKS/helm/values.yaml: -------------------------------------------------------------------------------- 1 | # Registry and repository for Docker images 2 | # Default is docker/robotshop/image:latest 3 | image: 4 | repo: robotshop 5 | version: latest 6 | pullPolicy: IfNotPresent 7 | 8 | # EUM configuration 9 | # Provide your key and set the endpoint 10 | eum: 11 | key: null 12 | url: https://eum-eu-west-1.instana.io 13 | #url: https://eum-us-west-2.instana.io 14 | 15 | # Pod Security Policy 16 | psp: 17 | enabled: false 18 | 19 | # For the mini ones minikube, minishift set to true 20 | nodeport: false 21 | 22 | # "special" Openshift. Set to true when deploying to any openshift flavour 23 | openshift: false 24 | 25 | ocCreateRoute: false 26 | 27 | ###################################### 28 | # Affinities for individual workloads 29 | # set in the following way: 30 | # : 31 | # affinity: {} 32 | # nodeSelector: {} 33 | # tolerations: [] 34 | ###################################### 35 | 36 | cart: {} 37 | 38 | catalogue: {} 39 | 40 | dispatch: {} 41 | 42 | mongodb: {} 43 | 44 | mysql: {} 45 | 46 | payment: 47 | # Alternative payment gateway URL 48 | # Default is https://www.paypal.com 49 | gateway: null 50 | #gateway: https://www.worldpay.com 51 | 52 | rabbitmq: {} 53 | 54 | ratings: {} 55 | 56 | redis: 57 | # Storage class to use with redis statefulset. 58 | storageClassName: gp2 59 | 60 | shipping: {} 61 | 62 | user: {} 63 | 64 | web: {} 65 | -------------------------------------------------------------------------------- /GKE/helm/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | name: robot-shop 3 | version: 1.1.0 4 | home: https://github.com/instana/robot-shop 5 | description: Sample micoservices application -------------------------------------------------------------------------------- /GKE/helm/gclb.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1 2 | kind: Ingress 3 | metadata: 4 | name: robot-shop-gclb 5 | annotations: 6 | kubernetes.io/ingress.backend: "robot-shop" 7 | kubernetes.io/ingress.class: gce 8 | spec: 9 | backend: 10 | serviceName: "robot-shop" 11 | servicePort: 8080 12 | 13 | -------------------------------------------------------------------------------- /GKE/helm/ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1 2 | kind: Ingress 3 | metadata: 4 | namespace: robot-shop 5 | name: robot-shop 6 | spec: 7 | ingressClassName: gce 8 | rules: 9 | - http: 10 | paths: 11 | - path: / 12 | pathType: Prefix 13 | backend: 14 | service: 15 | name: web 16 | port: 17 | number: 8080 -------------------------------------------------------------------------------- /GKE/helm/templates/cart-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: cart 5 | labels: 6 | service: cart 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: cart 12 | template: 13 | metadata: 14 | labels: 15 | service: cart 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: cart 22 | image: {{ .Values.image.repo }}/rs-cart:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | # agent networking access 25 | env: 26 | - name: INSTANA_AGENT_HOST 27 | valueFrom: 28 | fieldRef: 29 | fieldPath: status.hostIP 30 | ports: 31 | - containerPort: 8080 32 | resources: 33 | limits: 34 | cpu: 200m 35 | memory: 100Mi 36 | requests: 37 | cpu: 100m 38 | memory: 50Mi 39 | {{- with .Values.cart.affinity }} 40 | affinity: 41 | {{- toYaml . | nindent 8 }} 42 | {{- end }} 43 | {{- with .Values.cart.nodeSelector }} 44 | nodeSelector: 45 | {{- toYaml . | nindent 8 }} 46 | {{- end }} 47 | {{- with .Values.cart.tolerations }} 48 | tolerations: 49 | {{- toYaml . | nindent 8 }} 50 | {{- end }} -------------------------------------------------------------------------------- /GKE/helm/templates/cart-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: cart 5 | spec: 6 | ports: 7 | - name: http 8 | port: 8080 9 | targetPort: 8080 10 | selector: 11 | service: cart -------------------------------------------------------------------------------- /GKE/helm/templates/catalogue-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: catalogue 5 | labels: 6 | service: catalogue 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: catalogue 12 | template: 13 | metadata: 14 | labels: 15 | service: catalogue 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: catalogue 22 | image: {{ .Values.image.repo }}/rs-catalogue:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | env: 25 | - name: INSTANA_AGENT_HOST 26 | valueFrom: 27 | fieldRef: 28 | fieldPath: status.hostIP 29 | ports: 30 | - containerPort: 8080 31 | resources: 32 | limits: 33 | cpu: 200m 34 | memory: 100Mi 35 | requests: 36 | cpu: 100m 37 | memory: 50Mi 38 | restartPolicy: Always 39 | {{- with .Values.catalogue.affinity }} 40 | affinity: 41 | {{- toYaml . | nindent 8 }} 42 | {{- end }} 43 | {{- with .Values.catalogue.nodeSelector }} 44 | nodeSelector: 45 | {{- toYaml . | nindent 8 }} 46 | {{- end }} 47 | {{- with .Values.catalogue.tolerations }} 48 | tolerations: 49 | {{- toYaml . | nindent 8 }} 50 | {{- end }} -------------------------------------------------------------------------------- /GKE/helm/templates/catalogue-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | service: catalogue 6 | name: catalogue 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: catalogue -------------------------------------------------------------------------------- /GKE/helm/templates/clusterrole.yaml: -------------------------------------------------------------------------------- 1 | {{ if .Values.psp.enabled }} 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRole 4 | metadata: 5 | name: robot-shop 6 | rules: 7 | - apiGroups: 8 | - policy 9 | resourceNames: 10 | - robot-shop 11 | resources: 12 | - podsecuritypolicies 13 | verbs: 14 | - use 15 | {{ end }} -------------------------------------------------------------------------------- /GKE/helm/templates/clusterrolebinding.yaml: -------------------------------------------------------------------------------- 1 | {{ if .Values.psp.enabled }} 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRoleBinding 4 | metadata: 5 | name: robot-shop 6 | roleRef: 7 | apiGroup: rbac.authorization.k8s.io 8 | kind: ClusterRole 9 | name: robot-shop 10 | subjects: 11 | - kind: ServiceAccount 12 | name: robot-shop 13 | namespace: robot-shop 14 | {{ end }} -------------------------------------------------------------------------------- /GKE/helm/templates/dispatch-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: dispatch 5 | labels: 6 | service: dispatch 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: dispatch 12 | template: 13 | metadata: 14 | labels: 15 | service: dispatch 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: dispatch 22 | image: {{ .Values.image.repo }}/rs-dispatch:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | env: 25 | # agent networking access 26 | - name: INSTANA_AGENT_HOST 27 | valueFrom: 28 | fieldRef: 29 | fieldPath: status.hostIP 30 | resources: 31 | limits: 32 | cpu: 200m 33 | memory: 100Mi 34 | requests: 35 | cpu: 100m 36 | memory: 50Mi 37 | restartPolicy: Always 38 | {{- with .Values.dispatch.affinity }} 39 | affinity: 40 | {{- toYaml . | nindent 8 }} 41 | {{- end }} 42 | {{- with .Values.dispatch.nodeSelector }} 43 | nodeSelector: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | {{- with .Values.dispatch.tolerations }} 47 | tolerations: 48 | {{- toYaml . | nindent 8 }} 49 | {{- end }} -------------------------------------------------------------------------------- /GKE/helm/templates/dispatch-service.yaml: -------------------------------------------------------------------------------- 1 | # dispatch just listens to a message queue 2 | # it does not expose any ports 3 | apiVersion: v1 4 | kind: Service 5 | metadata: 6 | name: dispatch 7 | labels: 8 | service: dispatch 9 | spec: 10 | clusterIP: None 11 | ports: 12 | - name: headless 13 | port: 55555 14 | targetPort: 0 15 | selector: 16 | service: dispatch -------------------------------------------------------------------------------- /GKE/helm/templates/mongodb-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: mongodb 5 | labels: 6 | service: mongodb 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: mongodb 12 | template: 13 | metadata: 14 | labels: 15 | service: mongodb 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: mongodb 22 | image: {{ .Values.image.repo }}/rs-mongodb:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | ports: 25 | - containerPort: 27017 26 | resources: 27 | limits: 28 | cpu: 200m 29 | memory: 200Mi 30 | requests: 31 | cpu: 100m 32 | memory: 100Mi 33 | restartPolicy: Always 34 | {{- with .Values.mongodb.affinity }} 35 | affinity: 36 | {{- toYaml . | nindent 8 }} 37 | {{- end }} 38 | {{- with .Values.mongodb.nodeSelector }} 39 | nodeSelector: 40 | {{- toYaml . | nindent 8 }} 41 | {{- end }} 42 | {{- with .Values.mongodb.tolerations }} 43 | tolerations: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} -------------------------------------------------------------------------------- /GKE/helm/templates/mongodb-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | service: mongodb 6 | name: mongodb 7 | spec: 8 | ports: 9 | - name: mongo 10 | port: 27017 11 | targetPort: 27017 12 | selector: 13 | service: mongodb -------------------------------------------------------------------------------- /GKE/helm/templates/mysql-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: mysql 5 | labels: 6 | service: mysql 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: mysql 12 | template: 13 | metadata: 14 | labels: 15 | service: mysql 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: mysql 22 | image: {{ .Values.image.repo }}/rs-mysql-db:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | # added for Istio 25 | securityContext: 26 | capabilities: 27 | add: ["NET_ADMIN"] 28 | ports: 29 | - containerPort: 3306 30 | resources: 31 | limits: 32 | cpu: 200m 33 | memory: 1024Mi 34 | requests: 35 | cpu: 100m 36 | memory: 700Mi 37 | restartPolicy: Always 38 | {{- with .Values.mysql.affinity }} 39 | affinity: 40 | {{- toYaml . | nindent 8 }} 41 | {{- end }} 42 | {{- with .Values.mysql.nodeSelector }} 43 | nodeSelector: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | {{- with .Values.mysql.tolerations }} 47 | tolerations: 48 | {{- toYaml . | nindent 8 }} 49 | {{- end }} -------------------------------------------------------------------------------- /GKE/helm/templates/mysql-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | service: mysql 6 | name: mysql 7 | spec: 8 | ports: 9 | - name: mysql 10 | port: 3306 11 | targetPort: 3306 12 | selector: 13 | service: mysql -------------------------------------------------------------------------------- /GKE/helm/templates/payment-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: payment 5 | labels: 6 | service: payment 7 | stage: prod 8 | spec: 9 | replicas: 1 10 | selector: 11 | matchLabels: 12 | service: payment 13 | stage: prod 14 | template: 15 | metadata: 16 | labels: 17 | service: payment 18 | stage: prod 19 | spec: 20 | {{ if .Values.psp.enabled }} 21 | serviceAccountName: robot-shop 22 | {{ end }} 23 | containers: 24 | - name: payment 25 | image: {{ .Values.image.repo }}/rs-payment:{{ .Values.image.version }} 26 | imagePullPolicy: {{ .Values.image.pullPolicy }} 27 | # agent networking access 28 | env: 29 | - name: INSTANA_AGENT_HOST 30 | valueFrom: 31 | fieldRef: 32 | fieldPath: status.hostIP 33 | {{- if .Values.payment.gateway }} 34 | - name: PAYMENT_GATEWAY 35 | value: {{ .Values.payment.gateway }} 36 | {{- end }} 37 | ports: 38 | - containerPort: 8080 39 | resources: 40 | limits: 41 | cpu: 200m 42 | memory: 100Mi 43 | requests: 44 | cpu: 100m 45 | memory: 50Mi 46 | restartPolicy: Always 47 | {{- with .Values.payment.affinity }} 48 | affinity: 49 | {{- toYaml . | nindent 8 }} 50 | {{- end }} 51 | {{- with .Values.payment.nodeSelector }} 52 | nodeSelector: 53 | {{- toYaml . | nindent 8 }} 54 | {{- end }} 55 | {{- with .Values.payment.tolerations }} 56 | tolerations: 57 | {{- toYaml . | nindent 8 }} 58 | {{- end }} -------------------------------------------------------------------------------- /GKE/helm/templates/payment-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: payment 5 | labels: 6 | service: payment 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: payment -------------------------------------------------------------------------------- /GKE/helm/templates/podsecuritypolicy.yaml: -------------------------------------------------------------------------------- 1 | {{ if .Values.psp.enabled }} 2 | apiVersion: policy/v1beta1 3 | kind: PodSecurityPolicy 4 | metadata: 5 | name: robot-shop 6 | spec: 7 | allowPrivilegeEscalation: false 8 | fsGroup: 9 | rule: RunAsAny 10 | privileged: false 11 | runAsUser: 12 | rule: RunAsAny 13 | seLinux: 14 | rule: RunAsAny 15 | supplementalGroups: 16 | rule: RunAsAny 17 | allowedCapabilities: 18 | - 'NET_ADMIN' 19 | volumes: 20 | - configMap 21 | - downwardAPI 22 | - emptyDir 23 | - persistentVolumeClaim 24 | - secret 25 | - projected 26 | {{ end }} -------------------------------------------------------------------------------- /GKE/helm/templates/rabbitmq-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: rabbitmq 5 | labels: 6 | service: rabbitmq 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: rabbitmq 12 | template: 13 | metadata: 14 | labels: 15 | service: rabbitmq 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: rabbitmq 22 | image: rabbitmq:3.7-management-alpine 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | ports: 25 | - containerPort: 5672 26 | - containerPort: 15672 27 | resources: 28 | limits: 29 | cpu: 200m 30 | memory: 512Mi 31 | requests: 32 | cpu: 100m 33 | memory: 256Mi 34 | restartPolicy: Always 35 | {{- with .Values.rabbitmq.affinity }} 36 | affinity: 37 | {{- toYaml . | nindent 8 }} 38 | {{- end }} 39 | {{- with .Values.rabbitmq.nodeSelector }} 40 | nodeSelector: 41 | {{- toYaml . | nindent 8 }} 42 | {{- end }} 43 | {{- with .Values.rabbitmq.tolerations }} 44 | tolerations: 45 | {{- toYaml . | nindent 8 }} 46 | {{- end }} -------------------------------------------------------------------------------- /GKE/helm/templates/rabbitmq-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: rabbitmq 5 | labels: 6 | service: rabbitmq 7 | spec: 8 | ports: 9 | - name: tcp-amqp 10 | port: 5672 11 | targetPort: 5672 12 | - name: http-management 13 | port: 15672 14 | targetPort: 15672 15 | - name: tcp-epmd 16 | port: 4369 17 | targetPort: 4369 18 | selector: 19 | service: rabbitmq -------------------------------------------------------------------------------- /GKE/helm/templates/ratings-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: ratings 5 | labels: 6 | service: ratings 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: ratings 12 | template: 13 | metadata: 14 | labels: 15 | service: ratings 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: ratings 22 | image: {{ .Values.image.repo }}/rs-ratings:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | ports: 25 | - containerPort: 80 26 | resources: 27 | limits: 28 | cpu: 200m 29 | memory: 100Mi 30 | requests: 31 | cpu: 100m 32 | memory: 50Mi 33 | readinessProbe: 34 | httpGet: 35 | path: /_health 36 | port: 80 37 | initialDelaySeconds: 5 38 | periodSeconds: 5 39 | failureThreshold: 30 40 | successThreshold: 1 41 | restartPolicy: Always 42 | {{- with .Values.ratings.affinity }} 43 | affinity: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | {{- with .Values.ratings.nodeSelector }} 47 | nodeSelector: 48 | {{- toYaml . | nindent 8 }} 49 | {{- end }} 50 | {{- with .Values.ratings.tolerations }} 51 | tolerations: 52 | {{- toYaml . | nindent 8 }} 53 | {{- end }} -------------------------------------------------------------------------------- /GKE/helm/templates/ratings-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: ratings 5 | labels: 6 | service: ratings 7 | spec: 8 | ports: 9 | - name: http 10 | port: 80 11 | targetPort: 80 12 | selector: 13 | service: ratings -------------------------------------------------------------------------------- /GKE/helm/templates/redis-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | service: redis 6 | name: redis 7 | spec: 8 | ports: 9 | - name: redis 10 | port: 6379 11 | targetPort: 6379 12 | selector: 13 | service: redis -------------------------------------------------------------------------------- /GKE/helm/templates/redis-statefulset.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: StatefulSet 3 | metadata: 4 | labels: 5 | service: redis 6 | name: redis 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: redis 12 | serviceName: redis 13 | template: 14 | metadata: 15 | labels: 16 | service: redis 17 | spec: 18 | {{ if .Values.psp.enabled }} 19 | serviceAccountName: robot-shop 20 | {{ end }} 21 | containers: 22 | - name: redis 23 | image: redis:4.0.6 24 | imagePullPolicy: {{ .Values.image.pullPolicy }} 25 | ports: 26 | - containerPort: 6379 27 | volumeMounts: 28 | - name: data 29 | mountPath: /mnt/redis 30 | resources: 31 | limits: 32 | cpu: 200m 33 | memory: 100Mi 34 | requests: 35 | cpu: 100m 36 | memory: 50Mi 37 | restartPolicy: Always 38 | {{- with .Values.redis.affinity }} 39 | affinity: 40 | {{- toYaml . | nindent 8 }} 41 | {{- end }} 42 | {{- with .Values.redis.nodeSelector }} 43 | nodeSelector: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | {{- with .Values.redis.tolerations }} 47 | tolerations: 48 | {{- toYaml . | nindent 8 }} 49 | {{- end }} 50 | volumeClaimTemplates: 51 | - metadata: 52 | name: data 53 | spec: 54 | accessModes: [ "ReadWriteOnce" ] 55 | {{ if not .Values.openshift }} 56 | storageClassName: default 57 | volumeMode: Filesystem 58 | {{ end }} 59 | resources: 60 | requests: 61 | storage: 1Gi -------------------------------------------------------------------------------- /GKE/helm/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | {{ if .Values.psp.enabled }} 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | name: robot-shop 6 | namespace: robot-shop 7 | {{ end }} -------------------------------------------------------------------------------- /GKE/helm/templates/shipping-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: shipping 5 | labels: 6 | service: shipping 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: shipping 12 | template: 13 | metadata: 14 | labels: 15 | service: shipping 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: shipping 22 | image: {{ .Values.image.repo }}/rs-shipping:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | ports: 25 | - containerPort: 8080 26 | # it's Java it needs lots of memory 27 | resources: 28 | limits: 29 | cpu: 200m 30 | memory: 1000Mi 31 | requests: 32 | cpu: 100m 33 | memory: 500Mi 34 | readinessProbe: 35 | httpGet: 36 | path: /health 37 | port: 8080 38 | initialDelaySeconds: 5 39 | periodSeconds: 5 40 | failureThreshold: 30 41 | successThreshold: 1 42 | restartPolicy: Always 43 | {{- with .Values.shipping.affinity }} 44 | affinity: 45 | {{- toYaml . | nindent 8 }} 46 | {{- end }} 47 | {{- with .Values.shipping.nodeSelector }} 48 | nodeSelector: 49 | {{- toYaml . | nindent 8 }} 50 | {{- end }} 51 | {{- with .Values.shipping.tolerations }} 52 | tolerations: 53 | {{- toYaml . | nindent 8 }} 54 | {{- end }} -------------------------------------------------------------------------------- /GKE/helm/templates/shipping-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: shipping 5 | labels: 6 | service: shipping 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: shipping -------------------------------------------------------------------------------- /GKE/helm/templates/user-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: user 5 | labels: 6 | service: user 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: user 12 | template: 13 | metadata: 14 | labels: 15 | service: user 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: user 22 | image: {{ .Values.image.repo }}/rs-user:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | env: 25 | # agent networking access 26 | - name: INSTANA_AGENT_HOST 27 | valueFrom: 28 | fieldRef: 29 | fieldPath: status.hostIP 30 | ports: 31 | - containerPort: 8080 32 | resources: 33 | limits: 34 | cpu: 200m 35 | memory: 100Mi 36 | requests: 37 | cpu: 100m 38 | memory: 50Mi 39 | restartPolicy: Always 40 | {{- with .Values.user.affinity }} 41 | affinity: 42 | {{- toYaml . | nindent 8 }} 43 | {{- end }} 44 | {{- with .Values.user.nodeSelector }} 45 | nodeSelector: 46 | {{- toYaml . | nindent 8 }} 47 | {{- end }} 48 | {{- with .Values.user.tolerations }} 49 | tolerations: 50 | {{- toYaml . | nindent 8 }} 51 | {{- end }} -------------------------------------------------------------------------------- /GKE/helm/templates/user-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: user 5 | labels: 6 | service: user 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: user -------------------------------------------------------------------------------- /GKE/helm/templates/web-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: web 5 | labels: 6 | service: web 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: web 12 | template: 13 | metadata: 14 | labels: 15 | service: web 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: web 22 | image: {{ .Values.image.repo }}/rs-web:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | {{- if .Values.eum.key }} 25 | env: 26 | - name: INSTANA_EUM_KEY 27 | value: {{ .Values.eum.key }} 28 | - name: INSTANA_EUM_REPORTING_URL 29 | value: {{ .Values.eum.url }} 30 | {{- end}} 31 | ports: 32 | - containerPort: 8080 33 | resources: 34 | limits: 35 | cpu: 200m 36 | memory: 100Mi 37 | requests: 38 | cpu: 100m 39 | memory: 50Mi 40 | restartPolicy: Always 41 | {{- with .Values.web.affinity }} 42 | affinity: 43 | {{- toYaml . | nindent 8 }} 44 | {{- end }} 45 | {{- with .Values.web.nodeSelector }} 46 | nodeSelector: 47 | {{- toYaml . | nindent 8 }} 48 | {{- end }} 49 | {{- with .Values.web.tolerations }} 50 | tolerations: 51 | {{- toYaml . | nindent 8 }} 52 | {{- end }} -------------------------------------------------------------------------------- /GKE/helm/templates/web-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: web 5 | labels: 6 | service: web 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: web 14 | {{ if .Values.nodeport }} 15 | type: NodePort 16 | {{ else }} 17 | type: LoadBalancer 18 | {{ end }} 19 | --- 20 | {{if .Values.ocCreateRoute}} 21 | apiVersion: route.openshift.io/v1 22 | kind: Route 23 | metadata: 24 | name: web 25 | spec: 26 | to: 27 | kind: Service 28 | name: web 29 | {{end}} -------------------------------------------------------------------------------- /GKE/helm/values.yaml: -------------------------------------------------------------------------------- 1 | # Registry and repository for Docker images 2 | # Default is docker/robotshop/image:latest 3 | image: 4 | repo: robotshop 5 | version: latest 6 | pullPolicy: IfNotPresent 7 | 8 | # EUM configuration 9 | # Provide your key and set the endpoint 10 | eum: 11 | key: null 12 | url: https://eum-eu-west-1.instana.io 13 | #url: https://eum-us-west-2.instana.io 14 | 15 | # Pod Security Policy 16 | psp: 17 | enabled: false 18 | 19 | # For the mini ones minikube, minishift set to true 20 | nodeport: false 21 | 22 | # "special" Openshift. Set to true when deploying to any openshift flavour 23 | openshift: false 24 | 25 | ocCreateRoute: false 26 | 27 | ###################################### 28 | # Affinities for individual workloads 29 | # set in the following way: 30 | # : 31 | # affinity: {} 32 | # nodeSelector: {} 33 | # tolerations: [] 34 | ###################################### 35 | 36 | cart: {} 37 | 38 | catalogue: {} 39 | 40 | dispatch: {} 41 | 42 | mongodb: {} 43 | 44 | mysql: {} 45 | 46 | payment: 47 | # Alternative payment gateway URL 48 | # Default is https://www.paypal.com 49 | gateway: null 50 | #gateway: https://www.worldpay.com 51 | 52 | rabbitmq: {} 53 | 54 | ratings: {} 55 | 56 | redis: 57 | # Storage class to use with redis statefulset. 58 | storageClassName: default 59 | 60 | shipping: {} 61 | 62 | user: {} 63 | 64 | web: {} -------------------------------------------------------------------------------- /K8s/Istio/canary.yaml: -------------------------------------------------------------------------------- 1 | # Canary testing using Istio 2 | # The DestinationRule defines the subsets by Deployment label 3 | --- 4 | apiVersion: networking.istio.io/v1alpha3 5 | kind: DestinationRule 6 | metadata: 7 | name: canary-test 8 | spec: 9 | host: payment.robot-shop.svc.cluster.local 10 | subsets: 11 | - name: production 12 | labels: 13 | stage: prod 14 | - name: canary 15 | labels: 16 | stage: test 17 | --- 18 | # VirtualService subset references DestinationRule spec.subsets.name 19 | apiVersion: networking.istio.io/v1alpha3 20 | kind: VirtualService 21 | metadata: 22 | name: robotshop-canary 23 | spec: 24 | hosts: 25 | - payment.robot-shop.svc.cluster.local 26 | http: 27 | - route: 28 | - destination: 29 | host: payment.robot-shop.svc.cluster.local 30 | subset: production 31 | weight: 99 32 | - destination: 33 | host: payment.robot-shop.svc.cluster.local 34 | subset: canary 35 | weight: 1 36 | -------------------------------------------------------------------------------- /K8s/Istio/gateway.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: networking.istio.io/v1alpha3 3 | kind: Gateway 4 | metadata: 5 | name: robotshop-gateway 6 | spec: 7 | selector: 8 | istio: ingressgateway # default Istio controller 9 | servers: 10 | - port: 11 | number: 80 12 | name: http 13 | protocol: HTTP 14 | hosts: 15 | - "*" 16 | --- 17 | apiVersion: networking.istio.io/v1alpha3 18 | kind: VirtualService 19 | metadata: 20 | name: robotshop 21 | spec: 22 | hosts: 23 | - "*" 24 | gateways: 25 | - robotshop-gateway 26 | http: 27 | # default route 28 | - route: 29 | - destination: 30 | host: web.robot-shop.svc.cluster.local 31 | port: 32 | number: 8080 33 | -------------------------------------------------------------------------------- /K8s/Istio/payment-deployment-fix.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: payment-fix 5 | labels: 6 | service: payment 7 | stage: test 8 | spec: 9 | replicas: 1 10 | selector: 11 | matchLabels: 12 | service: payment 13 | stage: test 14 | template: 15 | metadata: 16 | labels: 17 | service: payment 18 | stage: test 19 | spec: 20 | containers: 21 | - name: payment-fix 22 | image: robotshop/rs-payment-fix:latest 23 | # agent networking access 24 | env: 25 | - name: INSTANA_AGENT_HOST 26 | valueFrom: 27 | fieldRef: 28 | fieldPath: status.hostIP 29 | ports: 30 | - containerPort: 8080 31 | resources: 32 | limits: 33 | cpu: 200m 34 | memory: 100Mi 35 | requests: 36 | cpu: 100m 37 | memory: 50Mi 38 | restartPolicy: Always 39 | -------------------------------------------------------------------------------- /K8s/README.md: -------------------------------------------------------------------------------- 1 | # Instana Agent Install 2 | 3 | The easiest way to install the Instana agent is with the helm [chart](https://hub.helm.sh/charts/stable/instana-agent). If you really want to do it by hand, template descriptors are available in the official [documentation](https://docs.instana.io/ecosystem/kubernetes/). 4 | 5 | # Stan's Robot Shop Install 6 | 7 | Install Stan's Robot Shop on to your K8s cluster using the helm chart, see the [README](helm/README.md) for details of the various options. 8 | 9 | ```shell 10 | $ cd helm 11 | $ helm install --name robot-shop --namespace robot-shop . 12 | ``` 13 | 14 | ## Quotas and Scaling 15 | 16 | You can apply resource quotas to the namespace where you installed Stan's Robot Shop. 17 | 18 | ```shell 19 | $ kubectl -n robot-shop apply -f resource-quota.yaml 20 | ``` 21 | 22 | The quotas and usage are shown in the Instana Kubernetes dashboards. 23 | 24 | Optinally you can also run the `autoscale.sh` script to configure automatic scaling of the deployments. You will need to edit the script if you did not deploy to the `robot-shop` namespace. Varying the load on the application will cause Kubernetes to scale up/down the various deployments. 25 | 26 | ## Istio 27 | 28 | Stan's Robot Shop will run on Kubernetes with Istio service mesh. Configure Istio ingress. 29 | 30 | ```shell 31 | $ kubectl -n robot-shop apply -f Istio/gateway.yaml 32 | ``` 33 | 34 | Now use the exposed Istio gateway to access Robot Shop. 35 | 36 | ```shell 37 | $ kubectl -n istio-system get svc istio-ingressgateway 38 | ``` 39 | 40 | The above will display the IP address of the Istio gateway. 41 | 42 | **NOTE** The Instana agent only works with later versions of Istio. -------------------------------------------------------------------------------- /K8s/autoscale.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | NS="robot-shop" 4 | DEPLOYMENTS="cart catalogue dispatch payment ratings shipping user web" 5 | 6 | for DEP in $DEPLOYMENTS 7 | do 8 | kubectl -n $NS autoscale deployment $DEP --max 2 --min 1 --cpu-percent 50 9 | done 10 | 11 | echo "Waiting 5 seconds for changes to apply..." 12 | sleep 5 13 | kubectl -n $NS get hpa 14 | 15 | -------------------------------------------------------------------------------- /K8s/helm/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | name: robot-shop 3 | version: 1.1.0 4 | home: https://github.com/instana/robot-shop 5 | description: Sample micoservices application 6 | 7 | -------------------------------------------------------------------------------- /K8s/helm/templates/cart-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: cart 5 | labels: 6 | service: cart 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: cart 12 | template: 13 | metadata: 14 | labels: 15 | service: cart 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: cart 22 | image: {{ .Values.image.repo }}/rs-cart:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | # agent networking access 25 | env: 26 | - name: INSTANA_AGENT_HOST 27 | valueFrom: 28 | fieldRef: 29 | fieldPath: status.hostIP 30 | ports: 31 | - containerPort: 8080 32 | resources: 33 | limits: 34 | cpu: 200m 35 | memory: 100Mi 36 | requests: 37 | cpu: 100m 38 | memory: 50Mi 39 | {{- with .Values.cart.affinity }} 40 | affinity: 41 | {{- toYaml . | nindent 8 }} 42 | {{- end }} 43 | {{- with .Values.cart.nodeSelector }} 44 | nodeSelector: 45 | {{- toYaml . | nindent 8 }} 46 | {{- end }} 47 | {{- with .Values.cart.tolerations }} 48 | tolerations: 49 | {{- toYaml . | nindent 8 }} 50 | {{- end }} 51 | -------------------------------------------------------------------------------- /K8s/helm/templates/cart-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: cart 5 | spec: 6 | ports: 7 | - name: http 8 | port: 8080 9 | targetPort: 8080 10 | selector: 11 | service: cart 12 | -------------------------------------------------------------------------------- /K8s/helm/templates/catalogue-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: catalogue 5 | labels: 6 | service: catalogue 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: catalogue 12 | template: 13 | metadata: 14 | labels: 15 | service: catalogue 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: catalogue 22 | image: {{ .Values.image.repo }}/rs-catalogue:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | env: 25 | - name: INSTANA_AGENT_HOST 26 | valueFrom: 27 | fieldRef: 28 | fieldPath: status.hostIP 29 | ports: 30 | - containerPort: 8080 31 | resources: 32 | limits: 33 | cpu: 200m 34 | memory: 100Mi 35 | requests: 36 | cpu: 100m 37 | memory: 50Mi 38 | restartPolicy: Always 39 | {{- with .Values.catalogue.affinity }} 40 | affinity: 41 | {{- toYaml . | nindent 8 }} 42 | {{- end }} 43 | {{- with .Values.catalogue.nodeSelector }} 44 | nodeSelector: 45 | {{- toYaml . | nindent 8 }} 46 | {{- end }} 47 | {{- with .Values.catalogue.tolerations }} 48 | tolerations: 49 | {{- toYaml . | nindent 8 }} 50 | {{- end }} 51 | -------------------------------------------------------------------------------- /K8s/helm/templates/catalogue-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | service: catalogue 6 | name: catalogue 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: catalogue 14 | -------------------------------------------------------------------------------- /K8s/helm/templates/clusterrole.yaml: -------------------------------------------------------------------------------- 1 | {{ if .Values.psp.enabled }} 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRole 4 | metadata: 5 | name: robot-shop 6 | rules: 7 | - apiGroups: 8 | - policy 9 | resourceNames: 10 | - robot-shop 11 | resources: 12 | - podsecuritypolicies 13 | verbs: 14 | - use 15 | {{ end }} 16 | -------------------------------------------------------------------------------- /K8s/helm/templates/clusterrolebinding.yaml: -------------------------------------------------------------------------------- 1 | {{ if .Values.psp.enabled }} 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRoleBinding 4 | metadata: 5 | name: robot-shop 6 | roleRef: 7 | apiGroup: rbac.authorization.k8s.io 8 | kind: ClusterRole 9 | name: robot-shop 10 | subjects: 11 | - kind: ServiceAccount 12 | name: robot-shop 13 | namespace: robot-shop 14 | {{ end }} 15 | -------------------------------------------------------------------------------- /K8s/helm/templates/dispatch-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: dispatch 5 | labels: 6 | service: dispatch 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: dispatch 12 | template: 13 | metadata: 14 | labels: 15 | service: dispatch 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: dispatch 22 | image: {{ .Values.image.repo }}/rs-dispatch:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | env: 25 | # agent networking access 26 | - name: INSTANA_AGENT_HOST 27 | valueFrom: 28 | fieldRef: 29 | fieldPath: status.hostIP 30 | resources: 31 | limits: 32 | cpu: 200m 33 | memory: 100Mi 34 | requests: 35 | cpu: 100m 36 | memory: 50Mi 37 | restartPolicy: Always 38 | {{- with .Values.dispatch.affinity }} 39 | affinity: 40 | {{- toYaml . | nindent 8 }} 41 | {{- end }} 42 | {{- with .Values.dispatch.nodeSelector }} 43 | nodeSelector: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | {{- with .Values.dispatch.tolerations }} 47 | tolerations: 48 | {{- toYaml . | nindent 8 }} 49 | {{- end }} 50 | -------------------------------------------------------------------------------- /K8s/helm/templates/dispatch-service.yaml: -------------------------------------------------------------------------------- 1 | # dispatch just listens to a message queue 2 | # it does not expose any ports 3 | apiVersion: v1 4 | kind: Service 5 | metadata: 6 | name: dispatch 7 | labels: 8 | service: dispatch 9 | spec: 10 | clusterIP: None 11 | ports: 12 | - name: headless 13 | port: 55555 14 | targetPort: 0 15 | selector: 16 | service: dispatch 17 | -------------------------------------------------------------------------------- /K8s/helm/templates/mongodb-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: mongodb 5 | labels: 6 | service: mongodb 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: mongodb 12 | template: 13 | metadata: 14 | labels: 15 | service: mongodb 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: mongodb 22 | image: {{ .Values.image.repo }}/rs-mongodb:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | ports: 25 | - containerPort: 27017 26 | resources: 27 | limits: 28 | cpu: 200m 29 | memory: 200Mi 30 | requests: 31 | cpu: 100m 32 | memory: 100Mi 33 | restartPolicy: Always 34 | {{- with .Values.mongodb.affinity }} 35 | affinity: 36 | {{- toYaml . | nindent 8 }} 37 | {{- end }} 38 | {{- with .Values.mongodb.nodeSelector }} 39 | nodeSelector: 40 | {{- toYaml . | nindent 8 }} 41 | {{- end }} 42 | {{- with .Values.mongodb.tolerations }} 43 | tolerations: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | -------------------------------------------------------------------------------- /K8s/helm/templates/mongodb-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | service: mongodb 6 | name: mongodb 7 | spec: 8 | ports: 9 | - name: mongo 10 | port: 27017 11 | targetPort: 27017 12 | selector: 13 | service: mongodb 14 | -------------------------------------------------------------------------------- /K8s/helm/templates/mysql-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: mysql 5 | labels: 6 | service: mysql 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: mysql 12 | template: 13 | metadata: 14 | labels: 15 | service: mysql 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: mysql 22 | image: {{ .Values.image.repo }}/rs-mysql-db:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | # added for Istio 25 | securityContext: 26 | capabilities: 27 | add: ["NET_ADMIN"] 28 | ports: 29 | - containerPort: 3306 30 | resources: 31 | limits: 32 | cpu: 200m 33 | memory: 1024Mi 34 | requests: 35 | cpu: 100m 36 | memory: 700Mi 37 | restartPolicy: Always 38 | {{- with .Values.mysql.affinity }} 39 | affinity: 40 | {{- toYaml . | nindent 8 }} 41 | {{- end }} 42 | {{- with .Values.mysql.nodeSelector }} 43 | nodeSelector: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | {{- with .Values.mysql.tolerations }} 47 | tolerations: 48 | {{- toYaml . | nindent 8 }} 49 | {{- end }} 50 | -------------------------------------------------------------------------------- /K8s/helm/templates/mysql-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | service: mysql 6 | name: mysql 7 | spec: 8 | ports: 9 | - name: mysql 10 | port: 3306 11 | targetPort: 3306 12 | selector: 13 | service: mysql 14 | -------------------------------------------------------------------------------- /K8s/helm/templates/payment-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: payment 5 | labels: 6 | service: payment 7 | stage: prod 8 | spec: 9 | replicas: 1 10 | selector: 11 | matchLabels: 12 | service: payment 13 | stage: prod 14 | template: 15 | metadata: 16 | labels: 17 | service: payment 18 | stage: prod 19 | spec: 20 | {{ if .Values.psp.enabled }} 21 | serviceAccountName: robot-shop 22 | {{ end }} 23 | containers: 24 | - name: payment 25 | image: {{ .Values.image.repo }}/rs-payment:{{ .Values.image.version }} 26 | imagePullPolicy: {{ .Values.image.pullPolicy }} 27 | # agent networking access 28 | env: 29 | - name: INSTANA_AGENT_HOST 30 | valueFrom: 31 | fieldRef: 32 | fieldPath: status.hostIP 33 | {{- if .Values.payment.gateway }} 34 | - name: PAYMENT_GATEWAY 35 | value: {{ .Values.payment.gateway }} 36 | {{- end }} 37 | ports: 38 | - containerPort: 8080 39 | resources: 40 | limits: 41 | cpu: 200m 42 | memory: 100Mi 43 | requests: 44 | cpu: 100m 45 | memory: 50Mi 46 | restartPolicy: Always 47 | {{- with .Values.payment.affinity }} 48 | affinity: 49 | {{- toYaml . | nindent 8 }} 50 | {{- end }} 51 | {{- with .Values.payment.nodeSelector }} 52 | nodeSelector: 53 | {{- toYaml . | nindent 8 }} 54 | {{- end }} 55 | {{- with .Values.payment.tolerations }} 56 | tolerations: 57 | {{- toYaml . | nindent 8 }} 58 | {{- end }} 59 | -------------------------------------------------------------------------------- /K8s/helm/templates/payment-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: payment 5 | labels: 6 | service: payment 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: payment 14 | -------------------------------------------------------------------------------- /K8s/helm/templates/podsecuritypolicy.yaml: -------------------------------------------------------------------------------- 1 | {{ if .Values.psp.enabled }} 2 | apiVersion: policy/v1beta1 3 | kind: PodSecurityPolicy 4 | metadata: 5 | name: robot-shop 6 | spec: 7 | allowPrivilegeEscalation: false 8 | fsGroup: 9 | rule: RunAsAny 10 | privileged: false 11 | runAsUser: 12 | rule: RunAsAny 13 | seLinux: 14 | rule: RunAsAny 15 | supplementalGroups: 16 | rule: RunAsAny 17 | allowedCapabilities: 18 | - 'NET_ADMIN' 19 | volumes: 20 | - configMap 21 | - downwardAPI 22 | - emptyDir 23 | - persistentVolumeClaim 24 | - secret 25 | - projected 26 | {{ end }} 27 | -------------------------------------------------------------------------------- /K8s/helm/templates/rabbitmq-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: rabbitmq 5 | labels: 6 | service: rabbitmq 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: rabbitmq 12 | template: 13 | metadata: 14 | labels: 15 | service: rabbitmq 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: rabbitmq 22 | image: rabbitmq:3.7-management-alpine 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | ports: 25 | - containerPort: 5672 26 | - containerPort: 15672 27 | resources: 28 | limits: 29 | cpu: 200m 30 | memory: 512Mi 31 | requests: 32 | cpu: 100m 33 | memory: 256Mi 34 | restartPolicy: Always 35 | {{- with .Values.rabbitmq.affinity }} 36 | affinity: 37 | {{- toYaml . | nindent 8 }} 38 | {{- end }} 39 | {{- with .Values.rabbitmq.nodeSelector }} 40 | nodeSelector: 41 | {{- toYaml . | nindent 8 }} 42 | {{- end }} 43 | {{- with .Values.rabbitmq.tolerations }} 44 | tolerations: 45 | {{- toYaml . | nindent 8 }} 46 | {{- end }} 47 | -------------------------------------------------------------------------------- /K8s/helm/templates/rabbitmq-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: rabbitmq 5 | labels: 6 | service: rabbitmq 7 | spec: 8 | ports: 9 | - name: tcp-amqp 10 | port: 5672 11 | targetPort: 5672 12 | - name: http-management 13 | port: 15672 14 | targetPort: 15672 15 | - name: tcp-epmd 16 | port: 4369 17 | targetPort: 4369 18 | selector: 19 | service: rabbitmq 20 | -------------------------------------------------------------------------------- /K8s/helm/templates/ratings-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: ratings 5 | labels: 6 | service: ratings 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: ratings 12 | template: 13 | metadata: 14 | labels: 15 | service: ratings 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: ratings 22 | image: {{ .Values.image.repo }}/rs-ratings:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | ports: 25 | - containerPort: 80 26 | resources: 27 | limits: 28 | cpu: 200m 29 | memory: 100Mi 30 | requests: 31 | cpu: 100m 32 | memory: 50Mi 33 | readinessProbe: 34 | httpGet: 35 | path: /_health 36 | port: 80 37 | initialDelaySeconds: 5 38 | periodSeconds: 5 39 | failureThreshold: 30 40 | successThreshold: 1 41 | restartPolicy: Always 42 | {{- with .Values.ratings.affinity }} 43 | affinity: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | {{- with .Values.ratings.nodeSelector }} 47 | nodeSelector: 48 | {{- toYaml . | nindent 8 }} 49 | {{- end }} 50 | {{- with .Values.ratings.tolerations }} 51 | tolerations: 52 | {{- toYaml . | nindent 8 }} 53 | {{- end }} 54 | -------------------------------------------------------------------------------- /K8s/helm/templates/ratings-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: ratings 5 | labels: 6 | service: ratings 7 | spec: 8 | ports: 9 | - name: http 10 | port: 80 11 | targetPort: 80 12 | selector: 13 | service: ratings 14 | 15 | -------------------------------------------------------------------------------- /K8s/helm/templates/redis-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | service: redis 6 | name: redis 7 | spec: 8 | ports: 9 | - name: redis 10 | port: 6379 11 | targetPort: 6379 12 | selector: 13 | service: redis 14 | -------------------------------------------------------------------------------- /K8s/helm/templates/redis-statefulset.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: StatefulSet 3 | metadata: 4 | labels: 5 | service: redis 6 | name: redis 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: redis 12 | serviceName: redis 13 | template: 14 | metadata: 15 | labels: 16 | service: redis 17 | spec: 18 | {{ if .Values.psp.enabled }} 19 | serviceAccountName: robot-shop 20 | {{ end }} 21 | containers: 22 | - name: redis 23 | image: redis:4.0.6 24 | imagePullPolicy: {{ .Values.image.pullPolicy }} 25 | ports: 26 | - containerPort: 6379 27 | volumeMounts: 28 | - name: data 29 | mountPath: /mnt/redis 30 | resources: 31 | limits: 32 | cpu: 200m 33 | memory: 100Mi 34 | requests: 35 | cpu: 100m 36 | memory: 50Mi 37 | restartPolicy: Always 38 | {{- with .Values.redis.affinity }} 39 | affinity: 40 | {{- toYaml . | nindent 8 }} 41 | {{- end }} 42 | {{- with .Values.redis.nodeSelector }} 43 | nodeSelector: 44 | {{- toYaml . | nindent 8 }} 45 | {{- end }} 46 | {{- with .Values.redis.tolerations }} 47 | tolerations: 48 | {{- toYaml . | nindent 8 }} 49 | {{- end }} 50 | volumeClaimTemplates: 51 | - metadata: 52 | name: data 53 | spec: 54 | accessModes: [ "ReadWriteOnce" ] 55 | {{ if not .Values.openshift }} 56 | storageClassName: {{ .Values.redis.storageClassName }} 57 | volumeMode: Filesystem 58 | {{ end }} 59 | resources: 60 | requests: 61 | storage: 1Gi 62 | 63 | -------------------------------------------------------------------------------- /K8s/helm/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | {{ if .Values.psp.enabled }} 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | name: robot-shop 6 | namespace: robot-shop 7 | {{ end }} 8 | -------------------------------------------------------------------------------- /K8s/helm/templates/shipping-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: shipping 5 | labels: 6 | service: shipping 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: shipping 12 | template: 13 | metadata: 14 | labels: 15 | service: shipping 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: shipping 22 | image: {{ .Values.image.repo }}/rs-shipping:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | ports: 25 | - containerPort: 8080 26 | # it's Java it needs lots of memory 27 | resources: 28 | limits: 29 | cpu: 200m 30 | memory: 1000Mi 31 | requests: 32 | cpu: 100m 33 | memory: 500Mi 34 | readinessProbe: 35 | httpGet: 36 | path: /health 37 | port: 8080 38 | initialDelaySeconds: 5 39 | periodSeconds: 5 40 | failureThreshold: 30 41 | successThreshold: 1 42 | restartPolicy: Always 43 | {{- with .Values.shipping.affinity }} 44 | affinity: 45 | {{- toYaml . | nindent 8 }} 46 | {{- end }} 47 | {{- with .Values.shipping.nodeSelector }} 48 | nodeSelector: 49 | {{- toYaml . | nindent 8 }} 50 | {{- end }} 51 | {{- with .Values.shipping.tolerations }} 52 | tolerations: 53 | {{- toYaml . | nindent 8 }} 54 | {{- end }} 55 | -------------------------------------------------------------------------------- /K8s/helm/templates/shipping-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: shipping 5 | labels: 6 | service: shipping 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: shipping 14 | -------------------------------------------------------------------------------- /K8s/helm/templates/user-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: user 5 | labels: 6 | service: user 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: user 12 | template: 13 | metadata: 14 | labels: 15 | service: user 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: user 22 | image: {{ .Values.image.repo }}/rs-user:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | env: 25 | # agent networking access 26 | - name: INSTANA_AGENT_HOST 27 | valueFrom: 28 | fieldRef: 29 | fieldPath: status.hostIP 30 | ports: 31 | - containerPort: 8080 32 | resources: 33 | limits: 34 | cpu: 200m 35 | memory: 100Mi 36 | requests: 37 | cpu: 100m 38 | memory: 50Mi 39 | restartPolicy: Always 40 | {{- with .Values.user.affinity }} 41 | affinity: 42 | {{- toYaml . | nindent 8 }} 43 | {{- end }} 44 | {{- with .Values.user.nodeSelector }} 45 | nodeSelector: 46 | {{- toYaml . | nindent 8 }} 47 | {{- end }} 48 | {{- with .Values.user.tolerations }} 49 | tolerations: 50 | {{- toYaml . | nindent 8 }} 51 | {{- end }} 52 | -------------------------------------------------------------------------------- /K8s/helm/templates/user-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: user 5 | labels: 6 | service: user 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: user 14 | -------------------------------------------------------------------------------- /K8s/helm/templates/web-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: web 5 | labels: 6 | service: web 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: web 12 | template: 13 | metadata: 14 | labels: 15 | service: web 16 | spec: 17 | {{ if .Values.psp.enabled }} 18 | serviceAccountName: robot-shop 19 | {{ end }} 20 | containers: 21 | - name: web 22 | image: {{ .Values.image.repo }}/rs-web:{{ .Values.image.version }} 23 | imagePullPolicy: {{ .Values.image.pullPolicy }} 24 | {{- if .Values.eum.key }} 25 | env: 26 | - name: INSTANA_EUM_KEY 27 | value: {{ .Values.eum.key }} 28 | - name: INSTANA_EUM_REPORTING_URL 29 | value: {{ .Values.eum.url }} 30 | {{- end}} 31 | ports: 32 | - containerPort: 8080 33 | resources: 34 | limits: 35 | cpu: 200m 36 | memory: 100Mi 37 | requests: 38 | cpu: 100m 39 | memory: 50Mi 40 | restartPolicy: Always 41 | {{- with .Values.web.affinity }} 42 | affinity: 43 | {{- toYaml . | nindent 8 }} 44 | {{- end }} 45 | {{- with .Values.web.nodeSelector }} 46 | nodeSelector: 47 | {{- toYaml . | nindent 8 }} 48 | {{- end }} 49 | {{- with .Values.web.tolerations }} 50 | tolerations: 51 | {{- toYaml . | nindent 8 }} 52 | {{- end }} 53 | -------------------------------------------------------------------------------- /K8s/helm/templates/web-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: web 5 | labels: 6 | service: web 7 | spec: 8 | ports: 9 | - name: http 10 | port: 8080 11 | targetPort: 8080 12 | selector: 13 | service: web 14 | {{ if .Values.nodeport }} 15 | type: NodePort 16 | {{ else }} 17 | type: LoadBalancer 18 | {{ end }} 19 | --- 20 | {{if .Values.ocCreateRoute}} 21 | apiVersion: route.openshift.io/v1 22 | kind: Route 23 | metadata: 24 | name: web 25 | spec: 26 | to: 27 | kind: Service 28 | name: web 29 | {{end}} -------------------------------------------------------------------------------- /K8s/helm/values.yaml: -------------------------------------------------------------------------------- 1 | # Registry and repository for Docker images 2 | # Default is docker/robotshop/image:latest 3 | image: 4 | repo: robotshop 5 | version: latest 6 | pullPolicy: IfNotPresent 7 | 8 | # EUM configuration 9 | # Provide your key and set the endpoint 10 | eum: 11 | key: null 12 | url: https://eum-eu-west-1.instana.io 13 | #url: https://eum-us-west-2.instana.io 14 | 15 | # Pod Security Policy 16 | psp: 17 | enabled: false 18 | 19 | # For the mini ones minikube, minishift set to true 20 | nodeport: false 21 | 22 | # "special" Openshift. Set to true when deploying to any openshift flavour 23 | openshift: false 24 | 25 | ocCreateRoute: false 26 | 27 | ###################################### 28 | # Affinities for individual workloads 29 | # set in the following way: 30 | # : 31 | # affinity: {} 32 | # nodeSelector: {} 33 | # tolerations: [] 34 | ###################################### 35 | 36 | cart: {} 37 | 38 | catalogue: {} 39 | 40 | dispatch: {} 41 | 42 | mongodb: {} 43 | 44 | mysql: {} 45 | 46 | payment: 47 | # Alternative payment gateway URL 48 | # Default is https://www.paypal.com 49 | gateway: null 50 | #gateway: https://www.worldpay.com 51 | 52 | rabbitmq: {} 53 | 54 | ratings: {} 55 | 56 | redis: 57 | # Storage class to use with redis statefulset. 58 | storageClassName: standard 59 | 60 | shipping: {} 61 | 62 | user: {} 63 | 64 | web: {} 65 | -------------------------------------------------------------------------------- /K8s/load-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: load 5 | labels: 6 | service: load 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | service: load 12 | template: 13 | metadata: 14 | labels: 15 | service: load 16 | spec: 17 | containers: 18 | - name: load 19 | env: 20 | - name: HOST 21 | value: "http://web:8080/" 22 | - name: NUM_CLIENTS 23 | value: "15" 24 | - name: SILENT 25 | value: "1" 26 | - name: ERROR 27 | value: "1" 28 | image: robotshop/rs-load:latest 29 | resources: 30 | limits: 31 | cpu: 200m 32 | memory: 200Mi 33 | requests: 34 | cpu: 100m 35 | memory: 100Mi 36 | -------------------------------------------------------------------------------- /K8s/resource-quota.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ResourceQuota 3 | metadata: 4 | name: robot-shop-quota 5 | spec: 6 | hard: 7 | limits.cpu: 4 8 | requests.cpu: 2 9 | limits.memory: 5Gi 10 | requests.memory: 3Gi 11 | pods: 20 12 | -------------------------------------------------------------------------------- /OpenShift/README.md: -------------------------------------------------------------------------------- 1 | # Instana Agent Installation 2 | 3 | See the official [documentation](https://docs.instana.io/quick_start/agent_setup/container/openshift/) for how to install the Instana agent on an OpenShift environment. 4 | 5 | # Robot Shop Deployment 6 | 7 | ## OCP 3.x 8 | 9 | For OpenShift run the `setup.sh` script to create the project and set the extra permissions. 10 | 11 | Use the Helm chart for Kubernetes to install Stan's Robot Shop. To install on Minishift. 12 | 13 | ### Helm 3 14 | 15 | ```shell 16 | $ cd K8s 17 | $ oc login -u developer 18 | $ oc project robot-shop 19 | $ helm install robot-shop --set openshift=true --set nodeport=true helm 20 | ``` 21 | 22 | To connect to the shop. 23 | 24 | ```shell 25 | $ minishift ip 26 | 192.168.99.106 27 | $ oc get svc web 28 | NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE 29 | web NodePort 172.30.180.253 8080:31147/TCP 4m 30 | ``` 31 | 32 | Use the IP and the node port to form the URL `http://192.168.99.106:31147/` 33 | 34 | ## OCP 4.x 35 | 36 | For Openshift cluster in version 4.x follow these steps: 37 | 38 | ``` 39 | export KUBECONFIG=/path/to/oc/cluster/dir/auth/kubeconfig 40 | oc adm new-project robot-shop 41 | oc adm policy add-scc-to-user anyuid -z default -n robot-shop 42 | oc adm policy add-scc-to-user privileged -z default -n robot-shop 43 | cd robot-shop/K8s 44 | helm install robot-shop --set openshift=true -n robot-shop helm 45 | ``` 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /OpenShift/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # set -x 4 | 5 | oc login -u system:admin 6 | oc adm new-project robot-shop 7 | oc adm policy add-role-to-user admin developer -n robot-shop 8 | oc adm policy add-scc-to-user anyuid -z default 9 | oc adm policy add-scc-to-user privileged -z default 10 | 11 | oc login -u developer 12 | 13 | -------------------------------------------------------------------------------- /Swarm/create-swarm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | 4 | if [ -z "$1" ] 5 | then 6 | echo "Usage: create-machines.sh [local|aws]" 7 | exit 1 8 | fi 9 | 10 | case $1 in 11 | local) 12 | DRIVER=virtualbox 13 | ;; 14 | aws) 15 | DRIVER=amazonec2 16 | ;; 17 | *) 18 | echo "Unknown option" 19 | exit 1 20 | esac 21 | 22 | for MACHINE in master worker-1 worker-2 23 | do 24 | echo "Creating $MACHINE" 25 | if [ "$DRIVER" = "aws" ] 26 | then 27 | docker-machine create \ 28 | --driver $DRIVER \ 29 | --amazonec2-instance-type "t2.medium" \ 30 | $MACHINE 31 | else 32 | docker-machine create \ 33 | --driver $DRIVER \ 34 | $MACHINE 35 | fi 36 | done 37 | 38 | sleep 3 39 | echo " " 40 | echo "Machines created" 41 | echo "Configuring Swarm" 42 | 43 | MASTER_IP=$(docker-machine ip master) 44 | 45 | # create the swarm master 46 | # connect local docker command to master machine 47 | echo "Creating master" 48 | eval $(docker-machine env master) 49 | JOIN_CMD=$(docker swarm init --advertise-addr "$MASTER_IP" | awk '/^[ \t]+/{print $0}' -) 50 | 51 | for MACHINE in $(docker-machine ls -q | fgrep worker) 52 | do 53 | echo "joining from $MACHINE" 54 | eval $(docker-machine env $MACHINE) 55 | $JOIN_CMD 56 | done 57 | 58 | echo " " 59 | echo "Swarm is ready" 60 | 61 | -------------------------------------------------------------------------------- /Swarm/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # set -x 4 | 5 | # Read in vars from .env file 6 | 7 | for VAR in $(egrep '^[A-Z]+=' ../.env) 8 | do 9 | export $VAR 10 | done 11 | 12 | # Connect to master 13 | eval $(docker-machine env master) 14 | 15 | docker stack deploy robot-shop -c ../docker-compose.yaml 16 | 17 | sleep 3 18 | echo " " 19 | echo "Robot Shop deployed" 20 | docker service ls 21 | 22 | echo " " 23 | IP=$(docker-machine ip master) 24 | echo "Go to the shop http://${IP}:8080/ when all the services have started" 25 | echo "This may take a while..." 26 | 27 | -------------------------------------------------------------------------------- /Swarm/instana-agent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Config here 4 | KEY="your unique key" 5 | ENDPOINT="endpoint for your tennant" 6 | # end of config 7 | 8 | for MACHINE in $(docker-machine ls -q) 9 | do 10 | echo "starting agent on $MACHINE" 11 | eval $(docker-machine env $MACHINE) 12 | docker run \ 13 | -d \ 14 | --rm \ 15 | --name instana-agent \ 16 | --volume /var/run/docker.sock:/var/run/docker.sock \ 17 | --volume /dev:/dev \ 18 | --volume /sys:/sys \ 19 | --volume /var/log:/var/log \ 20 | --privileged \ 21 | --net=host \ 22 | --pid=host \ 23 | --ipc=host \ 24 | --env="INSTANA_AGENT_KEY=$KEY" \ 25 | --env="INSTANA_AGENT_ENDPOINT=$ENDPOINT" \ 26 | --env="INSTANA_AGENT_ENDPOINT_PORT=443" \ 27 | --env="INSTANA_AGENT_ZONE=Stans-Robot-Shop" \ 28 | --env="INSTANA_AGENT_HTTP_LISTEN=*" \ 29 | instana/agent 30 | done 31 | 32 | -------------------------------------------------------------------------------- /cart/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:14 2 | 3 | ENV INSTANA_AUTO_PROFILE true 4 | 5 | EXPOSE 8080 6 | 7 | WORKDIR /opt/server 8 | 9 | COPY package.json /opt/server/ 10 | 11 | RUN npm install 12 | 13 | COPY server.js /opt/server/ 14 | 15 | CMD ["node", "server.js"] 16 | 17 | -------------------------------------------------------------------------------- /cart/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cart", 3 | "version": "1.0.0", 4 | "description": "cart REST API", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "SteveW", 10 | "license": "Apache-2.0", 11 | "dependencies": { 12 | "body-parser": "^1.18.1", 13 | "express": "^4.15.4", 14 | "redis": "^2.8.0", 15 | "request": "^2.88.2", 16 | "pino": "^5.10.8", 17 | "express-pino-logger": "^4.0.0", 18 | "pino-pretty": "^2.5.0", 19 | "@instana/collector": "^1.132.2", 20 | "prom-client": "^11.5.3" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /catalogue/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:14 2 | 3 | ENV INSTANA_AUTO_PROFILE true 4 | 5 | EXPOSE 8080 6 | 7 | WORKDIR /opt/server 8 | 9 | COPY package.json /opt/server/ 10 | 11 | RUN npm install 12 | 13 | COPY server.js /opt/server/ 14 | 15 | CMD ["node", "server.js"] 16 | 17 | -------------------------------------------------------------------------------- /catalogue/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "catalogue", 3 | "version": "1.0.0", 4 | "description": "product catalogue REST API", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "SteveW", 10 | "license": "Apache-2.0", 11 | "dependencies": { 12 | "body-parser": "^1.18.1", 13 | "express": "^4.15.4", 14 | "mongodb": "^3.5.3", 15 | "pino": "^5.10.8", 16 | "express-pino-logger": "^4.0.0", 17 | "pino-pretty": "^2.5.0", 18 | "@instana/collector": "^1.132.2" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /dispatch/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.17 2 | 3 | WORKDIR /go/src/app 4 | 5 | COPY *.go . 6 | 7 | RUN go mod init dispatch && go get 8 | RUN go install 9 | 10 | CMD dispatch 11 | -------------------------------------------------------------------------------- /dispatch/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | rabbitmq: 4 | image: rabbitmq:3.7-management-alpine 5 | ports: 6 | - "5672" 7 | - "15672:15672" 8 | networks: 9 | - robot-shop 10 | payment: 11 | build: 12 | context: ../payment 13 | image: steveww/rs-payment 14 | depends_on: 15 | - rabbitmq 16 | ports: 17 | - "8080:8080" 18 | networks: 19 | - robot-shop 20 | dispatch: 21 | build: 22 | context: . 23 | image: steveww/rs-dispatch 24 | depends_on: 25 | - rabbitmq 26 | networks: 27 | - robot-shop 28 | 29 | networks: 30 | robot-shop: 31 | -------------------------------------------------------------------------------- /docker-compose-load.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | load: 4 | image: ${REPO}/rs-load:${TAG} 5 | build: 6 | context: load-gen 7 | environment: 8 | HOST: http://web:8080 9 | networks: 10 | - robot-shop 11 | depends_on: 12 | - web 13 | logging: &logging 14 | driver: "json-file" 15 | options: 16 | max-size: "25m" 17 | max-file: "2" 18 | -------------------------------------------------------------------------------- /fluentd/Docker-Compose/README.md: -------------------------------------------------------------------------------- 1 | # Configuration 2 | 3 | Edit `fluent.conf` setting the parameters to match either your Humio account or Elasticsearch instance. See the [fluentd documentation](https://docs.fluentd.org/output/elasticsearch) and/or [Humio documentation](https://docs.humio.com/docs/ingesting-data/data-shippers/fluentd/) for details. 4 | 5 | Start `fluentd` in a Docker container using the `run.sh` script. 6 | 7 | ## Docker Compose 8 | 9 | To have all the containers in Stan's Robot Shop use fluentd for logging, the `docker-compose.yaml` needs to be edited. Change the logging section at the top of the file. 10 | 11 | ```yaml 12 | services: 13 | mongodb: 14 | build: 15 | context: mongo 16 | image: ${REPO}/rs-mongodb:${TAG} 17 | networks: 18 | - robto-shop 19 | logging: &logging 20 | driver: "fluentd" 21 | options: 22 | fluentd-address: localhost:24224 23 | tag: "{{.ImageName}}" 24 | redis: 25 | ``` 26 | 27 | If Robot Shop is already running, shut it down `docker-compose down` 28 | 29 | Start Robot Shop with `docker-compose up -d`. It takes a few minutes to start, after that check with Humio or ELK for log entries. 30 | 31 | Set up [logging integration](https://www.instana.com/docs/logging/) in Instana. 32 | 33 | -------------------------------------------------------------------------------- /fluentd/Docker-Compose/fluent.conf: -------------------------------------------------------------------------------- 1 | 2 | @type forward 3 | 4 | 5 | 6 | @type record_transformer 7 | enable_ruby 8 | 9 | docker.container_id ${record["container_id"]} 10 | docker.image_name ${tag} 11 | 12 | 13 | 14 | 15 | @type elasticsearch 16 | host cloud.humio.com 17 | port 9200 18 | scheme https 19 | ssl_version TLSv1_2 20 | user 21 | password 22 | logstash_format true 23 | 24 | 25 | -------------------------------------------------------------------------------- /fluentd/Docker-Compose/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | IMAGE_NAME="robotshop/fluentd:elastic" 4 | 5 | docker run \ 6 | -d \ 7 | --rm \ 8 | --name fluentd \ 9 | -p 24224:24224 \ 10 | -v $(pwd)/fluent.conf:/fluentd/etc/fluent.conf \ 11 | $IMAGE_NAME 12 | 13 | -------------------------------------------------------------------------------- /fluentd/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM fluentd 2 | USER root 3 | RUN apk update && \ 4 | apk add --virtual .build-dependencies build-base ruby-dev 5 | 6 | RUN fluent-gem install fluent-plugin-elasticsearch && \ 7 | fluent-gem install fluent-plugin-kubernetes_metadata_filter && \ 8 | fluent-gem install fluent-plugin-multi-format-parser 9 | 10 | -------------------------------------------------------------------------------- /fluentd/Kubernetes/README.md: -------------------------------------------------------------------------------- 1 | # Kubernetes 2 | 3 | Edit the `fluentd.yaml` file inserting your Humio or Elasticsearch instance details. 4 | 5 | Apply the configuration: 6 | 7 | ```shell 8 | $ kubectl apply -f fluentd.yaml 9 | ``` 10 | 11 | Set up [logging integration](https://www.instana.com/docs/logging/) in Instana. -------------------------------------------------------------------------------- /fluentd/README.md: -------------------------------------------------------------------------------- 1 | # Logging with Fluentd 2 | 3 | This example works with [Humio](https://humio.com/) and [ELK](https://elastic.co/). Fluentd is used to ship the logs from the containers to the logging backend. 4 | 5 | ## Build Fluentd Container 6 | 7 | The default `fluentd` Docker image does not include the output plugin for Elasticsearch. Therefore a new Docker image based on the default image with the Elasticsearch output plugin installed should be created, see the `Dockerfile` and `build.sh` script for examples. This example has already been built and pushed to Docker Hub. 8 | 9 | Deployment is slightly different depending on which platform Robot Shop is run on. See the appropriate subdirectories for the required files and further instructions. 10 | 11 | -------------------------------------------------------------------------------- /fluentd/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | IMAGE_NAME="robotshop/fluentd:elastic" 4 | 5 | 6 | docker build -t "$IMAGE_NAME" . 7 | 8 | if [ "$1" = "push" ] 9 | then 10 | docker push "$IMAGE_NAME" 11 | fi 12 | 13 | -------------------------------------------------------------------------------- /load-gen/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.9 2 | 3 | # Some default values 4 | ENV HOST="http://localhost:8080/" \ 5 | SILENT=0 \ 6 | NUM_CLIENTS=1 \ 7 | ERROR=0 \ 8 | RUN_TIME=0 9 | 10 | 11 | WORKDIR /load 12 | 13 | COPY requirements.txt /load/ 14 | 15 | RUN pip install -r requirements.txt 16 | 17 | COPY entrypoint.sh /load/ 18 | COPY robot-shop.py /load/ 19 | 20 | CMD ["./entrypoint.sh"] 21 | 22 | -------------------------------------------------------------------------------- /load-gen/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # get the tag info 4 | eval $(egrep '[A-Z]+=' ../.env) 5 | 6 | echo "Repo $REPO" 7 | echo "Tag $TAG" 8 | 9 | docker build -t ${REPO}/rs-load:${TAG} . && docker tag ${REPO}/rs-load:${TAG} ${REPO}/rs-load 10 | 11 | if [ "$1" = "push" ] 12 | then 13 | echo "pushing..." 14 | docker push ${REPO}/rs-load:${TAG} 15 | docker push ${REPO}/rs-load 16 | fi 17 | -------------------------------------------------------------------------------- /load-gen/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # set -x 4 | 5 | if [ -z "$HOST" ] 6 | then 7 | echo "HOST env not set" 8 | exit 1 9 | fi 10 | 11 | if echo "$NUM_CLIENTS" | egrep -q '^[0-9]+$' 12 | then 13 | if [ $NUM_CLIENTS -eq 0 ] 14 | then 15 | NUM_CLIENTS=1 16 | fi 17 | echo "Starting load with $NUM_CLIENTS clients" 18 | else 19 | echo "NUM_CLIENTS $NUM_CLIENTS is not a number" 20 | exit 1 21 | fi 22 | 23 | 24 | if [ "$RUN_TIME" != "0" ] 25 | then 26 | if echo "$RUN_TIME" | egrep -q '^([0-9]+h)?([0-9]+m)?$' 27 | then 28 | TIME="-t $RUN_TIME" 29 | else 30 | echo "Wrong time format, use 2h42m" 31 | exit 1 32 | fi 33 | else 34 | unset RUN_TIME 35 | unset TIME 36 | fi 37 | 38 | echo "Starting $CLIENTS clients for ${RUN_TIME:-ever}" 39 | if [ "$SILENT" -eq 1 ] 40 | then 41 | locust -f robot-shop.py --host "$HOST" --headless -r 1 -u $NUM_CLIENTS $TIME > /dev/null 2>&1 42 | else 43 | locust -f robot-shop.py --host "$HOST" --headless -r 1 -u $NUM_CLIENTS $TIME 44 | fi 45 | 46 | -------------------------------------------------------------------------------- /load-gen/requirements.txt: -------------------------------------------------------------------------------- 1 | locust 2 | -------------------------------------------------------------------------------- /mongo/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mongo:5 2 | 3 | COPY *.js /docker-entrypoint-initdb.d/ 4 | 5 | -------------------------------------------------------------------------------- /mongo/catalogue.js: -------------------------------------------------------------------------------- 1 | // 2 | // Products 3 | // 4 | db = db.getSiblingDB('catalogue'); 5 | db.products.insertMany([ 6 | {sku: 'Watson', name: 'Watson', description: 'Probably the smartest AI on the planet', price: 2001, instock: 2, categories: ['Artificial Intelligence']}, 7 | {sku: 'Ewooid', name: 'Ewooid', description: 'Fully sentient assistant', price: 200, instock: 0, categories: ['Artificial Intelligence']}, 8 | {sku: 'HPTD', name: 'High-Powered Travel Droid', description: 'Traveling to the far reaches of the Galaxy? You need this for protection. Comes in handy when you are lost in space', price: 1200, instock: 12, categories: ['Robot']}, 9 | {sku: 'UHJ', name: 'Ultimate Harvesting Juggernaut', description: 'Extraterrestrial vegetation harvester', price: 5000, instock: 10, categories: ['Robot']}, 10 | {sku: 'EPE', name: 'Extreme Probe Emulator', description: 'Versatile interface adapter for hacking into systems', price: 953, instock: 1, categories: ['Robot']}, 11 | {sku: 'EMM', name: 'Exceptional Medical Machine', description: 'Fully automatic surgery droid with exceptional bedside manner', price: 1024, instock: 1, categories: ['Robot']}, 12 | {sku: 'SHCE', name: 'Strategic Human Control Emulator', description: 'Diplomatic protocol assistant', price: 300, instock: 12, categories: ['Robot']}, 13 | {sku: 'RED', name: 'Responsive Enforcer Droid', description: 'Security detail, will gaurd anything', price: 700, instock: 5, categories: ['Robot']}, 14 | {sku: 'RMC', name: 'Robotic Mining Cyborg', description: 'Excellent tunneling capability to get those rare minerals', price: 42, instock: 48, categories: ['Robot']}, 15 | {sku: 'STAN-1', name: 'Stan', description: 'Observability guru', price: 67, instock: 1000, categories: ['Robot', 'Artificial Intelligence']}, 16 | {sku: 'CNA', name: 'Cybernated Neutralization Android', description: 'Is your spaceship a bit whiffy? This little fellow will bring a breath of fresh air', price: 1000, instock: 0, categories: ['Robot']} 17 | ]); 18 | 19 | // full text index for searching 20 | db.products.createIndex({ 21 | name: "text", 22 | description: "text" 23 | }); 24 | 25 | // unique index for product sku 26 | db.products.createIndex( 27 | { sku: 1 }, 28 | { unique: true } 29 | ); 30 | 31 | -------------------------------------------------------------------------------- /mongo/users.js: -------------------------------------------------------------------------------- 1 | // 2 | // Products 3 | // 4 | db = db.getSiblingDB('users'); 5 | db.users.insertMany([ 6 | {name: 'user', password: 'password', email: 'user@me.com'}, 7 | {name: 'stan', password: 'bigbrain', email: 'stan@instana.com'}, 8 | {name: 'partner-57', password: 'worktogether', email: 'howdy@partner.com'} 9 | ]); 10 | 11 | // unique index on the name 12 | db.users.createIndex( 13 | {name: 1}, 14 | {unique: true} 15 | ); 16 | 17 | -------------------------------------------------------------------------------- /mysql/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mysql:5.7 2 | 3 | VOLUME /data 4 | 5 | ENV MYSQL_ALLOW_EMPTY_PASSWORD=yes \ 6 | MYSQL_DATABASE=cities \ 7 | MYSQL_USER=shipping \ 8 | MYSQL_PASSWORD=secret 9 | 10 | # change datadir entry in /etc/mysql/my.cnf 11 | COPY config.sh /root/ 12 | RUN /root/config.sh 13 | 14 | COPY scripts/* /docker-entrypoint-initdb.d/ 15 | 16 | #RUN /entrypoint.sh mysqld & while [ ! -f /tmp/finished ]; do sleep 10; done 17 | #RUN rm /docker-entrypoint-initdb.d/* 18 | 19 | -------------------------------------------------------------------------------- /mysql/config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DIR="/etc/mysql" 4 | 5 | FILE=$(fgrep -Rl datadir "$DIR") 6 | if [ -n "$FILE" ] 7 | then 8 | # mkdir /data/mysql 9 | echo " " 10 | echo "Updating $FILE" 11 | echo " " 12 | sed -i -e '/^datadir/s/\/var\/lib\//\/data\//' $FILE 13 | fgrep -R datadir "$DIR" 14 | else 15 | echo " " 16 | echo "file not found" 17 | echo " " 18 | fi 19 | 20 | -------------------------------------------------------------------------------- /mysql/convert.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Convert cities CSV file to SQL 4 | 5 | if [ -z "$1" ] 6 | then 7 | echo "File required as first arg" 8 | exit 1 9 | fi 10 | 11 | # \x27 is a single quote 12 | # \x60 is back tick 13 | awk ' 14 | BEGIN { 15 | FS="," 16 | format = "INSERT INTO cities(country_code, city, name, region, latitude, longitude) VALUES(\x27%s\x27, \x27%s\x27, \x27%s\x27, \x27%s\x27, %s, %s);\n" 17 | getline 18 | } 19 | { 20 | gsub(/\x27/, "\x60", $2) 21 | gsub(/\x27/, "\x60", $3) 22 | gsub(/\x27/, "\x60", $4) 23 | if(NF == 6) printf format, $1, $2, $3, $4, $5, $6 24 | else printf format, $1, $2, $3, $4, $6, $7 25 | } 26 | ' $1 27 | 28 | -------------------------------------------------------------------------------- /mysql/scripts/10-dump.sql.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/mysql/scripts/10-dump.sql.gz -------------------------------------------------------------------------------- /mysql/scripts/20-ratings.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE ratings 2 | DEFAULT CHARACTER SET 'utf8'; 3 | 4 | USE ratings; 5 | 6 | CREATE TABLE ratings ( 7 | sku varchar(80) NOT NULL, 8 | avg_rating DECIMAL(3, 2) NOT NULL, 9 | rating_count INT NOT NULL, 10 | PRIMARY KEY (sku) 11 | ) ENGINE=InnoDB; 12 | 13 | 14 | GRANT ALL ON ratings.* TO 'ratings'@'%' 15 | IDENTIFIED BY 'iloveit'; 16 | 17 | -------------------------------------------------------------------------------- /mysql/scripts/99-finished.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # signal that the import has finsihed 4 | touch /tmp/finished 5 | 6 | -------------------------------------------------------------------------------- /payment/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.9 2 | 3 | EXPOSE 8080 4 | USER root 5 | 6 | ENV INSTANA_SERVICE_NAME=payment 7 | 8 | WORKDIR /app 9 | 10 | COPY requirements.txt /app/ 11 | 12 | RUN pip install -r requirements.txt 13 | 14 | COPY *.py /app/ 15 | COPY payment.ini /app/ 16 | 17 | #CMD ["python", "payment.py"] 18 | CMD ["uwsgi", "--ini", "payment.ini"] 19 | 20 | -------------------------------------------------------------------------------- /payment/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | rabbitmq: 4 | image: rabbitmq:3.7-management-alpine 5 | ports: 6 | - "5672" 7 | - "15672:15672" 8 | payment: 9 | build: 10 | context: . 11 | image: robotshop/rs-payment 12 | depends_on: 13 | - rabbitmq 14 | ports: 15 | - "8080:8080" 16 | -------------------------------------------------------------------------------- /payment/payment.ini: -------------------------------------------------------------------------------- 1 | [uwsgi] 2 | wsgi-file = payment.py 3 | callable = app 4 | 5 | master = true 6 | processes = 1 7 | lazy-apps = true 8 | enable-threads = true 9 | 10 | socket = 0.0.0.0:8080 11 | protocol = http 12 | 13 | uid = 1 14 | gid = 1 15 | 16 | 17 | -------------------------------------------------------------------------------- /payment/rabbitmq.py: -------------------------------------------------------------------------------- 1 | import json 2 | import pika 3 | import os 4 | 5 | class Publisher: 6 | HOST = os.getenv('AMQP_HOST', 'rabbitmq') 7 | VIRTUAL_HOST = '/' 8 | EXCHANGE='robot-shop' 9 | TYPE='direct' 10 | ROUTING_KEY = 'orders' 11 | 12 | def __init__(self, logger): 13 | self._logger = logger 14 | self._params = pika.connection.ConnectionParameters( 15 | host=self.HOST, 16 | virtual_host=self.VIRTUAL_HOST, 17 | credentials=pika.credentials.PlainCredentials('guest', 'guest')) 18 | self._conn = None 19 | self._channel = None 20 | 21 | def _connect(self): 22 | if not self._conn or self._conn.is_closed or self._channel is None or self._channel.is_closed: 23 | self._conn = pika.BlockingConnection(self._params) 24 | self._channel = self._conn.channel() 25 | self._channel.exchange_declare(exchange=self.EXCHANGE, exchange_type=self.TYPE, durable=True) 26 | self._logger.info('connected to broker') 27 | 28 | def _publish(self, msg, headers): 29 | self._channel.basic_publish(exchange=self.EXCHANGE, 30 | routing_key=self.ROUTING_KEY, 31 | properties=pika.BasicProperties(headers=headers), 32 | body=json.dumps(msg).encode()) 33 | self._logger.info('message sent') 34 | 35 | #Publish msg, reconnecting if necessary. 36 | def publish(self, msg, headers): 37 | if self._channel is None or self._channel.is_closed or self._conn is None or self._conn.is_closed: 38 | self._connect() 39 | try: 40 | self._publish(msg, headers) 41 | except (pika.exceptions.ConnectionClosed, pika.exceptions.StreamLostError): 42 | self._logger.info('reconnecting to queue') 43 | self._connect() 44 | self._publish(msg, headers) 45 | 46 | def close(self): 47 | if self._conn and self._conn.is_open: 48 | self._logger.info('closing queue connection') 49 | self._conn.close() 50 | 51 | -------------------------------------------------------------------------------- /payment/requirements.txt: -------------------------------------------------------------------------------- 1 | uwsgi 2 | Flask 3 | requests 4 | pika 5 | prometheus_client 6 | opentracing 7 | instana 8 | -------------------------------------------------------------------------------- /pullbaseimages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for DFILE in $(find . -name Dockerfile -print) 4 | do 5 | # multiple images 6 | for IMAGE in $(awk '/^FROM/ { print $2 }' $DFILE) 7 | do 8 | echo "Pulling $IMAGE" 9 | docker pull $IMAGE 10 | done 11 | done 12 | -------------------------------------------------------------------------------- /ratings/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # Build the app 3 | # 4 | FROM php:7.4-apache 5 | 6 | RUN apt-get update && apt-get install -yqq unzip libzip-dev \ 7 | && docker-php-ext-install pdo_mysql opcache zip 8 | 9 | # Enable AutoProfile for PHP which is currently opt-in beta 10 | RUN echo "instana.enable_auto_profile=1" > "/usr/local/etc/php/conf.d/zzz-instana-extras.ini" 11 | 12 | # relax permissions on status 13 | COPY status.conf /etc/apache2/mods-available/status.conf 14 | # Enable Apache mod_rewrite and status 15 | RUN a2enmod rewrite && a2enmod status 16 | 17 | WORKDIR /var/www/html 18 | 19 | COPY html/ /var/www/html 20 | 21 | COPY --from=composer /usr/bin/composer /usr/bin/composer 22 | RUN composer install 23 | 24 | # This is important. Symfony needs write permissions and we 25 | # dont know the context in which the container will run, i.e. 26 | # which user will be forced from the outside so better play 27 | # safe for this simple demo. 28 | RUN rm -Rf /var/www/var/* 29 | RUN chown -R www-data /var/www 30 | RUN chmod -R 777 /var/www 31 | 32 | -------------------------------------------------------------------------------- /ratings/html/.htaccess: -------------------------------------------------------------------------------- 1 | DirectoryIndex index.php 2 | 3 | 4 | RewriteEngine On 5 | RewriteCond %{ENV:REDIRECT_STATUS} ="" 6 | RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L] 7 | RewriteCond %{REQUEST_URI} !=/server-status 8 | RewriteCond %{REQUEST_FILENAME} !-f 9 | RewriteRule ^ %{ENV:BASE}/index.php [L] 10 | 11 | -------------------------------------------------------------------------------- /ratings/html/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "php": "^7.4", 4 | "ext-curl": "*", 5 | "ext-json": "*", 6 | "ext-pdo": "*", 7 | "psr/log": "*", 8 | "monolog/monolog": "^1.24.0", 9 | "symfony/config": "^5.2", 10 | "symfony/http-kernel": "^5.2", 11 | "symfony/http-foundation": "^5.2", 12 | "symfony/routing": "^5.2", 13 | "symfony/dependency-injection": "^5.2", 14 | "symfony/framework-bundle": "^5.2", 15 | "doctrine/annotations": "^1.10", 16 | "symfony/monolog-bundle": "^3.5", 17 | "instana/instana-php-sdk": "^1.10" 18 | }, 19 | "autoload": { 20 | "psr-4": { 21 | "Instana\\RobotShop\\Ratings\\": "src/" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ratings/html/index.php: -------------------------------------------------------------------------------- 1 | handle($request); 14 | $response->send(); 15 | $kernel->terminate($request, $response); 16 | -------------------------------------------------------------------------------- /ratings/html/info.php: -------------------------------------------------------------------------------- 1 | healthCheckService = $healthCheckService; 30 | } 31 | 32 | public function __invoke(Request $request) 33 | { 34 | $checks = []; 35 | try { 36 | $this->healthCheckService->checkConnectivity(); 37 | $checks['pdo_connectivity'] = true; 38 | } catch (\PDOException $e) { 39 | $checks['pdo_connectivity'] = false; 40 | } 41 | 42 | $this->logger->info('Health-Check', $checks); 43 | 44 | return new JsonResponse($checks, $checks['pdo_connectivity'] ? Response::HTTP_OK : Response::HTTP_BAD_REQUEST); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ratings/html/src/Database.php: -------------------------------------------------------------------------------- 1 | dsn = $dsn; 34 | $this->user = $user; 35 | $this->password = $password; 36 | } 37 | 38 | public function getConnection(): PDO 39 | { 40 | $opt = [ 41 | PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, 42 | PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, 43 | PDO::ATTR_EMULATE_PREPARES => false, 44 | ]; 45 | 46 | try { 47 | return new PDO($this->dsn, $this->user, $this->password, $opt); 48 | } catch (PDOException $e) { 49 | $msg = $e->getMessage(); 50 | $this->logger->error("Database error $msg"); 51 | 52 | return null; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /ratings/html/src/EventListener/InstanaDataCenterListener.php: -------------------------------------------------------------------------------- 1 | logger = $logger; 27 | } 28 | 29 | public function __invoke() 30 | { 31 | try { 32 | $entry = Tracer::getEntrySpan(); 33 | 34 | $dataCenter = self::$dataCenters[array_rand(self::$dataCenters)]; 35 | $entry->annotate('datacenter', $dataCenter); 36 | 37 | $this->logger->info(sprintf('Annotated DataCenter %s', $dataCenter)); 38 | } catch (InstanaRuntimeException $exception) { 39 | $this->logger->error('Unable to annotate entry span: %s', $exception->getMessage()); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ratings/html/src/Integration/InstanaHeadersLoggingProcessor.php: -------------------------------------------------------------------------------- 1 | ['addHeaderData', 1], 21 | KernelEvents::FINISH_REQUEST => ['removeHeaderData', 1], 22 | ]; 23 | } 24 | 25 | public function __invoke(array $records): array 26 | { 27 | if ($this->routeData && !isset($records['extra']['requests'])) { 28 | $records['extra']['instana'] = array_values($this->routeData); 29 | } 30 | 31 | return $records; 32 | } 33 | 34 | public function addHeaderData(RequestEvent $event): void 35 | { 36 | if ($event->isMasterRequest()) { 37 | $this->reset(); 38 | } 39 | 40 | $request = $event->getRequest(); 41 | if (null === $request->headers->get('X-INSTANA-L')) { 42 | return; 43 | } 44 | 45 | $currentTraceHeaders = [ 46 | 'l' => $request->headers->get('X-INSTANA-L', 'n/a'), 47 | 's' => $request->headers->get('X-INSTANA-S', 'n/a'), 48 | 't' => $request->headers->get('X-INSTANA-T', 'n/a'), 49 | ]; 50 | 51 | if (null !== $request->headers->get('X-INSTANA-SYNTHETIC')) { 52 | $currentTraceHeaders['sy'] = $request->headers->get('X-INSTANA-SYNTHETIC'); 53 | } 54 | 55 | $this->routeData[spl_object_id($request)] = $currentTraceHeaders; 56 | } 57 | 58 | public function reset(): void 59 | { 60 | $this->routeData = []; 61 | } 62 | 63 | public function removeHeaderData(FinishRequestEvent $event): void 64 | { 65 | $requestId = spl_object_id($event->getRequest()); 66 | unset($this->routeData[$requestId]); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ratings/html/src/Service/CatalogueService.php: -------------------------------------------------------------------------------- 1 | catalogueUrl = $catalogueUrl; 23 | } 24 | 25 | public function checkSKU(string $sku): bool 26 | { 27 | $url = sprintf('%s/product/%s', $this->catalogueUrl, $sku); 28 | 29 | $opt = [ 30 | CURLOPT_RETURNTRANSFER => true, 31 | ]; 32 | $curl = curl_init($url); 33 | curl_setopt_array($curl, $opt); 34 | 35 | $data = curl_exec($curl); 36 | if (!$data) { 37 | $this->logger->error('failed to connect to catalogue'); 38 | throw new Exception('Failed to connect to catalogue'); 39 | } 40 | 41 | $status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE); 42 | $this->logger->info("catalogue status $status"); 43 | 44 | curl_close($curl); 45 | 46 | return 200 === $status; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ratings/html/src/Service/HealthCheckService.php: -------------------------------------------------------------------------------- 1 | pdo = $pdo; 23 | } 24 | 25 | public function checkConnectivity(): bool 26 | { 27 | return $this->pdo->prepare('SELECT 1 + 1 FROM DUAL;')->execute(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ratings/html/src/Service/RatingsService.php: -------------------------------------------------------------------------------- 1 | connection = $connection; 27 | } 28 | 29 | public function ratingBySku(string $sku): array 30 | { 31 | $stmt = $this->connection->prepare(self::QUERY_RATINGS_BY_SKU); 32 | if (false === $stmt->execute([$sku])) { 33 | $this->logger->error('failed to query data'); 34 | 35 | throw new \Exception('Failed to query data', 500); 36 | } 37 | 38 | $data = $stmt->fetch(); 39 | if ($data) { 40 | // for some reason avg_rating is return as a string 41 | $data['avg_rating'] = (float) $data['avg_rating']; 42 | 43 | return $data; 44 | } 45 | 46 | // nicer to return an empty record than throw 404 47 | return ['avg_rating' => 0, 'rating_count' => 0]; 48 | } 49 | 50 | public function updateRatingForSKU(string $sku, $score, int $count): void 51 | { 52 | $stmt = $this->connection->prepare(self::QUERY_UPDATE_RATINGS_BY_SKU); 53 | if (!$stmt->execute([$score, $count, $sku])) { 54 | $this->logger->error('failed to update rating'); 55 | throw new \Exception('Failed to update data', 500); 56 | } 57 | } 58 | 59 | public function addRatingForSKU($sku, $rating): void 60 | { 61 | $stmt = $this->connection->prepare(self::QUERY_INSERT_RATING); 62 | if (!$stmt->execute([$sku, $rating, 1])) { 63 | $this->logger->error('failed to insert data'); 64 | throw new \Exception('Failed to insert data', 500); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /ratings/html/var/cache/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/ratings/html/var/cache/.gitkeep -------------------------------------------------------------------------------- /ratings/html/var/log/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/ratings/html/var/log/.gitkeep -------------------------------------------------------------------------------- /ratings/status.conf: -------------------------------------------------------------------------------- 1 | 2 | # Allow server status reports generated by mod_status, 3 | # with the URL of http://servername/server-status 4 | # Uncomment and change the "192.0.2.0/24" to allow access from other hosts. 5 | 6 | 7 | SetHandler server-status 8 | #Require local 9 | #Require ip 192.0.2.0/24 10 | 11 | 12 | # Keep track of extended status information for each request 13 | ExtendedStatus On 14 | 15 | # Determine if mod_status displays the first 63 characters of a request or 16 | # the last 63, assuming the request itself is greater than 63 chars. 17 | # Default: Off 18 | #SeeRequestTail On 19 | 20 | 21 | 22 | # Show Proxy LoadBalancer status in mod_status 23 | ProxyStatus On 24 | 25 | 26 | 27 | 28 | 29 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet 30 | -------------------------------------------------------------------------------- /shipping/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /.classpath 3 | /.project 4 | /.settings 5 | -------------------------------------------------------------------------------- /shipping/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # Build 3 | # 4 | FROM debian:10 AS build 5 | 6 | RUN apt-get update && apt-get -y install maven 7 | 8 | WORKDIR /opt/shipping 9 | 10 | COPY pom.xml /opt/shipping/ 11 | RUN mvn dependency:resolve 12 | COPY src /opt/shipping/src/ 13 | RUN mvn package 14 | 15 | # 16 | # Run 17 | # 18 | FROM openjdk:8-jdk 19 | 20 | EXPOSE 8080 21 | 22 | WORKDIR /opt/shipping 23 | 24 | ENV CART_ENDPOINT=cart:8080 25 | ENV DB_HOST=mysql 26 | 27 | COPY --from=build /opt/shipping/target/shipping-1.0.jar shipping.jar 28 | 29 | CMD [ "java", "-Xmn256m", "-Xmx768m", "-jar", "shipping.jar" ] 30 | 31 | -------------------------------------------------------------------------------- /shipping/src/main/java/com/instana/robotshop/shipping/Calculator.java: -------------------------------------------------------------------------------- 1 | package com.instana.robotshop.shipping; 2 | 3 | 4 | public class Calculator { 5 | private double latitude = 0; 6 | private double longitude = 0; 7 | 8 | Calculator(double latitdue, double longitude) { 9 | this.latitude = latitude; 10 | this.longitude = longitude; 11 | } 12 | 13 | Calculator(City city) { 14 | this.latitude = city.getLatitude(); 15 | this.longitude = city.getLongitude(); 16 | } 17 | 18 | /** 19 | * Calculate the distance between this location and the target location. 20 | * Use decimal lat/long degrees 21 | * Formula is Haversine https://www.movable-type.co.uk/scripts/latlong.html 22 | **/ 23 | public long getDistance(double targetLatitude, double targetLongitude) { 24 | double distance = 0.0; 25 | double earthRadius = 6371e3; // meters 26 | 27 | // convert to radians 28 | double latitudeR = Math.toRadians(this.latitude); 29 | double targetLatitudeR = Math.toRadians(targetLatitude); 30 | // difference in Radians 31 | double diffLatR = Math.toRadians(targetLatitude - this.latitude); 32 | double diffLongR = Math.toRadians(targetLongitude - this.longitude); 33 | 34 | double a = Math.sin(diffLatR / 2.0) * Math.sin(diffLatR / 2.0) 35 | + Math.cos(latitudeR) * Math.cos(targetLatitudeR) 36 | * Math.sin(diffLongR / 2.0) * Math.sin(diffLongR); 37 | 38 | double c = 2.0 * Math.atan2(Math.sqrt(a), Math.sqrt(1.0 - a)); 39 | 40 | return (long)Math.rint(earthRadius * c / 1000.0); 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /shipping/src/main/java/com/instana/robotshop/shipping/City.java: -------------------------------------------------------------------------------- 1 | package com.instana.robotshop.shipping; 2 | 3 | import javax.persistence.Table; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.Column; 9 | 10 | /* 11 | * Bean for City 12 | */ 13 | @Entity 14 | @Table(name = "cities") 15 | public class City { 16 | 17 | @Id 18 | @GeneratedValue(strategy = GenerationType.AUTO) 19 | private long uuid; 20 | 21 | @Column(name = "country_code") 22 | private String code; 23 | private String city; 24 | private String name; 25 | private String region; 26 | private double latitude; 27 | private double longitude; 28 | 29 | public long getUuid() { 30 | return this.uuid; 31 | } 32 | 33 | public String getCode() { 34 | return this.code; 35 | } 36 | 37 | public void setCode(String code) { 38 | this.code = code; 39 | } 40 | 41 | public String getCity() { 42 | return this.city; 43 | } 44 | 45 | public void setCity(String city) { 46 | this.city = city; 47 | } 48 | 49 | public String getName() { 50 | return this.name; 51 | } 52 | 53 | public void setName(String name) { 54 | this.name = name; 55 | } 56 | 57 | public String getRegion() { 58 | return this.region; 59 | } 60 | 61 | public void setRegion(String code) { 62 | this.region = region; 63 | } 64 | 65 | public double getLatitude() { 66 | return this.latitude; 67 | } 68 | 69 | public void setLatitude(double latitude) { 70 | this.latitude = latitude; 71 | } 72 | 73 | public double getLongitude() { 74 | return this.longitude; 75 | } 76 | 77 | public void setLongitude(double longitude) { 78 | this.longitude = longitude; 79 | } 80 | 81 | @Override 82 | public String toString() { 83 | return String.format("Country: %s City: %s Region: %s Coords: %f %f", this.code, this.city, this.region, this.latitude, this.longitude); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /shipping/src/main/java/com/instana/robotshop/shipping/CityRepository.java: -------------------------------------------------------------------------------- 1 | package com.instana.robotshop.shipping; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.repository.CrudRepository; 6 | import org.springframework.data.jpa.repository.Query; 7 | 8 | public interface CityRepository extends CrudRepository { 9 | List findByCode(String code); 10 | 11 | @Query( 12 | value = "select c from City c where c.code = ?1 and c.city like ?2%" 13 | ) 14 | List match(String code, String text); 15 | 16 | City findById(long id); 17 | } 18 | -------------------------------------------------------------------------------- /shipping/src/main/java/com/instana/robotshop/shipping/Code.java: -------------------------------------------------------------------------------- 1 | package com.instana.robotshop.shipping; 2 | 3 | import javax.persistence.Table; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | 9 | /* 10 | * Bean for Code 11 | */ 12 | @Entity 13 | @Table(name = "codes") 14 | public class Code { 15 | 16 | @Id 17 | @GeneratedValue(strategy = GenerationType.AUTO) 18 | private long uuid; 19 | 20 | private String code; 21 | private String name; 22 | 23 | public long getUuid() { 24 | return this.uuid; 25 | } 26 | 27 | public String getCode() { 28 | return this.code; 29 | } 30 | 31 | public void setCode(String code) { 32 | this.code = code; 33 | } 34 | 35 | public String getName() { 36 | return this.name; 37 | } 38 | 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return String.format("Code: %s Name: %s", this.code, this.name); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /shipping/src/main/java/com/instana/robotshop/shipping/CodeRepository.java: -------------------------------------------------------------------------------- 1 | package com.instana.robotshop.shipping; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.repository.PagingAndSortingRepository; 6 | 7 | public interface CodeRepository extends PagingAndSortingRepository { 8 | 9 | Iterable findAll(); 10 | 11 | Code findById(long id); 12 | } 13 | -------------------------------------------------------------------------------- /shipping/src/main/java/com/instana/robotshop/shipping/JpaConfig.java: -------------------------------------------------------------------------------- 1 | package com.instana.robotshop.shipping; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import javax.sql.DataSource; 6 | import org.springframework.boot.jdbc.DataSourceBuilder; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.context.annotation.Bean; 9 | 10 | @Configuration 11 | public class JpaConfig { 12 | private static final Logger logger = LoggerFactory.getLogger(JpaConfig.class); 13 | 14 | @Bean 15 | public DataSource getDataSource() { 16 | String JDBC_URL = String.format("jdbc:mysql://%s/cities?useSSL=false&autoReconnect=true", System.getenv("DB_HOST") == null ? "mysql" : System.getenv("DB_HOST")); 17 | 18 | logger.info("jdbc url {}", JDBC_URL); 19 | 20 | DataSourceBuilder bob = DataSourceBuilder.create(); 21 | 22 | bob.driverClassName("com.mysql.jdbc.Driver"); 23 | bob.url(JDBC_URL); 24 | bob.username("shipping"); 25 | bob.password("secret"); 26 | 27 | return bob.build(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /shipping/src/main/java/com/instana/robotshop/shipping/RetryableDataSource.java: -------------------------------------------------------------------------------- 1 | package com.instana.robotshop.shipping; 2 | 3 | import java.sql.Connection; 4 | import java.sql.SQLException; 5 | import javax.sql.DataSource; 6 | 7 | import org.springframework.jdbc.datasource.AbstractDataSource; 8 | import org.springframework.retry.annotation.Retryable; 9 | import org.springframework.retry.annotation.Backoff; 10 | 11 | class RetryableDataSource extends AbstractDataSource { 12 | private DataSource delegate; 13 | 14 | public RetryableDataSource(DataSource delegate) { 15 | this.delegate = delegate; 16 | } 17 | 18 | @Override 19 | @Retryable(maxAttempts = 10, backoff = @Backoff(multiplier = 2.3, maxDelay = 30000)) 20 | public Connection getConnection() throws SQLException { 21 | return delegate.getConnection(); 22 | } 23 | 24 | @Override 25 | @Retryable(maxAttempts = 10, backoff = @Backoff(multiplier = 2.3, maxDelay = 30000)) 26 | public Connection getConnection(String username, String password) throws SQLException { 27 | return delegate.getConnection(username, password); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /shipping/src/main/java/com/instana/robotshop/shipping/Ship.java: -------------------------------------------------------------------------------- 1 | package com.instana.robotshop.shipping; 2 | 3 | /** 4 | * Bean to hold shipping information 5 | **/ 6 | public class Ship { 7 | private long distance; 8 | private double cost; 9 | 10 | public Ship() { 11 | this.distance = 0; 12 | this.cost = 0.0; 13 | } 14 | 15 | public Ship(long distance, double cost) { 16 | this.distance = distance; 17 | this.cost = cost; 18 | } 19 | 20 | public void setDistance(long distance) { 21 | this.distance = distance; 22 | } 23 | 24 | public void setCost(double cost) { 25 | this.cost = cost; 26 | } 27 | 28 | public long getDistance() { 29 | return this.distance; 30 | } 31 | 32 | public double getCost() { 33 | return this.cost; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return String.format("Distance: %d Cost: %f", distance, cost); 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /shipping/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.jmx.enabled=true 2 | 3 | management.endpoint.info.enabled=true 4 | management.endpoint.health.enabled=true 5 | management.endpoint.metrics.enabled=true 6 | management.endpoint.env.enabled=true 7 | -------------------------------------------------------------------------------- /user/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:14 2 | 3 | ENV INSTANA_AUTO_PROFILE true 4 | 5 | EXPOSE 8080 6 | 7 | WORKDIR /opt/server 8 | 9 | COPY package.json /opt/server/ 10 | 11 | RUN npm install 12 | 13 | COPY server.js /opt/server/ 14 | 15 | CMD ["node", "server.js"] 16 | 17 | -------------------------------------------------------------------------------- /user/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "user", 3 | "version": "1.0.0", 4 | "description": "user REST API", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "SteveW", 10 | "license": "Apache-2.0", 11 | "dependencies": { 12 | "body-parser": "^1.18.1", 13 | "express": "^4.15.4", 14 | "mongodb": "^3.5.3", 15 | "redis": "^2.8.0", 16 | "pino": "^5.10.8", 17 | "express-pino-logger": "^4.0.0", 18 | "pino-pretty": "^2.5.0", 19 | "@instana/collector": "^1.132.2" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /web/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:1.21.6 2 | 3 | EXPOSE 8080 4 | 5 | ENV CATALOGUE_HOST=catalogue \ 6 | USER_HOST=user \ 7 | CART_HOST=cart \ 8 | SHIPPING_HOST=shipping \ 9 | PAYMENT_HOST=payment \ 10 | RATINGS_HOST=ratings 11 | 12 | COPY entrypoint.sh /root/ 13 | ENTRYPOINT ["/root/entrypoint.sh"] 14 | 15 | COPY default.conf.template /etc/nginx/conf.d/default.conf.template 16 | COPY static /usr/share/nginx/html 17 | -------------------------------------------------------------------------------- /web/default.conf.template: -------------------------------------------------------------------------------- 1 | # Instana tracing 2 | opentracing_load_tracer /usr/local/lib/libinstana_sensor.so /etc/instana-config.json; 3 | opentracing_propagate_context; 4 | 5 | server { 6 | listen 8080; 7 | server_name localhost; 8 | 9 | proxy_http_version 1.1; 10 | 11 | #charset koi8-r; 12 | #access_log /var/log/nginx/host.access.log main; 13 | #error_log /dev/stdout debug; 14 | #rewrite_log on; 15 | 16 | location / { 17 | root /usr/share/nginx/html; 18 | index index.html index.htm; 19 | ssi on; 20 | } 21 | 22 | location /images/ { 23 | expires 5s; 24 | root /usr/share/nginx/html; 25 | try_files $uri /images/placeholder.png; 26 | } 27 | 28 | #error_page 404 /404.html; 29 | 30 | # redirect server error pages to the static page /50x.html 31 | # 32 | error_page 500 502 503 504 /50x.html; 33 | location = /50x.html { 34 | root /usr/share/nginx/html; 35 | } 36 | 37 | # proxy the PHP scripts to Apache listening on 127.0.0.1:80 38 | # 39 | #location ~ \.php$ { 40 | # proxy_pass http://127.0.0.1; 41 | #} 42 | 43 | # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 44 | # 45 | #location ~ \.php$ { 46 | # root html; 47 | # fastcgi_pass 127.0.0.1:9000; 48 | # fastcgi_index index.php; 49 | # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 50 | # include fastcgi_params; 51 | #} 52 | 53 | # deny access to .htaccess files, if Apache's document root 54 | # concurs with nginx's one 55 | # 56 | #location ~ /\.ht { 57 | # deny all; 58 | #} 59 | 60 | location /api/catalogue/ { 61 | proxy_pass http://${CATALOGUE_HOST}:8080/; 62 | } 63 | 64 | location /api/user/ { 65 | proxy_pass http://${USER_HOST}:8080/; 66 | } 67 | 68 | location /api/cart/ { 69 | proxy_pass http://${CART_HOST}:8080/; 70 | } 71 | 72 | location /api/shipping/ { 73 | proxy_pass http://${SHIPPING_HOST}:8080/; 74 | } 75 | 76 | location /api/payment/ { 77 | proxy_pass http://${PAYMENT_HOST}:8080/; 78 | } 79 | 80 | location /api/ratings/ { 81 | proxy_pass http://${RATINGS_HOST}:80/; 82 | } 83 | 84 | location /nginx_status { 85 | stub_status on; 86 | access_log off; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /web/static/cart.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | Shopping cart for {{ data.uniqueid }} 4 |
5 | Your cart is empty, get shopping 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 38 | 39 |
QTYNameSub Total
16 | 17 | {{ item.name }}€{{ item.subtotal.toFixed(2) }}
 
 Inc Tax€{{ data.cart.tax.toFixed(2) }}
 Total€{{ data.cart.total.toFixed(2) }}
36 | 37 |
40 |
41 |
42 | -------------------------------------------------------------------------------- /web/static/css/auto-complete.css: -------------------------------------------------------------------------------- 1 | .autocomplete-suggestions { 2 | text-align: left; cursor: default; border: 1px solid #ccc; border-top: 0; background: #fff; box-shadow: -1px 1px 3px rgba(0,0,0,.1); 3 | 4 | /* core styles should not be changed */ 5 | position: absolute; display: none; z-index: 9999; max-height: 254px; overflow: hidden; overflow-y: auto; box-sizing: border-box; 6 | } 7 | .autocomplete-suggestion { position: relative; padding: 0 .6em; line-height: 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.02em; color: #333; } 8 | .autocomplete-suggestion b { font-weight: normal; color: #1f8dd6; } 9 | .autocomplete-suggestion.selected { background: #f0f0f0; } 10 | 11 | -------------------------------------------------------------------------------- /web/static/empty.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /web/static/eum-tmpl.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /web/static/images/Aplha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/web/static/images/Aplha.png -------------------------------------------------------------------------------- /web/static/images/CNA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/web/static/images/CNA.png -------------------------------------------------------------------------------- /web/static/images/EMM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/web/static/images/EMM.png -------------------------------------------------------------------------------- /web/static/images/EPE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/web/static/images/EPE.png -------------------------------------------------------------------------------- /web/static/images/Ewooid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/web/static/images/Ewooid.png -------------------------------------------------------------------------------- /web/static/images/HPTD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/web/static/images/HPTD.png -------------------------------------------------------------------------------- /web/static/images/RED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/web/static/images/RED.png -------------------------------------------------------------------------------- /web/static/images/RMC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/web/static/images/RMC.png -------------------------------------------------------------------------------- /web/static/images/SHCE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/web/static/images/SHCE.png -------------------------------------------------------------------------------- /web/static/images/STAN-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/web/static/images/STAN-1.png -------------------------------------------------------------------------------- /web/static/images/UHJ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/web/static/images/UHJ.png -------------------------------------------------------------------------------- /web/static/images/Watson.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/web/static/images/Watson.png -------------------------------------------------------------------------------- /web/static/images/placeholder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/web/static/images/placeholder.png -------------------------------------------------------------------------------- /web/static/media/graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/web/static/media/graph.png -------------------------------------------------------------------------------- /web/static/media/instana_icon_square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/web/static/media/instana_icon_square.png -------------------------------------------------------------------------------- /web/static/media/stan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iam-veeramalla/three-tier-architecture-demo/83b27eb025cea1a9e1eb32c751d939a03eba2e64/web/static/media/stan.png -------------------------------------------------------------------------------- /web/static/payment.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

Review your order

4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 33 | 34 |
QTYNameSub Total
{{ item.qty }}{{ item.name }}€{{ item.subtotal.toFixed(2) }}
 
 Inc Tax€{{ data.cart.tax.toFixed(2) }}
 Total€{{ data.cart.total.toFixed(2) }}
31 | 32 |
35 |
36 |
37 | {{ data.message }} 38 |
39 |
40 | Thank you for your order 41 | Continue shopping 42 |
43 |
44 | -------------------------------------------------------------------------------- /web/static/product.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 | {{ data.message }} 5 |
6 | 7 |

{{ data.product.name }}

8 |
9 | 10 |
11 |
12 | Rating 13 | 14 | {{ data.rating.avg_rating.toFixed(1) }} from {{ data.rating.rating_count }} votes 15 | 16 | 17 | No votes yet. Vote now. 18 | 19 |
20 | 21 | {{ vote }} 22 | 23 |
24 |
25 |
26 | {{ data.product.description }} 27 |
28 |
29 | Price €{{ data.product.price.toFixed(2) }} 30 | 31 | Out of stock 32 | 33 | 34 | Quantity 35 | 36 | 37 |
38 |
39 | 40 | -------------------------------------------------------------------------------- /web/static/search.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 | Sorry nothing matches your search 5 |
6 |
7 |

These ecellent candidates match your search

8 | 9 | 10 | 11 | 12 | 13 | 14 |
{{ item.name }}{{ item.description }}€{{ item.price }}
15 |
16 |
17 | -------------------------------------------------------------------------------- /web/static/shipping.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

Shipping information

4 |
5 | Select country 6 |
7 |
8 | Enter location 9 |
10 |
11 | 12 |
13 | 14 |
15 |
Distance {{ data.shipping.distance }}km
16 |
Cost €{{ data.shipping.cost.toFixed(2) }}
17 |
18 | 19 |
20 |
21 |
22 | 23 | -------------------------------------------------------------------------------- /web/static/splash.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

Welcome to Stan's Robot Shop

4 |

5 | Here you will find all of Stan's friends. Have a browse around and see who is here. 6 |

7 |

8 | This is a simple example microservices ecommerce application. 9 | It has been built using various technologies: 10 |

    11 |
  • AngularJS (1.x)
  • 12 |
  • Nginx
  • 13 |
  • NodeJS
  • 14 |
  • Java
  • 15 |
  • Python
  • 16 |
  • Golang
  • 17 |
  • PHP (Apache)
  • 18 |
  • MongoDB
  • 19 |
  • Redis
  • 20 |
  • MySQL
  • 21 |
22 | When deployed into an environment monitored by Instana, these technology stacks will be automatically 23 | detected and monitored, all with minimum configuration. Every request will be traced end to end. 24 | Stan will keep an eye on all those metrics, events and traces and let you know what needs your attention. 25 |

26 |

27 | To find out more visit the Instana site. 28 |

29 |

30 | All the code is available on Github. 31 |

32 |
33 | --------------------------------------------------------------------------------