mirror of
https://github.com/dadosfera/maestro.git
synced 2026-08-31 19:58:21 +00:00
137 lines
4.4 KiB
YAML
137 lines
4.4 KiB
YAML
name : K8s deploy
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
cloud:
|
|
description: "Cloud provider for the deployment"
|
|
required: true
|
|
default: "azure"
|
|
type: string
|
|
environment:
|
|
description: "Deployment environment"
|
|
required: true
|
|
default: "prd"
|
|
type: string
|
|
image:
|
|
description: "Image Tag"
|
|
required: true
|
|
type: string
|
|
|
|
jobs:
|
|
azure:
|
|
if: inputs.cloud == 'azure'
|
|
runs-on: [self-hosted, "prd-azure"]
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Helm
|
|
uses: azure/setup-helm@v1
|
|
with:
|
|
version: 'v3.9.0'
|
|
|
|
- name: Install Azure ClI
|
|
run: |
|
|
curl -sL https://aka.ms/InstallAzureCLIDeb | bash
|
|
|
|
- uses: azure/login@v2
|
|
with:
|
|
creds: '{"clientId":"${{ secrets.ARM_CLIENT_ID }}","clientSecret":"${{ secrets.ARM_CLIENT_SECRET }}","subscriptionId":"${{ secrets.ARM_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.ARM_TENANT_ID }}"}'
|
|
|
|
- name: Authenticate with cluster
|
|
env:
|
|
CLUSTER_NAME: platform-${{ inputs.environment }}
|
|
run: az aks get-credentials --resource-group dadosfera-prd --name ${CLUSTER_NAME} --overwrite-existing
|
|
|
|
- name: Setup kubectl
|
|
uses: azure/setup-kubectl@v1
|
|
with:
|
|
version: 'v1.30.1'
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.8'
|
|
|
|
- name: Install Helmfile
|
|
run: |
|
|
curl -fsSLO https://github.com/helmfile/helmfile/releases/download/v0.148.0/helmfile_0.148.0_linux_amd64.tar.gz
|
|
tar -xzf helmfile_0.148.0_linux_amd64.tar.gz
|
|
sudo mv helmfile /usr/local/bin/
|
|
helmfile --version
|
|
|
|
- name: Install Helm Diff Plugin
|
|
run: helm plugin install https://github.com/databus23/helm-diff || true
|
|
|
|
- name: Run Helmfile Apply
|
|
env:
|
|
ENV: ${{ inputs.environment }}
|
|
IMAGE_TAG: ${{ inputs.image }}
|
|
run: helmfile -f deploy/helmfiles/${ENV}.yaml sync --set image.tag=$IMAGE_TAG
|
|
|
|
oracle:
|
|
if: inputs.cloud == 'oracle'
|
|
runs-on: [self-hosted, "prd-oracle"]
|
|
env:
|
|
HOME: /home/runner
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Helm
|
|
uses: azure/setup-helm@v1
|
|
with:
|
|
version: 'v3.9.0'
|
|
|
|
- name: Install OCI CLI
|
|
env:
|
|
HOME: /home/runner
|
|
run: |
|
|
bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)" -- --accept-all-defaults
|
|
echo "$HOME/bin" >> $GITHUB_PATH
|
|
|
|
- name: Configure OCI CLI
|
|
run: |
|
|
mkdir -p ~/.oci || true
|
|
echo "${{ secrets.OCI_CONFIG }}" > ~/.oci/config
|
|
echo "${{ secrets.OCI_PRIVATE_KEY }}" > ~/.oci/oci_api_key.pem
|
|
chmod 600 ~/.oci/oci_api_key.pem
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.8'
|
|
|
|
- name: Install Helmfile
|
|
run: |
|
|
curl -fsSLO https://github.com/helmfile/helmfile/releases/download/v0.148.0/helmfile_0.148.0_linux_amd64.tar.gz
|
|
tar -xzf helmfile_0.148.0_linux_amd64.tar.gz
|
|
sudo mv helmfile /usr/local/bin/
|
|
helmfile --version
|
|
|
|
- name: Install Helm Diff Plugin
|
|
run: helm plugin install https://github.com/databus23/helm-diff || true
|
|
|
|
- name: Authenticate with OKE cluster
|
|
env:
|
|
ENV: ${{ inputs.environment }}
|
|
STG_CLUSTER_ID: "ocid1.cluster.oc1.sa-saopaulo-1.aaaaaaaagh3jvln52a3ebm3dodx6emmhv5bmfs7i7sv2k4zkbcbrzcl6v37q"
|
|
PRD_CLUSTER_ID: "ocid1.cluster.oc1.sa-saopaulo-1.aaaaaaaanf3vptl6hc2tzd4enfd2hfpsht3wikxww5xejc3l7cwfm6l3sndq"
|
|
run: |
|
|
if [ "$ENV" = "stg" ]; then
|
|
CLUSTER_ID=$STG_CLUSTER_ID
|
|
elif [ "$ENV" = "prd" ]; then
|
|
CLUSTER_ID=$PRD_CLUSTER_ID
|
|
else
|
|
echo "Unknown environment: $ENV"
|
|
exit 1
|
|
fi
|
|
|
|
oci ce cluster create-kubeconfig --cluster-id ${CLUSTER_ID} --file $HOME/.kube/config --region sa-saopaulo-1 --token-version 2.0.0 --kube-endpoint PRIVATE_ENDPOINT
|
|
|
|
- name: Run Helmfile Apply
|
|
env:
|
|
ENV: ${{ inputs.environment }}
|
|
IMAGE_TAG: ${{ inputs.image }}
|
|
run: helmfile -f deploy/helmfiles/${ENV}.yaml sync --set image.tag=$IMAGE_TAG |