Skip to content

Github Action for create any Kubernetes on cloud provider

Notifications You must be signed in to change notification settings

praparn/github-action-x-any-xks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Action for Any XKS

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

Slide for Presentation

Remark

  • 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

Built With

(back to top)

Azure AKS Cluster

Cloud provider's folder: aws-eks

*Remark: For use this github action on Azure Portal. Please enable the preview feature 'microsoft.ContainerService/CustomNodeConfigPreview' by follow this KB Azure Enable Feature

Prerequisites

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"


githubaction

Deployment Step-by-Step

  1. Clone the repo

    git clone https://github.com/praparn/github-action-x-any-xks.git
  2. Setup "secrets" elements as explain in Prerequisites

  3. 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
  4. Check progress on tab "action" until it finished. (Optional: Verify result on web console/cli for double check)
    githubaction

  5. 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"
  6. 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
  7. Check progress on tab "action" until it finished. (Optional: Verify result on web console/cli for double check)
    githubaction

  8. Check result of demo application by command:

    git pull
    kubectl get ing -n=management-ui --kubeconfig=./azure-aks/aks-config
  9. Download kubeconfig from file "aks-config" and check application demo on browser
    githubaction

    git pull
    kubectl get nodes --kubeconfig=./azure-aks/aks-config
    kubectl get ing -n=management-ui --kubeconfig=./azure-aks/aks-config

Modified Kubernetes Configuation

  1. 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"
  2. 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
  3. Check progress on tab "action" until it finished. (Optional: Verify result on web console/cli for double check)
    githubaction
  4. Check modify result
    githubaction
  5. Use "aks-config" and check modify result via command line
    git pull
    kubectl get nodes --kubeconfig=./azure-aks/aks-config

Destroy Step-by-Step

*Remark: When you had been destroy cluster. All properties on "./azure-aks/terraform.tfvars" will roll back to default

  1. 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
  2. Check progress on tab "action" until it finished. (Optional: Verify result on web console/cli for double check)
    githubaction
  3. 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
  4. Check progress on tab "action"
    githubaction

(back to top)

AWS EKS Cluster

Cloud provider's folder: azure-aks

Prerequisites

Before start to create EKS cluster. Please input credential for operate on ACCESS_KEY and SECRET_KEY

License

Distributed under the Apacher License. See LICENSE.txt for more information.

(back to top)

Contact

Praparn Lueangphoonlap - @facebook - eva10409@gmail.com

Project Link: https://github.com/praparn/github-action-x-any-xks

(back to top)

Utility Command

  1. Git reset and pull everything from remote/main
    git fetch origin
    git reset --hard origin/main
  2. 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)

(back to top)

About

Github Action for create any Kubernetes on cloud provider

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages