Cluster Deploy #44
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: "Cluster Deploy" | |
on: | |
workflow_dispatch: | |
inputs: | |
CLUSTER_NAME: | |
description: 'Enter a Name for Cluster:' | |
type: string | |
required: true | |
DATACENTER: | |
description: 'DataCenter to deploy the cluster in:' | |
type: choice | |
default: "Houston" | |
required: true | |
options: | |
- Houston | |
- Kty | |
CONTROL_PLANE_ENDPOINT_IP: | |
description: 'IP Address to be used for VIP:' | |
type: string | |
required: true | |
CONTROL_PLANE_MACHINE_COUNT: | |
description: "Control plane nodes needed:" | |
default: 3 | |
required: true | |
type: number | |
WORKER_MACHINE_COUNT: | |
description: "Worker nodes needed:" | |
default: 3 | |
required: true | |
type: number | |
KUBERNETES_VERSION: | |
description: "Kubernetes Version:" | |
default: "v1.30.2" | |
required: true | |
type: choice | |
options: | |
- "v1.30.2" | |
- "v1.30.1" | |
CTRL_CPU: | |
description: "Control Plane CPU:" | |
default: 2 | |
required: true | |
type: number | |
CTRL_MEM: | |
description: "Control Plane Memory in GB:" | |
default: 4 | |
required: true | |
type: number | |
WKR_CPU: | |
description: "Worker CPU:" | |
default: 4 | |
required: true | |
type: number | |
WKR_MEM: | |
description: "Worker Memory in GB:" | |
default: 16 | |
required: true | |
type: number | |
env: | |
# Vars from inputs | |
CLUSTER_NAME: ${{ inputs.CLUSTER_NAME }} | |
DATACENTER: ${{ inputs.DATACENTER }} | |
NAMESPACE: ${{ inputs.DATACENTER }} | |
CONTROL_PLANE_ENDPOINT_IP: ${{ inputs.CONTROL_PLANE_ENDPOINT_IP }} | |
CONTROL_PLANE_MACHINE_COUNT: ${{ inputs.CONTROL_PLANE_MACHINE_COUNT }} | |
WORKER_MACHINE_COUNT: ${{ inputs.WORKER_MACHINE_COUNT }} | |
KUBERNETES_VERSION: ${{ inputs.KUBERNETES_VERSION }} | |
CTRL_CPU: ${{ inputs.CTRL_CPU }} | |
CTRL_MEM: ${{ inputs.CTRL_MEM }} | |
WKR_CPU: ${{ inputs.WKR_CPU }} | |
WKR_MEM: ${{ inputs.WKR_MEM }} | |
# Vars from Actions Vars and Secrets | |
VSPHERE_SERVER: ${{ secrets.VSPHERE_SERVER }} | |
VSPHERE_USERNAME: ${{ secrets.VSPHERE_USERNAME }} | |
VSPHERE_PASSWORD: ${{ secrets.VSPHERE_PASSWORD }} | |
VSPHERE_TLS_THUMBPRINT: ${{ secrets.VSPHERE_TLS_THUMBPRINT }} | |
VSPHERE_SSH_AUTHORIZED_KEY: ${{ secrets.VSPHERE_SSH_AUTHORIZED_KEY }} | |
PORTAINER_URL: ${{ secrets.PORTAINER_URL }} | |
PORTAINER_API_KEY: ${{ secrets.PORTAINER_API_KEY }} | |
KUBE_CONFIG: "${{ secrets.KUBE_CONFIG }}" | |
VSPHERE_DATACENTER: ${{ vars.VSPHERE_DATACENTER }} | |
VSPHERE_DATASTORE: ${{ vars.VSPHERE_DATASTORE }} | |
VSPHERE_NETWORK: ${{ vars.VSPHERE_NETWORK }} | |
VSPHERE_FOLDER: ${{ vars.VSPHERE_FOLDER }} | |
VSPHERE_RESOURCE_POOL: ${{ vars.VSPHERE_RESOURCE_POOL }} | |
VSPHERE_TEMPLATE: ${{ vars.VSPHERE_TEMPLATE }} | |
VSPHERE_STORAGE_POLICY: "" | |
jobs: | |
Cluster_Deploy: | |
runs-on: sdulam | |
steps: | |
- name: 'Checkout the Current Branch' | |
uses: actions/[email protected] | |
- name: "Setup Variables" | |
run: | | |
export NAMESPACE=$(echo $DATACENTER | tr -s '[:upper:]' '[:lower:]') | |
# export CTRL_MEM=$(($CTRL_MEM * 1024)) | |
# export WKR_MEM=$(($WKR_MEM * 1024)) | |
echo "$KUBE_CONFIG" > deploy/capi_mgmt_kubeconfig.yaml | |
# export KUBECONFIG=capi_mgmt_kubeconfig.yaml | |
pwd | |
- name: "Generate Cluster Yaml and Deploy" | |
run: | | |
export NAMESPACE=$(echo $DATACENTER | tr -s '[:upper:]' '[:lower:]') | |
export CTRL_MEM=$(($CTRL_MEM * 1024)) | |
export WKR_MEM=$(($WKR_MEM * 1024)) | |
ansible-playbook deploy/main.yaml | |
kubectl get clusters -n $NAMESPACE | |
sleep 120 | |
- name: "Generate KUBECONFIG for the workload cluster" | |
run: | | |
export NAMESPACE=$(echo $DATACENTER | tr -s '[:upper:]' '[:lower:]') | |
clusterctl get kubeconfig $CLUSTER_NAME -n $NAMESPACE > deploy/$CLUSTER_NAME-kubeconfig | |
kubectl get clusters -n $NAMESPACE --kubeconfig deploy/capi_mgmt_kubeconfig.yaml | |
kubectl get nodes --kubeconfig deploy/$CLUSTER_NAME-kubeconfig | |
- name: "Deploy CNI" | |
run: | | |
export KUBECONFIG=deploy/$CLUSTER_NAME-kubeconfig | |
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml | |
kubectl get pods -n kube-system | |