switch from mariadb to postgres
This commit is contained in:
parent
d05812e9d6
commit
0678bbd56d
|
@ -0,0 +1,8 @@
|
|||
CREATE USER gitea WITH PASSWORD 'changeme';
|
||||
CREATE DATABASE gitea WITH OWNER gitea;
|
||||
|
||||
CREATE USER grafana WITH password 'changeme';
|
||||
CREATE DATABASE grafana WITH OWNER grafana;
|
||||
|
||||
CREATE USER nextcloud WITH PASSWORD 'changeme';
|
||||
CREATE DATABASE nextcloud WITH OWNER nextcloud;
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
k3d cluster delete local
|
||||
docker rm -f registry-localhost
|
||||
docker rm -f mariadb-localhost
|
||||
docker rm -f postgres-localhost
|
||||
docker rm -f nfs-localhost
|
||||
|
|
|
@ -30,26 +30,26 @@ spec:
|
|||
- name: SSH_DOMAIN
|
||||
value: ${GITEA_EXTERNAL_HOST}
|
||||
- name: DB_TYPE
|
||||
value: mysql
|
||||
value: postgres
|
||||
- name: DB_HOST
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mariadb-credentials-secret
|
||||
name: postgres-credentials-secret
|
||||
key: host
|
||||
- name: DB_NAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mariadb-credentials-secret
|
||||
name: postgres-credentials-secret
|
||||
key: database
|
||||
- name: DB_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mariadb-credentials-secret
|
||||
name: postgres-credentials-secret
|
||||
key: username
|
||||
- name: DB_PASSWD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mariadb-credentials-secret
|
||||
name: postgres-credentials-secret
|
||||
key: password
|
||||
ports:
|
||||
- name: http
|
||||
|
|
|
@ -3,11 +3,11 @@ resources:
|
|||
- ingress.yaml
|
||||
|
||||
secretGenerator:
|
||||
- name: mariadb-credentials-secret
|
||||
- name: postgres-credentials-secret
|
||||
type: Opaque
|
||||
behavior: create
|
||||
literals:
|
||||
- host=mariadb-localhost:3306
|
||||
- host=172.18.1.2:5432
|
||||
- database=gitea
|
||||
- username=gitea
|
||||
- password=changeme
|
||||
|
|
|
@ -22,26 +22,26 @@ spec:
|
|||
- name: GF_AUTH_ANONYMOUS_ORG_ROLE
|
||||
value: Admin
|
||||
- name: GF_DATABASE_TYPE
|
||||
value: mysql
|
||||
value: postgres
|
||||
- name: GF_DATABASE_HOST
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mariadb-credentials-secret
|
||||
name: postgres-credentials-secret
|
||||
key: host
|
||||
- name: GF_DATABASE_NAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mariadb-credentials-secret
|
||||
name: postgres-credentials-secret
|
||||
key: database
|
||||
- name: GF_DATABASE_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mariadb-credentials-secret
|
||||
name: postgres-credentials-secret
|
||||
key: username
|
||||
- name: GF_DATABASE_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mariadb-credentials-secret
|
||||
name: postgres-credentials-secret
|
||||
key: password
|
||||
ports:
|
||||
- name: http
|
||||
|
|
|
@ -8,11 +8,11 @@ configMapGenerator:
|
|||
- datasources.yaml=provision/datasources.yaml
|
||||
|
||||
secretGenerator:
|
||||
- name: mariadb-credentials-secret
|
||||
- name: postgres-credentials-secret
|
||||
type: Opaque
|
||||
behavior: create
|
||||
literals:
|
||||
- host=mariadb-localhost:3306
|
||||
- host=172.18.1.2:5432
|
||||
- database=grafana
|
||||
- username=grafana
|
||||
- password=changeme
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
resources:
|
||||
- mariadb-statefulset.yaml
|
||||
|
||||
secretGenerator:
|
||||
- name: mariadb-credentials-secret
|
||||
type: Opaque
|
||||
literals:
|
||||
- database=mariadb
|
||||
- username=mariadb
|
||||
- password=replaceme
|
|
@ -1,63 +0,0 @@
|
|||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: mariadb
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: mariadb
|
||||
serviceName: mariadb
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: mariadb
|
||||
spec:
|
||||
containers:
|
||||
- name: mariadb
|
||||
image: mariadb:10.5.2
|
||||
env:
|
||||
- name: MYSQL_DATABASE
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mariadb-credentials-secret
|
||||
key: database
|
||||
- name: MYSQL_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mariadb-credentials-secret
|
||||
key: username
|
||||
- name: MYSQL_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mariadb-credentials-secret
|
||||
key: password
|
||||
- name: MYSQL_RANDOM_ROOT_PASSWORD
|
||||
value: "yes"
|
||||
ports:
|
||||
- name: mariadb
|
||||
containerPort: 3306
|
||||
volumeMounts:
|
||||
- name: mariadb-pvc
|
||||
mountPath: /var/lib/mysql
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: mariadb-pvc
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 20Gi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mariadb
|
||||
labels:
|
||||
app: mariadb
|
||||
spec:
|
||||
selector:
|
||||
app: mariadb
|
||||
ports:
|
||||
- name: mariadb
|
||||
port: 3306
|
|
@ -4,11 +4,11 @@ resources:
|
|||
- ingress.yaml
|
||||
|
||||
secretGenerator:
|
||||
- name: mariadb-credentials-secret
|
||||
- name: postgres-credentials-secret
|
||||
type: Opaque
|
||||
behavior: create
|
||||
literals:
|
||||
- host=mariadb-localhost:3306
|
||||
- host=172.18.1.2:5432
|
||||
- database=nextcloud
|
||||
- username=nextcloud
|
||||
- password=changeme
|
||||
|
|
|
@ -19,25 +19,25 @@ spec:
|
|||
env:
|
||||
- name: TRUSTED_PROXIES
|
||||
value: 10.0.0.0/8
|
||||
- name: MYSQL_HOST
|
||||
- name: POSTGRES_HOST
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mariadb-credentials-secret
|
||||
name: postgres-credentials-secret
|
||||
key: host
|
||||
- name: MYSQL_DATABASE
|
||||
- name: POSTGRES_DATABASE
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mariadb-credentials-secret
|
||||
name: postgres-credentials-secret
|
||||
key: database
|
||||
- name: MYSQL_USER
|
||||
- name: POSTGRES_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mariadb-credentials-secret
|
||||
name: postgres-credentials-secret
|
||||
key: username
|
||||
- name: MYSQL_PASSWORD
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mariadb-credentials-secret
|
||||
name: postgres-credentials-secret
|
||||
key: password
|
||||
ports:
|
||||
- name: http
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
bases:
|
||||
- ../../bases/gitea
|
||||
# - ../../base/mariadb
|
||||
# - ../../base/postgres
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
bases:
|
||||
- ../../bases/grafana
|
||||
# - ../../base/mariadb
|
||||
# - ../../base/postgres
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
bases:
|
||||
- ../../bases/nextcloud
|
||||
# - ../../base/mariadb
|
||||
# - ../../base/postgres
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
||||
|
|
|
@ -39,23 +39,26 @@ if ! docker ps -a | grep registry-localhost &>/dev/null; then
|
|||
docker run -d \
|
||||
--name registry-localhost \
|
||||
--net "k3d-$cluster_name" \
|
||||
--ip 172.18.1.1 \
|
||||
--volume local_registry:/var/lib/registry \
|
||||
--restart always \
|
||||
-p 5000:5000 \
|
||||
registry:2
|
||||
fi
|
||||
|
||||
# local mariadb database
|
||||
if ! docker ps -a | grep mariadb-localhost &>/dev/null; then
|
||||
docker volume create local_mariadb
|
||||
# local postgres database
|
||||
if ! docker ps -a | grep postgres-localhost &>/dev/null; then
|
||||
docker volume create local_postgres
|
||||
docker run -d \
|
||||
--name mariadb-localhost \
|
||||
--name postgres-localhost \
|
||||
--net "k3d-$cluster_name" \
|
||||
--volume local_mariadb:/var/lib/mysql \
|
||||
--ip 172.18.1.2 \
|
||||
--volume local_postgres:/var/lib/postgresql/data \
|
||||
--volume "$PWD/.postgres/initdb.sql:/docker-entrypoint-initdb.d/initdb.sql:ro" \
|
||||
--restart always \
|
||||
--env MYSQL_ROOT_PASSWORD=changeme \
|
||||
-p 3306:3306 \
|
||||
mariadb:10.5
|
||||
--env POSTGRES_PASSWORD=changeme \
|
||||
-p 5432:5432 \
|
||||
postgres:9.6
|
||||
sleep 10
|
||||
fi
|
||||
|
||||
|
@ -65,6 +68,7 @@ if ! docker ps -a | grep nfs-localhost &>/dev/null; then
|
|||
docker run -d \
|
||||
--name nfs-localhost \
|
||||
--net "k3d-$cluster_name" \
|
||||
--ip 172.18.1.3 \
|
||||
--volume nfs_local:/data \
|
||||
--volume /lib/modules:/lib/modules:ro \
|
||||
--restart always \
|
||||
|
@ -78,22 +82,6 @@ if ! docker ps -a | grep nfs-localhost &>/dev/null; then
|
|||
sleep 10
|
||||
fi
|
||||
|
||||
docker exec mariadb-localhost mysql -vv -uroot -pchangeme -e "
|
||||
CREATE DATABASE IF NOT EXISTS gitea;
|
||||
CREATE USER IF NOT EXISTS 'gitea'@'%' IDENTIFIED BY 'changeme';
|
||||
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'%';
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS grafana;
|
||||
CREATE USER IF NOT EXISTS 'grafana'@'%' IDENTIFIED BY 'changeme';
|
||||
GRANT ALL PRIVILEGES ON grafana.* TO 'grafana'@'%';
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS nextcloud;
|
||||
CREATE USER IF NOT EXISTS 'nextcloud'@'%' IDENTIFIED BY 'changeme';
|
||||
GRANT ALL PRIVILEGES ON grafana.* TO 'nextcloud'@'%';
|
||||
|
||||
FLUSH PRIVILEGES;
|
||||
"
|
||||
|
||||
k3d kubeconfig merge "$cluster_name" --switch-context >/dev/null
|
||||
kubectl apply -f "$auto_deploy_manifest"
|
||||
kubectl get nodes
|
||||
|
|
Loading…
Reference in New Issue