diff --git a/performance-tests/src/test/java/io/opentelemetry/containers/ImageServiceContainer.java b/performance-tests/src/test/java/io/opentelemetry/containers/ImageServiceContainer.java index 316955e68..48078ac37 100644 --- a/performance-tests/src/test/java/io/opentelemetry/containers/ImageServiceContainer.java +++ b/performance-tests/src/test/java/io/opentelemetry/containers/ImageServiceContainer.java @@ -16,6 +16,7 @@ import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.utility.DockerImageName; +// TODO: The vehicle sample app doesn't exist anymore so this needs to be cleaned up public class ImageServiceContainer { private static final Logger logger = LoggerFactory.getLogger(ImageServiceContainer.class); diff --git a/performance-tests/src/test/java/io/opentelemetry/containers/VehicleInventoryServiceContainer.java b/performance-tests/src/test/java/io/opentelemetry/containers/VehicleInventoryServiceContainer.java index b4b3fb23c..c5bc152f1 100644 --- a/performance-tests/src/test/java/io/opentelemetry/containers/VehicleInventoryServiceContainer.java +++ b/performance-tests/src/test/java/io/opentelemetry/containers/VehicleInventoryServiceContainer.java @@ -20,72 +20,72 @@ import org.testcontainers.utility.DockerImageName; import org.testcontainers.utility.MountableFile; +// TODO: The vehicle sample app doesn't exist anymore so this needs to be cleaned up public class VehicleInventoryServiceContainer { - private static final Logger logger = - LoggerFactory.getLogger(VehicleInventoryServiceContainer.class); - private static final int PORT = 8001; + private static final Logger logger = LoggerFactory.getLogger(VehicleInventoryServiceContainer.class); + private static final int PORT = 8001; - private final Network network; - private final Startable collector; - private final DistroConfig distroConfig; - private final NamingConventions namingConventions; + private final Network network; + private final Startable collector; + private final DistroConfig distroConfig; + private final NamingConventions namingConventions; - public VehicleInventoryServiceContainer( - Network network, - Startable collector, - DistroConfig distroConfig, - NamingConventions namingConventions) { - this.network = network; - this.collector = collector; - this.distroConfig = distroConfig; - this.namingConventions = namingConventions; - } + public VehicleInventoryServiceContainer( + Network network, + Startable collector, + DistroConfig distroConfig, + NamingConventions namingConventions) { + this.network = network; + this.collector = collector; + this.distroConfig = distroConfig; + this.namingConventions = namingConventions; + } - public GenericContainer build() { - GenericContainer container = - new GenericContainer<>(DockerImageName.parse("performance-test/vehicle-inventory-service")) - .withNetwork(network) - .withNetworkAliases("vehicle-service") - .withLogConsumer(new Slf4jLogConsumer(logger)) - .withExposedPorts(PORT) - .waitingFor(Wait.forHttp("/vehicle-inventory/health-check").forPort(PORT)) - .withFileSystemBind( - namingConventions.localResults(), namingConventions.containerResults()) - .withCopyFileToContainer( - MountableFile.forClasspathResource("runVehicleInventory.sh"), - "vehicle-inventory-app/run.sh") - .withCopyFileToContainer( - MountableFile.forClasspathResource("profiler.py"), - "vehicle-inventory-app/profiler.py") - .withCopyFileToContainer( - MountableFile.forClasspathResource("executeProfiler.sh"), - "vehicle-inventory-app/executeProfiler.sh") - .withEnv("DJANGO_SETTINGS_MODULE", "VehicleInventoryApp.settings") - .withEnv("PORT", Integer.toString(PORT)) - .withEnv("POSTGRES_DATABASE", PostgresContainer.DATABASE_NAME) - .withEnv("POSTGRES_USER", PostgresContainer.USERNAME) - .withEnv("POSTGRES_PASSWORD", PostgresContainer.PASSWORD) - .withEnv("DB_SERVICE_HOST", PostgresContainer.NETWORK_ALIAS) - .withEnv("DB_SERVICE_PORT", Integer.toString(PostgreSQLContainer.POSTGRESQL_PORT)) - .withEnv("IMAGE_BACKEND_SERVICE_HOST", ImageServiceContainer.NETWORK_ALIAS) - .withEnv("IMAGE_BACKEND_SERVICE_PORT", Integer.toString(ImageServiceContainer.PORT)) - .withEnv(distroConfig.getAdditionalEnvVars()) - .dependsOn(collector) - .withCreateContainerCmdModifier( - cmd -> cmd.getHostConfig().withCpusetCpus(RuntimeUtil.getApplicationCores())) - .withCommand("bash run.sh"); + public GenericContainer build() { + GenericContainer container = new GenericContainer<>( + DockerImageName.parse("performance-test/vehicle-inventory-service")) + .withNetwork(network) + .withNetworkAliases("vehicle-service") + .withLogConsumer(new Slf4jLogConsumer(logger)) + .withExposedPorts(PORT) + .waitingFor(Wait.forHttp("/vehicle-inventory/health-check").forPort(PORT)) + .withFileSystemBind( + namingConventions.localResults(), namingConventions.containerResults()) + .withCopyFileToContainer( + MountableFile.forClasspathResource("runVehicleInventory.sh"), + "vehicle-inventory-app/run.sh") + .withCopyFileToContainer( + MountableFile.forClasspathResource("profiler.py"), + "vehicle-inventory-app/profiler.py") + .withCopyFileToContainer( + MountableFile.forClasspathResource("executeProfiler.sh"), + "vehicle-inventory-app/executeProfiler.sh") + .withEnv("DJANGO_SETTINGS_MODULE", "VehicleInventoryApp.settings") + .withEnv("PORT", Integer.toString(PORT)) + .withEnv("POSTGRES_DATABASE", PostgresContainer.DATABASE_NAME) + .withEnv("POSTGRES_USER", PostgresContainer.USERNAME) + .withEnv("POSTGRES_PASSWORD", PostgresContainer.PASSWORD) + .withEnv("DB_SERVICE_HOST", PostgresContainer.NETWORK_ALIAS) + .withEnv("DB_SERVICE_PORT", Integer.toString(PostgreSQLContainer.POSTGRESQL_PORT)) + .withEnv("IMAGE_BACKEND_SERVICE_HOST", ImageServiceContainer.NETWORK_ALIAS) + .withEnv("IMAGE_BACKEND_SERVICE_PORT", Integer.toString(ImageServiceContainer.PORT)) + .withEnv(distroConfig.getAdditionalEnvVars()) + .dependsOn(collector) + .withCreateContainerCmdModifier( + cmd -> cmd.getHostConfig().withCpusetCpus(RuntimeUtil.getApplicationCores())) + .withCommand("bash run.sh"); - if (distroConfig.doInstrument()) { - container - .withEnv("DO_INSTRUMENT", "true") - .withEnv("OTEL_TRACES_EXPORTER", "otlp") - .withEnv("OTEL_METRICS_EXPORTER", "none") - .withEnv("OTEL_IMR_EXPORT_INTERVAL", "5000") - .withEnv("OTEL_EXPORTER_OTLP_INSECURE", "true") - .withEnv("OTEL_EXPORTER_OTLP_ENDPOINT", "http://collector:4317") - .withEnv("OTEL_RESOURCE_ATTRIBUTES", "service.name=vehicle_inventory_service"); + if (distroConfig.doInstrument()) { + container + .withEnv("DO_INSTRUMENT", "true") + .withEnv("OTEL_TRACES_EXPORTER", "otlp") + .withEnv("OTEL_METRICS_EXPORTER", "none") + .withEnv("OTEL_IMR_EXPORT_INTERVAL", "5000") + .withEnv("OTEL_EXPORTER_OTLP_INSECURE", "true") + .withEnv("OTEL_EXPORTER_OTLP_ENDPOINT", "http://collector:4317") + .withEnv("OTEL_RESOURCE_ATTRIBUTES", "service.name=vehicle_inventory_service"); + } + return container; } - return container; - } } diff --git a/sample-applications/vehicle-dealership-sample-app/.gitignore b/sample-applications/vehicle-dealership-sample-app/.gitignore deleted file mode 100644 index 2eea525d8..000000000 --- a/sample-applications/vehicle-dealership-sample-app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.env \ No newline at end of file diff --git a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/.gitignore b/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/.gitignore deleted file mode 100644 index 57afcb2fe..000000000 --- a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -static -.idea -.env -db.sqlite3 -*.iml \ No newline at end of file diff --git a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/Dockerfile b/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/Dockerfile deleted file mode 100644 index c06aeee84..000000000 --- a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 - -# Use an official Python runtime as a parent image -FROM python:3.10 - -# Set environment variables -ENV PYTHONDONTWRITEBYTECODE 1 -ENV PYTHONUNBUFFERED 1 - -# Set the working directory -WORKDIR /image-service-app - -# Install dependencies -COPY ImageServiceApp/requirements.txt /image-service-app/ -RUN pip install -r requirements.txt - -# Copy the project code into the container -COPY ImageServiceApp/. /image-service-app/ \ No newline at end of file diff --git a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/ImageServiceApp/asgi.py b/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/ImageServiceApp/asgi.py deleted file mode 100644 index 245731bb3..000000000 --- a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/ImageServiceApp/asgi.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -""" -ASGI config for ImageServiceApp project. - -It exposes the ASGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/ -""" - -import os - -from django.core.asgi import get_asgi_application - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ImageServiceApp.settings") - -application = get_asgi_application() diff --git a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/ImageServiceApp/settings.py b/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/ImageServiceApp/settings.py deleted file mode 100644 index cb2b3833c..000000000 --- a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/ImageServiceApp/settings.py +++ /dev/null @@ -1,135 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -""" -Django settings for ImageServiceApp project. - -Generated by 'django-admin startproject' using Django 5.0. - -For more information on this file, see -https://docs.djangoproject.com/en/5.0/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/5.0/ref/settings/ -""" - -import os -from pathlib import Path - -from dotenv import load_dotenv - -load_dotenv() - -# Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve().parent.parent - - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/ - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False - -ALLOWED_HOSTS = ["*"] - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = "django-insecure-kixr5rw-%ik9i@395&jyjc$p_2%r(^vu0pv=)$$0)z8sjh84=#" - -# Application definition - -INSTALLED_APPS = [ - "django.contrib.admin", - "django.contrib.auth", - "django.contrib.contenttypes", - "django.contrib.sessions", - "django.contrib.messages", - "django.contrib.staticfiles", - "MainService.apps.MainServiceConfig", -] - -MIDDLEWARE = [ - "django.middleware.security.SecurityMiddleware", - "django.contrib.sessions.middleware.SessionMiddleware", - "django.middleware.common.CommonMiddleware", - "django.middleware.csrf.CsrfViewMiddleware", - "django.contrib.auth.middleware.AuthenticationMiddleware", - "django.contrib.messages.middleware.MessageMiddleware", - "django.middleware.clickjacking.XFrameOptionsMiddleware", -] - -ROOT_URLCONF = "ImageServiceApp.urls" - -TEMPLATES = [ - { - "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [], - "APP_DIRS": True, - "OPTIONS": { - "context_processors": [ - "django.template.context_processors.debug", - "django.template.context_processors.request", - "django.contrib.auth.context_processors.auth", - "django.contrib.messages.context_processors.messages", - ], - }, - }, -] - -WSGI_APPLICATION = "ImageServiceApp.wsgi.application" - - -# Database -# https://docs.djangoproject.com/en/5.0/ref/settings/#databases - -DATABASES = { - "default": { - "ENGINE": "django.db.backends.postgresql", - "USER": os.environ.get("POSTGRES_USER"), - "NAME": os.environ.get("POSTGRES_DATABASE"), - "PASSWORD": os.environ.get("POSTGRES_PASSWORD"), - "HOST": os.environ.get("DB_SERVICE_HOST"), - "PORT": os.environ.get("DB_SERVICE_PORT"), - } -} - - -# Password validation -# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { - "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", - }, - { - "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", - }, - { - "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", - }, - { - "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", - }, -] - - -# Internationalization -# https://docs.djangoproject.com/en/5.0/topics/i18n/ - -LANGUAGE_CODE = "en-us" - -TIME_ZONE = "UTC" - -USE_I18N = True - -USE_TZ = True - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/5.0/howto/static-files/ - -STATIC_URL = "static/" -STATIC_ROOT = os.path.join(BASE_DIR, "static") - -# Default primary key field type -# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field - -DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/ImageServiceApp/urls.py b/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/ImageServiceApp/urls.py deleted file mode 100644 index 0c649876f..000000000 --- a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/ImageServiceApp/urls.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -""" -URL configuration for ImageServiceApp project. - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/5.0/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" -from django.urls import include, path - -urlpatterns = [path("images/", include("MainService.urls"))] diff --git a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/ImageServiceApp/wsgi.py b/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/ImageServiceApp/wsgi.py deleted file mode 100644 index 550aca41f..000000000 --- a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/ImageServiceApp/wsgi.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -""" -WSGI config for ImageServiceApp project. - -It exposes the WSGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/ -""" - -import os - -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ImageServiceApp.settings") - -application = get_wsgi_application() diff --git a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/admin.py b/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/admin.py deleted file mode 100644 index de01c2baf..000000000 --- a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/admin.py +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# from django.contrib import admin - -# Register your models here. diff --git a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/apps.py b/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/apps.py deleted file mode 100644 index a779be6c9..000000000 --- a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/apps.py +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -from django.apps import AppConfig - - -class MainServiceConfig(AppConfig): - default_auto_field = "django.db.models.BigAutoField" - name = "MainService" diff --git a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/models.py b/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/models.py deleted file mode 100644 index 65a375ee1..000000000 --- a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/models.py +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# from django.db import models - -# Create your models here. diff --git a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/tests.py b/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/tests.py deleted file mode 100644 index 7b3609942..000000000 --- a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/tests.py +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# from django.test import TestCase - -# Create your tests here. diff --git a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/urls.py b/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/urls.py deleted file mode 100644 index 2190280a7..000000000 --- a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/urls.py +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -from django.urls import path - -from . import views - -urlpatterns = [ - path("", views.index, name="index"), - path("name/", views.handle_image, name="image"), - path("remote-image", views.get_remote_image, name="remote-image"), - path("health-check/", views.health_check, name="health_check"), -] diff --git a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/views.py b/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/views.py deleted file mode 100644 index f0c54f100..000000000 --- a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/MainService/views.py +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -import os -from threading import Thread -from time import sleep - -import boto3 -import requests -from django.http import HttpResponse, HttpResponseNotAllowed -from django.views.decorators.csrf import csrf_exempt -from dotenv import load_dotenv - -load_dotenv() - -s3_client = boto3.client("s3") -s3_resource = boto3.resource("s3") -sqs = boto3.resource("sqs", region_name="us-west-2") - - -# create resources if they don't exist -# TODO: auto gen bucket name -bucket_name = os.environ.get("S3_BUCKET") -bucket = s3_resource.create_bucket(Bucket=bucket_name) -queue = sqs.create_queue( - QueueName="imageQueue.fifo", Attributes={"FifoQueue": "true", "ContentBasedDeduplication": "true"} -) - - -def read_from_queue(): - while True: - for message in queue.receive_messages(): - image_name = message.body - print("receiving " + image_name + " from the queue") - s3_client.put_object(Bucket=bucket_name, Key=image_name) - message.delete() - sleep(10) - - -thread = Thread(target=read_from_queue) - - -def index(request): - # return all images in s3? - return HttpResponse("Hello, world LOL!") - - -def health_check(request): - return HttpResponse("Image Service is up and running!") - - -@csrf_exempt -def handle_image(request, image_name): - print(image_name) - if request.method == "POST": - put_image(image_name) - return HttpResponse("Putting to queue") - if request.method == "GET": - return HttpResponse(get_image(image_name)) - return HttpResponseNotAllowed("Only GET requests are allowed!") - - -def get_image(image_name): - s3_object = s3_client.get_object(Bucket=bucket_name, Key=image_name) - return str(s3_object) - - -def get_remote_image(request): - api_url = "https://google.com" - return HttpResponse(requests.get(api_url, timeout=10)) - - -def put_image(image_name): - queue.send_message(MessageBody=image_name, MessageGroupId="1") - print("adding " + image_name + " to the queue") - if not thread.is_alive(): - thread.start() - return HttpResponse("Image added to the queue") diff --git a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/manage.py b/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/manage.py deleted file mode 100755 index 31c6f725f..000000000 --- a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/manage.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# pylint: skip-file -"""Django's command-line utility for administrative tasks.""" -import os -import sys - - -def main(): - """Run administrative tasks.""" - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ImageServiceApp.settings") - try: - from django.core.management import execute_from_command_line - except ImportError as exc: - raise ImportError( - "Couldn't import Django. Are you sure it's installed and " - "available on your PYTHONPATH environment variable? Did you " - "forget to activate a virtual environment?" - ) from exc - execute_from_command_line(sys.argv) - - -if __name__ == "__main__": - main() diff --git a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/requirements.txt b/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/requirements.txt deleted file mode 100644 index b329cbad0..000000000 --- a/sample-applications/vehicle-dealership-sample-app/ImageServiceApp/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -Django~=5.0 -requests~=2.31.0 -boto3~=1.34.14 -python-dotenv~=1.0.0 -psycopg2~=2.9.9 \ No newline at end of file diff --git a/sample-applications/vehicle-dealership-sample-app/README.md b/sample-applications/vehicle-dealership-sample-app/README.md deleted file mode 100644 index 1960ddf2d..000000000 --- a/sample-applications/vehicle-dealership-sample-app/README.md +++ /dev/null @@ -1,160 +0,0 @@ -# Python Sample App - -This directory contains code for a microservices based sample app that is used to test Python Enablement. Currently, there are two services: -1. Image Service -2. Vehicle Inventory Service - - -## Deployment - -### Prerequisite -* A docker installation that is set up to build images for AMD64 architecture: - * Working on Mac with intel / AMD64 architecture: - * Install [Docker Desktop](https://www.docker.com/products/docker-desktop/) on your laptop for building the application container images. - * (Make sure to open Docker Desktop and complete the setup) - * Working on Mac with Apple M1 chip / ARM64 architecture: - * Recommended to use Cloud Desktop as Docker desktop will default to creating images for local architecture - * Cloud Desktop - * Docker is installed by default - -* kubectl - https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html -* eksctl - https://docs.aws.amazon.com/eks/latest/userguide/eksctl.html -* python3 (>=3.10) - https://www.python.org/downloads/ - -### EKS -To get started with AWS EKS, you can run the one touch script as below. -`bash script.sh ` - -This will create the docker images, upload them to ECR and then create pods on EKS with those images. - -Second, run the following command and wait for a munite until ALB is ready, you should find a public ALB endpoint to access your service -``` -kubectl get svc -n ingress-nginx - -ingress-nginx LoadBalancer 10.100.160.24 xxx99c97703dc47b198a8609290e59e2-2108118875.us-east-1.elb.amazonaws.com 80:32080/TCP,443:32081/TCP,9113:30959/TCP 3d19h -``` -You will be able to access the app through this endpoint: xxx99c97703dc47b198a8609290e59e2-2108118875.us-east-1.elb.amazonaws.com - - -### EC2 -To deploy to EC2, you will have to go through the following steps. - -1. Create an S3 bucket to upload the python code to. -2. Create a zip file of this directory and upload it to S3. -3. Set up a VPC with a public subnet and a security group accepting all traffic. -4. Set up 2 EC2 instances all with the following configuration: - - Running on Amazon Linux 2 - - Instance type t2.small or larger - - A key-pair you save to your computer. When creating the first EC2 instance you will get a choice to create a new one and reuse it for the other instance. - - Use the VPC, public subnet, and security group created in step 3 - - Enable auto-assign public IP - - An IAM instance profile with the following permissions: - - AmazonS3FullAccess - - AmazonSQSFullAccess - - Name one vehicle-service and the other image-service -5. Go to RDS and create a Postgres DB with the following configurations: - - Use the Dev/Test template - - Update the Master username to `root` and create a password of your choosing. Write it down since you will need it later. - - In the Connectivity settings, choose the VPC and security group created in step 3. - - Switch to Connect to an EC2 compute instance and choose the vehicle-service EC2 instance and then create the DB. -6. Connect to the `vehicle-service` EC2 instance and run the following: -``` -sudo dnf install python3.11 -sudo dnf install python3.11-pip -sudo dnf install python3.11-devel -sudo dnf install postgresql15 -sudo dnf install postgresql-devel -sudo dnf install gcc* - -createdb vehicle_inventory -h -U root -createuser djangouser -h -U root - -psql -h -d vehicle_inventory -U root - -alter user djangouser with encrypted password ''; -grant all privileges on database vehicle_inventory to djangouser; -ALTER DATABASE vehicle_inventory OWNER TO djangouser; - -aws s3 sync s3:// . - -cd to the vehicle microservice directory and run: - -python3.11 -m pip install -r requirements.txt - -Create a .env file with the following: -POSTGRES_ROOT_PASSWORD= -POSTGRES_DATABASE=vehicle_inventory -POSTGRES_USER=djangouser -POSTGRES_PASSWORD= -DB_SERVICE_HOST= -DB_SERVICE_PORT=5432 -IMAGE_BACKEND_SERVICE_HOST= -IMAGE_BACKEND_SERVICE_PORT=8000 - -python3.11 manage.py migrate --noinput && python3.11 manage.py runserver 0.0.0.0:8001 -``` -7. Go to the EC2 console and select the `image-service`, Go Actions -> Networking -> Connect RDS database. -8. Connect to the `image-service` EC2 instance and run the following: -``` -sudo dnf install python3.11 -sudo dnf install python3.11-pip -sudo dnf install python3.11-devel -sudo dnf install postgresql15 -sudo dnf install postgresql-devel -sudo dnf install gcc* - -aws s3 sync s3:// . - -cd to the image microservice directory and run: - -python3.11 -m pip install -r requirements.txt - -Create a .env file with the following: -POSTGRES_ROOT_PASSWORD= -POSTGRES_DATABASE=vehicle_inventory -POSTGRES_USER=djangouser -POSTGRES_PASSWORD= -DB_SERVICE_HOST= -DB_SERVICE_PORT=5432 -S3_BUCKET= - -python3.11 manage.py migrate --noinput && python3.11 manage.py runserver 0.0.0.0:8000 -``` - -Now you should be able to access the APIs below through the EC2 addr:port of each service. - -### Locally with Docker -To get started, make sure you either have you AWS creds in `$HOME/.aws` or the following: `AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN` are exported. -1. Run `bash local_script.sh `. -This will create docker containers, move the requirement env variables there and start them up. - -They should be accessible through `0.0.0.0:8000` for the image service and `0.0.0.0:8001` for the vehicle service. - -## APIs - -The following are the APIs and what they do: -1. `GET /vehicle-inventory/heatlh-check/`: returns 200 if the vehicle service is up and running. -2. `GET /vehicle-inventory/`: returns all the vehicles entries for postgres db -3. `POST /vehicle-inventory/`: puts vehicle into db. For example: `curl -X POST http://0.0.0.0:8001/vehicle-inventory/ - -d '{"make": "BMW","model": "M340","year": 2022,"image_name": "newCar.jpg"}'` -4. `GET /vehicle-inventory/`: returns vehicle entry with id = -5. `DELETE /vehicle-inventory/`: deletes vehicle entry with id = -6. `GET /vehicle-inventory/make/`: returns vehicle entries with make = -7. `GET /vehicle-inventory//image`: returns image file information from S3 for the specific vehicle by calling - the image microservice -8. `GET /vehicle-inventory/image/`: returns image information for from S3 if present through - the image service. -9. `POST /vehicle-inventory/image/`: Calls the image service API `POST /images/name/` -10. `GET /vehicle-inventory/history/`: returns all the vehicle purchase history entries from postgres db -11. `POST /vehicle-inventory/history/`: puts vehicle purchase history into db. For example: `curl -X POST http://0.0.0. - 0:8001/vehicle-inventory/history/ -d '{"vehicle_id": "1","purchase_price": "66000"}'` -12. `GET /vehicle-inventory/history/`: returns vehicle purchase history entry with id = -13. `DELETE /vehicle-inventory/history/`: deletes vehicle purchase history entry with id = -14. `GET /vehicle-inventory/history//vehicle`: returns vehicle entry that is linked to vehicle purchase history - with id = -15. `GET /images/name/`: returns image information for from S3 if present. -16. `POST /images/name/`: creates an empty file in S3. This is an async endpoint since it will put image - name in an SQS queue and not wait for the file to be created in S3. Instead, a long running thread will poll SQS - and then create the image file later. -17. `GET /image/remote-image`: makes a remote http call to google.com. -18. `GET /image/heatlh-check/`: returns 200 if the image service is up and running. \ No newline at end of file diff --git a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/.gitignore b/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/.gitignore deleted file mode 100644 index de23badf8..000000000 --- a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -static -.idea -.env -my.cnf -*.iml \ No newline at end of file diff --git a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/Dockerfile b/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/Dockerfile deleted file mode 100644 index 601cf6e7c..000000000 --- a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 - -# Use an official Python runtime as a parent image -FROM python:3.10 - -# Set environment variables -ENV PYTHONDONTWRITEBYTECODE 1 -ENV PYTHONUNBUFFERED 1 - -# Set the working directory -WORKDIR /vehicle-inventory-app - -# Install dependencies -COPY VehicleInventoryApp/requirements.txt /vehicle-inventory-app/ -RUN pip install -r requirements.txt - -# Copy the project code into the container -COPY VehicleInventoryApp/. /vehicle-inventory-app/ \ No newline at end of file diff --git a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/admin.py b/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/admin.py deleted file mode 100644 index de01c2baf..000000000 --- a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/admin.py +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# from django.contrib import admin - -# Register your models here. diff --git a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/apps.py b/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/apps.py deleted file mode 100644 index a779be6c9..000000000 --- a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/apps.py +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -from django.apps import AppConfig - - -class MainServiceConfig(AppConfig): - default_auto_field = "django.db.models.BigAutoField" - name = "MainService" diff --git a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/migrations/0001_initial.py b/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/migrations/0001_initial.py deleted file mode 100644 index 6cff587be..000000000 --- a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/migrations/0001_initial.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# pylint: skip-file -# Generated by Django 5.0 on 2024-01-15 21:37 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - initial = True - - dependencies = [] - - operations = [ - migrations.CreateModel( - name="Vehicle", - fields=[ - ("id", models.AutoField(primary_key=True, serialize=False)), - ("make", models.CharField(max_length=255)), - ("model", models.CharField(max_length=255)), - ("year", models.IntegerField()), - ("image_name", models.TextField(max_length=255)), - ], - ), - ] diff --git a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/migrations/0002_vehiclepurchasehistory.py b/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/migrations/0002_vehiclepurchasehistory.py deleted file mode 100644 index c08fa99f3..000000000 --- a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/migrations/0002_vehiclepurchasehistory.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# pylint: skip-file -# Generated by Django 5.0 on 2024-02-27 21:52 - -import django.db.models.deletion -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("MainService", "0001_initial"), - ] - - operations = [ - migrations.CreateModel( - name="VehiclePurchaseHistory", - fields=[ - ("id", models.AutoField(primary_key=True, serialize=False)), - ("purchase_date", models.DateField(auto_now_add=True)), - ("purchase_price", models.IntegerField()), - ("vehicle", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="MainService.vehicle")), - ], - ), - ] diff --git a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/migrations/__init__.py b/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/migrations/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/models.py b/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/models.py deleted file mode 100644 index d9efb04e5..000000000 --- a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/models.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -from django.db import models - - -class Vehicle(models.Model): - id = models.AutoField(primary_key=True) - make = models.CharField(max_length=255) - model = models.CharField(max_length=255) - year = models.IntegerField() - image_name = models.TextField(max_length=255) - - -class VehiclePurchaseHistory(models.Model): - id = models.AutoField(primary_key=True) - vehicle = models.ForeignKey("Vehicle", on_delete=models.CASCADE) - purchase_date = models.DateField(auto_now_add=True) - purchase_price = models.IntegerField() diff --git a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/tests.py b/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/tests.py deleted file mode 100644 index 7b3609942..000000000 --- a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/tests.py +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# from django.test import TestCase - -# Create your tests here. diff --git a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/url.py b/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/url.py deleted file mode 100644 index 7d4e55b85..000000000 --- a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/url.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -from django.urls import path - -from . import views - -urlpatterns = [ - path("", views.vehicle, name="vehicle"), - path("", views.vehicle_by_id, name="vehicle_by_id"), - path("make/", views.get_vehicles_by_make, name="get_vehicles_by_make"), - path("/image", views.get_vehicle_image, name="get_vehicle_image"), - path("image/", views.image, name="image"), - path("history/", views.vehicle_purchase_history, name="purchase_history"), - path( - "history/", - views.vehicle_purchase_history_by_id, - name="vehicle_purchase_history_by_id", - ), - path( - "history//vehicle", - views.get_vehicle_from_vehicle_history, - name="get_vehicle_from_vehicle_history", - ), - path("health-check/", views.health_check, name="health_check"), -] diff --git a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/views.py b/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/views.py deleted file mode 100644 index 0a73bcd05..000000000 --- a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/MainService/views.py +++ /dev/null @@ -1,160 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -import json -import os -import time -from html import escape - -import requests -from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseNotAllowed, HttpResponseNotFound -from django.views.decorators.csrf import csrf_exempt -from dotenv import load_dotenv -from MainService.models import Vehicle, VehiclePurchaseHistory - -load_dotenv() - - -def health_check(request): - return HttpResponse("Vehicle Inventory Service up and running!") - - -def get_image_endpoint(): - load_dotenv() - return "http://" + os.environ.get("IMAGE_BACKEND_SERVICE_HOST") + ":" + os.environ.get("IMAGE_BACKEND_SERVICE_PORT") - - -@csrf_exempt -def vehicle(request): - if request.method == "POST": - body_unicode = request.body.decode("utf-8") - body = json.loads(body_unicode) - try: - vehicle_object = Vehicle( - make=body["make"], model=body["model"], year=body["year"], image_name=body["image_name"] - ) - vehicle_object.save() - requests.post(build_image_url(body["image_name"]), timeout=10) - return HttpResponse("VehicleId = " + str(vehicle_object.id)) - except KeyError as exception: - return HttpResponseBadRequest("Missing key: " + str(exception)) - elif request.method == "GET": - vehicle_objects = Vehicle.objects.all().values() - return HttpResponse(vehicle_objects) - return HttpResponseNotAllowed("Only GET/POST requests are allowed!") - - -@csrf_exempt -def vehicle_by_id(request, vehicle_id): - if request.method == "GET": - throttle_time = request.GET.get("throttle") - if throttle_time: - print("going to throttle for " + throttle_time + " seconds") - time.sleep(int(throttle_time)) - - vehicle_objects = Vehicle.objects.filter(id=vehicle_id).values() - if not vehicle_objects: - return HttpResponseNotFound("Vehicle with id=" + escape(str(vehicle_id)) + " is not found") - return HttpResponse(vehicle_objects) - if request.method == "DELETE": - vehicle_objects = Vehicle.objects.filter(id=vehicle_id) - vehicle_objects_values = Vehicle.objects.filter(id=vehicle_id).values() - if not vehicle_objects_values: - return HttpResponseNotFound("Vehicle with id=" + escape(str(vehicle_id)) + " is not found") - vehicle_objects.delete() - return HttpResponse("Vehicle with id=" + escape(str(vehicle_id)) + " has been deleted") - return HttpResponseNotAllowed("Only GET/DELETE requests are allowed!") - - -def get_vehicles_by_make(request, vehicles_make): - if request.method == "GET": - vehicles_objects = Vehicle.objects.filter(make=vehicles_make).values() - if not vehicles_objects: - return HttpResponseNotFound("Couldn't find any vehicle with make=" + escape(str(vehicles_make))) - return HttpResponse(vehicles_objects) - return HttpResponseNotAllowed("Only GET requests are allowed!") - - -def get_vehicle_image(request, vehicle_id): - if request.method == "GET": - vehicle_object = Vehicle.objects.filter(id=vehicle_id).first() - if not vehicle_object: - return HttpResponseNotFound("Vehicle with id=" + escape(str(vehicle_id)) + " is not found") - image_name = getattr(vehicle_object, "image_name") - return HttpResponse(requests.get(build_image_url(image_name), timeout=10)) - return HttpResponseNotAllowed("Only GET requests are allowed!") - - -@csrf_exempt -def image(request, image_name): - if request.method == "GET": - response = requests.get(build_image_url(image_name), timeout=10) - if response.ok: - return HttpResponse(response) - return HttpResponseNotFound("Image with name: " + escape(image_name) + " is not found") - if request.method == "POST": - response = requests.post(build_image_url(image_name), timeout=10) - if response.ok: - return HttpResponse(response) - return HttpResponseNotFound("Image with name: " + escape(image_name) + " failed to saved") - return HttpResponseNotAllowed("Only GET/POST requests are allowed!") - - -@csrf_exempt -def vehicle_purchase_history(request): - if request.method == "POST": - body_unicode = request.body.decode("utf-8") - body = json.loads(body_unicode) - try: - vehicle_purchase_history_object = VehiclePurchaseHistory( - vehicle_id=body["vehicle_id"], purchase_price=body["purchase_price"] - ) - vehicle_purchase_history_object.save() - return HttpResponse("VehiclePurchaseHistoryId = " + str(vehicle_purchase_history_object.id)) - except KeyError as exception: - return HttpResponseBadRequest("Missing key: " + str(exception)) - elif request.method == "GET": - vehicle_purchase_history_object = VehiclePurchaseHistory.objects.all().values() - return HttpResponse(vehicle_purchase_history_object) - return HttpResponseNotAllowed("Only GET/POST requests are allowed!") - - -@csrf_exempt -def vehicle_purchase_history_by_id(request, vehicle_purchase_history_id): - if request.method == "GET": - vehicle_purchase_history_object = VehiclePurchaseHistory.objects.filter(id=vehicle_purchase_history_id).values() - if not vehicle_purchase_history_object: - return HttpResponseNotFound( - "VehiclePurchaseHistory with id=" + escape(str(vehicle_purchase_history_id)) + " is not found" - ) - return HttpResponse(vehicle_purchase_history_object) - if request.method == "DELETE": - vehicle_purchase_history_object = VehiclePurchaseHistory.objects.filter(id=vehicle_purchase_history_id) - vehicle_purchase_history_object_values = Vehicle.objects.filter(id=vehicle_purchase_history_id).values() - if not vehicle_purchase_history_object_values: - return HttpResponseNotFound( - "VehiclePurchaseHistory with id=" + escape(str(vehicle_purchase_history_id)) + " is not found" - ) - vehicle_purchase_history_object.delete() - return HttpResponse( - "VehiclePurchaseHistory with id=" + escape(str(vehicle_purchase_history_id)) + " has been deleted" - ) - return HttpResponseNotAllowed("Only GET/DELETE requests are allowed!") - - -def get_vehicle_from_vehicle_history(request, vehicle_purchase_history_id): - if request.method == "GET": - vehicle_purchase_history_object = VehiclePurchaseHistory.objects.filter(id=vehicle_purchase_history_id).first() - if not vehicle_purchase_history_object: - return HttpResponseNotFound( - "VehiclePurchaseHistory with id=" + escape(str(vehicle_purchase_history_id)) + " is not found" - ) - vehicle_id = getattr(vehicle_purchase_history_object, "vehicle_id") - vehicle_objects = Vehicle.objects.filter(id=vehicle_id).values() - if not vehicle_objects: - return HttpResponseNotFound("Vehicle with id=" + escape(str(vehicle_id)) + " is not found") - return HttpResponse(vehicle_objects) - return HttpResponseNotAllowed("Only GET requests are allowed!") - - -def build_image_url(image_name): - return get_image_endpoint() + "/images/name/" + image_name diff --git a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/VehicleInventoryApp/asgi.py b/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/VehicleInventoryApp/asgi.py deleted file mode 100644 index 1bed60ba1..000000000 --- a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/VehicleInventoryApp/asgi.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -""" -ASGI config for VehicleInventoryApp project. - -It exposes the ASGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/ -""" - -import os - -from django.core.asgi import get_asgi_application - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "VehicleInventoryApp.settings") - -application = get_asgi_application() diff --git a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/VehicleInventoryApp/settings.py b/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/VehicleInventoryApp/settings.py deleted file mode 100644 index af06003f3..000000000 --- a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/VehicleInventoryApp/settings.py +++ /dev/null @@ -1,134 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -""" -Django settings for VehicleInventoryApp project. - -Generated by 'django-admin startproject' using Django 5.0. - -For more information on this file, see -https://docs.djangoproject.com/en/5.0/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/5.0/ref/settings/ -""" - -import os -from pathlib import Path - -from dotenv import load_dotenv - -load_dotenv() - -# Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve().parent.parent - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = "django-insecure-kixr5rw-%ik9i@395&jyjc$p_2%r(^vu0pv=)$$0)z8sjh84=#" - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/ - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False - -ALLOWED_HOSTS = ["*"] - - -# Application definition - -INSTALLED_APPS = [ - "django.contrib.admin", - "django.contrib.auth", - "django.contrib.contenttypes", - "django.contrib.sessions", - "django.contrib.messages", - "django.contrib.staticfiles", - "MainService.apps.MainServiceConfig", -] - -MIDDLEWARE = [ - "django.contrib.sessions.middleware.SessionMiddleware", - "django.middleware.common.CommonMiddleware", - "django.middleware.csrf.CsrfViewMiddleware", - "django.contrib.auth.middleware.AuthenticationMiddleware", - "django.contrib.messages.middleware.MessageMiddleware", - "django.middleware.clickjacking.XFrameOptionsMiddleware", -] - -ROOT_URLCONF = "VehicleInventoryApp.urls" - -TEMPLATES = [ - { - "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [BASE_DIR / "templates"], - "APP_DIRS": True, - "OPTIONS": { - "context_processors": [ - "django.template.context_processors.debug", - "django.template.context_processors.request", - "django.contrib.auth.context_processors.auth", - "django.contrib.messages.context_processors.messages", - ], - }, - }, -] - -WSGI_APPLICATION = "VehicleInventoryApp.wsgi.application" - - -# Database -# https://docs.djangoproject.com/en/5.0/ref/settings/#databases - -DATABASES = { - "default": { - "ENGINE": "django.db.backends.postgresql", - "USER": os.environ.get("POSTGRES_USER"), - "NAME": os.environ.get("POSTGRES_DATABASE"), - "PASSWORD": os.environ.get("POSTGRES_PASSWORD"), - "HOST": os.environ.get("DB_SERVICE_HOST"), - "PORT": os.environ.get("DB_SERVICE_PORT"), - } -} - - -# Password validation -# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { - "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", - }, - { - "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", - }, - { - "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", - }, - { - "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", - }, -] - - -# Internationalization -# https://docs.djangoproject.com/en/5.0/topics/i18n/ - -LANGUAGE_CODE = "en-us" - -TIME_ZONE = "UTC" - -USE_I18N = True - -USE_TZ = True - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/5.0/howto/static-files/ - -STATIC_URL = "static/" -STATIC_ROOT = os.path.join(BASE_DIR, "static") - -# Default primary key field type -# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field - -DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/VehicleInventoryApp/urls.py b/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/VehicleInventoryApp/urls.py deleted file mode 100644 index 2fbba9212..000000000 --- a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/VehicleInventoryApp/urls.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -""" -URL configuration for VehicleInventoryApp project. - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/5.0/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" -from django.urls import include, path - -urlpatterns = [path("vehicle-inventory/", include("MainService.url"))] diff --git a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/VehicleInventoryApp/wsgi.py b/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/VehicleInventoryApp/wsgi.py deleted file mode 100644 index cbd1e60c6..000000000 --- a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/VehicleInventoryApp/wsgi.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -""" -WSGI config for VehicleInventoryApp project. - -It exposes the WSGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/ -""" - -import os - -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "VehicleInventoryApp.settings") - -application = get_wsgi_application() diff --git a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/manage.py b/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/manage.py deleted file mode 100755 index 7fbad3ef9..000000000 --- a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/manage.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# pylint: skip-file -"""Django's command-line utility for administrative tasks.""" -import os -import sys - - -def main(): - """Run administrative tasks.""" - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "VehicleInventoryApp.settings") - try: - from django.core.management import execute_from_command_line - except ImportError as exc: - raise ImportError( - "Couldn't import Django. Are you sure it's installed and " - "available on your PYTHONPATH environment variable? Did you " - "forget to activate a virtual environment?" - ) from exc - execute_from_command_line(sys.argv) - - -if __name__ == "__main__": - main() diff --git a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/requirements.txt b/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/requirements.txt deleted file mode 100644 index 78cedc1c4..000000000 --- a/sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -Django~=5.0 -requests~=2.31.0 -psycopg2~=2.9.9 -python-dotenv~=1.0.0 \ No newline at end of file diff --git a/sample-applications/vehicle-dealership-sample-app/docker-compose.yaml b/sample-applications/vehicle-dealership-sample-app/docker-compose.yaml deleted file mode 100644 index fe6123316..000000000 --- a/sample-applications/vehicle-dealership-sample-app/docker-compose.yaml +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -version: '3' -services: - db: - image: postgres:14.0 - container_name: vehicle_inventory_db - restart: always - volumes: - - data:/var/lib/postgres - environment: - POSTGRES_DB: ${POSTGRES_DATABASE} - POSTGRES_USER: ${POSTGRES_USER} - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} - PGUSER: ${POSTGRES_USER} - ports: - - "5432:5432" - healthcheck: - test: ["CMD", "pg_isready", "-d", "vehicle_inventory", "-U", "djangouser"] - timeout: 20s - retries: 10 - expose: - - 5432 - - vehicle-inventory-backend: - image: pythonsampleapp/vehicle-inventory-service - build: - context: . - dockerfile: VehicleInventoryApp/Dockerfile - container_name: vehicle-inventory-backend - command: sh -c "python3 manage.py migrate --noinput && python3 manage.py collectstatic --noinput && python3 manage.py runserver 0.0.0.0:8001 --noreload" - restart: always - volumes: - - ./VehicleInventoryApp/.:/vehicle-inventory-app - environment: - DJANGO_SETTINGS_MODULE: "VehicleInventoryApp.settings" - OTEL_TRACES_SAMPLER: "xray" - ports: - - "8001:8001" - depends_on: - db: - condition: service_healthy - - image-backend: - image: pythonsampleapp/image-service - build: - context: . - dockerfile: ImageServiceApp/Dockerfile - container_name: image-service-backend - command: sh -c "python3 manage.py runserver 0.0.0.0:8000 --noreload" - restart: always - volumes: - - ./ImageServiceApp/.:/image-service-app - - $HOME/.aws/credentials:/home/app/.aws/credentials:ro - environment: - DJANGO_SETTINGS_MODULE: "ImageServiceApp.settings" - OTEL_TRACES_SAMPLER: "xray" - ports: - - "8000:8000" - depends_on: - db: - condition: service_healthy - -volumes: - data: - -networks: - mynet: \ No newline at end of file diff --git a/sample-applications/vehicle-dealership-sample-app/eks/backend-deployment.yaml b/sample-applications/vehicle-dealership-sample-app/eks/backend-deployment.yaml deleted file mode 100644 index c63b1e595..000000000 --- a/sample-applications/vehicle-dealership-sample-app/eks/backend-deployment.yaml +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -apiVersion: apps/v1 -kind: Deployment -metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: vehicle-inventory-backend - name: vehicle-inventory-backend -spec: - replicas: 1 - selector: - matchLabels: - io.kompose.service: vehicle-inventory-backend - strategy: - type: Recreate - template: - metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.31.2 (HEAD) - instrumentation.opentelemetry.io/inject-python: "true" - creationTimestamp: null - labels: - io.kompose.network/vehicleinventoryapp-default: "true" - io.kompose.service: vehicle-inventory-backend - spec: - containers: - - args: - - sh - - -c - - python3 manage.py migrate --noinput && python3 manage.py collectstatic --noinput && python3 manage.py runserver 0.0.0.0:8001 --noreload - image: ${REPOSITORY_PREFIX}/pythonsampleapp/vehicle-inventory-service:latest - name: vehicle-inventory-backend - env: - - name: POSTGRES_DATABASE - value: vehicle_inventory - - name: POSTGRES_PASSWORD - value: ${POSTGRES_PASSWORD} - - name: POSTGRES_USER - value: djangouser -# Setting PYTHONPATH is currently required due to the issue in OTel: open-telemetry/opentelemetry-operator#2302 - - name: PYTHONPATH - value: "/vehicle-inventory-app" - - name: DJANGO_SETTINGS_MODULE - value: "VehicleInventoryApp.settings" - imagePullPolicy: Always - ports: - - containerPort: 8001 - hostPort: 8001 - protocol: TCP - resources: {} - restartPolicy: Always -status: {} diff --git a/sample-applications/vehicle-dealership-sample-app/eks/backend-service.yaml b/sample-applications/vehicle-dealership-sample-app/eks/backend-service.yaml deleted file mode 100644 index 778e20015..000000000 --- a/sample-applications/vehicle-dealership-sample-app/eks/backend-service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: vehicle-inventory-backend - name: vehicle-inventory-backend -spec: - ports: - - port: 8001 - selector: - io.kompose.service: vehicle-inventory-backend -status: - loadBalancer: {} diff --git a/sample-applications/vehicle-dealership-sample-app/eks/data-persistentvolumeclaim.yaml b/sample-applications/vehicle-dealership-sample-app/eks/data-persistentvolumeclaim.yaml deleted file mode 100644 index 3af0f440d..000000000 --- a/sample-applications/vehicle-dealership-sample-app/eks/data-persistentvolumeclaim.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - creationTimestamp: null - labels: - io.kompose.service: data - name: data -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 100Mi -status: {} diff --git a/sample-applications/vehicle-dealership-sample-app/eks/db-deployment.yaml b/sample-applications/vehicle-dealership-sample-app/eks/db-deployment.yaml deleted file mode 100644 index 5f9a7d208..000000000 --- a/sample-applications/vehicle-dealership-sample-app/eks/db-deployment.yaml +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -apiVersion: apps/v1 -kind: Deployment -metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: db - name: db -spec: - replicas: 1 - selector: - matchLabels: - io.kompose.service: db - strategy: - type: Recreate - template: - metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.network/vehicleinventoryapp-default: "true" - io.kompose.service: db - spec: - containers: - - env: - - name: POSTGRES_DB - value: vehicle_inventory - - name: POSTGRES_PASSWORD - value: ${POSTGRES_PASSWORD} - - name: POSTGRES_USER - value: djangouser - image: postgres:14.0 - livenessProbe: - exec: - command: - - pg_isready - - -d - - vehicle_inventory - - -U - - djangouser - failureThreshold: 10 - timeoutSeconds: 20 - name: vehicle-inventory-db - ports: - - containerPort: 5432 - hostPort: 5432 - protocol: TCP - resources: {} - volumeMounts: - - mountPath: /var/lib/postgres - name: data - restartPolicy: Always - volumes: - - name: data - persistentVolumeClaim: - claimName: data -status: {} diff --git a/sample-applications/vehicle-dealership-sample-app/eks/db-service.yaml b/sample-applications/vehicle-dealership-sample-app/eks/db-service.yaml deleted file mode 100644 index dcb601c67..000000000 --- a/sample-applications/vehicle-dealership-sample-app/eks/db-service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: db - name: db -spec: - ports: - - port: 5432 - selector: - io.kompose.service: db -status: - loadBalancer: {} diff --git a/sample-applications/vehicle-dealership-sample-app/eks/image-backend-deployment.yaml b/sample-applications/vehicle-dealership-sample-app/eks/image-backend-deployment.yaml deleted file mode 100644 index 23320678d..000000000 --- a/sample-applications/vehicle-dealership-sample-app/eks/image-backend-deployment.yaml +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -apiVersion: apps/v1 -kind: Deployment -metadata: - annotations: - kompose.cmd: Kompose convert -f docker-compose.yaml - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: image-backend - name: image-backend -spec: - replicas: 1 - selector: - matchLabels: - io.kompose.service: image-backend - strategy: - type: Recreate - template: - metadata: - annotations: - kompose.cmd: Kompose convert -f docker-compose.yaml - kompose.version: 1.31.2 (HEAD) - instrumentation.opentelemetry.io/inject-python: "true" - creationTimestamp: null - labels: - io.kompose.network/imageserviceapp-default: "true" - io.kompose.service: image-backend - spec: - containers: - - args: - - sh - - -c - - python3 manage.py runserver 0.0.0.0:8000 --noreload - image: ${REPOSITORY_PREFIX}/pythonsampleapp/image-service:latest - name: image-service-backend - imagePullPolicy: Always - ports: - - containerPort: 8000 - hostPort: 8000 - protocol: TCP - resources: {} - env: - - name: S3_BUCKET - value: ${S3_BUCKET} - - name: POSTGRES_DATABASE - value: vehicle_inventory - - name: POSTGRES_PASSWORD - value: ${POSTGRES_PASSWORD} - - name: POSTGRES_USER - value: djangouser -# Setting PYTHONPATH is currently required due to the issue in OTel: open-telemetry/opentelemetry-operator#2302 - - name: PYTHONPATH - value: "/image-service-app" - - name: DJANGO_SETTINGS_MODULE - value: "ImageServiceApp.settings" - restartPolicy: Always -status: {} diff --git a/sample-applications/vehicle-dealership-sample-app/eks/image-backend-service.yaml b/sample-applications/vehicle-dealership-sample-app/eks/image-backend-service.yaml deleted file mode 100644 index a4917f293..000000000 --- a/sample-applications/vehicle-dealership-sample-app/eks/image-backend-service.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: Kompose convert -f docker-compose.yaml - kompose.version: 1.31.2 (HEAD) - creationTimestamp: null - labels: - io.kompose.service: image-backend - name: image-backend -spec: - ports: - - name: "8000" - port: 8000 - targetPort: 8000 - selector: - io.kompose.service: image-backend -status: - loadBalancer: {} diff --git a/sample-applications/vehicle-dealership-sample-app/eks/k8s-nginx-ingress/namespace.yaml b/sample-applications/vehicle-dealership-sample-app/eks/k8s-nginx-ingress/namespace.yaml deleted file mode 100644 index 86436d51c..000000000 --- a/sample-applications/vehicle-dealership-sample-app/eks/k8s-nginx-ingress/namespace.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -apiVersion: v1 -kind: Namespace -metadata: - name: ingress-nginx \ No newline at end of file diff --git a/sample-applications/vehicle-dealership-sample-app/eks/k8s-nginx-ingress/nginx-alb.yaml b/sample-applications/vehicle-dealership-sample-app/eks/k8s-nginx-ingress/nginx-alb.yaml deleted file mode 100644 index a34317d3a..000000000 --- a/sample-applications/vehicle-dealership-sample-app/eks/k8s-nginx-ingress/nginx-alb.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -apiVersion: v1 -kind: Service -metadata: - name: ingress-nginx - namespace: ingress-nginx - annotations: - prometheus.io/port: '9113' - prometheus.io/scrape: 'true' - prometheus.io/scheme: http -spec: - type: LoadBalancer - ports: - - name: http - port: 80 - targetPort: 80 - nodePort: 32080 - protocol: TCP - - name: https - port: 443 - targetPort: 443 - nodePort: 32081 - protocol: TCP - selector: - app: ingress-nginx diff --git a/sample-applications/vehicle-dealership-sample-app/eks/k8s-nginx-ingress/nginx-ingress.yaml b/sample-applications/vehicle-dealership-sample-app/eks/k8s-nginx-ingress/nginx-ingress.yaml deleted file mode 100644 index 25929a14b..000000000 --- a/sample-applications/vehicle-dealership-sample-app/eks/k8s-nginx-ingress/nginx-ingress.yaml +++ /dev/null @@ -1,360 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 ---- - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: default-http-backend - labels: - app: default-http-backend - namespace: ingress-nginx -spec: - replicas: 1 - selector: - matchLabels: - app: default-http-backend - template: - metadata: - labels: - app: default-http-backend - spec: - terminationGracePeriodSeconds: 60 - containers: - - name: default-http-backend - # Any image is permissible as long as: - # 1. It serves a 404 page at / - # 2. It serves 200 on a /healthz endpoint - image: gcr.io/google_containers/defaultbackend:1.4 - livenessProbe: - httpGet: - path: /healthz - port: 8080 - scheme: HTTP - initialDelaySeconds: 30 - timeoutSeconds: 5 - ports: - - containerPort: 8080 - resources: - limits: - cpu: 10m - memory: 20Mi - requests: - cpu: 10m - memory: 20Mi ---- - -apiVersion: v1 -kind: Service -metadata: - name: default-http-backend - namespace: ingress-nginx - labels: - app: default-http-backend -spec: - ports: - - port: 80 - targetPort: 8080 - selector: - app: default-http-backend ---- - -kind: ConfigMap -apiVersion: v1 -metadata: - name: nginx-configuration - namespace: ingress-nginx - labels: - app: ingress-nginx -data: - allow-snippet-annotations: "true" - enable-opentelemetry: "true" - opentelemetry-operation-name: HTTP $request_method $service_name - opentelemetry-trust-incoming-span: "true" - otel-sampler: AlwaysOn - otel-sampler-parent-based: "true" - otel-sampler-ratio: "1.0" - otel-service-name: nginx-proxy - otlp-collector-host: "otel-collector.default.svc" - otlp-collector-port: "4317" ---- - -kind: ConfigMap -apiVersion: v1 -metadata: - name: tcp-services - namespace: ingress-nginx ---- - -kind: ConfigMap -apiVersion: v1 -metadata: - name: udp-services - namespace: ingress-nginx ---- - -apiVersion: v1 -kind: ServiceAccount -metadata: - name: nginx-ingress-serviceaccount - namespace: ingress-nginx - ---- - -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: nginx-ingress-clusterrole -rules: - - apiGroups: - - "" - resources: - - configmaps - - endpoints - - nodes - - pods - - secrets - verbs: - - list - - watch - - update - - apiGroups: - - "" - resources: - - nodes - verbs: - - get - - apiGroups: - - "" - resources: - - services - verbs: - - get - - list - - watch - - apiGroups: - - "networking.k8s.io" - - "extensions" - resources: - - ingresses - verbs: - - get - - list - - watch - - apiGroups: - - "" - resources: - - events - verbs: - - create - - patch - - apiGroups: - - "networking.k8s.io" - - "extensions" - resources: - - ingresses/status - verbs: - - update - - apiGroups: - - "discovery.k8s.io" - resources: - - "endpointslices" - verbs: - - list - - watch - - apiGroups: - - "coordination.k8s.io" - resources: - - "leases" - verbs: - - get - - list - - create - - update - ---- - -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: nginx-ingress-role - namespace: ingress-nginx -rules: - - apiGroups: - - "" - resources: - - configmaps - - pods - - secrets - - namespaces - verbs: - - get - - apiGroups: - - "" - resources: - - configmaps - resourceNames: - # Defaults to "-" - # Here: "-" - # This has to be adapted if you change either parameter - # when launching the nginx-ingress-controller. - - "ingress-controller-leader-nginx" - - "ingress-controller-leader" - verbs: - - get - - update - - apiGroups: - - "" - resources: - - configmaps - verbs: - - create - - apiGroups: - - "" - resources: - - endpoints - verbs: - - get - ---- - -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: nginx-ingress-role-nisa-binding - namespace: ingress-nginx -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: nginx-ingress-role -subjects: - - kind: ServiceAccount - name: nginx-ingress-serviceaccount - namespace: ingress-nginx - ---- - -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: nginx-ingress-clusterrole-nisa-binding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: nginx-ingress-clusterrole -subjects: - - kind: ServiceAccount - name: nginx-ingress-serviceaccount - namespace: ingress-nginx ---- - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: nginx-ingress-controller - namespace: ingress-nginx - annotations: - prometheus.io/port: '9113' - prometheus.io/scrape: 'true' -spec: - replicas: 1 - selector: - matchLabels: - app: ingress-nginx - template: - metadata: - labels: - app: ingress-nginx - annotations: - prometheus.io/port: '9113' - prometheus.io/scrape: 'true' - prometheus.io/scheme: http - spec: - serviceAccountName: nginx-ingress-serviceaccount - containers: - - name: nginx-ingress-controller - # image: us.gcr.io/k8s-artifacts-prod/ingress-nginx/controller:v1.1.1 - image: registry.k8s.io/ingress-nginx/controller:v1.4.0 - # image: public.ecr.aws/y8s3a7r9/ingress-nginx-controller:latest - args: - - /nginx-ingress-controller - - --default-backend-service=$(POD_NAMESPACE)/default-http-backend - - --configmap=$(POD_NAMESPACE)/nginx-configuration - - --tcp-services-configmap=$(POD_NAMESPACE)/tcp-services - - --udp-services-configmap=$(POD_NAMESPACE)/udp-services - - --publish-service=$(POD_NAMESPACE)/ingress-nginx - - --annotations-prefix=nginx.ingress.kubernetes.io - # - --validating-webhook=:8443 - # - --validating-webhook-certificate=/usr/local/certificates/cert - # - --validating-webhook-key=/usr/local/certificates/key - securityContext: - capabilities: - drop: - - ALL - add: - - NET_BIND_SERVICE - # www-data -> 33 - runAsUser: 101 - env: - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: POD_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - - name: LD_PRELOAD - value: /usr/local/lib/libmimalloc.so - ports: - - name: http - containerPort: 80 - - name: https - containerPort: 443 - - containerPort: 8443 - name: webhook - protocol: TCP - - name: prometheus - containerPort: 9113 - livenessProbe: - failureThreshold: 3 - httpGet: - path: /healthz - port: 10254 - scheme: HTTP - initialDelaySeconds: 10 - periodSeconds: 10 - successThreshold: 1 - timeoutSeconds: 1 - readinessProbe: - failureThreshold: 3 - httpGet: - path: /healthz - port: 10254 - scheme: HTTP - periodSeconds: 10 - successThreshold: 1 - timeoutSeconds: 1 - volumeMounts: - - mountPath: /modules_mount - name: modules - # - mountPath: /usr/local/certificates/ - # name: webhook-cert - # readOnly: true - initContainers: - - command: ['sh', '-c', "/usr/local/bin/init_module.sh"] - image: registry.k8s.io/ingress-nginx/opentelemetry:v20230107-helm-chart-4.4.2-2-g96b3d2165@sha256:331b9bebd6acfcd2d3048abbdd86555f5be76b7e3d0b5af4300b04235c6056c9 - imagePullPolicy: IfNotPresent - name: opentelemetry - securityContext: - allowPrivilegeEscalation: false - volumeMounts: - - mountPath: /modules_mount - name: modules - volumes: - - emptyDir: {} - name: modules - # - name: webhook-cert - # secret: - # defaultMode: 420 - # secretName: ingress-nginx-admission diff --git a/sample-applications/vehicle-dealership-sample-app/eks/k8s-nginx-ingress/python-nginx-ingress.yaml b/sample-applications/vehicle-dealership-sample-app/eks/k8s-nginx-ingress/python-nginx-ingress.yaml deleted file mode 100644 index f1f0bc8ec..000000000 --- a/sample-applications/vehicle-dealership-sample-app/eks/k8s-nginx-ingress/python-nginx-ingress.yaml +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: petclinic-nginx-ingress - annotations: - kubernetes.io/ingress.class: nginx - nginx.ingress.kubernetes.io/ssl-redirect: "false" - nginx.ingress.kubernetes.io/enable-opentelemetry: "true" -spec: - rules: - - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: vehicle-inventory-backend - port: - number: 8001 - - path: /images - pathType: Prefix - backend: - service: - name: image-backend - port: - number: 8000 \ No newline at end of file diff --git a/sample-applications/vehicle-dealership-sample-app/local_script.sh b/sample-applications/vehicle-dealership-sample-app/local_script.sh deleted file mode 100644 index 12e4de963..000000000 --- a/sample-applications/vehicle-dealership-sample-app/local_script.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 - -password=$1 -s3_bucket=$2 - -if [ -n "$1" ]; then - password="$1" -else - echo "password can't be empty!" - exit 1 -fi - -if [ -n "$2" ]; then - s3_bucket="$2" -else - echo "s3 bucket cannot be empty!" - exit 1 -fi - -rm VehicleInventoryApp/.env -rm ImageServiceApp/.env -rm .env - -echo "POSTGRES_DATABASE=vehicle_inventory" >> VehicleInventoryApp/.env -echo "POSTGRES_USER=djangouser" >> VehicleInventoryApp/.env -echo "POSTGRES_PASSWORD=${password}" >> VehicleInventoryApp/.env -echo "DB_SERVICE_HOST=db" >> VehicleInventoryApp/.env -echo "DB_SERVICE_PORT=5432" >> VehicleInventoryApp/.env -echo "IMAGE_BACKEND_SERVICE_HOST=image-service-backend" >> VehicleInventoryApp/.env -echo "IMAGE_BACKEND_SERVICE_PORT=8000" >> VehicleInventoryApp/.env - -echo "POSTGRES_DATABASE=vehicle_inventory" >> ImageServiceApp/.env -echo "POSTGRES_USER=djangouser" >> ImageServiceApp/.env -echo "POSTGRES_PASSWORD=${password}" >> ImageServiceApp/.env -echo "DB_SERVICE_HOST=db" >> ImageServiceApp/.env -echo "DB_SERVICE_PORT=5432" >> ImageServiceApp/.env -echo "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" >> ImageServiceApp/.env -echo "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" >> ImageServiceApp/.env -echo "AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN}" >> ImageServiceApp/.env -echo "S3_BUCKET=${s3_bucket}" >> ImageServiceApp/.env - -echo "POSTGRES_DATABASE=vehicle_inventory" >> .env -echo "POSTGRES_USER=djangouser" >> .env -echo "POSTGRES_PASSWORD=${password}" >> .env - -docker-compose up --build diff --git a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/.gitignore b/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/.gitignore deleted file mode 100644 index b512c09d4..000000000 --- a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/Dockerfile b/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/Dockerfile deleted file mode 100644 index ca8249222..000000000 --- a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# Use the official lightweight Node.js 16 image. -# https://hub.docker.com/_/node -FROM node:16-slim - -# Create and change to the app directory. -WORKDIR /usr/src/app - -# Copy application dependency manifests to the container image. -# A wildcard is used to ensure copying both package.json AND package-lock.json (if available). -# Copying this first prevents re-running npm install on every code change. -COPY package*.json ./ - -# Install production dependencies. -# If you have native dependencies, you'll need additional tools. -# For a full list of package.json changes, see: -# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md -RUN npm install --only=production - -# Copy local code to the container image. -COPY . . - -# Run the web service on container startup. -CMD [ "node", "index.js" ] - diff --git a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/README.md b/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/README.md deleted file mode 100644 index 0c9f7cb20..000000000 --- a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Random Traffic Generator -The traffic generator generates the following traffic: -1. Every minute, sends a single POST request to the VehicleInventoryApp and sends a single GET request. -2. Every hour, sends a burst of requests: 5 POST requests to the VehicleInventoryApp and 5 GET requests. -3. Every 5 minutes, sleeps for random amount of time between 30-60 seconds and then sends a GET request to the VehicleInventoryApp with a random throttle param between 5-20 seconds. The backend reads that throttle param and simulates throttling for that amount of time before responding to the request. -4. Every 5 minutes, sleeps for random amount of time between 30-60 seconds and then sends a GET request to the VehicleInventoryApp with an invalid car id to trigger 404 error. -5. Every 5 minutes, sleeps for random amount of time between 30-60 seconds and then sends a GET request to the ImageServiceApp with a non existent image name to trigger 500 error due to S3 Error: "An error occurred (NoSuchKey) when calling the GetObject operation: The specified key does not exist." - -## Running locally -1. Run `npm install` -2. Run locally: - - If you are running against you application locally, just run `node index.js`. The default endpoint is `0.0.0.0:8000` for the ImageServiceApp and `0.0.0.0:8001` for VehicleInventoryApp. - - If you want to run against the application on EKS, before running the `node index.js`, run `export `. - -## Deploying to EKS -Run `bash build.sh `. This does the following: -1. This will retrieve the endpoint from EKS ingress-nginx pod -2. Build docker image of the traffic -3. Push the docker image to ECR -4. Deploy the image to EKS - diff --git a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/build.sh b/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/build.sh deleted file mode 100644 index 39079ad27..000000000 --- a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/build.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -account=$1 -region=$2 - -# Save the endpoint URL to a variable -endpoint=$(kubectl get svc -n ingress-nginx | grep "ingress-nginx" | awk '{print $4}') - -# Print the endpoint -echo "Endpoint: $endpoint" - -export REPOSITORY_PREFIX=${account}.dkr.ecr.${region}.amazonaws.com -aws ecr get-login-password --region ${region} | docker login --username AWS --password-stdin ${REPOSITORY_PREFIX} -aws ecr create-repository --repository-name random-traffic-generator --region ${region} || true -docker build -t random-traffic-generator:latest . -docker tag random-traffic-generator:latest ${REPOSITORY_PREFIX}/random-traffic-generator:latest -docker push ${REPOSITORY_PREFIX}/random-traffic-generator:latest - -sed -e 's#\${REPOSITORY_PREFIX}'"#${REPOSITORY_PREFIX}#g" -e 's#\${URL}'"#$endpoint#g" deployment.yaml | kubectl apply -f - - - diff --git a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/deployment.yaml b/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/deployment.yaml deleted file mode 100644 index 8a79b0e81..000000000 --- a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/deployment.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -apiVersion: apps/v1 -kind: Deployment -metadata: - name: random-traffic-generator - labels: - app: random-traffic-generator -spec: - replicas: 1 - selector: - matchLabels: - app: random-traffic-generator - template: - metadata: - labels: - app: random-traffic-generator - spec: - containers: - - name: random-traffic-generator - image: ${REPOSITORY_PREFIX}/random-traffic-generator:latest - env: - - name: URL - value: "${URL}" - diff --git a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/index.js b/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/index.js deleted file mode 100644 index 9a9d07752..000000000 --- a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/index.js +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -const axios = require('axios'); -const cron = require('node-cron'); - -const vehicleURL = process.env.URL ? `${process.env.URL}/vehicle-inventory` : 'http://0.0.0.0:8001/vehicle-inventory' - -function getRandomNumber(min, max) { - return Math.floor(Math.random() * (max - min + 1)) + min; -} - - -function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} - -console.log(vehicleURL) - -// sends two requests every minute, 1 POST request and 1 GET request -const postGetCarsTrafficTask = cron.schedule('* * * * *', async () => { - console.log('add 1 car every 1 minutes'); - const carData = {"make": "BMW", "model": "M340", "year": 2022, "image_name": "newCar.jpg"} - axios.post(`http://${vehicleURL}/`, carData, { timeout: 10000 }) - .catch(err => { - console.error(err.response && err.response.data); - }); - - // gets image from image service through the vehicle service - axios.get(`http://${vehicleURL}/1/image`, { timeout: 10000 }) - .catch(err => { - console.error(`${err.response}, ${err.response.data}`); - }); // Catch and log errors - - axios.get(`http://${vehicleURL}/1`, { timeout: 10000 }) - .catch(err => { - console.error(err.response && err.response.data); - }); // Catch and log errors -}, { scheduled: false }); -postGetCarsTrafficTask.start(); - -// sends a burst of traffic sending 10 requests every 15 mins: -// 5 POST requests and 5 GET requests. -const postGetCarsTrafficBurstTask = cron.schedule('*/15 * * * *', async () => { - console.log('add 5 cars within 1 minutes'); - const carData = {"make": "BMW", "model": "M340", "year": 2022, "image_name": "newCar.jpg"} - for (let i = 0; i < 5; i++) { - axios.post(`http://${vehicleURL}/`, carData, { timeout: 10000 }) - .catch(err => { - console.error(err.response && err.response.data); - }); // Catch and log errors - - // gets image from image service through the vehicle service - axios.get(`http://${vehicleURL}/1/image`, { timeout: 10000 }) - .catch(err => { - console.error(err.response && err.response.data); - }); // Catch and log errors - } -}, { scheduled: false }); -postGetCarsTrafficBurstTask.start(); - -// sends a GET request with custom throttle parameter in the body that mimics being throttled. The throttle time -// is going to be random between 2 - 5 secs. -const getCarThrottle = cron.schedule('*/5 * * * *', async () => { - sleepSecs = getRandomNumber(30,60); - console.log(`sleep ${sleepSecs} seconds`); - await sleep(sleepSecs*1000); - throttleSecs = getRandomNumber(2,5); - console.log(`request will be throttled for ${throttleSecs} seconds`) - axios.get(`http://${vehicleURL}/1`, {params: {"throttle": throttleSecs}}, { timeout: 10000 }) - .catch(err => { - console.error(err.response && err.response.data); - }); // Catch and log errors -}, { scheduled: false }); -getCarThrottle.start(); - -// sends an invalid GET request with a non existent car id to trigger 404 error -const getInvalidRequest = cron.schedule('*/5 * * * *', async () => { - sleepSecs = getRandomNumber(30,120); - console.log(`sleep ${sleepSecs} seconds`); - await sleep(sleepSecs*1000); - console.log("getting non existent car to trigger 404"); - axios.get(`http://${vehicleURL}/123456789`, { timeout: 10000 }) - .catch(err => { - console.error(err.response && err.response.data); - }); // Catch and log errors -}, { scheduled: false }); -getInvalidRequest.start(); - -// sends an invalid GET request with a non existent image name to trigger 500 error due to S3 Error: -// "An error occurred (NoSuchKey) when calling the GetObject operation: The specified key does not exist." -// The vehicle service will then return 404. -const getNonExistentImage = cron.schedule('*/5 * * * *', async () => { - sleepSecs = getRandomNumber(30,120); - console.log(`sleep ${sleepSecs} seconds`); - await sleep(sleepSecs*1000); - console.log('get an non existent image to trigger aws error'); - axios.get(`http://${vehicleURL}/image/doesnotexist.jpeg`) - .catch(err => { - console.error(err.response && err.response.data); - }); // Catch and log errors -}, { scheduled: false }); -getNonExistentImage.start(); \ No newline at end of file diff --git a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/package-lock.json b/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/package-lock.json deleted file mode 100644 index 53e4d4887..000000000 --- a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/package-lock.json +++ /dev/null @@ -1,126 +0,0 @@ -{ - "name": "random-traffic-generator", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "random-traffic-generator", - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "axios": "^1.4.0", - "node-cron": "^3.0.2" - } - }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" - }, - "node_modules/axios": { - "version": "1.6.7", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz", - "integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==", - "dependencies": { - "follow-redirects": "^1.15.4", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" - } - }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/follow-redirects": { - "version": "1.15.6", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", - "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, - "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/node-cron": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/node-cron/-/node-cron-3.0.3.tgz", - "integrity": "sha512-dOal67//nohNgYWb+nWmg5dkFdIwDm8EpeGYMekPMrngV3637lqnX0lbUcCtgibHTz6SEz7DAIjKvKDFYCnO1A==", - "dependencies": { - "uuid": "8.3.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" - }, - "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "bin": { - "uuid": "dist/bin/uuid" - } - } - } -} diff --git a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/package.json b/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/package.json deleted file mode 100644 index 74db18e0e..000000000 --- a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "random-traffic-generator", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "dependencies": { - "axios": "^1.4.0", - "node-cron": "^3.0.2" - } - } \ No newline at end of file diff --git a/sample-applications/vehicle-dealership-sample-app/script.sh b/sample-applications/vehicle-dealership-sample-app/script.sh deleted file mode 100644 index 6978b2243..000000000 --- a/sample-applications/vehicle-dealership-sample-app/script.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 - -account=$1 -cluster_name=$2 -region=$3 -password=$4 -s3_bucket=$5 - -rm VehicleInventoryApp/.env -touch VehicleInventoryApp/.env -rm ImageServiceApp/.env -touch ImageServiceApp/.env - -export REPOSITORY_PREFIX=${account}.dkr.ecr.$region.amazonaws.com -export POSTGRES_DATABASE=vehicle_inventory -export POSTGRES_USER=djangouser -export POSTGRES_PASSWORD=${password} -export S3_BUCKET=${s3_bucket} - -docker-compose build - -eksctl create cluster --name ${cluster_name} --region ${region} --zones ${region}a,${region}b -eksctl create addon --name aws-ebs-csi-driver --cluster ${cluster_name} --service-account-role-arn arn:aws:iam::${account}:role/Admin --region ${region} --force - -./scripts/push-ecr.sh ${region} - -./scripts/set-permissions.sh ${cluster_name} ${region} - -./scripts/deploy-eks.sh \ No newline at end of file diff --git a/sample-applications/vehicle-dealership-sample-app/scripts/deploy-eks.sh b/sample-applications/vehicle-dealership-sample-app/scripts/deploy-eks.sh deleted file mode 100755 index c9f7aae8a..000000000 --- a/sample-applications/vehicle-dealership-sample-app/scripts/deploy-eks.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 - -if [ -n "$1" ]; then - OPERATION="$1" -else - OPERATION="apply" -fi - -if [ -z "${REPOSITORY_PREFIX}" ] -then - echo "Please set the REPOSITORY_PREFIX" -else - for config in $(ls ./eks/*.yaml) - do - sed -e 's#\${REPOSITORY_PREFIX}'"#${REPOSITORY_PREFIX}#g" -e 's#\${POSTGRES_PASSWORD}'"#${POSTGRES_PASSWORD}#g" -e 's#\${S3_BUCKET}'"#${S3_BUCKET}#g" ${config} | kubectl ${OPERATION} -f - - done - - for config in $(ls ./eks/k8s-nginx-ingress/*.yaml) - do - sed -e 's#\${REPOSITORY_PREFIX}'"#${REPOSITORY_PREFIX}#g" -e 's#\${POSTGRES_PASSWORD}'"#${POSTGRES_PASSWORD}#g" -e 's#\${S3_BUCKET}'"#${S3_BUCKET}#g" ${config} | kubectl ${OPERATION} -f - - done -fi \ No newline at end of file diff --git a/sample-applications/vehicle-dealership-sample-app/scripts/push-ecr.sh b/sample-applications/vehicle-dealership-sample-app/scripts/push-ecr.sh deleted file mode 100755 index 37d050260..000000000 --- a/sample-applications/vehicle-dealership-sample-app/scripts/push-ecr.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 - -REGION=${1:-"us-east-1"} - -aws ecr get-login-password --region ${REGION} | docker login --username AWS --password-stdin ${REPOSITORY_PREFIX} - -aws ecr create-repository --repository-name pythonsampleapp/image-service --region ${REGION} || true -docker tag pythonsampleapp/image-service:latest ${REPOSITORY_PREFIX}/pythonsampleapp/image-service:latest -docker push ${REPOSITORY_PREFIX}/pythonsampleapp/image-service:latest - -aws ecr create-repository --repository-name pythonsampleapp/vehicle-inventory-service --region ${REGION} || true -docker tag pythonsampleapp/vehicle-inventory-service:latest ${REPOSITORY_PREFIX}/pythonsampleapp/vehicle-inventory-service:latest -docker push ${REPOSITORY_PREFIX}/pythonsampleapp/vehicle-inventory-service:latest \ No newline at end of file diff --git a/sample-applications/vehicle-dealership-sample-app/scripts/set-permissions.sh b/sample-applications/vehicle-dealership-sample-app/scripts/set-permissions.sh deleted file mode 100755 index 9a8a80eee..000000000 --- a/sample-applications/vehicle-dealership-sample-app/scripts/set-permissions.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 - -#set -ex - -CLUSTER_NAME=${1:-"python-test"} -REGION=${2:-"us-east-1"} -OPERATION=${3:-"attach"} - - -POLICY_ARNS=( - "arn:aws:iam::aws:policy/AmazonSQSFullAccess" - "arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess" - "arn:aws:iam::aws:policy/CloudWatchLogsFullAccess" - "arn:aws:iam::aws:policy/AmazonS3FullAccess" - "arn:aws:iam::aws:policy/AmazonEC2FullAccess" -) - -NODE_GROUP=$(aws eks list-nodegroups --cluster-name "$CLUSTER_NAME" --region "$REGION" --output text | awk '{print $2}') - -role_arn=$(aws eks describe-nodegroup --cluster-name "$CLUSTER_NAME" --region "$REGION" --nodegroup-name "$NODE_GROUP" --query "nodegroup.nodeRole" --output text) -if [ -z "$role_arn" ]; then - echo "Error: Failed to retrieve the node group IAM role arn." - exit 1 -fi - -role_name=$(echo $role_arn | awk -F '/' '{print $NF}') - -if [ "$OPERATION" == "attach" ]; then - echo "Attaching policies to the node group..." - - for policy_arn in "${POLICY_ARNS[@]}"; do - aws iam attach-role-policy --role-name "$role_name" --policy-arn "$policy_arn" - done - - echo "Policies attached to the node group successfully." -else - echo "Removing policies in the node group..." - - for policy_arn in "${POLICY_ARNS[@]}"; do - aws iam detach-role-policy --role-name "$role_name" --policy-arn "$policy_arn" - done - - echo "Policies detached to the node group successfully." -fi - diff --git a/scripts/set-up-performance-tests.sh b/scripts/set-up-performance-tests.sh index a561eddc2..4df38fb14 100755 --- a/scripts/set-up-performance-tests.sh +++ b/scripts/set-up-performance-tests.sh @@ -30,6 +30,7 @@ if [ "$DISTRO" = "aws_opentelemetry_distro-*-py3-none-any.whl" ]; then fi # Create application images +# TODO: The vehicle sample app doesn't exist anymore so this needs to be cleaned up cd .. docker build . -t performance-test/vehicle-inventory-service -f performance-tests/Dockerfile-VehicleInventoryService-base --build-arg="DISTRO=${DISTRO}" if [ $? = 1 ]; then