Amazon Elastic Kubernetes Service
Amazon Elastic kubernetes Service:
Amazon EKS is a managed service that helps make it easier to run Kubernetes on AWS. Through EKS, organizations can run Kubernetes without installing and operating a Kubernetes control plane or worker nodes.Amazon EKS automatically manages the availability and scalability of the Kubernetes control plane nodes that are responsible for starting and stopping containers, scheduling containers on virtual machines, storing cluster data, and other tasks.
Kubernetes
Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available.
Working of Kubernetes
Client contacts to master through API Server then API server contacts to Schedular, it decides where to launch the pod after this Schedular contacts to Controller, it will keep on checking the pod and contacts to kubelet, after this kubelet contact to container engine and it launches container.
Task:
Deploy Wordpress and MySQL database on EKS
Prerequisites:
Need to have a Kubectl command installed.
AWS CLI Command
KSCTL COMMAND
Basic knowledge of AWS
Steps to achieve this task
STEP 1:
Download the AWS CLI and set the path in system variable
Download eksctl and set the path in system variables and create the variable for the user
Update your cluster's local kubeconfig file
aws eks update_kubeconfig –name clustername
Create the namespace
kubectl create ns namespace_name
SSTEP 5:
we will use EFS service of AWS so that our data is always be there in case our pod get terminated due to any reason
Attach the VPC of your cluster and same security group which your nodes have so that all the nodes should have get storage from same place.
STEP 6:
we have to install nfs-utils in each node our cluster has
created. In order to achive this login to your node via ssh or putty
yum install amazon-nfs-utils
If already install skip the step.
SSTEP 7:
we will create efs-provisioner,it will contact to efs and ask for the storage, for permission,we will create rbac file
Yaml file for creation of efs-provisioner
CCode:
kind: Deployment
apiVersion: apps/v1
metadata:
name: efs-provisioner
spec:
selector:
matchLabels:
app: efs-provisioner
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
app: efs-provisioner
spec:
containers:
- name: efs-provisioner
image: quay.io/external_storage/efs-provisioner:v0.1.0
env:
- name: FILE_SYSTEM_ID
value: fs-aa54de7b
- name: AWS_REGION
value: ap-south-1
- name: PROVISIONER_NAME
value: parul1
volumeMounts:
- name: pv-volume
mountPath: /persistentvolumes
volumes:
- name: pv-volume
nfs:
server: fs-c2e66d13.efs.ap-south-1.amazonaws.com
path: /
Sstep 8:
Create a yaml file in order to claim persistent storage
Code:
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: aws-efs
provisioner: saba1
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: efs-wordpress
annotations:
volume.beta.kubernetes.io/storage-class: "aws-efs"
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: efs-mysql
annotations:
volume.beta.kubernetes.io/storage-class: "aws-efs"
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
sStep 9:
Now we will run a kustomization file, it will pass our additional informationas well as run our mysql file and wordpress file
kustomization file :
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
secretGenerator:
- name: secret
literals:
- password=saba
resources:
- mysql.yml
- wordpress.yml
Our mysql and wordpress code is as:
Code:
apiVersion: v1
kind: Service
metadata:
name: wordpress-mysql
labels:
app: wordpress
spec:
ports:
- port: 3306
selector:
app: wordpress
tier: mysql
clusterIP: None
---
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: wordpress-mysql
labels:
app: wordpress
spec:
selector:
matchLabels:
app: wordpress
tier: mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: wordpress
tier: mysql
spec:
containers:
- image: mysql:5.6
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: secret
key: password
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: efs-mysql
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: far-cluster
region: ap-southeast-1
fargateProfiles:
- name: fargate-default
selectors:
- namespace: parulns
- namespace: default
Comments
Post a Comment