The latest commit added the ghost-blog-service.yaml file, which includes the 'blog' namespace, and also support for both http and https ports and updated the configurations to include the namespace 'blog' across all the yaml files in the repository.

This commit is contained in:
gregory hendrickson
2023-01-26 01:11:43 -08:00
parent cfd4c4cbba
commit 3a00bf67a3
7 changed files with 87 additions and 72 deletions

View File

@@ -17,4 +17,25 @@ kubectl apply -f ingress-service.yaml
This will create the necessary resources in the cluster, including a deployment for the Ghost app, a service for connecting to the MySQL server, and an ingress service for routing traffic to the Ghost app via the nginx-proxy with https and http. This will create the necessary resources in the cluster, including a deployment for the Ghost app, a service for connecting to the MySQL server, and an ingress service for routing traffic to the Ghost app via the nginx-proxy with https and http.
Volumes Volumes
This configuration is using a Persistent Volume to store the Ghost blog data, this can be done by creating a persistent volume and persistent volume claim, and then referencing it in the ghost-blog-deployment.yaml file. This configuration is using a Persistent Volume to store the Ghost blog data, this can be done by creating a persistent volume and persistent volume claim, and then referencing it in the ghost-blog-deployment.yaml file.
# ingress-service.yaml
In this example, $(VAR_HOST) and $(SECRET_NAME) are variables that are stored in a configMap and a Secret, respectively. These variables can be managed and updated separately from the YAML files, making it easier to update and maintain your configuration.
To use variables in your YAML files, you'll first need to create a configMap and a Secret that contains the variables you need. You can do this using the kubectl command-line tool.
For configMap, you can create it with the following command:
Copy code
kubectl create configmap my-config-map --from-literal=VAR_HOST=example.com
And for Secret:
Copy code
kubectl create secret generic my-secret --from-literal=SECRET_NAME=mysecret
Once you've created the configMap and Secret, you can reference them in your YAML files using the $(VAR_NAME) syntax.
You can also manage and update the variables in the configMap and Secret using kubectl commands.
It's important to note that configMap and Secret are not the only way to use variables in Kubernetes, you can also use other tools like Helm or Kustomize.
#

View File

@@ -2,8 +2,9 @@ apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: ghost-blog name: ghost-blog
namespace: blog
spec: spec:
replicas: 1 replicas: 2
selector: selector:
matchLabels: matchLabels:
app: ghost-blog app: ghost-blog
@@ -17,45 +18,28 @@ spec:
image: ghost:latest image: ghost:latest
ports: ports:
- containerPort: 2368 - containerPort: 2368
resources:
limits:
memory: "512Mi"
cpu: "500m"
requests:
memory: "256Mi"
cpu: "250m"
env: env:
- name: database__client - name: database__client
value: mysql value: mysql
- name: database__connection__host - name: database__connection__host
value: mysql value: mysql-service
- name: database__connection__user - name: database__connection__user
value: ghost value: $(MYSQL_USER)
- name: database__connection__password - name: database__connection__password
value: ghostpassword value: $(MYSQL_PASSWORD)
- name: database__connection__database - name: url
value: ghost
- name: nginx-proxy
image: nginx:latest
ports:
- containerPort: 80
- containerPort: 443
resources: resources:
limits: limits:
memory: "512Mi" cpu: "0.5"
cpu: "500m" memory: "1Gi"
requests: requests:
memory: "256Mi" cpu: "0.1"
cpu: "250m" memory: "512Mi"
env:
- name: ghost-blog-nginx-proxy
value: ghost-blog
- name: ghost-blog-nginx-config
value: /etc/nginx/conf.d/default.conf
volumeMounts: volumeMounts:
- name: ghost-blog-nginx-config-volume - name: ghost-persistent-storage
mountPath: /etc/nginx/conf.d/ mountPath: /var/lib/ghost/content
volumes: volumes:
- name: ghost-blog-nginx-config-volume - name: ghost-persistent-storage
configMap: persistentVolumeClaim:
name: ghost-blog-nginx-config claimName: ghost-pvc

View File

@@ -2,6 +2,9 @@ apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: mysql name: mysql
namespace: blog
labels:
app: mysql
spec: spec:
replicas: 1 replicas: 1
selector: selector:
@@ -17,19 +20,26 @@ spec:
image: mysql:latest image: mysql:latest
ports: ports:
- containerPort: 3306 - containerPort: 3306
resources:
limits:
memory: "512Mi"
cpu: "500m"
requests:
memory: "256Mi"
cpu: "250m"
env: env:
- name: MYSQL_ROOT_PASSWORD - name: MYSQL_ROOT_PASSWORD
value: password value: password
- name: MYSQL_DATABASE - name: MYSQL_DATABASE
value: ghost value: ghost_db
- name: MYSQL_USER - name: MYSQL_USER
value: ghost value: ghost
- name: MYSQL_PASSWORD - name: MYSQL_PASSWORD
value: ghostpassword value: password
resources:
limits:
cpu: "0.5"
memory: "1Gi"
requests:
cpu: "0.1"
memory: "512Mi"
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pvc

4
namespace.yaml Normal file
View File

@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: blog

View File

@@ -1,37 +1,31 @@
apiVersion: networking.k8s.io/v1 apiVersion: networking.k8s.io/v1
kind: Ingress kind: Ingress
metadata: metadata:
name: ghost-blog-ingress name: ingress-service
namespace: blog
annotations: annotations:
nginx.ingress.kubernetes.io/rewrite-target: / nginx.ingress.kubernetes.io/rewrite-target: /
kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/configuration-snippet: |
cert-manager.io/cluster-issuer: letsencrypt-prod proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_pass_request_headers on;
spec: spec:
tls:
- hosts:
- example.com
secretName: example-com-tls
rules: rules:
- host: example.com - host: $(VAR_HOST)
http: http:
paths: paths:
- path: / - path: /
pathType: Prefix pathType: Prefix
pathRewrite: / pathRewrite: /ghost/
backend: backend:
service: service:
name: ghost-blog-service name: ghost-blog-service
port: port:
name: http name: http
- host: example.com path: /
http: tls:
paths: - hosts:
- path: / - $(VAR_HOST)
pathType: Prefix secretName: $(SECRET_NAME)
pathRewrite: /
backend:
service:
name: ghost-blog-service
port:
name: https

View File

@@ -2,6 +2,7 @@ apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: ghost-blog-service name: ghost-blog-service
namespace: blog
spec: spec:
selector: selector:
app: ghost-blog app: ghost-blog

View File

@@ -2,6 +2,7 @@ apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: mysql-service name: mysql-service
namespace: blog
spec: spec:
selector: selector:
app: mysql app: mysql