Deploying Nextcloud and MySQL On Elastic Kubernetes Service & Efs
Amazon EKS
Amazon Elastic Kubernetes Service (Amazon EKS) is a managed service that makes it easy for you to run Kubernetes on AWS without needing to stand up or maintain your own Kubernetes control plane. Kubernetes is an open-source system for automating the deployment, scaling, and management of containerized applications. Customers such as Intel, Snap, Intuit, GoDaddy, and Autodesk trust EKS to run their most sensitive and mission-critical applications because of its security, reliability, and scalability. For more understanding
Benefits Of EKS
scale, reliability, and availability of the AWS platform, as well as integrations with AWS networking and security services, such as Application Load Balancers for load distribution, Identity Access Manager (IAM) for role-based access control
On the Top Top Of EKS, we Have Developed NextCloud and Use MySql as Database So What Is Next Cloud?
NextCloud
Nextcloud is a suite of client-server software for creating and using file hosting services. Nextcloud is free and open-source, which means that anyone is allowed to install and operate it on their own private server devices Nextcloud application functionally is similar to Dropbox, Office 365 or Google Drive, but can be used on home-local computers or for off-premises file storage hosting.
MYSQL
MySQL is a relational database often used to store data for websites working in conjunction with PHP. Relational means that different tables of the database can be cross-referenced to one another. SQL stands for “Structured Query Language” which is the standard language used to interact with databases
Here We Goo…
Prerequisite for this Deployment
1-aws cli
2-kubectl
3-eksctl
First Of All We Will Create an IAM user to get access to AWS EKS through CommandLine
Click on the ADD USER
Give User name , Programmatic Access so user will get access key and Secret Key
Click On Attach existing policies and Select AdministratorAccess then Next Tags
Add Tags If You Want otherwise go-ahead Then Next And Create User
After Click On Create User, Download keys
Configure accesss Key & Secret Keys
Now The EKS Role Come in Play
Before This Create SSH Public keys
First We will Create Cluster configuration File in YAML format
in this file, we have to select which type of instance we need and other things
I suggest run all files in the end
eksctl create cluster -f clusterconfig.yml #run this command to create cluster
As soon you run this command you will see output something like this. then wait for the minimum. 20 mins then cluster will automatically create
after created you can see the cluster in AWS EKS
AWS EKS cluster behind the scene using EC2 as master & slave Nodes
EKSCTL send a request to Cloudformation Behind the scene so it Also Creates Cloudformation Stack
Manage Kubernetes From Your Local
Our Kubernetes cluster is running on the cloud so we can send a command from anywhere in the world for this we only need Kubernetes configuration file to manage it
aws eks update-kubeconfig — name productionEnv #run this command to setup Kubernetes configuration in your pc and dont forget to give your clustername
So Now Our Kubernetes is Fully working. we can check with Kubectl get pods Command
EFS - Elastic File System
What is EFS
Amazon Elastic File System (Amazon EFS) provides a simple, scalable, fully managed elastic NFS file system for use with AWS Cloud services and on-premises resources
We have to Create one centralized Storage So our all the nodes mount the data there
Go in EFS and then click on Create file system
Select Your VPC, At the time of creating cluster it also creates its own virtual private network So we have to select that one and as soon as we select it auto-select all the connected node with VPC
Then we have to Select the same security group. so they are can make connectivity with each other
Then Next, Next, Next and Create File System
After this, We Have To Install amazon-efs-utils in all three instances. With SSH so here we have to use that ssh key which we enter while configuring the cluster
sudo yum install amazon-efs-utils -y #run and install this in all the nodes
Now Start Our today’s Main deployment of NextCloud & MySql
First We have to create EFS Provisioner
in this yml file, we have only given our efs id in Value and the server name of our efs
it internally creates a deployment of EFS, to use the efs storage, we need to set the efs-provisioner
Now we create ClusterRoleBinding
To grant permissions across a whole cluster, we can use a ClusterRoleBinding. The following ClusterRoleBinding allows any user in the group “manager” to read secrets in any namespace
Now we create Storage Classes
this will Send PVC request to EFS and take the storage from there and create PVC for it so Now Our Pvc is created and it's connected with one centralized storage so now we can mount our pods data in it within one centralized location
Now we create deploy-mysql.yml
MySql Store Our Data Which is generated by NextCloud and here we use a secret to hide data from other team members this is not used to secure data is just for hide this from human so they can't read and in secret, we store data in BASE64 encoding
Now we create deploy-nextcloud.yml
in NextCloud it is just for safe our data in the private world so no one can access it in over the internet so we can achieve it with the nextcloud
After This RUN all these below commands in this sequence
1-kubectl apply -f create-efs-provisioner.yaml
2-kubectl apply -f create-rbac.yaml
3-kubectl apply -f create-storage.yaml
4-kubectl apply -f secret.yml
5-kubectl apply -f deploy-mysql.yaml
6-kubectl apply -f deploy-nextcloud.yaml
After Run All this The load balancer will automatically launch in the AWS and its provide Public DNS to Access Website with it
NextCloud is deployed successfully on EKS
NOW WE CAN DELETE THE CLUSTER
eksctl delete cluster -f clusterconfig.yml