Skip to content

feat: prepare release 2.5.1 for FinOps components #81

feat: prepare release 2.5.1 for FinOps components

feat: prepare release 2.5.1 for FinOps components #81

name: release-pullrequest-AKS
on:
pull_request:
branches:
- main
jobs:
install-AKS:
runs-on: ubuntu-latest
strategy:
matrix:
k8s_version: [ "1.31.7", "1.32.3" ]
steps:
- name: Extract and Store Trimmed Repository Name
run: |
REPO_CHART_NAME="${{ github.repository }}"
REPO_APP_NAME=$(echo "$REPO_CHART_NAME" | sed 's/-chart$//') # Remove "-chart" suffix if present
# Check if the trimmed repo exists
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/$REPO_APP_NAME")
if [[ "$HTTP_STATUS" -eq 200 ]]; then
echo "Using trimmed repository name: $REPO_APP_NAME"
echo "REPO_APP_NAME=$REPO_APP_NAME" >> $GITHUB_ENV
else
echo "Trimmed repository not found. Falling back to original repository name."
echo "REPO_APP_NAME=$REPO_CHART_NAME" >> $GITHUB_ENV
fi
- name: Use the Stored Variable
run: |
echo "Trimmed Repository Name: ${{ env.REPO_APP_NAME }}"
- name: Authenticate with GitHub App
id: authenticate
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}
- name: Extract latest App Version
uses: tdemin/find-latest-tag@v1
id: app_version
with:
repo: https://${{ steps.authenticate.outputs.token }}@github.com/${{ env.REPO_APP_NAME }}.git
- name: Extract latest Chart Version
uses: tdemin/find-latest-tag@v1
id: chart_version
with:
repo: https://${{ steps.authenticate.outputs.token }}@github.com/${{ github.repository }}.git
- name: Checkout
uses: actions/checkout@v3
- name: Print Version
run: |
echo APP_VERSION:${{steps.app_version.outputs.tag}}
echo CHART_VERSION:${{steps.chart_version.outputs.tag}}
- name: Replace Version in Chart.yaml
run: sed -i 's/CHART_VERSION/${{ steps.chart_version.outputs.tag }}/g' ./chart/Chart.yaml
- name: Print latest App Version
run: echo ${{ steps.app_version.outputs.tag }}
- name: Replace App Version in Chart.yaml
run: sed -i 's/APP_VERSION/${{ steps.app_version.outputs.tag }}/g' ./chart/Chart.yaml
- name: Set up Helm
uses: azure/[email protected]
- name: Helm lint
run: helm lint ./chart
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1
# Create the aso-credential secret to be used by Azure Service Operator.
- name: Create ASO Credential Secret
run: |
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
name: aso-credential
namespace: default
stringData:
AZURE_SUBSCRIPTION_ID: "${{ secrets.AZURE_SUBSCRIPTION_ID }}"
AZURE_TENANT_ID: "${{ secrets.AZURE_TENANT_ID }}"
AZURE_CLIENT_ID: "${{ secrets.AZURE_CLIENT_ID }}"
AZURE_CLIENT_SECRET: "${{ secrets.AZURE_CLIENT_SECRET }}"
EOF
- name: Install cert-manager using Helm
run: |
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install cert-manager jetstack/cert-manager --namespace cert-manager --set crds.enabled=true --wait --create-namespace --version=v1.17.1
- name: Install Azure Service Operator on Kind using Helm
run: |
helm repo add aso2 https://raw.githubusercontent.com/Azure/azure-service-operator/main/v2/charts
helm repo update
helm install aso2 aso2/azure-service-operator --create-namespace --wait --version=2.12.0 --namespace=azureserviceoperator-system --set crdPattern='resources.azure.com/*;containerservice.azure.com/*' --set replicaCount=1
# Prepare a sanitized version string (replace '.' with '-') and store it in K8S_VERSION_NODOT
- name: Prepare version variable
run: echo "K8S_VERSION_NODOT=$(echo '${{ matrix.k8s_version }}' | tr '.' '-')" >> $GITHUB_ENV
# Create a ResourceGroup CR that will serve as the owner for the ManagedCluster.
- name: Deploy ResourceGroup CR via ASO
run: |
echo "Deploying ResourceGroup for Kubernetes version ${{ matrix.k8s_version }}..."
cat <<EOF | kubectl apply -f -
apiVersion: resources.azure.com/v1api20200601
kind: ResourceGroup
metadata:
name: managedcluster-$K8S_VERSION_NODOT
namespace: default
spec:
location: northeurope
EOF
- name: Wait for ResourceGroup Provisioning
run: |
echo "Waiting for ResourceGroup resource to become Ready..."
kubectl wait --for=condition=Ready --timeout=600s resourcegroup/managedcluster-$K8S_VERSION_NODOT
- name: Deploy ManagedCluster CR via ASO
run: |
echo "Deploying ManagedCluster resource with Kubernetes version ${{ matrix.k8s_version }}..."
cat <<EOF | kubectl apply -f -
apiVersion: containerservice.azure.com/v1api20240901
kind: ManagedCluster
metadata:
name: managedcluster-$K8S_VERSION_NODOT
spec:
owner:
name: managedcluster-$K8S_VERSION_NODOT
location: "northeurope"
dnsPrefix: "aks-$K8S_VERSION_NODOT"
kubernetesVersion: "${{ matrix.k8s_version }}"
agentPoolProfiles:
- name: systempool
count: 2
vmSize: Standard_DS2_v2
mode: System
operatorSpec:
secrets:
adminCredentials:
name: "managedcluster-$K8S_VERSION_NODOT-kubeconfig"
key: "kubeconfig"
identity:
type: SystemAssigned
EOF
- name: Wait for ManagedCluster Provisioning
run: |
kubectl get managedcluster/managedcluster-$K8S_VERSION_NODOT -o yaml
- name: Wait for ManagedCluster Provisioning
run: |
echo "Waiting for ManagedCluster resource to become Ready..."
kubectl wait --for=condition=Ready --timeout=600s managedcluster/managedcluster-$K8S_VERSION_NODOT
- name: Retrieve ManagedCluster Kubeconfig
run: |
echo "Extracting kubeconfig from secret..."
kubectl get secret managedcluster-$K8S_VERSION_NODOT-kubeconfig -o jsonpath='{.data.kubeconfig}' | base64 -d > managedcluster-$K8S_VERSION_NODOT-kubeconfig.yaml
- name: Install Krateo PlatformOps with standard configuration
run: helm install installer-$K8S_VERSION_NODOT ./chart --create-namespace -n krateo-system-$K8S_VERSION_NODOT --wait --kubeconfig=managedcluster-$K8S_VERSION_NODOT-kubeconfig.yaml --set krateoplatformops.finopsoperatorcratedb.env.CRATEDB_OPERATOR_DEBUG_VOLUME_STORAGE_CLASS=default --set krateoplatformops.finopscratedbcustomresource.resources.disk.storageClass=default --set krateoplatformops.finopscratedbcustomresource.resources.disk.storageClass=default --set krateoplatformops.service.type=LoadBalancer --set krateoplatformops.service.externalIpAvailable=true
- name: Wait for krateoplatformops krateo to become ready
run: kubectl wait krateoplatformops krateo --for condition=Ready=True --timeout=600s --namespace krateo-system-$K8S_VERSION_NODOT --kubeconfig=managedcluster-$K8S_VERSION_NODOT-kubeconfig.yaml
- name: Get Krateo PlatformOps CR status on ManagedCluster
if: always()
run: kubectl get krateoplatformops krateo --namespace krateo-system-$K8S_VERSION_NODOT --kubeconfig=managedcluster-$K8S_VERSION_NODOT-kubeconfig.yaml -o yaml
- name: Get events on ManagedCluster
if: always()
run: kubectl get events -A --sort-by='.lastTimestamp' --kubeconfig=managedcluster-$K8S_VERSION_NODOT-kubeconfig.yaml
- name: Clean Up Krateo PlatformOps CR on ManagedCluster
if: always()
run: kubectl delete krateoplatformops krateo --namespace krateo-system-$K8S_VERSION_NODOT --kubeconfig=managedcluster-$K8S_VERSION_NODOT-kubeconfig.yaml
- name: Clean Up Installer Helm Chart on ManagedCluster
if: always()
run: helm uninstall installer-$K8S_VERSION_NODOT --namespace krateo-system-$K8S_VERSION_NODOT --kubeconfig=managedcluster-$K8S_VERSION_NODOT-kubeconfig.yaml
- name: Clean Up krateo-system namespace on ManagedCluster
if: always()
run: kubectl delete namespace krateo-system-$K8S_VERSION_NODOT --kubeconfig=managedcluster-$K8S_VERSION_NODOT-kubeconfig.yaml
- name: Clean Up ManagedCluster Resource
if: always()
run: kubectl delete managedcluster/managedcluster-$K8S_VERSION_NODOT
- name: Clean Up ResourceGroup CR
if: always()
run: kubectl delete resourcegroups/managedcluster-$K8S_VERSION_NODOT
- name: Get events
if: always()
run: kubectl get events -A --sort-by='.lastTimestamp'