Setting up OwnCloud on top ofAWS using EKS

Saptarsiroy
6 min readJul 11, 2020

Amazon Web Services or aws

AWS is a subsidiary of amazon that provides cloud computing as services, or in other words Infrastructure as a Service (also called IAAS). AWS provides all the computing power(including cpu, ram, gpu) , storage solutions(like ssd), and networking (includes routers, switches, firewall etc) as a services. It is one of the top cloud infrastructure.

Kubernetes

Kubernetes is a open-source platform for container-orchestration system that is used for automating the process of deploying, scaling, and managing computer applications.

EKS or Elastic Kubernetes Service

In layman terms we can say that eks is the combination of aws and kubernetes. launching kubernetes on top of aws makes it a powerful tool for automation. EKS is a fully managed service provided by aws for container -orchesration. It uses the computing power of aws to launch computer applications. Many top companies like Intel, HSBC, Snap, GoDaddy and AutoDesk relies on eks to launch their sensitive and critical applications because of its reliability, security, and scalability.

OwnCloud

OwnCloud is a free and open-source file hosting software for storing, accessing and sharing files, calendars, contacts and emails on the cloud. Since its development in 2010, ownCloud allows creation of private on-demand cloud that offers similar functionalities like those of Dropbox.

Since, you have understood what is aws, eks and owncloud the without further delay let’s start our deployment.

But before we start, there are some pre-requisites.

Pre-Requisites:

  1. You must have an aws account and an iam user created with AdministratorAccess power.
  2. Installed aws cli and configured the profile
  3. Installed kubectl and eksctl programs.

These are required for creating ownCloud on top of eks.

Steps for creating Cluster

  1. Before we do anything, we have to create our cluster on top of eks. To do this we have to create our own cluster.yml file, that would automatically launch the kubernetes cluster on top of eks.

I have named the file as k8scluster.yml, you can name anything.

apiversion: eksctl.io/v1alpha5kind: ClusterConfimetadata: name: cloudcluster region: ap-south-1nodeGroups: - name: ng-1 instanceType: t2.micro desiredCapacity: 2 ssh:  publicKeyName: clusterKey - name: ng-mixed minSize: 1 maxSize: 3 instancesDistribution:   maxPrice: 0.050   instanceTypes: ["t3.micro","t3.small"]   onDemandBaseCapacity: 0   onDemandPercentageAboveBaseCapacity: 80   spotInstancePools: 2 ssh:   publicKeyName: clusterKey

2. After creating this yaml file we have to launch our cluster using eksctl. This will create three nodes as the worker nodes. More will be launched if more traffic is inbound.

eksctl create cluster -f k8scluster.yml
eksctl command

3. After creating cluster your screen should look like this:

This will take sometime, approximately 10 to 20 mins to create the cluster. After creating cluster it should say

EKS cluster cloudcluster in ap-south-1 region is ready”

4. After creating cluster, we have to setup a database to store our data. Here I am using mariadb. To create database, we have to create a file database.yml which will deploy the database on eks cluster. The file consists of three sections — Service, PVC and Deployment. The first part will create a service with cluster IP for connecting to the database. The second part will create a pvc or persistentVolumeClaim of 1Gib in size(using ebs service in aws )to make our data permanent in case of pod failure. The third part will create a Deployment which will monitor the database pod and launch in case it is terminated. The pvc what we have created will be mounted to the ‘/var/lib/mysql’ directory since it stores all the data.

Here is the database.yml file.

apiVersion: v1kind: Servicemetadata: name: oc-mariadb labels:  app: owncloudspec: ports:  - port: 3306 selector:  app: owncloud  tier: database clusterIP: None---apiVersion: v1kind: PersistentVolumeClaimmetadata: name: db-pvc labels:  app: owncloudspec: accessModes: - ReadWriteOnce resources:  requests:    storage: 1Gi---apiVersion: apps/v1kind: Deploymentmetadata: name: oc-mariadb 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. After creating the database file, we will now create the file which will launch owncloud as frontend. The file name is owncloud.yml. This file also has 3 parts — Service, PVC and Deployment. The first part or the service part will create a LoadBalancer to control the traffic between the three nodes. The second part will create a PVC of 1 Gib and mount to the folder ‘/var/www/html’ directory to make our data permanent in case of pod failure. The third part will create a Deployment that monitors the pods and a launch in case a pod get terminated. It will also autoscale and create more if traffic increases.

apiVersion: v1kind: Servicemetadata:  name: owncloud  labels:    app: owncloudspec: ports:   - port: 80    nodePort: 30040 selector:   app: owncloud   tier: frontend type: LoadBalancer---apiVersion: v1kind: PersistentVolumeClaimmetadata: name: oc-pvc labels:   app: owncloudspec: accessModes: - ReadWriteOnce resources:   requests:    storage: 1Gi---apiVersion: apps/v1kind: Deploymentmetadata:  name: owncloud  labels:    app: owncloudspec:  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. After creating the files we have to create a kustomization.yml file to automatically create the deployments, PCV and services. It would also contain the password for mysql database and automatically connects to the database

Here is the file.

apiVersion: kustomize.config.k8s.io/v1beta1kind: KustomizationsecretGenerator: - name: mysql-passwd   literals:      - password=admin_password - name: mysqluser-passwd   literals:      - usrpasswd=user_passwordresources:   - database.yml   - owncloud.yml

7. Now it’s time to finally launch owncloud using kubectl. But before this we have to configure kubectl using this command.

aws eks update-kubeconfig --name cloudcluster

This will update kubectl so that it connects to the eks cluster which can be viewed by using

kubectl config view

Now it’s time to launch our ownCloud. It can be run using the command

kubectl create -k .

Also make sure that you are in the same directory that contains all the files.

Voila!! You have successfully created your ownCloud on top of eks. Now use

kubectl get all

To get the url of your owncloud.

URL for ownCloud
ownCloud mainpage
Inside ownCLoud

I have done this activity under the mentorship of Mr. Vimal Daga who taught me this in two days in his training on ‘Amazon EKS services’. I would also like to thanks LinuxWorld and Sir for the constant support and the giving us this wonderful opportunity.

--

--

No responses yet