Hey All, would like to share my journey on K8s setup with a quite brief story and small workflow. Would like share this demo scripts as I have faced many challenges while implementing them.
Fyi; All the below mentioned setup was in AWS cloud. Managed EKS.
It is always challenging on moving forward to adapt with latest technology; All are meant to ease our process to automate the lifestyle here.
It all started with the a migration plan to move forward to an automated environment. We initially had tough path to go with;
— either with Dockeriznig the application and moving to kubernetes (k8s) — Or directly to k8’s architecture
We finalized with moving k8s directly as do not want another setup plan and also we have some time left for our new product launch. :p
Lets get into the process;
- It is assumed you have already Dockerized your application and have .yaml file ready for deployment.
- AWS cloud account
- Container Registry; Preferably with the native cloud managed. We have ECR (elastic container registry form AWS)
- we have used kubectl here as the managing tool.
It was pretty fair that the AWS docs have clear ideas in creating them; however there are some minute tricks which will end up in spinning all around.
Decide which is the environment you are going to use as the administration console, from which you can manage the k8s cluster, deployments etc. Either your local machine or any machines in cloud.
Create two IAM user with following access; — One for EKS cluster to manage services and — Other for admin console from which you have access to the resources EKS cluster role:
To create your Amazon EKS service role in the IAM console
— Open the IAM console at https://console.aws.amazon.com/iam/.
— Choose Roles, then Create role.
— Choose EKS from the list of services, then Allows Amazon EKS to manage your clusters on your behalf for your use case, then Next: Permissions.
For Role name, enter a unique name for your role, such as eksServiceRole, then choose Create role.
— Another IAM role / user with following access; (if you prefer ec2 instance as a manager, create IAM roles, else go with IAM user and bind the keys in your local machine)
— ECR container access — IAM pass for EKS — EKS manager role with LIST/ UPDATE/ DESCRIBE/CREATE access to the eks cluster.
Once the IAM user / role was created bind with your machine with awscli.
- Create a VPC for EKS as mentioned in the document; preferably go with aws template initially and later we can modify them.
Refer create cluster VPC section in the document: https://docs.aws.amazon.com/eks/latest/userguide/getting-started.html
- Install and configure kubectl for eks; use the below link based on your native machine mac/windows/linux distros
Install aws-iam-authenticator from the below link
- use aws cli for cluster creation from the local machine with aws cli configured in previous step.
aws — region us-east-1 eks create-cluster — name Developement — role-arn arn:aws:iam::REPLACEHERE — resources-vpc-config subnetIds=REPLACE SUBNETS HERE ,securityGroupIds=SECURITYGROUP
make sure to replace the values with VPC created from cloud formation template.
Wait for the cluster to be active you can fetch the status of cluster using the below command or checking via console.
**aws eks --region *region* describe-cluster --name *devel* --query cluster.status**
once the status is active move the next step:
Adding the cluster to your your kubeconfig
**aws eks --region *region* update-kubeconfig --name *cluster_name*
To confirm the cluster has joined your manger
**kubectl get services**
troubleshoot: if you are facing issues joining the cluster
Make sure you have used the same IAM user to join eks, and from which eks cluster was created.
you will have your cluster listed. It takes 2 to 3 minutes for joining.
- Follow the launch and configure the eks worker nodes from a simple cloud formation template.
Once completed we have nodes listed; Check those by
kubectl get nodes
Now we have our environment ready for deployments, in the next blog we will have our sample application with load balanced services.
Link for Part 2 [opsinsights.dev/my-first-path-to-kubernetes..
Did you find this article valuable?
Support Jothimani Radhakrishnan by becoming a sponsor. Any amount is appreciated!