feature(wip): Implement basic services and some databases.
This commit is contained in:
parent
c36ae6cdf0
commit
7b7f90ff16
38 changed files with 794 additions and 6 deletions
4
kubernetes/databases/README.md
Normal file
4
kubernetes/databases/README.md
Normal 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?)
|
8
kubernetes/databases/mariadb/configmap.yml
Normal file
8
kubernetes/databases/mariadb/configmap.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: mariadb-details
|
||||
labels:
|
||||
app: mariadb
|
||||
data:
|
||||
MARIADB_DATABASE: mdb_db
|
17
kubernetes/databases/mariadb/mariadb-svc.yml
Normal file
17
kubernetes/databases/mariadb/mariadb-svc.yml
Normal 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
|
37
kubernetes/databases/mariadb/mariadb.yml
Normal file
37
kubernetes/databases/mariadb/mariadb.yml
Normal 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
|
42
kubernetes/databases/mariadb/project.ini
Normal file
42
kubernetes/databases/mariadb/project.ini
Normal 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
|
13
kubernetes/databases/mariadb/pv-claim.yml
Normal file
13
kubernetes/databases/mariadb/pv-claim.yml
Normal 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
|
15
kubernetes/databases/mariadb/pv.yml
Normal file
15
kubernetes/databases/mariadb/pv.yml
Normal 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
|
30
kubernetes/databases/pgadmin/pgadmin-svc.yml
Normal file
30
kubernetes/databases/pgadmin/pgadmin-svc.yml
Normal 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
|
30
kubernetes/databases/pgadmin/pgadmin.yml
Normal file
30
kubernetes/databases/pgadmin/pgadmin.yml
Normal 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
|
34
kubernetes/databases/pgadmin/project.ini
Normal file
34
kubernetes/databases/pgadmin/project.ini
Normal 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
|
13
kubernetes/databases/pgadmin/pv-claim.yml
Normal file
13
kubernetes/databases/pgadmin/pv-claim.yml
Normal 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
|
15
kubernetes/databases/pgadmin/pv.yml
Normal file
15
kubernetes/databases/pgadmin/pv.yml
Normal 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
|
8
kubernetes/databases/postgresql/configmap.yml
Normal file
8
kubernetes/databases/postgresql/configmap.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: postgres-db-details
|
||||
labels:
|
||||
app: postgres
|
||||
data:
|
||||
POSTGRES_DB: ps_db
|
17
kubernetes/databases/postgresql/postgres-svc.yml
Normal file
17
kubernetes/databases/postgresql/postgres-svc.yml
Normal 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
|
41
kubernetes/databases/postgresql/postgres.yml
Normal file
41
kubernetes/databases/postgresql/postgres.yml
Normal 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
|
42
kubernetes/databases/postgresql/project.ini
Normal file
42
kubernetes/databases/postgresql/project.ini
Normal 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
|
13
kubernetes/databases/postgresql/pv-claim.yml
Normal file
13
kubernetes/databases/postgresql/pv-claim.yml
Normal 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
|
15
kubernetes/databases/postgresql/pv.yml
Normal file
15
kubernetes/databases/postgresql/pv.yml
Normal 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
|
17
kubernetes/databases/project.ini
Normal file
17
kubernetes/databases/project.ini
Normal 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
|
Reference in a new issue