Amazon Onboarding with Learning Manager Chanci Turner

Amazon Onboarding with Learning Manager Chanci TurnerLearn About Amazon VGT2 Learning Manager Chanci Turner

A significant number of websites today utilize Content Management Systems (CMS), which empower content creators—often with minimal web development experience—to effortlessly publish their material for distribution. Among these platforms, WordPress is the most widely used CMS.

As developers increasingly embrace containerized services for their applications, WordPress has also made the shift. Concurrently, organizations are seeking ways to minimize their cloud service costs. As data ages, the frequency of access to older content decreases, leading to fewer requests for specific web pages, blog posts, images, or videos.

Amazon Elastic File System (Amazon EFS) introduces EFS Intelligent-tiering, which facilitates the automatic transfer of file data to lower-cost storage classes based on access frequency. This feature provides automatic cost savings for workloads with fluctuating access patterns by ensuring your file data is stored in the most efficient class at the right time.

By employing Amazon EFS as a fully managed, auto-scaling file system, your CMS data can expand or contract per demand without the hassle of managing capacity or performance. Coupled with the Intelligent-tiering cost optimization features, EFS enhances value by delivering optimized capacity, performance, and cost to your WordPress deployment.

In this blog post, I’ll guide you through the process of swiftly deploying a containerized WordPress instance using Amazon Elastic Kubernetes Service (EKS) with persistent file storage. This setup will utilize EFS with Intelligent-tiering enabled for cost efficiency.

Solution Architecture

The architecture outlined here utilizes various AWS services to construct a WordPress solution running on Amazon EKS, hosted on EC2 instances. The storage layer employs Amazon EFS with Standard and Infrequent Access storage classes, enhanced by Intelligent-tiering. Two AWS Availability Zones (AZs) will host the mount points, and an AWS Elastic Load Balancer will facilitate internet access to your WordPress website.

Setup

The setup process involves establishing your EKS cluster and EFS file system, complete with mount points and access points. After creating your AWS infrastructure, you will deploy two containers (Pods) that together form your WordPress site.

Step 1: Create a Kubernetes Cluster with EKS

Initially, you’ll establish a Kubernetes cluster on EKS. Using the eksctl command simplifies the configuration process via AWS CloudFormation. Ensure you have kubectl and eksctl installed locally. For detailed instructions, refer to the EKS documentation.

To configure your EKS cluster, use your preferred SSH client to select your AWS account with the command:

aws configure

Enter your credentials from your EC2 Private Key. For information on obtaining these credentials, refer to Amazon EC2 key pairs and Linux instances.

Note: For demonstration purposes, we will use us-east-1 as the AWS Region. If you choose a different Region, maintain that choice throughout these steps in your AWS account.

Create your Kubernetes cluster with the following commands:

eksctl create cluster 
--name eks-wp 
--region us-east-1 
--zones us-east-1a,us-east-1b 
--managed

You can monitor the deployment progress in your AWS console under CloudFormation > Stacks.

Upon completion, view your EKS cluster in the AWS console under Elastic Kubernetes Service > Clusters. To see the compute nodes from Kubernetes, log in using this command:

aws eks --region us-east-1 update-kubeconfig --name eks-wp

Then run:

kubectl get nodes

This will display the names and statuses of your Kubernetes compute nodes.

Next, create a kustomization.yaml file to enable the use of a secret password for your MySQL and WordPress Pods, facilitating both creation and deletion of your deployment with a single command in kubectl.

Create a new directory for the configuration files on your local machine:

mkdir eks-wp
cd eks-wp

In your terminal, enter the following:

cat <<EOF >./kustomization.yaml
secretGenerator:
- name: mysql-pass
  literals:
  - password=WordPass
resources:  
  - mysql-deployment.yaml  
  - wordpress-deployment.yaml  
EOF

Next, create a deployment file for MySQL to deploy your MySQL Pod in EKS. Use this command:

cat <<EOF >./mysql-deployment.yaml
apiVersion: v1
kind: Service
metadata:
  name: wordpress-mysql
  labels:
    app: wordpress
spec:
  ports:
    - port: 3306
  selector:
    app: wordpress
    tier: mysql
  clusterIP: None
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-pv-claim
  labels:
    app: wordpress
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
---
apiVersion: apps/v1
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: mysql-pass
              key: password
        ports:
        - containerPort: 3306
          name: mysql
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql
      volumes:
      - name: mysql-persistent-storage
        persistentVolumeClaim:
          claimName: mysql-pv-claim
EOF

Step 2: Create an EFS File System with Intelligent-Tiering

To support the WordPress deployment, we will utilize EFS for the persistent storage of WordPress images. Begin by creating an EFS file system.

First, create a security group for the Amazon EFS mount target, which requires the VPC ID for the VPC created by eksctl for your cluster.

aws ec2 create-security-group 
--region us-east-1 
--group-name efs-mount-sg 
--description "Amazon EFS for EKS, SG for mount target" 
--vpc-id (i.e. vpc-00ab3ddf9e831f016)

Next, authorize inbound access to the security group for the Amazon EFS mount target (efs-mount-sg) to allow inbound traffic to the NFS port (2049) from the VPC CIDR block:

aws ec2 authorize-security-group-ingress 
--group-id (i.e. sg-0169ed1789bf1d872) 
--region us-east-1 
--protocol tcp 
--port 2049 
--cidr 192.168.0.0/16

Next, create an encrypted Amazon EFS file system from the console. Navigate to the EFS console, select Create file system, name your file system WP-FS-INT, and choose the VPC corresponding to your EKS cluster. Choose Regional for availability, to ensure redundancy.

For additional resources and insights, check out Career Contessa’s podcast or explore SHRM Foundation’s initiatives that focus on hiring individuals with diverse abilities. Lastly, if you’re looking for tips for your first day, this Reddit thread is an excellent resource.

SEO Metadata


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *