Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Magento2 ARM Template #293

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Magento2/Kubernetes/azurefile/sc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: azurefile-sc
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: kubernetes.io/azure-file
reclaimPolicy: Retain
allowVolumeExpansion: true
23 changes: 23 additions & 0 deletions Magento2/Kubernetes/elasticsearch/pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: elasticsearch-pv
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
azureFile:
secretName: input-secrets
secretNamespace: magento
shareName: elasticsearch
readOnly: false
mountOptions:
- dir_mode=0777
- file_mode=0777
- mfsymlinks
- uid=1000
- gid=1000
- cache=none
persistentVolumeReclaimPolicy: Retain
storageClassName: azurefile-sc
11 changes: 11 additions & 0 deletions Magento2/Kubernetes/elasticsearch/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: elasticsearch-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: azurefile-sc
12 changes: 12 additions & 0 deletions Magento2/Kubernetes/elasticsearch/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: elasticsearch-service
namespace: magento
spec:
selector:
app: elasticsearch
ports:
- protocol: TCP
port: 9200
targetPort: 9200
35 changes: 35 additions & 0 deletions Magento2/Kubernetes/elasticsearch/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: elasticsearch
namespace: magento
spec:
replicas: 1
selector:
matchLabels:
app: elasticsearch
serviceName: elasticsearch-service
template:
metadata:
labels:
app: elasticsearch
spec:
containers:
- name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.24
ports:
- containerPort: 9200
name: main
env:
- name: discovery.type
value: "single-node"
- name: xpack.security.enabled
value: "false"
volumeMounts:
- mountPath: /usr/share/elasticsearch/data
name: elasticsearch-data
volumes:
- name: elasticsearch-data
persistentVolumeClaim:
claimName: elasticsearch-pvc
readOnly: false
33 changes: 33 additions & 0 deletions Magento2/Kubernetes/ingress/ingress-tls.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: magento-ingress
namespace: magento
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/proxy-buffer-size: "256k"
nginx.org/proxy-buffers: "4 256k"
nginx.ingress.kubernetes.io/proxy-buffers-number: "4"
nginx.ingress.kubernetes.io/proxy-busy-buffers-size: "256k"
nginx.org/proxy-connect-timeout: "60s"
nginx.org/proxy-read-timeout: "60s"
nginx.ingress.kubernetes.io/force-ssl-redirect: "false"
spec:
ingressClassName: nginx
tls:
- hosts:
- __FQDN__
secretName: magento-secret
rules:
- host: __FQDN__
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: __SERVICE_NAME__
port:
number: __SERVICE_PORT__
28 changes: 28 additions & 0 deletions Magento2/Kubernetes/ingress/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: magento-ingress
namespace: magento
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/proxy-buffer-size: "256k"
nginx.org/proxy-buffers: "4 256k"
nginx.ingress.kubernetes.io/proxy-buffers-number: "4"
nginx.ingress.kubernetes.io/proxy-busy-buffers-size: "256k"
nginx.org/proxy-connect-timeout: "60s"
nginx.org/proxy-read-timeout: "60s"
nginx.ingress.kubernetes.io/force-ssl-redirect: "false"
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: __SERVICE_NAME__
port:
number: __SERVICE_PORT__
75 changes: 75 additions & 0 deletions Magento2/Kubernetes/magento/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: magento-config
namespace: magento
data:
PHP_VERSION: "8.3"
MAGENTO_PORT: "8080"
MAGENTO_DATABASE_NAME: "magento"
MAGENTO_SEARCH_ENGINE: "elasticsearch7"
ELASTICSEARCH_HOST: elasticsearch-service.magento.svc.cluster.local
ELASTICSEARCH_PORT: "9200"
MAGENTO_ADMIN_FIRSTNAME: "Admin"
MAGENTO_ADMIN_LASTNAME: "User"
MAGENTO_ADMIN_FRONTNAME: "admin"
MAGENTO_LANGUAGE: "en_US"
MAGENTO_USE_REWRITES: "1"
SESSION_BACKEND: "redis"
SESSION_REDIS_SERVER_HOST: redis-service.magento.svc.cluster.local
SESSION_REDIS_PORT: "6379"
SESSION_REDIS_DATABASE: "2"
SESSION_REDIS_LOG_LEVEL: "4"
MAGENTO_FORCE_INSTALL: "false"
MAGENTO_DEPLOY_SAMPLE_DATA: "false"
MAGENTO_REMOVE_SAMPLE_DATA: "false"
MAGENTO_DISABLE_2FA: "true"
VARNISH_LISTEN_HOST: "varnish-service.magento.svc.cluster.local"
VARNISH_LISTEN_PORT: "8081"
VARNISH_BACKEND_HOST: magento-service.magento.svc.cluster.local
VARNISH_BACKEND_PORT: "8080"
VARNISH_STORAGE: "malloc,256M"
default.conf: |
# Example configuration:
upstream fastcgi_backend {
# use tcp connection
# server 127.0.0.1:9000;
# or socket
server unix:/run/php/php8.3-fpm.sock;
}
server {
listen 8080;
server_name magento-service.magento.svc.cluster.local;
set $MAGE_ROOT /var/www/html/magento2;
set $MAGE_DEBUG_SHOW_ARGS 0;

include /usr/local/bin/nginx.conf.sample;
}

