diff --git a/.gitignore b/.gitignore index 444dc55..94965a1 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ .DS_Store Thumbs.db +blog-config-map.yaml \ No newline at end of file diff --git a/README.md b/README.md index c9b6da0..789c342 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file +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 \ No newline at end of file diff --git a/deployments/nginx-proxy-deployment.yaml b/deployments/nginx-proxy-deployment.yaml index f1246e7..ba8512f 100644 --- a/deployments/nginx-proxy-deployment.yaml +++ b/deployments/nginx-proxy-deployment.yaml @@ -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 \ No newline at end of file diff --git a/services/nginx-proxy-service.yaml b/services/nginx-proxy-service.yaml new file mode 100644 index 0000000..acba1dd --- /dev/null +++ b/services/nginx-proxy-service.yaml @@ -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 diff --git a/volumes/blog-pv.yaml b/volumes/blog-pv.yaml index 9205fde..552b120 100644 --- a/volumes/blog-pv.yaml +++ b/volumes/blog-pv.yaml @@ -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 \ No newline at end of file diff --git a/volumes/blog-pvc.yaml b/volumes/blog-pvc.yaml index fd8d4be..ec5b801 100644 --- a/volumes/blog-pvc.yaml +++ b/volumes/blog-pvc.yaml @@ -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 \ No newline at end of file diff --git a/volumes/mysql-pv.yaml b/volumes/mysql-pv.yaml index b21bd95..6a58093 100644 --- a/volumes/mysql-pv.yaml +++ b/volumes/mysql-pv.yaml @@ -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 \ No newline at end of file diff --git a/volumes/mysql-pvc.yaml b/volumes/mysql-pvc.yaml index 44eee00..44ea900 100644 --- a/volumes/mysql-pvc.yaml +++ b/volumes/mysql-pvc.yaml @@ -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 \ No newline at end of file diff --git a/volumes/nginx-pv.yaml b/volumes/nginx-pv.yaml index e69de29..c8a0888 100644 --- a/volumes/nginx-pv.yaml +++ b/volumes/nginx-pv.yaml @@ -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 \ No newline at end of file diff --git a/volumes/nginx-pvc.yaml b/volumes/nginx-pvc.yaml index e69de29..94a134a 100644 --- a/volumes/nginx-pvc.yaml +++ b/volumes/nginx-pvc.yaml @@ -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