-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
91901dd
commit 189fb5a
Showing
2 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: 'K8: Delete' | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
deployment_name: | ||
description: 'Deployment Name' | ||
required: true | ||
type: string | ||
|
||
# Special permissions required for OIDC authentication | ||
permissions: | ||
id-token: write | ||
contents: read | ||
actions: read | ||
|
||
jobs: | ||
k8-cluster-delete: | ||
name: 'K8: Delete Cluster Resources' | ||
runs-on: [self-hosted, "${{ github.ref_name }}"] | ||
environment: ${{ github.ref_name }} | ||
env: | ||
KUBERNETES_NAMESPACE: "${{ vars.KUBERNETES_NAMESPACE }}" | ||
KUBERNETES_CLUSTER_NAME: "${{ vars.KUBERNETES_CLUSTER_NAME }}" | ||
KUBERNETES_MANIFEST_PATH: "${{ vars.KUBERNETES_MANIFEST_PATH }}" | ||
AZURE_RESOURCE_GROUP: "${{ vars.AZURE_RESOURCE_GROUP }}" | ||
AZURE_STORAGE_ACCOUNT: ${{ vars.AZURE_STORAGE_ACCOUNT }} | ||
AZURE_STORAGE_FILE_SHARE: ${{ vars.AZURE_STORAGE_FILE_SHARE }} | ||
AZCOPY_VERSION: "v10" | ||
steps: | ||
# Checkout the repository to the GitHub Actions runner | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: GitHub Configuration | ||
run: git config --global url."https://oauth2:${{ secrets.GH_TOKEN }}@github.com".insteadOf https://github.com | ||
|
||
- name: Clone cicd-deployment-scripts | ||
run: git clone https://github.com/code-kern-ai/cicd-deployment-scripts.git | ||
|
||
# Install the latest version of Kubernetes CLI and configure the Kubernetes CLI configuration file with a Kubernetes Cloud user API token | ||
- name: Azure Login | ||
uses: azure/login@v2 | ||
with: | ||
client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
|
||
# Use kubelogin to configure your kubeconfig for Azure auth | ||
- name: Set up kubelogin for non-interactive login | ||
uses: azure/use-kubelogin@v1 | ||
with: | ||
kubelogin-version: 'v0.0.25' | ||
|
||
- uses: azure/aks-set-context@v3 | ||
with: | ||
resource-group: ${{ env.AZURE_RESOURCE_GROUP }} | ||
cluster-name: ${{ env.KUBERNETES_CLUSTER_NAME }} | ||
admin: 'false' | ||
use-kubelogin: 'true' | ||
|
||
- name: Delete Cluster Deployment | ||
shell: bash | ||
run: | | ||
bash cicd-deployment-scripts/k8s/delete.sh \ | ||
-n ${{ env.KUBERNETES_NAMESPACE }} \ | ||
-d ${{ inputs.deployment_name }} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# !/bin/bash | ||
set -e | ||
|
||
KUBERNETES_NAMESPACE="" | ||
KUBERNETES_DEPLOYMENT_NAME="" | ||
|
||
while getopts n:d: flag | ||
do | ||
case "${flag}" in | ||
n) KUBERNETES_NAMESPACE=${OPTARG};; | ||
d) KUBERNETES_DEPLOYMENT_NAME=${OPTARG};; | ||
esac | ||
done | ||
|
||
declare -A secret_rename_mapping=( \ | ||
["cognition-gateway"]="cg-gateway" \ | ||
["cognition-pdf2md"]="cg-gateway" \ | ||
["cognition-task-master"]="cg-task-master" \ | ||
["gates-gateway"]="gt-gateway" \ | ||
["kratos"]="kratos" \ | ||
["oathkeeper"]="oathkeeper" \ | ||
["object-storage"]="obj-storage" \ | ||
["platform-monitoring"]="plfm-monitor" \ | ||
["refinery-commercial-proxy"]="rf-comm-proxy" \ | ||
["refinery-config"]="rf-config" \ | ||
["refinery-doc-ock"]="rf-doc-ock" \ | ||
["refinery-embedder"]="rf-embedder" \ | ||
["refinery-gateway"]="rf-gateway" \ | ||
["refinery-gateway-proxy"]="rf-gw-proxy" \ | ||
["refinery-model-provider"]="rf-mdl-prvd" \ | ||
["refinery-neural-search"]="rf-nrl-search" \ | ||
["refinery-tokenizer"]="rf-tokenizer" \ | ||
["refinery-updater"]="rf-updater" \ | ||
["refinery-weak-supervisor"]="rf-weak-supvsr" \ | ||
["refinery-websocket"]="rf-websocket" \ | ||
["refinery-zero-shot"]="rf-zero-shot" \ | ||
) | ||
|
||
kubectl config set-context --current --namespace=$KUBERNETES_NAMESPACE | ||
echo "Context set to namespace: \"$KUBERNETES_NAMESPACE\"" | ||
|
||
KUBERNETES_SERVICE_NAME=$KUBERNETES_DEPLOYMENT_NAME | ||
KUBERNETES_SECRET_NAME=${secret_rename_mapping[$KUBERNETES_DEPLOYMENT_NAME]} | ||
|
||
kubectl delete deployment $KUBERNETES_DEPLOYMENT_NAME | ||
kubectl delete service $KUBERNETES_SERVICE_NAME | ||
kubectl delete secret $KUBERNETES_SECRET_NAME |