# Optional override of deployment mode. We recommend you use the
# command 'bin/magento deploy:mode:set' to switch modes instead.
#
# set $MAGE_MODE default; # or production or developer
#
# If you set MAGE_MODE in server config, you must pass the variable into the
# PHP entry point blocks, which are indicated below. You can pass
# it in using:
#
# fastcgi_param MAGE_MODE $MAGE_MODE;
#
# In production mode, you should uncomment the 'expires' directive in the /static/ location block

# Modules can be loaded only at the very beginning of the Nginx config file, please move the line below to the main config file
# load_module /etc/nginx/modules/ngx_http_image_filter_module.so;

---
apiVersion: v1
kind: ConfigMap
metadata:
name: magento-cron-config
namespace: magento
data:
CONFIG__DEFAULT__SYSTEM__CRON__INDEX__USE_SEPARATE_PROCESS: "0"
CONFIG__DEFAULT__SYSTEM__CRON__DEFAULT__USE_SEPARATE_PROCESS: "0"
CONFIG__DEFAULT__SYSTEM__CRON__CONSUMERS__USE_SEPARATE_PROCESS: "0"
CONFIG__DEFAULT__SYSTEM__CRON__DDG_AUTOMATION__USE_SEPARATE_PROCESS: "0"
46 changes: 46 additions & 0 deletions Magento2/Kubernetes/magento/cron.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: magento-cron
namespace: magento
spec:
replicas: 1
selector:
matchLabels:
app: magento-cron
template:
metadata:
labels:
app: magento-cron
spec:
containers:
- name: magento-cron
image: aaakarshit/magento-cron:v1.0.0
envFrom:
- configMapRef:
name: input-config
- configMapRef:
name: magento-config
- configMapRef:
name: magento-cron-config
- secretRef:
name: input-secrets
volumeMounts:
- name: azurefile-magento
mountPath: /var/www/html/mount/static
subPath: static
- name: azurefile-magento
mountPath: /var/www/html/mount/media
subPath: media
readinessProbe:
exec:
command: ["sh", "-c", "test -f /tmp/magento-setup-complete-${HOSTNAME}"]
failureThreshold: 145 # Check till 15 minutes
initialDelaySeconds: 180 # Start checking after 3 minutes
periodSeconds: 5 # Check every 5 seconds
successThreshold: 1 # If the file is present, it's ready
volumes:
- name: azurefile-magento
persistentVolumeClaim:
claimName: magento-pvc
readOnly: false
55 changes: 55 additions & 0 deletions Magento2/Kubernetes/magento/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: magento-server
namespace: magento
spec:
replicas: 1
selector:
matchLabels:
app: magento-server
template:
metadata:
labels:
app: magento-server
spec:
containers:
- name: magento-server
image: aaakarshit/magento-server:v1.0.0
ports:
- containerPort: 8080
envFrom:
- configMapRef:
name: magento-config
- configMapRef:
name: input-config
- secretRef:
name: input-secrets
volumeMounts:
- name: azurefile-magento
mountPath: /var/www/html/mount/static
subPath: static
- name: azurefile-magento
mountPath: /var/www/html/mount/media
subPath: media
- name: magento-config
mountPath: /etc/nginx/conf.d/default.conf
subPath: default.conf
readinessProbe:
exec:
command: ["sh", "-c", "test -f /tmp/magento-setup-complete-${HOSTNAME}"]
failureThreshold: 145 # Check till 15 minutes
initialDelaySeconds: 180 # Start checking after 3 minutes
periodSeconds: 5 # Check every 5 seconds
successThreshold: 1 # If the file is present, it's ready
volumes:
- name: azurefile-magento
persistentVolumeClaim:
claimName: magento-pvc
readOnly: false
- name: magento-config
configMap:
name: magento-config
items:
- key: default.conf
path: default.conf
40 changes: 40 additions & 0 deletions Magento2/Kubernetes/magento/job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: batch/v1
kind: Job
metadata:
name: magento-setup-job
namespace: magento
spec:
template:
metadata:
labels:
app: magento-setup-job
spec:
containers:
- name: magento-setup-job
image: aaakarshit/magento-setup-job:v1.0.0
envFrom:
- configMapRef:
name: magento-config
- configMapRef:
name: input-config
- secretRef:
name: input-secrets
volumeMounts:
- name: azurefile-magento
mountPath: /var/www/html/mount/static
subPath: static
- name: azurefile-magento
mountPath: /var/www/html/mount/media
subPath: media
restartPolicy: Never
volumes:
- name: azurefile-magento
persistentVolumeClaim:
claimName: magento-pvc
readOnly: false
- name: magento-config
configMap:
name: magento-config
items:
- key: default.conf
path: default.conf
Loading