y0zg / eks-ops

eks-ops

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Start EKS cluster and Applicatio Infrastrcture with Terraform and Run Deploy of App from Jenkins

This will start an EKS cluster with terraform and other components for deploying the A App

  1. Prerequisites:

  • Install Terraform on your workstation/server
  • Install aws cli on your workstation/server
  • Install kubectl on your workstation/server
  1. Variables:

  • Change the aws_region to your requested region (default: us-east-1)
  • Change kubernetes_version to the desired version (default: 1.18)
  • Change k8s_service_account_namespace to the namespace for your application (default: default)
  • Change k8s_service_account_name to the service account name for your application (default: k8s_service_account_name)
  1. Run:

  • Run the following to start your eks environment:
  • terraform init
  • terraform apply --auto-approve
  • After the environement is up run the following to update your kubeconfig file (you can get the cluster_name value from the cluster_name output in terraform)
  • aws eks --region=us-east-1 update-kubeconfig --name <cluster_name>
  1. To test the environemet run the following:

  • kubectl get nodes -o wide
  1. Optional:

If you'd like to add more authrized users or roles to your eks cluster follow this:

  • Create an IAM role or user that is authorized to user EKS

  • From an authorized user edit aws-auth-cm.yaml update aws-auth configmap and add the relevant users/roles and execute with kubectl data: mapRoles: |

    • rolearn:
  • then do "kubectl apply -f aws-auth-cm.yaml "

Important: Make sure you get the nodes role arn from the currently configured configmap using kubectl get configmap aws-auth -n kube-system -o yaml and replace with the above

  1. Add Jenkins Agent to IAM role that have the correct rights to perform all the actions needed.

  2. Testing Consul Server :

  • connect Consul server Public ip on port 8500 .
  1. Connection Jenkins and Running the Deploy

  • create credentials to connect EKS , choose kubeconfig and paste there the content of cat .kube/config
  • connect Jenkins Seever Public ip on port 8080
  • Run the job : deploy kalandula app
  1. check form kubectl get pods and kubectl get svc , to see if the app and LB service deployed .

  2. connect EKS public cluster ip to check the Application is up and Running .

  3. Config Bastion:

Edit ~/.ssh/config on local machine as /general/ssh_config. (modify the template with your pramaters)

  1. Run jenkins jobs:

  • Kandula app depploy
  • filebeat_deploy
  • node_exporter_deploy
  • consul_deploy
  1. Stop Environment

  • Run Jenknis job to destory all resources on Kube.
  • Make sure no pods or svc are up.
  • Run ```terrafrom/terraform destory --auto-approve

About

eks-ops


Languages

Language:HCL 58.2%Language:HTML 28.5%Language:Groovy 8.3%Language:Shell 5.0%