From 8020652d564274ff32375230db4b0f531a17863d Mon Sep 17 00:00:00 2001 From: Isaac Hunter Date: Sun, 17 Nov 2024 12:54:32 -0500 Subject: [PATCH] add storage, delete script, docs for port forwarding --- k8s/README.md | 26 ++++++++++++++++++++++++++ k8s/namespaces.yml | 6 ------ k8s/scripts/create.sh | 4 ++++ k8s/scripts/destroy.sh | 8 ++++++++ k8s/storage.yml | 41 +++++++++++++++++++++++++++++++++++++++++ k8s/workloads.yml | 13 +++++++++++++ 6 files changed, 92 insertions(+), 6 deletions(-) delete mode 100644 k8s/namespaces.yml create mode 100644 k8s/scripts/destroy.sh create mode 100644 k8s/storage.yml diff --git a/k8s/README.md b/k8s/README.md index 1cd51a9..86a66fc 100644 --- a/k8s/README.md +++ b/k8s/README.md @@ -33,3 +33,29 @@ ```sh minikube dashboard ``` + +### Accessing Cluster + +The general way to access a nodeport is via the following command: + +```sh +kubectl port-forward svc/service-name host-port:service-port --namespace namespace +``` + +Running this command will start a long-running process in that terminal tab. You would start a new terminal instance for each port you forward. + +#### Forwarding Base Routes + +Run this command to open up the base 8080 port onto 30080 on your local machine: + +```sh +kubectl port-forward svc/proxy 30080:8080 --namespace main +``` + +#### Forwarding Club Manager Admin + +Use this command to forward the port 8081, used for the club manager site/admin, onto 30081 of your local machine: + +```sh +kubectl port-forward svc/proxy 30081:8081 --namespace main +``` diff --git a/k8s/namespaces.yml b/k8s/namespaces.yml deleted file mode 100644 index 02f3b30..0000000 --- a/k8s/namespaces.yml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: main - labels: - name: main diff --git a/k8s/scripts/create.sh b/k8s/scripts/create.sh index 8dd5a64..6cac543 100755 --- a/k8s/scripts/create.sh +++ b/k8s/scripts/create.sh @@ -13,6 +13,10 @@ helm install redis ./charts/redis \ --namespace redis \ --create-namespace +# Create main namespace if it doesn't exist +kubectl create namespace main --dry-run=client -o yaml | kubectl apply -f - + # Apply kubernetes files +kubectl apply -f namespaces.yml kubectl apply -f . diff --git a/k8s/scripts/destroy.sh b/k8s/scripts/destroy.sh new file mode 100644 index 0000000..dc517b0 --- /dev/null +++ b/k8s/scripts/destroy.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +set -e + +kubectl delete -f . --grace-period=0 --force --wait=false + +helm uninstall postgres --namespace postgres +helm uninstall redis --namespace redis diff --git a/k8s/storage.yml b/k8s/storage.yml new file mode 100644 index 0000000..3142c2c --- /dev/null +++ b/k8s/storage.yml @@ -0,0 +1,41 @@ +######################## +## Volume Definitions ## +######################## +# What volumes exist and how + +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: cluster-storage + namespace: main +spec: + storageClassName: cluster-pv + capacity: + storage: 20Gi + accessModes: + - ReadWriteOnce + volumeMode: Filesystem + persistentVolumeReclaimPolicy: Recycle + hostPath: + path: /mnt/data + type: DirectoryOrCreate + +################### +## Volume Claims ## +################### +# Who is assigned what volume + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: club-static-pvc + namespace: main +spec: + storageClassName: cluster-pv + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1G diff --git a/k8s/workloads.yml b/k8s/workloads.yml index 48da885..beaf900 100644 --- a/k8s/workloads.yml +++ b/k8s/workloads.yml @@ -1,3 +1,6 @@ +############################# +## Jukebox Server Workload ## +############################# apiVersion: apps/v1 kind: Deployment metadata: @@ -20,6 +23,9 @@ spec: - configMapRef: name: jukebox-server-config +############################ +## Reverse Proxy Workload ## +############################ --- apiVersion: apps/v1 kind: Deployment @@ -42,6 +48,9 @@ spec: - configMapRef: name: proxy-config +################################## +## Club Manager Server Workload ## +################################## --- apiVersion: apps/v1 kind: Deployment @@ -63,3 +72,7 @@ spec: envFrom: - configMapRef: name: club-manager-config + volumes: + - name: club-static + persistentVolumeClaim: + claimName: club-static-pvc