Last active
June 24, 2024 19:15
-
-
Save sagar290/7da571f393a0ff5d53f7f4b5248f1423 to your computer and use it in GitHub Desktop.
Deploy WordPress easily in Kubernetes with this wordpress-complete-config.yaml. It includes configurations for WordPress, MySQL. kubectl apply -f wordpress-complete-config.yaml.
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
# Add secret | |
apiVersion: v1 | |
kind: Secret | |
metadata: | |
name: mysql-secret | |
type: Opaque | |
data: | |
MYSQL_ROOT_PASSWORD: bXlwYXNzd29yZAo= | |
--- | |
# Installing PV and PVC | |
apiVersion: v1 | |
kind: PersistentVolume | |
metadata: | |
name: mysql-pv | |
namespace: hermes | |
spec: | |
capacity: | |
storage: 10Gi | |
accessModes: | |
- ReadWriteOnce | |
persistentVolumeReclaimPolicy: Retain | |
storageClassName: manual | |
hostPath: | |
path: /mnt/data | |
--- | |
apiVersion: v1 | |
kind: PersistentVolumeClaim | |
metadata: | |
name: mysql-pvc | |
namespace: hermes | |
spec: | |
accessModes: | |
- ReadWriteOnce | |
resources: | |
requests: | |
storage: 5Gi | |
storageClassName: manual | |
--- | |
apiVersion: v1 | |
kind: PersistentVolume | |
metadata: | |
name: wordpress-pv | |
namespace: hermes | |
spec: | |
capacity: | |
storage: 5Gi | |
accessModes: | |
- ReadWriteOnce | |
persistentVolumeReclaimPolicy: Retain | |
storageClassName: manual | |
hostPath: | |
path: /home/ubuntu/project/wp-data | |
--- | |
apiVersion: v1 | |
kind: PersistentVolumeClaim | |
metadata: | |
name: wordpress-pvc | |
namespace: hermes | |
spec: | |
accessModes: | |
- ReadWriteOnce | |
resources: | |
requests: | |
storage: 1Gi | |
storageClassName: manual | |
--- | |
# Installing Mysql | |
apiVersion: apps/v1 | |
kind: StatefulSet | |
metadata: | |
name: mysql | |
labels: | |
app: mysql | |
spec: | |
replicas: 1 | |
serviceName: mysql | |
selector: | |
matchLabels: | |
app: mysql | |
template: | |
metadata: | |
labels: | |
app: mysql | |
spec: | |
containers: | |
- name: database | |
image: mysql:latest | |
envFrom: | |
- secretRef: | |
name: mysql-secret | |
ports: | |
- containerPort: 3306 | |
volumeMounts: | |
- name: mysql-data | |
mountPath: /var/lib/mysql | |
volumes: | |
- name: mysql-data | |
persistentVolumeClaim: | |
claimName: mysql-pvc | |
--- | |
# Installing Mysql Service | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: mysql-service | |
spec: | |
ports: | |
- port: 3306 | |
protocol: TCP | |
selector: | |
app: mysql | |
--- | |
# Installing wordpress | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: wordpress | |
spec: | |
replicas: 2 | |
selector: | |
matchLabels: | |
app: wordpress | |
template: | |
metadata: | |
labels: | |
app: wordpress | |
spec: | |
containers: | |
- name: wordpress | |
image: wordpress:latest | |
ports: | |
- containerPort: 80 | |
name: wordpress | |
volumeMounts: | |
- name: wordpress-data | |
mountPath: /var/www/html | |
env: | |
- name: WORDPRESS_DEBUG | |
value: "true" | |
- name: WORDPRESS_DB_HOST | |
value: mysql-service | |
- name: WORDPRESS_DB_PASSWORD | |
valueFrom: | |
secretKeyRef: | |
name: mysql-secret | |
key: MYSQL_ROOT_PASSWORD | |
- name: WORDPRESS_DB_USER | |
value: root | |
- name: WORDPRESS_DB_NAME | |
value: wordpress | |
volumes: | |
- name: wordpress-data | |
persistentVolumeClaim: | |
claimName: wordpress-pvc | |
--- | |
kind: Service | |
apiVersion: v1 | |
metadata: | |
name: wordpress-service | |
spec: | |
type: NodePort | |
selector: | |
app: wordpress | |
ports: | |
- name: http | |
protocol: TCP | |
port: 80 | |
targetPort: 80 | |
nodePort: 30007 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment