How To Setup Magento In AWS EKS Using Helm in 2023

You are currently viewing How To Setup Magento In AWS EKS Using Helm in 2023

Magento is a popular open-source e-commerce platform used by businesses for their online stores. Running Magento in a cloud environment like Amazon Web Services (AWS) can provide benefits like scalability, reliability, and cost optimization.

In this article, we will explore the steps to set up Magento in AWS using Amazon Elastic Container Service for Kubernetes (EKS) and Helm.

Steps to Setup Magento in AWS EKS using Helm:

Create EKS Cluster

Create an Amazon Elastic Kubernetes Service (EKS) cluster. This can be done via the “eksctl” command line tool.

curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
eksctl create cluster --name magento-cluster

Install Helm

Helm is a package manager for Kubernetes, and it is used to deploy and manage applications on a Kubernetes cluster. You can install Helm by following the official Helm installation guide.

sudo yum install openssl -y
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 > get_helm.sh
chmod 700 get_helm.sh
./get_helm.sh

Set Up EBS CSI addon for EKS

First, create an IAM OIDC provider for your cluster.

oidc_id=$(aws eks describe-cluster --name magento-cluster --query "cluster.identity.oidc.issuer" --output text | cut -d '/' -f 5)
aws iam list-open-id-connect-providers | grep $oidc_id | cut -d "/" -f4
eksctl utils associate-iam-oidc-provider --cluster magento-cluster --approve

Add IAM Role using eksctl

eksctl create iamserviceaccount \
--name ebs-csi-controller-sa \
--namespace kube-system \
--cluster magento-cluster \
--attach-policy-arn arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy \
--approve \
--role-only \
--role-name AmazonEKS_EBS_CSI_DriverRoleMagento

Then add EBS CSI to EKS by running the following command

eksctl create addon --name aws-ebs-csi-driver --cluster magento-cluster --service-account-role-arn arn:aws:iam::111122223333:role/AmazonEKS_EBS_CSI_DriverRoleMagento --force

Install Magento using Helm

Install the Magento chart: To install the Magento chart, run the following command:

helm repo add bitnami https://charts.bitnami.com/bitnami

Once the chart is added then install Magento using the below command.

helm install my-release bitnami/magento

This will install the latest version of the Magento chart from the official Bitnami repository.

After that, run these commands to set the hostname

export APP_HOST=$(kubectl get svc --namespace default my-release-magento --template "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}")
  export APP_PASSWORD=$(kubectl get secret --namespace default my-release-magento -o jsonpath="{.data.magento-password}" | base64 -d)
  export DATABASE_ROOT_PASSWORD=$(kubectl get secret --namespace default my-release-mariadb -o jsonpath="{.data.mariadb-root-password}" | base64 -d)
  export APP_DATABASE_PASSWORD=$(kubectl get secret --namespace default my-release-mariadb -o jsonpath="{.data.mariadb-password}" | base64 -d)
helm upgrade --namespace default my-release bitnami/magento \
    --set magentoHost=$APP_HOST,magentoPassword=$APP_PASSWORD,mariadb.auth.rootPassword=$DATABASE_ROOT_PASSWORD,mariadb.auth.password=$APP_DATABASE_PASSWORD

A new user will be created with the username “user”. To get the password, then run the command

echo Password : $(kubectl get secret --namespace default my-release-magento -o jsonpath="{.data.magento-password}" | base64 -d)

Access the Magento site

After the installation is complete, you can access the Magento site using the URL provided by the output of the install command. Alternatively, you can go to EC2->Load Balancer and grab the Load balancer URL from there.

Conclusion

With these steps, you have successfully deployed Magento on AWS EKS using Helm. You can now customize your Magento store as per your needs and start accepting orders.

Note: This guide is a basic setup for deploying Magento on AWS EKS using Helm. In a production environment, you may need to configure additional settings, such as scaling, backup and restore, security, etc.

Atiqur Rahman

I am MD. Atiqur Rahman graduated from BUET and is an AWS-certified solutions architect. I have successfully achieved 6 certifications from AWS including Cloud Practitioner, Solutions Architect, SysOps Administrator, and Developer Associate. I have more than 8 years of working experience as a DevOps engineer designing complex SAAS applications.

Leave a Reply