AWS EKS cluster for the Integration: OWNCLOUD with MySQL
Hello guys !!
In this blog i am going to share some interesting facts while creating AWS EKS cluster for an automated Master-Slave architecture. In this blog we will cover a lot of facts and implementations one by one.
We are going to create a great integration where we will connect owncloud with MySQL database on an automated AWS EKS cluster also this complete integration we are going to build by creating our own lab environment over AWS.
Before moving forward, lets go through some of the major concepts in AWS :
About EKS :
EKS stands for Elastic Kubernetes Service, which is an Amazon offering that helps in running the Kubernetes on AWS without requiring the user to maintain their own Kubernetes control plane. It is a fully managed service by Amazon.
What does EKS do ?
Amazon EKS runs Kubernetes control plane instances across multiple Availability Zones to ensure high availability. Amazon EKS automatically detects and replaces unhealthy control plane instances, and it provides automated version upgrades and patching for them.
What is VPC ?
Amazon Virtual Private Cloud (Amazon VPC) enables us to launch AWS resources into a virtual network that we have defined. This virtual network closely resembles a traditional network that we had operate in our own data center, with the benefits of using the scalable infrastructure of AWS. It provide a complete isolation from the outer world.
In VPC , there is concept of subnets that means Subnetwork or subnet is a logical subdivision of an IP network. The practice of dividing a network into two or more networks is called subnetting. AWS provides two types of subnetting one is Public which allow the internet to access the machine and another is private which is hidden from the internet. Here we are going to create our own lab so it will be automatically isolated and for allowing it to connect to the outer world we will be creating the Internet Gateway for our VPC and for connecting to the internet Gateway we will create the Routing table and attach it to our subnet or subnets.
What is Internet Gateway?
An internet gateway is a horizontally scaled, redundant, and highly available VPC component that allows communication between your VPC and the internet.
What is Routing Table ?
A route table contains a set of rules, called routes, that are used to determine where network traffic from your subnet or gateway is to be directed.
So with our complete plan we will have a architcture like this :
Requirements for this task :
- Account on AWS , also a IAM user created.
- AWS CLI installed and configured.
- eksctl installed for accessing the cluster (Although we are going to create everything with Terraform ).
- Kubectl setup : It is used for a communication with the cluster API server.
Now first of all we will create a VPC environment for deploying our cluster setup . This Virtual Private Cloud, we are going to create from GUI , Lets create it :
Step 1 : Go to the VPC Service on the AWS service Dashboard and choose VPC option , then choose Create VPC
Step 2 : After creating VPC we will now move toward creating Subnet , here i have planned to create two subnets in two different availability zones, named subnet_public and subnet_private .
Step 3 : Now we will create the Internet Gateway and attach the VPC we have created for allowing the subnets to connect to the internet.
Step 4 : After this we need to create a routing table for setting up the route from the subnet to the Internet Gateway
Now we will add this routing table to the subnet
Similarly add this routing table to other subnet also.
Hence, we have successfully created our VPC or simply our lab setup with having an internet connectivity with it. This architecture will be like
EKS Cluster Setup
Now lets start creating our EKS cluster setup. For this cluster we are going to use the terraform code, where firstly we will create a IAM ROLE and then attach the required policies for our cluster. Then we will create our cluster named by “mycluster”.
Now initialize the terraform for adding all the terraform plugins, with “terraform init” command.
After this apply the terraform code to perform it execution and to create the EKS cluster, with “terraform apply” command .
After some seconds, check the AWS console that the cluster has been created or not ?
Yeah!!!!! the cluster has been successfully created. Now check the instances, they might be created or in a creating status for now.
One that need to be noticed is that in the terraform code for creating the cluster, we have used the VPC and subnets that we have created and not the default once i.e., we have created our own isolated cluster for running the EKS cluster.
Now update the kubeconfig file for managing our EKS cluster with the kubectl command, by using “ aws eks update-kubeconfig — — name < cluster name>” , here our cluster name is mycluster.
So guys, as we have successfully created the setup for our cluster, Now its time to create the deployments over these clusters without thinking about any downtime or any management issues beacause Kubernetes is a very intelligent and advanced tool for management. With the yml code we will make the deployments for the owncloud , mysql and pvc for them also a Load Balancer service for OwnCloud, so that the traffic would be managed.
- Code for creating the mysql-deployment , i.e., mysql-deployment.yml file
2. Code for creating owncloud-deployment, i.e., owncloud-deployment.yml
3. Creating rbac.yml file for security so that we can get more security for our deployments.
Finally, our individual code is ready but as this is an automation world so here we execute the complete code with a single command, i.e., by using the kustomization.yml file .
For executing this kustomization.yml file we will use the command
“kubectl create -f .”
Now check for the services by using “kubectl get all -o wide” command , here we have used “-o wide” for accessing detailed information about the deployments.
Now lets check over the AWS Dashboard, we see that a Load Balancer is also created by which we will access our OwnCloud dashboard and also it will handle all the traffic coming to the OwnCloud dashboard.
Through this DNS name of the Load Balancer, we can access the OwnCloud Dashboard, i.e.,
Now creating our account, in order to use the OwnCloud.
Here we can easily upload and retrive multiple files, folders, pictures etc.
On this OwnCloud, your data is safe and secure and can be retrived anytime and anywhere, without any Downtime because Kubernetes cluster in AWS is handling the Traffic.
Now After implementing this complete setup, we will destroy the EKS cluster from the CLI itself, i.e., we will destroy the cluster by using the terraform command “terraform destroy ”.
Hence, we have worked on multiple things and implemented them successfully also. I hope you enjoyed this implementation of AWS Elastic Kubernetes Service.
Feel free to ask about any query, i will try to solve it as soon as i can..
Thank you !!!