Launching ownCloud using AWS EKS

The main components used in making this project include AWS EKS , MariaDB (MySQL) and ownCloud.

Let’s take a look at these components to understand better -

  1. AWS EKS — Amazon Web Services is a cloud computing platform that provides customers with a wide array of cloud services. It is a secured cloud services platform that offers compute power, database storage, content delivery and various other functionalities. One such functionality of AWS is EKS. It 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
  2. MariaDB (MySQL) — MariaDB is an open source relational database management system (DBMS) that is a compatible drop-in replacement for the widely used MySQL database technology. While MySQL is a relational database management system based on SQL — Structured Query Language. It is used for a wide range of purposes, including data warehousing, e-commerce, and logging applications. The most common use for MySQL however, is for the purpose of a web database.
  3. ownCloud — ownCloud is a suite of client–server software for creating and using file hosting services like storing, accessing and sharing files, calendars, contacts and emails on the cloud. It is a free and open-source software.

Here are the steps for launching ownCloud using AWS EKS and MariaDB-

  1. Create an AWS account , then create an IAM user with Administrator Access powers . Further install kubectl and ekctl programs.

2. Creating cluster using EKS- Inorder to create cluster on top of EKS we first need to create a yml file like ekscluster.yml which would automate the process of launching the cluster.

apiversion: eksctl.io/v1alpha5
kind: ClusterConfi
metadata:
name: ekscluster
region: ap-south-1
nodeGroups:
- name: ng1
instanceType: t2.micro
desiredCapacity: 2
ssh:
publicKeyName: clusterKey
- name: ngkey
minSize: 1
maxSize: 3
instancesDistribution:
maxPrice: 0.050
instanceTypes: ["t3.micro","t3.small"]
onDemandBaseCapacity: 0
onDemandPercentageAboveBaseCapacity: 80
spotInstancePools: 2
ssh:
publicKeyName: clusterKey

3. Launching the cluster- Next we launch the the cluster named ekscluster using the eksctl command given below. It will launch the desired no of worker nodes and as the inbound traffic increases it will increase the number of nodes with the help of the concept called Auto-Scaling.

eksctl create cluster -f ekscluster.yml

4. Creating database for data storage- After launching the cluster using EKS , we now need to setup the database which will be used to store the data at the backend. This creation has to be driven by another yml file named eks_database.yml. This database is also created on top of EKS and contains three components-

a. Service — It is used of networking purposes. It creates a cluster IP that allows connection to the database.

b. PVC — It is refers to Persistent Volume Claim that is used for creating a volume on the fly using the EBS service of AWS. This is important inorder to keep make our data persistent because unexpected failure of pods may occur due to various reasons. This volume is then mounted to the database directory var/lib/mysql.

c. Deployment — It is the main automating tool which allows the the management and monitoring on the real time basis and if due to any reason the pods terminate it launches a new one using the PVC created earlier which is already mounted to the database directory.

eks_database.yml

apiVersion: v1
kind: Service
metadata:
name: eks_db
labels:
app: owncloud
spec:
ports:
- port: 3306
selector:
app: owncloud
tier: database
clusterIP: None
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: eks_db-pvc
labels:
app: owncloud
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: eks_db
labels:
app: owncloud
spec:
selector:
matchLabels:
app: owncloud
tier: database
strategy:
type: Recreate
template:
metadata:
labels:
app: owncloud
tier: database
spec:
containers:
- image: mariadb:latest
name: database
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
- name: mysql-passwd
key: password
- name: MYSQL_USER
value: Sappy
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: mysqluser-passwd
key: usrpasswd
- name: MYSQL_DATABASE
value: mydb
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: db-pv
mountPath: /var/lib/mysql
volumes:
- name: db-pv
persistentVolumeClaim:
claimName: db-pvc

5. Launching ownCloud as the frontend — The creation of database is follewed by the launching of frontend which will collect the data to be stored in the database. For this we create another yml file called as eks_owncloud.yml. It again includes the same three components -

a. Service — This is used of load balancing so that we can control the traffic between various nodes.

b. PVC — It refers to the creation of volume inorder to make the data of the frontend permanent by mounting the html directory to the volume. The html directory which is to be mounted is var/www/html.

c. Deployment — It performs the same function as it does in database file ie. automation. It has the ability to monitor and manage the pods as well as launch them whenever any of them gets terminated. It also does Auto-Scaling to make it ready for the increasing traffic demands.

eks_owncloud.yml

apiVersion: v1
kind: Service
metadata:
name: eks_owncloud
labels:
app: owncloud
spec:
ports:
- port: 80
nodePort: 30040
selector:
app: owncloud
tier: frontend
type: LoadBalancer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: eks_oc-pvc
labels:
app: owncloud
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: owncloud
labels:
app: owncloud
spec:
selector:
matchLabels:
app: owncloud
tier: frontend
strategy:
type: Recreate
template:
metadata:
labels:
app: owncloud
tier: frontend
spec:
containers:
- image: owncloud:latest
name: owncloud
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-passwd
key: password
- name: MYSQL_USER
value: Sappy
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: mysqluser-passwd
key: usrpasswd
- name: MYSQL_DATABASE
value: mydb
ports:
- containerPort: 80
name: owncloud
volumeMounts:
- name: oc-pv
mountPath: /var/www/html
volumes:
- name: oc-pv
persistentVolumeClaim:
claimName: oc-pvc

6. Now we will create a kustomization.yml file to automatically create the deployments ,services and pvc.

kustomization.yml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
secretGenerator:
- name: mysql-passwd
literals:
- password=admin_password
- name: mysqluser-passwd
literals:
- usrpasswd=user_password
resources:
- eks_database.yml
- eks_owncloud.yml

7. Configuring ownCloud- Now we configure the ownCloud using the following command

aws eks update-kubeconfig — name ekscluster

It updates the kubectl and allows it to connect to the eks cluster which can be viewed using the following command

kubectl config view

8. Launching the ownCloud- We have made all the necessary setup and configured the kubectl now we are set to launch the frontend using the following command.

kubectl create -k .

The ownCloud has been successfully launched.

The main page of the ownCloud looks like this

While heading inside we get a view like this

This is a task assigned by VIMAL DAGA sir whose excellent mentorship in the Amazon EKS Service training led me to eplore this powerful service of AWS. I am thankful to him for guiding and teaching us with such a depth.