{"id":24849279,"url":"https://github.com/bugbiteme/python-rest-api","last_synced_at":"2025-03-26T11:25:30.936Z","repository":{"id":229038010,"uuid":"775523587","full_name":"bugbiteme/python-rest-api","owner":"bugbiteme","description":"A generic REST API written in Python (fast API) ","archived":false,"fork":false,"pushed_at":"2024-05-08T21:35:05.000Z","size":873,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T12:36:09.289Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bugbiteme.png","metadata":{"files":{"readme":"README.INSTRUCTIONS.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-21T14:50:43.000Z","updated_at":"2024-05-08T21:35:09.000Z","dependencies_parsed_at":"2024-03-21T18:40:48.712Z","dependency_job_id":"45e84661-d27d-4ab6-8570-81984405404e","html_url":"https://github.com/bugbiteme/python-rest-api","commit_stats":null,"previous_names":["bugbiteme/python-rest-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugbiteme%2Fpython-rest-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugbiteme%2Fpython-rest-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugbiteme%2Fpython-rest-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugbiteme%2Fpython-rest-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bugbiteme","download_url":"https://codeload.github.com/bugbiteme/python-rest-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245642647,"owners_count":20648893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-31T12:30:26.373Z","updated_at":"2025-03-26T11:25:30.917Z","avatar_url":"https://github.com/bugbiteme.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenShift Virtualization with OpenShift Service Mesh\n![alt text](img/image.png)\n\n## Overview\nThe purpose of this demo is to demonstrate how to get additional value out of the OpenShift Platform, \nwhen looking at OCP as an option to host Virtual Machines (OpenShift Virtualization).   \n   \nThis demo environment shows the integration of OpenShift Virtualization with Service Mesh, a component included with the OpenShift Container Platform (OCP).\n\n### OpenShift Virtualization\n![screen shot](img/ocv1.png)\n\nOpenShift Virtualization is a feature within OpenShift, which is a platform designed to simplify the management of applications and services.\n\nOpenShift Virtualization brings the ability to manage both traditional virtual machines and containerized applications within the same platform. This means you can run and manage VMs alongside containerized applications, offering a flexible and efficient alternative way to host and manage your VMs. It allows users to migrate existing virtualized workloads to OpenShift and manage them using Kubernetes concepts and tools, which can simplify operations and improve resource utilization. In essence, OpenShift Virtualization provides a modern, hybrid approach to application hosting that leverages both VMs and containers' strengths.\n\n\n### OpenShift Service Mesh  \n![diagram](img/mesh01.png)\n\nOpenShift Service Mesh is a dedicated infrastructure layer for handling communication between services in OpenShift. It's built on top of the popular open-source project Istio, and it provides a way to connect, manage, and secure microservices without having to modify their code. Here are the key benefits and features of OpenShift Service Mesh:\n\n- Enhanced Communication Control: It gives you fine-grained control over how your services communicate with each other, including routing, load balancing, and failure recovery mechanisms.\n    \n- Security: Offers strong security features by default, including encrypted service-to-service communication, ensuring that sensitive data is protected as it moves within your cluster.\n    \n- Observability: Provides detailed insights into the behavior of your services, including metrics, logging, and tracing capabilities, which can help with debugging and monitoring.\n    \n- Simplified Operations: Automates many common networking tasks involved in managing microservices, reducing the complexity of deploying and managing your applications.\n\nA standout feature of OpenShift Service Mesh is its support for various rollout strategies for deploying new versions of services, such as canary deployments.\n\nCanary Deployment is a technique to reduce the risk of introducing a new software version in production by slowly rolling out the change to a small subset of users before making it available to everybody. The idea is to \"release\" the new version to a limited number of users (the \"canaries\") and monitor the performance and stability of the application. If everything goes well, the new version is gradually rolled out to the rest of the users. If issues are detected, the rollout can be halted or rolled back, minimizing the impact on the majority of users.\n\nThis capability allows developers to test new features and roll back if something goes wrong without affecting all users, providing a safer environment for continuous innovation and improvement. OpenShift Service Mesh facilitates implementing canary deployments and other sophisticated deployment strategies, enabling businesses to adopt a more agile and resilient approach to software delivery.\n\n### OpenShift Virtualization with Service Mesh\n\nOpenShift Virtualization allows for running VMs alongside containerized applications on the OpenShift platform. When you integrate these VMs with OpenShift Service Mesh, you essentially bring the advanced networking, security, and observability features of the service mesh to your virtualized workloads. This means that VMs can participate in the service mesh alongside containers, benefiting from consistent, policy-driven networking and security models.\n\nIntegrating VMs into OpenShift Service Mesh is especially beneficial for:\n\n- Legacy Applications: For applications that are not yet containerized or cannot be easily transitioned to containers, running them in VMs within the Service Mesh allows them to benefit from modern development practices and infrastructure without a complete rewrite.\n\n- Hybrid Applications: Applications that have components in both VMs and containers can interact more efficiently, with enhanced security and monitoring, facilitating a smoother migration path to fully containerized architectures.\n\n## Demo: Non-disruptivly Migrating from a Legacy VM Based Application to Modern Container Based Application \n\nMigrating from a legacy VM-based application to a modern container-based application in a non-disruptive manner is a critical task for many organizations aiming to modernize their infrastructure without affecting their current operations. Using a Service Mesh, specifically with canary deployment strategies, provides a controlled and effective pathway for this transition. \n\n### Instructions\n\n#### Install OpenShift Virtualization\nInstall OpenShift Virtualization using Operator Hub (as admin).\n\n#### Install and configure OpenShift Service Mesh\n*(logged in as admin)*\n1. Install OpenShift Service Mesh using Operator Hub (as admin)\n\n- Enable the following Service Mesh Operators \n  - OpenShift Elasticsearch Operator\n  - Red Hat OpenShift distributed tracing platform\n  - Kiali Operator (provided by Red Hat)\n  - Red Hat OpenShift Service Mesh\n\n*(logged in as user/non-admin)*   \n\n2. Create a project called `isio-system`\n3. While in the `isio-system` project, from the `Administrator` view:\n   - `Operators-\u003eInstalled Operators`\n   - Click on `Red Hat OpenShift Service Mesh`\n   - Click on `Create Instance` -\u003e `Create` (default settings)\n4. Observe the deployment on the Service Mesh Control Plane in the Topology view   \n![istio-system](img/istio-system.png)\n```\noc get pods -n istio-system\nNAME                                    READY   STATUS    RESTARTS   AGE\ngrafana-7854c4bc44-6b97l                2/2     Running   0          7m45s\nistio-egressgateway-5b6d946db7-7zk9t    1/1     Running   0          7m46s\nistio-ingressgateway-7c64676496-vcknz   1/1     Running   0          7m46s\nistiod-basic-69fcf6d7c8-h85tb           1/1     Running   0          8m31s\njaeger-85b69fbf95-7dggn                 2/2     Running   0          7m42s\nkiali-7495b469df-v4qrq                  1/1     Running   0          7m1s\nprometheus-6bc7d48f74-8gnn6             3/3     Running   0          8m18s\n```\n\n#### Deploy Kubernetes Resources\n![Initial Topology](img/topo1.png)\nI have created a script that will deploy all the Custom Resources needed to set up the demo:    \n\n```\n./setup-demo.sh    \n\nservicemeshmemberroll.maistra.io/default created\nservice/service-a created\nservice/service-b created\ndeployment.apps/service-a created\nvirtualmachine.kubevirt.io/fedora01 created\nvirtualservice.networking.istio.io/hello-vs created\ngateway.networking.istio.io/hello-gateway created\nvirtualservice.networking.istio.io/service-b created\ndestinationrule.networking.istio.io/service-b-destination-rule created\n```\nPlease note that you may need to wait a few minutes before the app is running on the VM becomes available (3-5 mins).\n\nTo test:\nA REST API called `service-a` is a front-end API that is registered with the istio-gateway with two paths:\n- `/hello` returns `{\"message\":\"Hello World from service-a\"}`\n- `/hello-service` calls service-b (currently running on a Fedora VM) returns `{\"response\":{\"message\":\"Hello World from fedora01\"}}`\n\n\n```\nexport GATEWAY=$(oc get route istio-ingressgateway -n istio-system -o template --template '{{ .spec.host }}')\n\n❯ curl $GATEWAY/hello\n\n{\"message\":\"Hello World from service-a\"}\n\n❯ curl $GATEWAY/hello-service\n\n{\"response\":{\"message\":\"Hello World from fedora01\"}}\n```\n\n### Start the Demo\n![demo](img/demo.png)\n\nTo visualize this demo, you should use Kiali to observe traffic as it flows from `service-a` to `service-b`.\nThis will also let you observe traffic topology as it transitions from VM1 to the `service-b-v1` pod.\n\nTo get the URL for Kiali\n\n```\noc get route kiali -n istio-system\n```\n\nYou should also have two terminals open showing the responses change from `fedora01` to `service-b-v1` as the roll out occures and a window to show the roll out istelf happening.\n\n- From terminal 1\n```\n ./generate-traffic.sh\n \n{\"response\":{\"message\":\"Hello World from fedora01\"}}\n\n{\"response\":{\"message\":\"Hello World from fedora01\"}}\n\n{\"response\":{\"message\":\"Hello World from fedora01\"}}\n...\n...\n```\n\nOnce you have established service-b is returning a response from the VM, create a deployment of the service-b pod:\n\n- From terminal 2\n```\noc apply -f k8/deploy-serviceb-v1.yaml    \n\ndeployment.apps/service-b-v1 created\n```\nvalidate the deployment\n\n![Deploy new service](img/topo2.png)\n```\noc get pods   \n\nNAME                           READY   STATUS    RESTARTS   AGE\nservice-a-865d68dfdd-2dkfs     2/2     Running   0          32m\nservice-b-v1-c46576c9-2srwm    2/2     Running   0          45s\nvirt-launcher-fedora01-8vcgh   3/3     Running   0          32m\n```\nAt this point there is no traffic going to the service-b-v1 pod\n\nInitiate the role out to start directing traffic to the newly deployed pod\n\n```\n./deploy-VM1-v1.sh\n\nvirtualservice.networking.istio.io/service-b unchanged\nall traffic is routed to VM1\nvirtualservice.networking.istio.io/service-b configured\n90% traffic is routed to VM1 10% to pod\nvirtualservice.networking.istio.io/service-b configured\n75% traffic is routed to VM1 25% to pod\nvirtualservice.networking.istio.io/service-b configured\n50% traffic is routed to VM1 50% to pod\nvirtualservice.networking.istio.io/service-b configured\n25% traffic is routed to VM1 75% to pod\nvirtualservice.networking.istio.io/service-b configured\n10% traffic is routed to VM1 90% to pod\nvirtualservice.networking.istio.io/service-b configured\nAll traffic is routed to pod\n```\n\nYou should slowly start seeing the output change from: \n```\n{\"response\":{\"message\":\"Hello World from fedora01\"}}\n\n{\"response\":{\"message\":\"Hello World from fedora01\"}}\n...\n...\n```\n\nto:\n```\n{\"response\":{\"message\":\"Hello World from service-b-v1\"}}\n\n{\"response\":{\"message\":\"Hello World from service-b-v1\"}}\n\n{\"response\":{\"message\":\"Hello World from service-b-v1\"}}\n```\n\nYou can also observe this with Kiali (wich may lag behind by a minute)\n\nIn Kiali, make sure to display `Traffic Distribution`. `Response Time` is also good to display to show the benefits of running\nthe same workload in a container rather than a legacy VM.\n\n![VM](img/kiali01.png)\n![Mix](img/kiali02.png)\n![pod](img/kiali03.png)\n\n## TODO\nThere is always room for improvement, but this demo was meant to keep it as simple as possible. This is open source, so feel free to make it better!\n    \n       \nSome ideas:\n- Deploy rources with GitOps/ArgoCD\n- Build the new ap/pod with Pipelines/Tekton\n- Use Argo Rollouts to auto roll out the pod\n- Promote between environments (dev/test/prod)\n- More robust VM deployment\n- etc...","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugbiteme%2Fpython-rest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbugbiteme%2Fpython-rest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugbiteme%2Fpython-rest-api/lists"}