Last active
March 23, 2021 13:31
-
-
Save nimboya/26bed32aa965798a0ca1f86b0c85a67f to your computer and use it in GitHub Desktop.
WordPress In Kubernetes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: networking.k8s.io/v1beta1 | |
kind: Ingress | |
metadata: | |
name: wping | |
annotations: | |
kubernetes.io/ingress.class: alb | |
alb.ingress.kubernetes.io/scheme: internet-facing | |
alb.ingress.kubernetes.io/target-type: ip | |
spec: | |
tls: | |
- hosts: | |
- wordpressapp.com | |
rules: | |
- host: wordpressapp.com | |
http: | |
paths: | |
- backend: | |
serviceName: wordpressnp | |
servicePort: 80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setting up Amazon EKS | |
1. Run the following command to install the Kubernetes Cluster after install eksctl from eksctl.io | |
2. Configure the appropriate permissions to give access to IAM, EKS, EC2, and VPC. | |
3. Login to the EC2 Linux Instance with the appropriate | |
4. Install kubectl from here: https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/ | |
5. Enter the following command `eksctl create cluster` | |
# Installing AWS ALB Ingress | |
Run the following kubectl command to install it | |
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.1.3/docs/examples/2048/2048_full.yaml | |
# Deploying WordPress | |
Deploy WordPress by running `kubectl apply -f .` in the folder that has the following files | |
- mysql-deployment.yaml | |
- wordpress-deployment.yaml | |
- wpsecret.yaml | |
- ing.nse.yml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
storageClassName: default | |
resources: | |
requests: | |
storage: 200Gi | |
--- | |
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: 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: wordpress | |
labels: | |
app: wordpress | |
spec: | |
ports: | |
- port: 80 | |
selector: | |
app: wordpress | |
tier: frontend | |
type: NodePort | |
--- | |
apiVersion: v1 | |
kind: PersistentVolumeClaim | |
metadata: | |
name: wp-pv-claim | |
labels: | |
app: wordpress | |
spec: | |
accessModes: | |
- ReadWriteOnce | |
storageClassName: default | |
resources: | |
requests: | |
storage: 100Gi | |
--- | |
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 | |
kind: Deployment | |
metadata: | |
name: wordpress | |
labels: | |
app: wordpress | |
spec: | |
selector: | |
matchLabels: | |
app: wordpress | |
tier: frontend | |
strategy: | |
type: Recreate | |
template: | |
metadata: | |
labels: | |
app: wordpress | |
tier: frontend | |
spec: | |
containers: | |
- image: wordpress:5.5-php7.3-apache | |
name: wordpress | |
env: | |
- name: WORDPRESS_DB_HOST | |
value: wordpress-mysql | |
- name: WORDPRESS_DB_PASSWORD | |
valueFrom: | |
secretKeyRef: | |
name: mysql-pass | |
key: password | |
ports: | |
- containerPort: 80 | |
name: wordpress | |
volumeMounts: | |
- name: wordpress-persistent-storage | |
mountPath: /var/www/html | |
volumes: | |
- name: wordpress-persistent-storage | |
persistentVolumeClaim: | |
claimName: wp-pv-claim |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Secret | |
metadata: | |
name: mysql-pass | |
type: Opaque | |
data: | |
password: YWRtaW4= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment