├── requirements.txt ├── release_files.json ├── Dockerfile ├── README.md ├── main.py ├── license_policy.yml ├── ingress-controller-service.yaml ├── repolinter.json ├── LICENSE └── oci-oke-deployment.yaml /requirements.txt: -------------------------------------------------------------------------------- 1 | fastapi 2 | uvicorn -------------------------------------------------------------------------------- /release_files.json: -------------------------------------------------------------------------------- 1 | // see https://github.com/oracle-devrel/action-release-zip-maker for docs 2 | [ 3 | ] -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python 2 | 3 | WORKDIR /code 4 | 5 | COPY ./requirements.txt /code/requirements.txt 6 | RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt 7 | COPY ./main.py /code/ 8 | 9 | CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sample illustration of OCI Devops deployment pipeline with Blue-Green deployment strategy using Oracle Container Engine for Kubernetes (OKE). 2 | Used in LAB 16-1 3 | [![License: UPL](https://img.shields.io/badge/license-UPL-green)](https://img.shields.io/badge/license-UPL-green) 4 | 5 | ------------ 6 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | 3 | from fastapi import FastAPI 4 | 5 | import os 6 | 7 | app = FastAPI() 8 | 9 | 10 | @app.get("/") 11 | def read_root(): 12 | version="0.1" 13 | namespace = os.getenv('POD_NAMESPACE', default = 'ns-red') 14 | return {"Message": "You are experimenting DevOps deployment strategies in OCI", "Version":version,"Namespace":namespace} 15 | -------------------------------------------------------------------------------- /license_policy.yml: -------------------------------------------------------------------------------- 1 | license_policies: 2 | - license_key: upl-1.0 3 | label: Approved License 4 | color_code: '#00800' 5 | icon: icon-ok-circle 6 | - license_key: bsd-simplified 7 | label: Approved License 8 | color_code: '#00800' 9 | icon: icon-ok-circle 10 | - license_key: bsd-new 11 | label: Approved License 12 | color_code: '#00800' 13 | icon: icon-ok-circle 14 | - license_key: mit 15 | label: Approved License 16 | color_code: '#00800' 17 | icon: icon-ok-circle 18 | -------------------------------------------------------------------------------- /ingress-controller-service.yaml: -------------------------------------------------------------------------------- 1 | # this is a ingress controller service as a LB service 2 | # This acts as a reverse proxy for prod and canary version of application. 3 | # More info - https://www.nginx.com/resources/glossary/reverse-proxy-vs-load-balancer/ 4 | apiVersion: v1 5 | kind: Service 6 | metadata: 7 | name: ingress-nginx 8 | namespace: ingress-nginx 9 | labels: 10 | app.kubernetes.io/name: ingress-nginx 11 | app.kubernetes.io/part-of: ingress-nginx 12 | spec: 13 | type: LoadBalancer 14 | selector: 15 | app.kubernetes.io/name: ingress-nginx 16 | app.kubernetes.io/part-of: ingress-nginx 17 | ports: 18 | - name: http 19 | port: 80 20 | targetPort: http 21 | - name: https 22 | port: 443 23 | targetPort: https 24 | 25 | -------------------------------------------------------------------------------- /repolinter.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/todogroup/repolinter/master/rulesets/schema.json", 3 | "version": 2, 4 | "axioms": {}, 5 | "rules": { 6 | "readme-file-exists" : { 7 | "level": "error", 8 | "rule": { 9 | "type": "file-existence", 10 | "options": { 11 | "globsAny": ["README*"] 12 | } 13 | } 14 | }, 15 | "license-file-exists" : { 16 | "level": "error", 17 | "rule": { 18 | "type": "file-existence", 19 | "options": { 20 | "globsAny": ["LICENSE*"] 21 | } 22 | } 23 | }, 24 | "copyright-notice-present" : { 25 | "level": "warning", 26 | "rule": { 27 | "type": "file-starts-with", 28 | "options": { 29 | "globsAll": ["**/*"], 30 | "skip-binary-files": true, 31 | "skip-paths-matching": { 32 | "extensions": ["yaml","yml","md","json","xml","tpl","ipynb","pickle","joblib","properties"], 33 | "patterns": ["\\.github"], 34 | "flags": "" 35 | }, 36 | "lineCount": 2, 37 | "patterns": [ 38 | "Copyright \\([cC]\\) [12][90]\\d\\d(\\-[12][90]\\d\\d)? Oracle and/or its affiliates\\." 39 | ], 40 | "succeed-on-non-exist": true 41 | } 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021 Oracle and/or its affiliates. 2 | 3 | The Universal Permissive License (UPL), Version 1.0 4 | 5 | Subject to the condition set forth below, permission is hereby granted to any 6 | person obtaining a copy of this software, associated documentation and/or data 7 | (collectively the "Software"), free of charge and under any and all copyright 8 | rights in the Software, and any and all patent rights owned or freely 9 | licensable by each licensor hereunder covering either (i) the unmodified 10 | Software as contributed to or provided by such licensor, or (ii) the Larger 11 | Works (as defined below), to deal in both 12 | 13 | (a) the Software, and 14 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 15 | one is included with the Software (each a "Larger Work" to which the Software 16 | is contributed by such licensors), 17 | 18 | without restriction, including without limitation the rights to copy, create 19 | derivative works of, display, perform, and distribute the Software and make, 20 | use, sell, offer for sale, import, export, have made, and have sold the 21 | Software and the Larger Work(s), and to sublicense the foregoing rights on 22 | either these or other terms. 23 | 24 | This license is subject to the following condition: 25 | The above copyright notice and either this complete permission notice or at 26 | a minimum a reference to the UPL must be included in all copies or 27 | substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 35 | SOFTWARE. -------------------------------------------------------------------------------- /oci-oke-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: sample-app-deployment 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: sample-bg-app 9 | replicas: 3 10 | template: 11 | metadata: 12 | labels: 13 | app: sample-bg-app 14 | spec: 15 | containers: 16 | - name: sample-bg-app 17 | # enter the path to your image, be sure to include the correct region prefix 18 | image: .ocir.io//: 19 | #for example, image: iad.ocir.io/oracletenacy/iad-dop-lab16-1-ocir-1/oci_sample_webapp_user22:${BUILDRUN_HASH} 20 | imagePullPolicy: Always 21 | ports: 22 | - containerPort: 80 23 | protocol: TCP 24 | livenessProbe: 25 | exec: 26 | command: 27 | - cat 28 | initialDelaySeconds: 5 29 | periodSeconds: 5 30 | env: 31 | - name: POD_NAMESPACE 32 | valueFrom: 33 | fieldRef: 34 | fieldPath: metadata.namespace 35 | #imagePullSecrets: 36 | #- name: ocirsecret 37 | 38 | --- 39 | apiVersion: v1 40 | kind: Service 41 | metadata: 42 | name: sample-bg-app-service 43 | annotations: 44 | service.beta.kubernetes.io/oci-load-balancer-shape: "10Mbps" 45 | spec: 46 | type: ClusterIP 47 | ports: 48 | - port: 8080 49 | protocol: TCP 50 | targetPort: 80 51 | selector: 52 | app: sample-bg-app 53 | --- 54 | apiVersion: networking.k8s.io/v1 55 | kind: Ingress 56 | metadata: 57 | name: sample-bg-app-ing 58 | annotations: 59 | kubernetes.io/ingress.class: "nginx" 60 | spec: 61 | # tls: 62 | # - secretName: tls-secret 63 | rules: 64 | - host: host.com 65 | #for example, - host: user22host.com 66 | http: 67 | paths: 68 | - path: / 69 | pathType: Prefix 70 | backend: 71 | service: 72 | name: sample-bg-app-service 73 | port: 74 | number: 8080 75 | --------------------------------------------------------------------------------