From 658c77d672487d47587e3ca3b2583d5f706cccb0 Mon Sep 17 00:00:00 2001 From: gregory hendrickson Date: Thu, 26 Jan 2023 00:43:29 -0800 Subject: [PATCH] Added configurations for deploying Ghost blog on Kubernetes using MySQL and nginx-proxy. Included resource limits for ghost-blog-deployment and mysql-deployment.yaml, created ingress-service.yaml for nginx-proxy with https and http, and added ghost-blog-service.yaml and mysql-service.yaml for connecting the Ghost blog app to the MySQL server. Also added a namespace 'blog' for better organization of resources. --- deployments/ghost-blog-deployment.yaml | 41 ++++++++++++++++--- deployments/mysql-deployment.yaml | 22 +++++----- deployments/traefik-deployment.yaml | 26 ------------ networking/ingress-service.yaml | 37 +++++++++++++++++ ...g-service.yaml => ghost-blog-service.yaml} | 7 ++-- services/mysql-service.yaml | 5 ++- 6 files changed, 90 insertions(+), 48 deletions(-) delete mode 100644 deployments/traefik-deployment.yaml create mode 100644 networking/ingress-service.yaml rename services/{blog-service.yaml => ghost-blog-service.yaml} (72%) diff --git a/deployments/ghost-blog-deployment.yaml b/deployments/ghost-blog-deployment.yaml index 82983b9..c319c92 100644 --- a/deployments/ghost-blog-deployment.yaml +++ b/deployments/ghost-blog-deployment.yaml @@ -3,10 +3,10 @@ kind: Deployment metadata: name: ghost-blog spec: + replicas: 1 selector: matchLabels: app: ghost-blog - replicas: 1 template: metadata: labels: @@ -14,19 +14,48 @@ spec: spec: containers: - name: ghost-blog - image: ghost:3 + image: ghost:latest ports: - containerPort: 2368 + resources: + limits: + memory: "512Mi" + cpu: "500m" + requests: + memory: "256Mi" + cpu: "250m" env: - name: database__client value: mysql - name: database__connection__host - value: mysql-service + value: mysql - name: database__connection__user value: ghost - name: database__connection__password - value: ghost + value: ghostpassword - name: database__connection__database value: ghost - - \ No newline at end of file + - name: nginx-proxy + image: nginx:latest + ports: + - containerPort: 80 + - containerPort: 443 + resources: + limits: + memory: "512Mi" + cpu: "500m" + requests: + memory: "256Mi" + cpu: "250m" + env: + - name: ghost-blog-nginx-proxy + value: ghost-blog + - name: ghost-blog-nginx-config + value: /etc/nginx/conf.d/default.conf + volumeMounts: + - name: ghost-blog-nginx-config-volume + mountPath: /etc/nginx/conf.d/ + volumes: + - name: ghost-blog-nginx-config-volume + configMap: + name: ghost-blog-nginx-config diff --git a/deployments/mysql-deployment.yaml b/deployments/mysql-deployment.yaml index 4671a46..d14a4fb 100644 --- a/deployments/mysql-deployment.yaml +++ b/deployments/mysql-deployment.yaml @@ -14,7 +14,16 @@ spec: spec: containers: - name: mysql - image: mysql:5.7 + image: mysql:latest + ports: + - containerPort: 3306 + resources: + limits: + memory: "512Mi" + cpu: "500m" + requests: + memory: "256Mi" + cpu: "250m" env: - name: MYSQL_ROOT_PASSWORD value: password @@ -23,13 +32,4 @@ spec: - name: MYSQL_USER value: ghost - name: MYSQL_PASSWORD - value: password - ports: - - containerPort: 3306 - volumeMounts: - - name: mysql-data - mountPath: /var/lib/mysql - volumes: - - name: mysql-data - configMap: - name: mysql-data \ No newline at end of file + value: ghostpassword diff --git a/deployments/traefik-deployment.yaml b/deployments/traefik-deployment.yaml deleted file mode 100644 index ef52f86..0000000 --- a/deployments/traefik-deployment.yaml +++ /dev/null @@ -1,26 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: traefik -spec: - replicas: 1 - selector: - matchLabels: - app: traefik - template: - metadata: - labels: - app: traefik - spec: - containers: - - name: traefik - image: traefik:v2.3 - ports: - - name: web - containerPort: 80 - - name: websecure - containerPort: 443 - - name: admin - containerPort: 8080 - args: - - \ No newline at end of file diff --git a/networking/ingress-service.yaml b/networking/ingress-service.yaml new file mode 100644 index 0000000..f732051 --- /dev/null +++ b/networking/ingress-service.yaml @@ -0,0 +1,37 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ghost-blog-ingress + annotations: + nginx.ingress.kubernetes.io/rewrite-target: / + kubernetes.io/ingress.class: nginx + cert-manager.io/cluster-issuer: letsencrypt-prod +spec: + tls: + - hosts: + - example.com + secretName: example-com-tls + rules: + - host: example.com + http: + paths: + - path: / + pathType: Prefix + pathRewrite: / + backend: + service: + name: ghost-blog-service + port: + name: http + - host: example.com + http: + paths: + - path: / + pathType: Prefix + pathRewrite: / + backend: + service: + name: ghost-blog-service + port: + name: https + diff --git a/services/blog-service.yaml b/services/ghost-blog-service.yaml similarity index 72% rename from services/blog-service.yaml rename to services/ghost-blog-service.yaml index 01dd182..c080399 100644 --- a/services/blog-service.yaml +++ b/services/ghost-blog-service.yaml @@ -7,8 +7,9 @@ spec: app: ghost-blog ports: - name: http - port: 2368 + port: 80 + targetPort: 2368 + - name: https + port: 443 targetPort: 2368 type: ClusterIP - - diff --git a/services/mysql-service.yaml b/services/mysql-service.yaml index 874c150..676ae37 100644 --- a/services/mysql-service.yaml +++ b/services/mysql-service.yaml @@ -1,11 +1,12 @@ apiVersion: v1 kind: Service metadata: - name: mysql + name: mysql-service spec: selector: app: mysql ports: - name: mysql port: 3306 - type: ClusterIP \ No newline at end of file + targetPort: 3306 + type: ClusterIP