feature(wip): Implement basic services and some databases.

This commit is contained in:
greysoh 2024-07-19 10:45:34 -04:00
parent c36ae6cdf0
commit 7b7f90ff16
Signed by: imterah
GPG key ID: 8FA7DD57BA6CEA37
38 changed files with 794 additions and 6 deletions

View file

@ -0,0 +1,4 @@
# IP map
* `192.168.2.11` = PostgreSQL
* `192.168.2.12` = MariaDB/MySQL
* `192.168.2.13-14` = Reserved (maybe add Redis?)

View file

@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: mariadb-details
labels:
app: mariadb
data:
MARIADB_DATABASE: mdb_db

View file

@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: mariadb
labels:
app: mariadb
annotations:
metallb.universe.tf/loadBalancerIPs: 192.168.2.12
spec:
type: LoadBalancer
ports:
- protocol: TCP
port: 3306
targetPort: 3306
selector:
app: mariadb

View file

@ -0,0 +1,37 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: mariadb-deployment
spec:
replicas: 2
selector:
matchLabels:
app: mariadb
template:
metadata:
labels:
app: mariadb
spec:
containers:
- name: mariadb
image: "mariadb:11.2.4"
ports:
- containerPort: 3306
envFrom:
- configMapRef:
name: mariadb-details
env:
- name: MARIADB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: db-credentials
key: password
- name: MARIADB_DATABASE
value: mdb_db
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: mariadb_data
volumes:
- name: mariadb_data
persistentVolumeClaim:
claimName: mariadb-volume-claim

View file

@ -0,0 +1,42 @@
[meta]
format_ver = 1
[mariadb_configmap]
mode = k3s
depends_on = metallb_ip_config:db_credentials
[#mariadb_configmap/k3s]
mode = install
yml_path = ./configmap.yml
[mariadb_pv]
mode = k3s
depends_on = mariadb_configmap
[#mariadb_pv/k3s]
mode = install
yml_path = ./pv.yml
[mariadb_pv_claim]
mode = k3s
depends_on = mariadb_pv
[#mariadb_pv_claim/k3s]
mode = install
yml_path = ./pv-claim.yml
[mariadb]
mode = k3s
depends_on = mariadb_pv_claim
[#mariadb/k3s]
mode = install
yml_path = ./mariadb.yml
[mariadb_svc]
mode = k3s
depends_on = mariadb
[#mariadb_svc/k3s]
mode = install
yml_path = ./mariadb-svc.yml

View file

@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mariadb-volume-claim
labels:
app: mariadb
spec:
storageClassName: manual
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi

View file

@ -0,0 +1,15 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: mariadb-volume
labels:
type: local
app: mariadb
spec:
storageClassName: manual
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
hostPath:
path: /var/lib/mysql

View file

@ -0,0 +1,30 @@
apiVersion: v1
kind: Service
metadata:
name: pgadmin
spec:
ports:
- name: web
port: 80
targetPort: web
selector:
app: pgadmin
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: pgadmin-ingress
spec:
rules:
- host: "pgadmin.hofers.cloud"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: pgadmin
port:
name: web

View file

@ -0,0 +1,30 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: pgadmin
spec:
replicas: 1
selector:
matchLabels:
app: pgadmin
template:
metadata:
labels:
app: pgadmin
spec:
containers:
- name: pgadmin
image: dpage/pgadmin4
ports:
- containerPort: 80
env:
- name: PGADMIN_DEFAULT_EMAIL
valueFrom:
secretKeyRef:
name: pgadmin-credentials
key: default-email
- name: PGADMIN_DEFAULT_PASSWORD
valueFrom:
secretKeyRef:
name: pgadmin-credentials
key: default-password

View file

@ -0,0 +1,34 @@
[meta]
format_ver = 1
[pgadmin_pv]
mode = k3s
depends_on = traefik:postgres_svc
[#pgadmin_pv/k3s]
mode = install
yml_path = ./pv.yml
[pgadmin_pv_claim]
mode = k3s
depends_on = pgadmin_pv
[#pgadmin_pv_claim/k3s]
mode = install
yml_path = ./pv-claim.yml
[pgadmin]
mode = k3s
depends_on = pgadmin_pv_claim
[#pgadmin/k3s]
mode = install
yml_path = ./pgadmin.yml
[pgadmin_svc]
mode = k3s
depends_on = pgadmin
[#pgadmin_svc/k3s]
mode = install
yml_path = ./pgadmin-svc.yml

View file

@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pgadmin-volume-claim
labels:
app: pgadmin
spec:
storageClassName: manual
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi

View file

@ -0,0 +1,15 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: pgadmin-data
labels:
type: local
app: pgadmin
spec:
storageClassName: manual
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
hostPath:
path: /var/lib/pgadmin

View file

@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-db-details
labels:
app: postgres
data:
POSTGRES_DB: ps_db

View file

@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: postgres
labels:
app: postgres
annotations:
metallb.universe.tf/loadBalancerIPs: 192.168.2.11
spec:
type: LoadBalancer
ports:
- protocol: TCP
port: 5432
targetPort: 5432
selector:
app: postgres

View file

@ -0,0 +1,41 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres-deployment
spec:
replicas: 2
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: "postgres:16"
imagePullPolicy: IfNotPresent
ports:
- containerPort: 5432
envFrom:
- configMapRef:
name: postgres-db-details
env:
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: db-credentials
key: username
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: db-credentials
key: password
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgresdata
volumes:
- name: postgresdata
persistentVolumeClaim:
claimName: postgres-volume-claim

View file

@ -0,0 +1,42 @@
[meta]
format_ver = 1
[postgres_configmap]
mode = k3s
depends_on = metallb_ip_config:db_credentials
[#postgres_configmap/k3s]
mode = install
yml_path = ./configmap.yml
[postgres_pv]
mode = k3s
depends_on = postgres_configmap
[#postgres_pv/k3s]
mode = install
yml_path = ./pv.yml
[postgres_pv_claim]
mode = k3s
depends_on = postgres_pv
[#postgres_pv_claim/k3s]
mode = install
yml_path = ./pv-claim.yml
[postgres]
mode = k3s
depends_on = postgres_pv_claim
[#postgres/k3s]
mode = install
yml_path = ./postgres.yml
[postgres_svc]
mode = k3s
depends_on = postgres
[#postgres_svc/k3s]
mode = install
yml_path = ./postgres-svc.yml

View file

@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-volume-claim
labels:
app: postgres
spec:
storageClassName: manual
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi

View file

@ -0,0 +1,15 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: postgres-volume
labels:
type: local
app: postgres
spec:
storageClassName: manual
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
hostPath:
path: /data/postgresql

View file

@ -0,0 +1,17 @@
[meta]
format_ver = 1
[postgres]
description = PostgreSQL
mode = include
path = ./postgresql/project.ini
[mariadb]
description = MariaDB
mode = include
path = ./mariadb/project.ini
[pgadmin]
description = pgAdmin
mode = include
path = ./pgadmin/project.ini