- Use case: Need to create a 3-tier web application using Docker + Kubernetes utilizing any of their favorite Infrastructure as Code. It can be a dummy application or hello world too. But should be able to demonstrate the understanding of the technologies. ANSWER:
-
Basic 3 tier of an application consists of 3 layers
-
- The presentation layer
-
- application layer
-
- presentation layer of the application represents the UI, and provides the user interface for interaction and the display of information. This layer could be a web application, mobile application, or a third-party application consuming your services.
-
- An application layer is an abstraction layer that specifies the shared communications protocols and interface methods used by hosts in a communications network. An application layer abstraction is specified in both the Internet Protocol Suite (TCP/IP) and the OSI model.
-
- Database layer consists of a database which is attched to application for data storage.
-
For the purpose iam taking the Python flask application whichh consists of an application and mysql database. referhere
-
I have already build the docker image and pushed it into the docker repository referhere.
-
For the deployment of this application i am using the EKS k8s cluster. The eks cluster is created through eksctl.
-
Then i have created two types of pods
-
a. One is the pod which contains the application.
-
b. Second one is the pod which contains the mysql pod.
-
For this application i have taken the aws infrastucture through Terraform.
-
The instance for building docker image was built through terraform.
-
For creating cluster through eksctl we have following steps
-
- Create a linux instance, install aws cli, create iam credentials
-
- install kubectl Referhere
-
- Install eksctl referhere
-
- Create a file called as cluster.yaml with the following content
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: basic-cluster
region: us-west-2
nodeGroups:
- name: basic
instanceType: t2.large
desiredCapacity: 2
volumeSize: 20
ssh:
allow: true # will use ~/.ssh/id_rsa.pub as the default ssh key