Acquira

my_first_aws_k8s_project

Oct 14th, 2020 (edited)
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.73 KB | None | 0 0
  1. sudo apt install curl -y
  2. curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.19.0/bin/linux/amd64/kubectl
  3. chmod +x ./kubectl
  4. sudo mv ./kubectl /usr/local/bin/kubectl
  5.  
  6. #On AWS Console
  7.     #Go to IAM
  8.         #Create new user:
  9.             #Programmatic Access
  10.             #Create group with access : AdministratorAccess
  11.         #Save aside the newly created user keys
  12.  
  13. sudo apt install awscli -y
  14. aws configure
  15.     #Add previously created keys : Client Key Id / Client Secret Key
  16.     #To confirm you are successfully logged in : aws s3 ls
  17.  
  18. curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64
  19. chmod +x kops-linux-amd64
  20. sudo mv kops-linux-amd64 /usr/local/bin/kops
  21.  
  22.  
  23. aws iam create-group --group-name kops
  24. aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonEC2FullAccess --group-name kops
  25. aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonRoute53FullAccess --group-name kops
  26. aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess --group-name kops
  27. aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/IAMFullAccess --group-name kops
  28. aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonVPCFullAccess --group-name kops
  29. aws iam create-user --user-name kops
  30. aws iam add-user-to-group --user-name kops --group-name kops
  31. aws iam create-access-key --user-name kops
  32.  
  33. #Create s3 bucket, be careful not using "_" in the bucket name
  34. aws s3api create-bucket --bucket pso-kubernetes-state-demo  --region us-east-1
  35.  
  36. #Create your hosted DNS zone
  37.     #Go to Route53 and create a subdomain for your dns record
  38.     #Add the 4 route to your DNS console (cloudflare/ovh/alibaba etc.)
  39.  
  40. host -t NS my.domain.com
  41.  
  42. # Modifier .bashrc
  43. export KOPS_STATE_STORE="s3://pso-kubernetes-state-demo"
  44. export EDITOR=nano
  45.  
  46. #Ressourcer le fichier .bashrc pour prendre les modifications en compte
  47. source ~/.bashrc
  48.  
  49. ssh-keygen -t rsa
  50.     #When generating keys, rename them to be easily recognizable
  51.  
  52. kops create cluster --name=kubernetes.safecorp.fr --zones=us-east-1a --node-count=2 --node-size=t2.micro --master-size=t2.micro --dns-zone=kubernetes.safecorp.fr --ssh-public-key=/home/fitec/.ssh/kuber.pub --kubernetes-version=1.18.0
  53.  
  54. kops update cluster --name kubernetes.safecorp.fr --yes
  55.  
  56. #To check if your cluster is up and running
  57. kops validate cluster
  58.  
  59. #Connect with private peer key
  60. ssh -i ~/.ssh/kuber ubuntu@x.x.x.x
  61.  
  62.  
  63.  
  64. #upgrade cluster
  65. kops edit cluster --name kubernetes.safecorp.fr
  66.     #Modifier la ligne kubernetesVersion par la version souhaitée
  67.  
  68. kops update cluster --name kubernetes.safecorp.fr --yes
  69.  
  70. kops rolling-update --name kubernetes.safecorp.fr --yes
Add Comment
Please, Sign In to add comment