diff --git a/.github/workflows/production_deployment.yml b/.github/workflows/production_deployment.yml new file mode 100644 index 00000000..5eaabc2a --- /dev/null +++ b/.github/workflows/production_deployment.yml @@ -0,0 +1,44 @@ +name: Deploy to Production + +on: + release: + types: [created] + +jobs: + production_deploy: + runs-on: ubuntu-latest + environment: Production + steps: + - uses: actions/checkout@v2 + - uses: satackey/action-docker-layer-caching@v0.0.11 + continue-on-error: true + - name: push to dockerhub + uses: fylein/docker-release-action@master + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} + IMAGE_NAME: fyle_xero-api + - name: Deploy to Production + uses: fylein/aws-eks-deploy-action@master + env: + EKS_CLUSTER_NAME: ${{ secrets.EKS_CLUSTER_NAME }} + AWS_REGION: ${{ secrets.AWS_REGION }} + LOCAL_HOST: ${{ secrets.LOCAL_HOST }} + LOCAL_PORT: ${{ secrets.LOCAL_PORT }} + REMOTE_PORT: ${{ secrets.REMOTE_PORT }} + EKS_KUBECTL_ROLE: ${{ secrets.EKS_KUBECTL_ROLE }} + ROLE_SESSION_NAME: ${{ secrets.ROLE_SESSION_NAME }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + KUBERNETES_MANIFEST_FILE_PATH: deployment/production/controller.yml + - name: Slack Notification + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_COLOR: ${{ job.status }} + SLACK_MESSAGE: Production Deploy Status - ${{ job.status }} + SLACK_TITLE: Deploy Xero API to Production + SLACK_ICON_EMOJI: ":pepeok:" + SLACK_USERNAME: QBO_API + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_FOOTER: '' diff --git a/.github/workflows/deployment.yml b/.github/workflows/staging_deployment.yml similarity index 100% rename from .github/workflows/deployment.yml rename to .github/workflows/staging_deployment.yml diff --git a/.gitignore b/.gitignore index d1f0e77c..115b50b9 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ __pycache__/ # Test files test.py +debugger # Cache demo_cache.sqlite diff --git a/deployment/production/controller.yml b/deployment/production/controller.yml new file mode 100644 index 00000000..d786edd7 --- /dev/null +++ b/deployment/production/controller.yml @@ -0,0 +1,94 @@ +apiVersion: v1 +kind: Service +metadata: + name: xero-api + namespace: integrations + labels: + app: xero-api +spec: + ports: + - port: 8000 + selector: + app: xero-api + type: ClusterIP +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: xero-api + namespace: integrations + labels: + app: xero-api +spec: + replicas: 1 + selector: + matchLabels: + app: xero-api + strategy: + type: RollingUpdate + template: + metadata: + labels: + app: xero-api + spec: + containers: + - name: xero-api + image: docker.io/{{DOCKERHUB_USERNAME}}/fyle_xero-api:{{RELEASE_VERSION}} + resources: + limits: + memory: 300Mi + requests: + memory: 300Mi + env: + - name: GET_HOSTS_FROM + value: dns + ports: + - containerPort: 8000 + readinessProbe: + httpGet: + path: /api/workspaces/ready/ + port: 8000 + initialDelaySeconds: 10 + timeoutSeconds: 1 + envFrom: + - secretRef: + name: xero-api-secrets + imagePullSecrets: + - name: myregistrykey2 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: xero-api-qcluster + namespace: integrations + labels: + app: xero-api-qcluster +spec: + replicas: 1 + selector: + matchLabels: + app: xero-api-qcluster + strategy: + type: RollingUpdate + template: + metadata: + labels: + app: xero-api-qcluster + spec: + containers: + - name: xero-api + image: docker.io/{{DOCKERHUB_USERNAME}}/fyle_xero-api:{{RELEASE_VERSION}} + command: ['/bin/bash', 'start_qcluster.sh'] + resources: + limits: + memory: 650Mi + requests: + memory: 650Mi + env: + - name: GET_HOSTS_FROM + value: dns + envFrom: + - secretRef: + name: xero-api-secrets + imagePullSecrets: + - name: myregistrykey2