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

@@ -18,3 +18,24 @@ This will create the necessary resources in the cluster, including a deployment
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.
# 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
metadata:
name: ghost-blog
namespace: blog
spec:
replicas: 1
replicas: 2
selector:
matchLabels:
app: ghost-blog
@@ -17,45 +18,28 @@ spec:
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
value: mysql-service
- name: database__connection__user
value: ghost
value: $(MYSQL_USER)
- name: database__connection__password
value: ghostpassword
- name: database__connection__database
value: ghost
- name: nginx-proxy
image: nginx:latest
ports:
- containerPort: 80
- containerPort: 443
value: $(MYSQL_PASSWORD)
- name: url
resources:
limits:
memory: "512Mi"
cpu: "500m"
cpu: "0.5"
memory: "1Gi"
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
cpu: "0.1"
memory: "512Mi"
volumeMounts:
- name: ghost-blog-nginx-config-volume
mountPath: /etc/nginx/conf.d/
- name: ghost-persistent-storage
mountPath: /var/lib/ghost/content
volumes:
- name: ghost-blog-nginx-config-volume
configMap:
name: ghost-blog-nginx-config
- name: ghost-persistent-storage
persistentVolumeClaim:
claimName: ghost-pvc

View File

@@ -2,6 +2,9 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
namespace: blog
labels:
app: mysql
spec:
replicas: 1
selector:
@@ -17,19 +20,26 @@ spec:
image: mysql:latest
ports:
- containerPort: 3306
resources:
limits:
memory: "512Mi"
cpu: "500m"
requests:
memory: "256Mi"
cpu: "250m"
env:
- name: MYSQL_ROOT_PASSWORD
value: password
- name: MYSQL_DATABASE
value: ghost
value: ghost_db
- name: MYSQL_USER
value: ghost
- 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
kind: Ingress
metadata:
name: ghost-blog-ingress
name: ingress-service
namespace: blog
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
kubernetes.io/ingress.class: nginx
cert-manager.io/cluster-issuer: letsencrypt-prod
nginx.ingress.kubernetes.io/configuration-snippet: |
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:
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
- host: $(VAR_HOST)
http:
paths:
- path: /
pathType: Prefix
pathRewrite: /ghost/
backend:
service:
name: ghost-blog-service
port:
name: http
path: /
tls:
- hosts:
- $(VAR_HOST)
secretName: $(SECRET_NAME)

View File

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

View File

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