updated all volumes, updated nginx-proxy.

This commit is contained in:
gregory hendrickson
2023-01-26 03:07:32 -08:00
parent a64ac34a99
commit 250a82b87c
10 changed files with 89 additions and 58 deletions

1
.gitignore vendored
View File

@@ -14,3 +14,4 @@
.DS_Store
Thumbs.db
blog-config-map.yaml

View File

@@ -7,7 +7,6 @@ The kubectl command-line tool installed on your local machine
Deployment
To deploy the Ghost blog, run the following commands:
Copy code
kubectl apply -f namespace.yaml
kubectl apply -f ghost-blog-deployment.yaml
kubectl apply -f ghost-blog-service.yaml
@@ -19,24 +18,7 @@ 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
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.
# ghost-blog-deployment.yaml
In this example, the ghost-blog-deployment.yaml file has been updated to include the use of configMapKeyRef and secretKeyRef to reference variables for the url and database connection details respectively. The configMap and secrets resources must be created separately and referenced here. Additionally, the database__client and all database__connection__* keys are using secrets to manage the sensitive data. I've also defined resources limits and requests for the ghost-blog container. volumeMounts and volumes sections are added to the deployment.yaml file for the persistent volume claim for ghost-data.
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

View File

@@ -1,37 +1,38 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-proxy
name: nginx-proxy-manager
namespace: blog
spec:
replicas: 1
selector:
app: nginx-proxy
matchLabels:
app: nginx-proxy
app: nginx-proxy-manager
template:
metadata:
labels:
app: nginx-proxy
app: nginx-proxy-manager
spec:
containers:
- name: nginx-proxy
image: nginx:latest
ports:
- name: http
containerPort: 80
- name: https
containerPort: 443
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 50m
memory: 64Mi
volumeMounts:
- name: nginx-proxy-data
mountPath: /etc/nginx
- name: nginx-proxy-manager
image: jc21/nginx-proxy-manager:latest
ports:
- containerPort: 80
name: http
- containerPort: 443
name: https
volumeMounts:
- name: nginx-proxy-manager-data
mountPath: /data
resources:
limits:
memory: "128Mi"
cpu: "500m"
requests:
memory: "64Mi"
cpu: "250m"
volumes:
- name: nginx-proxy-data
persistentVolumeClaim:
claimName: nginx-proxy-data-pvc
- name: nginx-proxy-manager-data
persistentVolumeClaim:
claimName: nginx-proxy-manager-pvc

View File

@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: nginx-proxy
namespace: blog
spec:
selector:
app: nginx-proxy
ports:
- name: http
port: 80
targetPort: 80
- name: https
port: 443
targetPort: 443

View File

@@ -1,14 +1,13 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: ghost-blog-pv
labels:
type: local
name: ghost-data-pv
namespace: blog
spec:
storageClassName: manual
capacity:
storage: 1Gi
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data/ghost-blog"
path: /data/ghost-data
persistentVolumeReclaimPolicy: Retain

View File

@@ -1,11 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ghost-blog-pvc
name: ghost-data-pvc
namespace: blog
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storage: 10Gi
selector:
matchLabels:
app: ghost-blog

View File

@@ -3,12 +3,12 @@ kind: PersistentVolume
metadata:
name: mysql-pv
labels:
type: local
app: mysql
spec:
storageClassName: manual
storageClassName: standard
capacity:
storage: 1Gi
storage: 5Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data/mysql"
path: /mnt/data/mysql

View File

@@ -2,10 +2,13 @@ apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pvc
namespace: blog
labels:
app: mysql
spec:
storageClassName: manual
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storage: 5Gi

View File

@@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: nginx-proxy-pv
namespace: blog
spec:
capacity:
storage: 2Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data/nginx-proxy"
persistentVolumeReclaimPolicy: Retain

View File

@@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nginx-proxy-pvc
namespace: blog
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
selector:
matchLabels:
app: nginx-proxy