Setup DigitalOcean K8s Cluster #20
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
name: Setup DigitalOcean K8s Cluster | |
on: | |
workflow_dispatch: | |
inputs: | |
CLUSTER_NAME: | |
description: 'Name of the Kubernetes cluster' | |
type: string | |
default: 'perfo-cluster' | |
required: true | |
NODE_SIZE: | |
description: 'Size of the nodes' | |
options: | |
- s-2vcpu-2gb | |
- s-4vcpu-8gb | |
- s-8vcpu-16gb | |
- s-16vcpu-32gb | |
type: choice | |
default: s-8vcpu-16gb | |
required: true | |
NODE_COUNT: | |
description: 'Number of nodes' | |
type: number | |
default: 3 | |
required: true | |
KUBERNETES_VERSION: | |
description: 'Kubernetes version to use' | |
type: string | |
default: '1.31' | |
required: true | |
ACCOUNT_ID: | |
description: 'Your account ID' | |
type: string | |
required: true | |
ACCESS_KEY: | |
description: 'Your access key' | |
type: string | |
required: true | |
STORAGE_VERSION: | |
description: 'storage version' | |
type: string | |
required: false | |
NODE_AGENT_VERSION: | |
description: 'node agent version' | |
type: string | |
required: false | |
ENABLE_KDR: | |
description: 'Enable KDR' | |
required: false | |
type: boolean | |
default: false | |
PRIVATE_NODE_AGENT: | |
description: 'Private node agent version' | |
required: false | |
type: string | |
jobs: | |
setup-cluster: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install kubectl | |
run: | | |
sudo snap install kubectl --classic | |
kubectl version --client --output=yaml | |
- name: Install doctl | |
uses: digitalocean/action-doctl@v2 | |
with: | |
token: ${{ secrets.DIGITALOCEAN_TOKEN }} | |
- name: Create Kubernetes Cluster | |
run: | | |
doctl kubernetes cluster create ${{ github.event.inputs.CLUSTER_NAME }} \ | |
--region fra1 \ | |
--version ${{ github.event.inputs.KUBERNETES_VERSION }} \ | |
--vpc-uuid 7ff72b70-98a3-4743-9e83-2f0131047d39 \ | |
--node-pool "name=default-pool;size=${{ github.event.inputs.NODE_SIZE }};count=${{ github.event.inputs.NODE_COUNT }}" \ | |
--wait | |
- name: Configure kubectl | |
run: | | |
doctl kubernetes cluster kubeconfig save ${{ github.event.inputs.CLUSTER_NAME }} | |
kubectl config set-context $(kubectl config current-context) --namespace=default | |
- name: Connect to the cluster | |
run: | | |
CLUSTER_ID=$(doctl kubernetes cluster get ${{ github.event.inputs.CLUSTER_NAME }} --format ID --no-header) | |
doctl kubernetes cluster kubeconfig save $CLUSTER_ID | |
- name: Run performance Test | |
env: | |
QUAYIO_REGISTRY_PASSWORD: ${{ secrets.QUAYIO_REGISTRY_PASSWORD }} | |
QUAYIO_REGISTRY_USERNAME: ${{ secrets.QUAYIO_REGISTRY_USERNAME }} | |
run: | | |
CMD="python performance.py -skip-cluster -nodes ${{ github.event.inputs.NODE_COUNT }} -account ${{ github.event.inputs.ACCOUNT_ID }} -accessKey ${{ github.event.inputs.ACCESS_KEY }}" | |
if [ ! -z "${{ github.event.inputs.STORAGE_VERSION }}" ]; then | |
CMD="$CMD -storage-version ${{ github.event.inputs.STORAGE_VERSION }}" | |
fi | |
if [ ! -z "${{ github.event.inputs.NODE_AGENT_VERSION }}" ]; then | |
CMD="$CMD -node-agent-version ${{ github.event.inputs.NODE_AGENT_VERSION }}" | |
fi | |
if [ "${{ github.event.inputs.ENABLE_KDR }}" == "true" ]; then | |
CMD="$CMD -kdr" | |
fi | |
if [ ! -z "${{ github.event.inputs.PRIVATE_NODE_AGENT }}" ]; then | |
CMD="$CMD -private-node-agent ${{ github.event.inputs.PRIVATE_NODE_AGENT }}" | |
fi | |
echo "Running command: $CMD" | |
eval $CMD |