Skip to content

Commit 857c307

Browse files
authored
Create create-digitalocean-k8s-cluster.yml.yml
1 parent 2276a65 commit 857c307

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Create DigitalOcean Kubernetes Cluster
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
cluster_name:
7+
description: 'Cluster Name'
8+
required: true
9+
default: 'my-do-cluster'
10+
region:
11+
description: 'Region'
12+
required: false
13+
default: 'nyc1'
14+
node_size:
15+
description: 'Node Size'
16+
required: false
17+
default: 's-2vcpu-4gb'
18+
node_count:
19+
description: 'Node Count'
20+
required: false
21+
default: '2'
22+
23+
jobs:
24+
create-cluster:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Install doctl (DigitalOcean CLI)
31+
run: |
32+
curl -sSL https://github.com/digitalocean/doctl/releases/latest/download/doctl-$(uname -s)-$(uname -m) -o doctl
33+
chmod +x doctl
34+
sudo mv doctl /usr/local/bin/
35+
36+
- name: Authenticate with DigitalOcean
37+
env:
38+
DIGITALOCEAN_ACCESS_TOKEN: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
39+
run: |
40+
doctl auth init -t $DIGITALOCEAN_ACCESS_TOKEN
41+
42+
- name: Create Kubernetes Cluster
43+
env:
44+
CLUSTER_NAME: ${{ github.event.inputs.cluster_name }}
45+
REGION: ${{ github.event.inputs.region }}
46+
NODE_SIZE: ${{ github.event.inputs.node_size }}
47+
NODE_COUNT: ${{ github.event.inputs.node_count }}
48+
run: |
49+
doctl kubernetes cluster create $CLUSTER_NAME \
50+
--region $REGION \
51+
--size $NODE_SIZE \
52+
--count $NODE_COUNT \
53+
--wait
54+
55+
- name: Get Cluster Kubeconfig
56+
env:
57+
CLUSTER_NAME: ${{ github.event.inputs.cluster_name }}
58+
run: |
59+
doctl kubernetes cluster kubeconfig save $CLUSTER_NAME

0 commit comments

Comments
 (0)