{"id":51116470,"url":"https://github.com/oracle-devrel/python-oci-bluegreen-oke-app","last_synced_at":"2026-06-24T22:30:32.549Z","repository":{"id":45661318,"uuid":"513919786","full_name":"oracle-devrel/python-oci-bluegreen-oke-app","owner":"oracle-devrel","description":"python-oci-bluegreen-oke-app","archived":false,"fork":false,"pushed_at":"2025-01-21T20:29:56.000Z","size":3980,"stargazers_count":6,"open_issues_count":0,"forks_count":32,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-04-21T19:34:12.468Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"upl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oracle-devrel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-14T13:50:15.000Z","updated_at":"2026-03-20T00:56:05.000Z","dependencies_parsed_at":"2025-01-21T21:35:17.944Z","dependency_job_id":null,"html_url":"https://github.com/oracle-devrel/python-oci-bluegreen-oke-app","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"oracle-devrel/repo-template","purl":"pkg:github/oracle-devrel/python-oci-bluegreen-oke-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-devrel%2Fpython-oci-bluegreen-oke-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-devrel%2Fpython-oci-bluegreen-oke-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-devrel%2Fpython-oci-bluegreen-oke-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-devrel%2Fpython-oci-bluegreen-oke-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oracle-devrel","download_url":"https://codeload.github.com/oracle-devrel/python-oci-bluegreen-oke-app/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-devrel%2Fpython-oci-bluegreen-oke-app/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34752465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-24T02:00:07.484Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2026-06-24T22:30:30.526Z","updated_at":"2026-06-24T22:30:32.513Z","avatar_url":"https://github.com/oracle-devrel.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sample illustration of OCI Devops deployment pipeline with *BLUE-GREEN* deployment strategies using Oracle Container Engine for Kubernetes (OKE).\n\n[![License: UPL](https://img.shields.io/badge/license-UPL-green)](https://img.shields.io/badge/license-UPL-green) [![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=python-oci-bluegreen-oke-app)](https://sonarcloud.io/dashboard?id=python-oci-bluegreen-oke-app)\n\n\n\n------------\n\n\nObjective\n---\n\n- Create OCI Devops build pipeline.\n- Build a sample python application.\n- Push the artifact to OCI Container and OCI Artifact repo.\n- Use OCI Deployment pipeline with BLUE/GREEN Deployment strategies.\n- Validate deployment and manual role back.\n\n\n\nProcedure\n---\n\n- Create an OCI container registry . https://docs.oracle.com/en-us/iaas/Content/Registry/home.htm\n\n![](images/oci-container-repo.png)\n\n\n- Create an OCI artifact registry . https://docs.oracle.com/en-us/iaas/Content/artifacts/home.htm\n\n![](images/oci-artifact-repo.png)\n\n- Set policies \u0026 create a devops project - https://docs.oracle.com/en-us/iaas/Content/devops/using/home.htm.\n\n\n![](images/oci-devops-project.png)\n\n\n- Create devops artifacts. - https://docs.oracle.com/en-us/iaas/Content/devops/using/artifacts.htm\n\n- Create an artifact with type `Docker image` for build to push the artifact.Ensure use your `container repo` url,with `${BUILDRUN_HASH}` at the end of the URL.This is to make the docker image version as dynamic.\n\n![](images/oci-devops-artifact-docker.png)\n\n\n- Create an artifact as type `Kubernetes manifest`.Enusure to add your `artifact repo` path and version as `${BUILDRUN_HASH}` .\n\n![](images/oci-artifact-repo-path.png)\n\n![](images/oci-artifact-repo-path-2.png)\n\n\n\n- You can clone this repo and push to an OCI Code repo .Or create github repo by using `import` option to this repo to your github profile.\n\n    - Managing code repo for OCI Devops - https://docs.oracle.com/en-us/iaas/Content/devops/using/managing_coderepo.htm\n\n\n- Create an OCI devops build pipeline. https://docs.oracle.com/en-us/iaas/Content/devops/using/create_buildpipeline.htm\n\n![](images/oci-devops-buidpipeline.png)\n\n- Add a `manage build` stage to the build pipe line . https://docs.oracle.com/en-us/iaas/Content/devops/using/add_buildstage.htm\n\n\n![](images/oci-manage-build-1.png)\n![](images/oci-manage-build-1-1.png)\n\n- Accordingly select the `code repo /connection type /repo name`.\n\nIf you are using a code repo other than `OCI code repo` ,ensure to set an external connection - https://docs.oracle.com/en-us/iaas/Content/devops/using/create_connection.htm\n\n![](images/oci-manage-build-2.png)\n\n\n- Add an `Deliver artifact` stage to the build pipeline.\n\n![](images/oci-build-upload-artifact-1.png)\n\n- Select the two `artifacts` created.\n\n![](images/oci-build-upload-artifact-2.png)\n\n- Associate the build stage `output artifact` names .\n\n![](images/oci-build-upload-artifact-3.png)\n\n- Snippet from [build_spec.yaml.](build_spec.yaml) with output artifacts.\n\n```\noutputArtifacts:\n  - name: oke_app_base\n    type: DOCKER_IMAGE\n    # this location tag doesn't effect the tag used to deliver the container image\n    # to the Container Registry\n    location: oke_app_base:latest\n\n  - name: oke_deploy_manifest\n    type: BINARY\n    # this location tag doesn't effect the tag used to deliver the container image\n    # to the Container Registry\n    location: ${OCI_PRIMARY_SOURCE_DIR}/oci-oke-deployment.yaml\n```\n\n- Create a new OKE (With public endpoint and public or private workers) - https://docs.oracle.com/en-us/iaas/Content/ContEng/home.htm .You may reuse an existing one accordingly . Use `Access cluster` option to set your access to `OKE`.\n\n![](images/oci-oke.png)\n\n\n- Create a new devops environment as type `Kubernete Cluster`.-https://docs.oracle.com/en-us/iaas/Content/devops/using/create_oke_environment.htm\n\n\n![](images/oci-devops-oke-env.png)\n![](images/oci-devops-oke-env-2.png)\n\n\n- Create a new devops deployment pipeline. - https://docs.oracle.com/en-us/iaas/Content/devops/using/deployment_pipelines.htm\n\n![](images/oci-devops-deployment.png)\n\n- Add a stage as `Blue/Green Strategy`.\n\n![](images/oci-deploy-stage-bg-1.png)\n\n- Select the `Deployment type` as `OKE` and select the `environment` created.\n\n- Associate the the `oke environment` created.\n\n![](images/oci-deploy-stage-bg-2.png)\n\n\n- Select Namespace A as `ns-green` and Namespace B as `ns-blue`.(These are names for test ,you may use other names accordingly)\n\n![](images/oci-deploy-stage-bg-3.png)\n\n- Select the `Kubernetes Artifacts`.\n\n![](images/oci-deploy-stage-bg-4.png)\n\n- Fill the ingress name as `sample-oke-bg-app-ing` .Its the sample ingress name declared via [deployment manifest.](oci-oke-deployment.yaml)\n\n![](images/oci-deploy-stage-bg-5.png)\n\n- As its a demo keep the `Validation controls` as `None`or you may connect with a function to validate the deployment.\n\n![](images/oci-deploy-bg-validation.png)\n\n- Enable the `Approval controls` and add `1` as the number of approvers.\n\n![](images/oci-deploy-approval.png)\n\n- Click add to add the stages.\n\n![](images/oci-deploy-all-stages.png)\n\n\n- Switch back to `Build pipeline` and add a `Trigger Deployment` stage.Select the deployment pipeline and associate.Ensure to `check` the Send build pipelines Parameters option.\n\n![](images/oci-build-trigger-deploy.png)\n\n\n- In order to run the blue green we should install `Nginx Ingress Controller` to our `OKE` cluster.\n- Launch `OCI Cloud shell` to enable the OKE access.\n- Follow the instruction via `Access Cluster` tab for the OKE cluster.\n\n![](images/oci-oke.png)\n\n- Validate the kubernetes access using `kubectl get nodes` \u0026 `kubectl config view`.\n\n![](images/kubectl-get-nodes.png)\n\n- We will be following the procedure to install and setup `Ingress Controller` - https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengsettingupingresscontroller.htm\n\n- Create a `clusterrolebinding` with user `ocid`.\n\n```\nkubectl create clusterrolebinding oke_cluster_role_\u003cusername\u003e --clusterrole=cluster-admin --user=ocid1.user.oc1..xxx\n```\n\n\n- Install the Ingress controller,always use the latest version. - https://github.com/kubernetes/ingress-nginx#changelog\n\n```\nkubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.2/deploy/static/provider/cloud/deploy.yaml\n```\n\n- Create and save the file cloud-generic.yaml containing the following code to define the ingress-nginx ingress controller service as a load balancer service.\n\n```\nkind: Service\napiVersion: v1\nmetadata:\n  name: ingress-nginx\n  namespace: ingress-nginx\n  labels:\n    app.kubernetes.io/name: ingress-nginx\n    app.kubernetes.io/part-of: ingress-nginx\nspec:\n  type: LoadBalancer\n  selector:\n    app.kubernetes.io/name: ingress-nginx\n    app.kubernetes.io/part-of: ingress-nginx\n  ports:\n    - name: http\n      port: 80\n      targetPort: http\n    - name: https\n      port: 443\n      targetPort: https\n\n```\n\n- Using the file you just saved, create the ingress-nginx ingress controller service by running the following command.\n\n```\nkubectl apply -f cloud-generic.yaml\n```\n\n- You may follow the procedure to create a TLS certificate for nginx.\n\n```\nopenssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout tls.key -out tls.crt -subj \"/CN=nginxsvc/O=nginxsvc\"\nkubectl create secret tls tls-secret --key tls.key --cert tls.crt\n```\n\n- You may skip the sample application example in the procedure.\n\n- Validate the installation.\n\n```\nkubectl get svc -n ingress-nginx\n```\n- The EXTERNAL-IP for the ingress-nginx ingress controller service is shown as `pending` until the load balancer has been fully created in Oracle Cloud Infrastructure.Repeat the kubectl get svc command until an EXTERNAL-IP is shown for the ingress-nginx ingress controller service.\n\n\n![](images/kubectl-get-svc.png)\n\n- Create two new namespaces for the deployment.\n\n```\nkubectl create ns ns-blue;kubectl create ns  ns-green\n```\n\n- Go back to build pipeline and do click `Start manual run`.\n\n![](images/oci-build-run-1.png)\n\n- Wait untill all the  `build stages` completed.\n\n![](images/oci-build-run-2.png)\n\n- Switch to the `deployment pipeline` and click on the deployment which is in `progress`.\n\n![](images/oci-deploy-bg-1.png)\n\n- The pipeline will be pending for `Approval` stage.\n- Validate the first deployment at this stage.You should see a valid deployments at namespace `ns-green`.\n\n```\nfor i in ns-green ns-blue ; do echo \"-- NS:$i --\";kubectl get po,ing -n $i; done\n\n```\n\n![](images/oci-deploy-bg-validate-1.png)\n\n- Click on the `3 dots` and validate the `Control:Approval` stage.\n\n![](images/oci-deploy-bg-approval-1.png)\n![](images/oci-deploy-bg-approval-2.png)\n\n- Wait for all the steps to complete.\n\n![](images/oci-deploy-bg-all-stages.png)\n\n- Validate the deployment using the `Ingress Address`.\n\n```\ncurl -k http://\u003cIngress Address\u003e\n```\n\n- Edit the source code - `main.py` and change the version to `0.1` and run the build pipeline again to test a new deployment scenario.\n\n```\nfrom typing import Optional\n\nfrom fastapi import FastAPI\n\nimport os\n\napp = FastAPI()\n\n\n@app.get(\"/\")\ndef read_root():\n    version=\"0.0\"\n    namespace = os.getenv('POD_NAMESPACE', default = 'ns-red')\n    return {\"Message\": \"with Love from OCI Devops \",\"Version\":version,\"Namespace\":namespace}\n```\n\n- Go back to build pipeline and do click `Start manual run`.\n\n![](images/oci-build-run-1.png)\n\n- Wait untill all the  `build stages` completed.\n\n![](images/oci-build-run-2.png)\n\n- Switch to the `deployment pipeline` and click on the deployment which is in `progress`.\n\n![](images/oci-deploy-bg-1.png)\n\n- The pipeline will be pending for `Approval` stage.\n- Validate the first deployment at this stage.You should see a valid deployments at namespace `ns-blue` too.\n\n```\nfor i in ns-green ns-blue ; do echo \"-- NS:$i --\";kubectl get po,ing -n $i; done\n\n```\n\n![](images/oci-deploy-bg-stage-2.png)\n\n- Validate the deployment using the `Ingress Address`.\n\n```\ncurl -k http://\u003cIngress Address\u003e\n```\n\nOutput :\n\n```\n{\"Message\":\"with Love from OCI Devops \",\"Version\":\"0.1\",\"Namespace\":\"ns-blue\"}\n```\n\n- You can continue other re-run from build pipeline and validate the switch between environment.\n\n- Let us now try a `Manul roleback`.\n\n- Use the `3 dots` at the stage `Traffic Shift` stage and select `Manual Rollback`.\n\n![](images/oci-deploy-bg-roleback-1.png)\n\n- Select a previously sucessful deployment.\n\n![](images/oci-deploy-bg-roleback-2.png)\n\n- Close the `select deployment` page and click `Rollback Stage` option.\n\n![](images/oci-deploy-bg-roleback-3.png)\n\n- Wait for stage to complete .\n\n![](images/oci-deploy-bg-rolleback-done.png)\n\n- Validate the deployment using the `Ingress Address`.\n\n```\ncurl -k http://\u003cIngress Address\u003e\n```\n\nOutput :\n\n```\n{\"Message\":\"with Love from OCI Devops \",\"Version\":\"0.0\",\"Namespace\":\"ns-green\"}\n```\n\nNote : Re-Run of deployment pipeline with OKE Blue-Green stage is not supported for now.\n\n\nRead more\n----\n\n\n- OCI Devops - https://docs.oracle.com/en-us/iaas/Content/devops/using/home.htm.\n- OCI Reference architectures  -  https://docs.oracle.com/solutions/\n- OCI Devops samples - https://github.com/oracle-devrel/oci-devops-examples\n\n\n## Contributing\nThis project is open source.  Please submit your contributions by forking this repository and submitting a pull request!  Oracle appreciates any contributions that are made by the open source community.\n\n## License\nCopyright (c) 2024 Oracle and/or its affiliates.\n\nLicensed under the Universal Permissive License (UPL), Version 1.0.\n\nSee [LICENSE](LICENSE.txt) for more details.\n\nORACLE AND ITS AFFILIATES DO NOT PROVIDE ANY WARRANTY WHATSOEVER, EXPRESS OR IMPLIED, FOR ANY SOFTWARE, MATERIAL OR CONTENT OF ANY KIND CONTAINED OR PRODUCED WITHIN THIS REPOSITORY, AND IN PARTICULAR SPECIFICALLY DISCLAIM ANY AND ALL IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.  FURTHERMORE, ORACLE AND ITS AFFILIATES DO NOT REPRESENT THAT ANY CUSTOMARY SECURITY REVIEW HAS BEEN PERFORMED WITH RESPECT TO ANY SOFTWARE, MATERIAL OR CONTENT CONTAINED OR PRODUCED WITHIN THIS REPOSITORY. IN ADDITION, AND WITHOUT LIMITING THE FOREGOING, THIRD PARTIES MAY HAVE POSTED SOFTWARE, MATERIAL OR CONTENT TO THIS REPOSITORY WITHOUT ANY REVIEW. USE AT YOUR OWN RISK. \n\nContributors\n===========\n\n- Author : [Rahul M R](https://github.com/RahulMR42)\n- Colloboroators : NA\n- Last release : March 2022","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foracle-devrel%2Fpython-oci-bluegreen-oke-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foracle-devrel%2Fpython-oci-bluegreen-oke-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foracle-devrel%2Fpython-oci-bluegreen-oke-app/lists"}