This repository is backgroud to leverage feature of github action and terraform technology for manage in lifecycle of Kubernetes on cloud platform and minimize effort to all contributed for operate Kubernetes cluster (Any XKS). And will continute update
- All credential in this project was designed to store on "secrets" on github. If you new with this. Please kindly following GitHub Secrets
- As project are coverage multiple cloud provider. So when you fork/clone this repository in action. You can consider to remove unused cloud provider's folder
- In case to create multiple cluster with same cloud provider. Please create new branch for operate , Create new secret of the {XXXX_CLUSTERNAME} and workflow file parameter to fit with your branch
Cloud provider's folder: aws-eks
- Video: Setup new repository and Create Azure environment
- Video: Create AKS cluster
- Video: Modify AKS cluster (Upgrade Version)
- Video: Modify AKS cluster (Change Worker)
- Video: Destroy AKS cluster
- Video: Destroy Azure environment
*Remark: For use this github action on Azure Portal. Please enable the preview feature 'microsoft.ContainerService/CustomNodeConfigPreview' by follow this KB Azure Enable Feature
Before start to create AKS cluster. Please input credential for operate on Azure Portal on github's "secrets" as detail below:
- {AZURE_CREDENTIALS}: Store output in JSON format of your service principle. If you not yet to create service principle. Please follow this KB Azure Service Principle
{ "clientId": "<GUID>", "clientSecret": "<GUID>", "subscriptionId": "<GUID>", "tenantId": "<GUID>", (...) }
- {AZURE_CLIENT_ID}: Input client id (You can check this from "{AZURE_CREDENTIALS}")
"Azure Client ID"
- {AZURE_CLIENT_SECRET}: Input client secret id (You can check this from "{AZURE_CREDENTIALS}")
"Azure Client Secret"
- {AZURE_SUBSCRIPTION_ID}: Input subscription id (You can check this from "{AZURE_CREDENTIALS}")
"Azure Subscription ID"
- {AZURE_TENANT_ID}: Input tanant id (You can check this from "{AZURE_CREDENTIALS}")
"Azure Tanent ID"
- {AZURE_REGION}: Input your region on portal. Ex:"eastasia" Region code
"Region Name"
- {AZURE_RESOURCEGROUP}: Input your resource group name for create other elements
"Resource Group Name"
- {AZURE_STORAGEACCOUNT}: Input your storage account name for keep terraform state on portal. Remark: Storage account name must be between 3 and 24 characters in length and use numbers and lower-case letters only
"Storage Account Name"
- {AZURE_CLUSTERNAME}: Input your AKS cluster name
"AKS Cluster Name"
-
Clone the repo
git clone https://github.com/praparn/github-action-x-any-xks.git
-
Setup "secrets" elements as explain in Prerequisites
-
Create Azure environment by commit and tag "aks-init-env*"
git pull git tag #check tag duplicate echo "aks-init-env-yyyymmddhhmmss" > ./azure-aks/result/result-env-init git add -A git commit -m "Any commend that you need" git tag aks-init-env-yyyymmddhhmmss -m "aks-init-env-yyyymmddhhmmss" git push --atomic origin <branch name> aks-init-env-yyyymmddhhmmss
-
Check progress on tab "action" until it finished. (Optional: Verify result on web console/cli for double check)
-
Edit properties of Kubernetes cluster on file "./azure-aks/terraform.tfvars" *Remark:
- Please check detail for each properties that can configure on file variable.tf
- Prohibited value start with ### XXX ### will be reserve for system
- Basic configure is avaliable on "#----------Basic System properties" and "#----------Basic AKS properties
- Advance configure is avaliable on "#----------Advance AKS properties"
-
Create AKS cluster by commit and tag "aks-init-cluster*"
git pull git tag #check tag duplicate echo "aks-cluster-create-yyyymmddhhmmss" > ./azure-aks/result/result-aks-init git add -A git commit -m "Any commend that you need" git tag aks-cluster-create-yyyymmddhhmmss -m "aks-cluster-create-yyyymmddhhmmss" git push --atomic origin <branch name> aks-cluster-create-yyyymmddhhmmss
-
Check progress on tab "action" until it finished. (Optional: Verify result on web console/cli for double check)
-
Check result of demo application by command:
git pull kubectl get ing -n=management-ui --kubeconfig=./azure-aks/aks-config
-
Download kubeconfig from file "aks-config" and check application demo on browser
git pull kubectl get nodes --kubeconfig=./azure-aks/aks-config kubectl get ing -n=management-ui --kubeconfig=./azure-aks/aks-config
- Edit properties of Kubernetes cluster on file "./azure-aks/terraform.tfvars"
*Remark:
- Please check detail for each properties that can configure on file variable.tf
- Prohibited value start with ### XXX ### will be reserve for system
- Basic configure is avaliable on "#----------Basic System properties" and "#----------Basic AKS properties
- Advance configure is avaliable on "#----------Advance AKS properties"
- Apply the change on cluster by commit and tag "aks-cluster-modify*"
git pull git tag #check tag duplicate echo "aks-cluster-modify-yyyymmddhhmmss" > ./azure-aks/result/result-aks-modify git add -A git commit -m "Any commend that you need" git tag aks-cluster-modify-yyyymmddhhmmss -m "aks-cluster-modify*-yyyymmddhhmmss" git push --atomic origin <branch name> aks-cluster-modify-yyyymmddhhmmss
- Check progress on tab "action" until it finished. (Optional: Verify result on web console/cli for double check)
- Check modify result
- Use "aks-config" and check modify result via command line
git pull kubectl get nodes --kubeconfig=./azure-aks/aks-config
*Remark: When you had been destroy cluster. All properties on "./azure-aks/terraform.tfvars" will roll back to default
- Delete the cluster by commit and tag "aks-cluster-destroy*"
git pull git tag #check tag duplicate echo "aks-cluster-destroy-yyyymmddhhmmss" > ./azure-aks/result/result-aks-destroy git add -A git commit -m "Any commend that you need" git tag aks-cluster-destroy-yyyymmddhhmmss -m "aks-cluster-destroy*-yyyymmddhhmmss" git push --atomic origin <branch name> aks-cluster-destroy-yyyymmddhhmmss
- Check progress on tab "action" until it finished. (Optional: Verify result on web console/cli for double check)
- Destroy Azure environment by commit and tag "aks-destroy-env*"
git pull git tag #check tag duplicate echo "aks-destroy-env-yyyymmddhhmmss" > ./azure-aks/result/result-env-destroy git add -A git commit -m "Any commend that you need" git tag aks-destroy-env-yyyymmddhhmmss -m "aks-destroy-env-yyyymmddhhmmss" git push --atomic origin <branch name> aks-destroy-env-yyyymmddhhmmss
- Check progress on tab "action"
Cloud provider's folder: azure-aks
Before start to create EKS cluster. Please input credential for operate on ACCESS_KEY and SECRET_KEY
Distributed under the Apacher License. See LICENSE.txt
for more information.
Praparn Lueangphoonlap - @facebook - eva10409@gmail.com
Project Link: https://github.com/praparn/github-action-x-any-xks
- Git reset and pull everything from remote/main
git fetch origin git reset --hard origin/main
- Git reset tag (Delete all tags local/remote)
git tag -l | xargs git tag -d git fetch --tags git push origin --delete $(git tag -l) git tag -d $(git tag -l)