setup nfs
This commit is contained in:
parent
6711667af8
commit
8e91aa8936
|
@ -1,7 +1,6 @@
|
||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
k3d cluster delete local
|
k3d cluster delete local
|
||||||
# docker stop registry.localhost
|
docker rm -f registry-localhost
|
||||||
# docker container rm registry.localhost
|
docker rm -f mariadb-localhost
|
||||||
# docker stop mariadb.localhost
|
docker rm -f nfs-localhost
|
||||||
# docker container rm mariadb.localhost
|
|
||||||
|
|
|
@ -57,31 +57,45 @@ spec:
|
||||||
- name: ssh
|
- name: ssh
|
||||||
containerPort: 22
|
containerPort: 22
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: gitea-pvc
|
- name: gitea-data
|
||||||
mountPath: /data
|
mountPath: /data
|
||||||
# - name: gitea-app-ini
|
|
||||||
# mountPath: /data/gitea/conf/
|
|
||||||
# readOnly: true
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: gitea-pvc
|
- name: gitea-data
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: gitea-pvc
|
claimName: gitea-data
|
||||||
# - name: gitea-app-ini
|
|
||||||
# secret:
|
|
||||||
# secretName: gitea-app-ini-secret
|
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: PersistentVolumeClaim
|
kind: PersistentVolume
|
||||||
metadata:
|
metadata:
|
||||||
name: gitea-pvc
|
name: gitea-data-nfs
|
||||||
labels:
|
labels:
|
||||||
app: gitea
|
app: gitea
|
||||||
spec:
|
spec:
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
- ReadWriteMany
|
||||||
|
capacity:
|
||||||
|
storage: 100Mi
|
||||||
|
nfs:
|
||||||
|
server: nfs-localhost
|
||||||
|
path: /gitea
|
||||||
|
mountOptions: ["vers=4"]
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: gitea-data
|
||||||
|
labels:
|
||||||
|
app: gitea
|
||||||
|
spec:
|
||||||
|
storageClassName: ""
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteMany
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
storage: 20Gi
|
storage: 100Mi
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: gitea
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
|
|
|
@ -7,7 +7,7 @@ secretGenerator:
|
||||||
type: Opaque
|
type: Opaque
|
||||||
behavior: create
|
behavior: create
|
||||||
literals:
|
literals:
|
||||||
- host=mariadb.localhost:3306
|
- host=172.18.1.0:3306
|
||||||
- database=gitea
|
- database=gitea
|
||||||
- username=gitea
|
- username=gitea
|
||||||
- password=changeme
|
- password=changeme
|
||||||
|
|
|
@ -12,7 +12,7 @@ secretGenerator:
|
||||||
type: Opaque
|
type: Opaque
|
||||||
behavior: create
|
behavior: create
|
||||||
literals:
|
literals:
|
||||||
- host=mariadb.localhost:3306
|
- host=172.18.1.0:3306
|
||||||
- database=grafana
|
- database=grafana
|
||||||
- username=grafana
|
- username=grafana
|
||||||
- password=changeme
|
- password=changeme
|
||||||
|
|
|
@ -8,7 +8,7 @@ secretGenerator:
|
||||||
type: Opaque
|
type: Opaque
|
||||||
behavior: create
|
behavior: create
|
||||||
literals:
|
literals:
|
||||||
- host=mariadb.localhost:3306
|
- host=172.18.1.0:3306
|
||||||
- database=nextcloud
|
- database=nextcloud
|
||||||
- username=nextcloud
|
- username=nextcloud
|
||||||
- password=changeme
|
- password=changeme
|
||||||
|
|
|
@ -16,13 +16,13 @@ spec:
|
||||||
runAsUser: 33
|
runAsUser: 33
|
||||||
runAsGroup: 33
|
runAsGroup: 33
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: nextcloud-pvc
|
- name: nextcloud-data
|
||||||
mountPath: /var/www/html
|
mountPath: /var/www/html
|
||||||
command:
|
command:
|
||||||
- php
|
- php
|
||||||
- -f
|
- -f
|
||||||
- /var/www/html/cron.php
|
- /var/www/html/cron.php
|
||||||
volumes:
|
volumes:
|
||||||
- name: nextcloud-pvc
|
- name: nextcloud-data
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: nextcloud-pvc
|
claimName: nextcloud-data
|
||||||
|
|
|
@ -15,7 +15,7 @@ spec:
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: nextcloud
|
- name: nextcloud
|
||||||
image: nextcloud:18.0.4
|
image: nextcloud:19.0.2
|
||||||
env:
|
env:
|
||||||
- name: TRUSTED_PROXIES
|
- name: TRUSTED_PROXIES
|
||||||
value: 10.0.0.0/8
|
value: 10.0.0.0/8
|
||||||
|
@ -43,25 +43,45 @@ spec:
|
||||||
- name: http
|
- name: http
|
||||||
containerPort: 80
|
containerPort: 80
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: nextcloud-pvc
|
- name: nextcloud-data
|
||||||
mountPath: /var/www/html
|
mountPath: /var/www/html
|
||||||
volumes:
|
volumes:
|
||||||
- name: nextcloud-pvc
|
- name: nextcloud-data
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: nextcloud-pvc
|
claimName: nextcloud-data
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: PersistentVolumeClaim
|
kind: PersistentVolume
|
||||||
metadata:
|
metadata:
|
||||||
name: nextcloud-pvc
|
name: nextcloud-data-nfs
|
||||||
labels:
|
labels:
|
||||||
app: nextcloud
|
app: nextcloud
|
||||||
spec:
|
spec:
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
- ReadWriteMany
|
||||||
|
capacity:
|
||||||
|
storage: 100Mi
|
||||||
|
nfs:
|
||||||
|
server: nfs-localhost
|
||||||
|
path: /nextcloud
|
||||||
|
mountOptions: ["vers=4"]
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: nextcloud-data
|
||||||
|
labels:
|
||||||
|
app: nextcloud
|
||||||
|
spec:
|
||||||
|
storageClassName: ""
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteMany
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
storage: 50Gi
|
storage: 100Mi
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: nextcloud
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
|
|
|
@ -16,7 +16,7 @@ spec:
|
||||||
solvers:
|
solvers:
|
||||||
- selector:
|
- selector:
|
||||||
dnsZones:
|
dnsZones:
|
||||||
- badjware.dev
|
- local.badjware.dev
|
||||||
dns01:
|
dns01:
|
||||||
cnameStrategy: Follow
|
cnameStrategy: Follow
|
||||||
digitalocean:
|
digitalocean:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
bases:
|
bases:
|
||||||
- ../../namespaces/gitea
|
- ../../namespaces/gitea
|
||||||
- ../../namespaces/grafana
|
# - ../../namespaces/grafana
|
||||||
- ../../namespaces/nextcloud
|
- ../../namespaces/nextcloud
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
DRONE_EXTERNAL_HOST=drone.localhost
|
DRONE_EXTERNAL_HOST=drone.local.badjware.dev
|
||||||
GITEA_EXTERNAL_HOST=gitea.localhost
|
GITEA_EXTERNAL_HOST=gitea.local.badjware.dev
|
||||||
GRAFANA_EXTERNAL_HOST=grafana.localhost
|
GRAFANA_EXTERNAL_HOST=grafana.local.badjware.dev
|
||||||
KUBERNETES_DASHBOARD_EXTERNAL_HOST=kubernetes-dashboard.localhost
|
KUBERNETES_DASHBOARD_EXTERNAL_HOST=kubernetes-dashboard.local.badjware.dev
|
||||||
NEXTCLOUD_EXTERNAL_HOST=nextcloud.localhost
|
NEXTCLOUD_EXTERNAL_HOST=nextcloud.local.badjware.dev
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash -e
|
#!/bin/bash -ex
|
||||||
|
|
||||||
cluster_name='local'
|
cluster_name='local'
|
||||||
k3s_registry_config="$HOME/.config/k3d/registries.yaml"
|
k3s_registry_config="$HOME/.config/k3d/registries.yaml"
|
||||||
|
@ -12,9 +12,9 @@ if [[ ! -f "$k3s_registry_cofing" ]]; then
|
||||||
mkdir -p "$(dirname "$k3s_registry_config")"
|
mkdir -p "$(dirname "$k3s_registry_config")"
|
||||||
cat >"$k3s_registry_config" <<EOF
|
cat >"$k3s_registry_config" <<EOF
|
||||||
mirrors:
|
mirrors:
|
||||||
"registry.localhost:5000":
|
"registry-localhost:5000":
|
||||||
endpoint:
|
endpoint:
|
||||||
- http://registry.localhost:5000
|
- http://registry-localhost:5000
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
echo '~/.config/k3d/registries.yaml already exists, skipping generation'
|
echo '~/.config/k3d/registries.yaml already exists, skipping generation'
|
||||||
|
@ -34,32 +34,53 @@ fi
|
||||||
# --volume ":/var/lib/rancher/k3s/server/manifests/auto-deploy.yaml" \
|
# --volume ":/var/lib/rancher/k3s/server/manifests/auto-deploy.yaml" \
|
||||||
|
|
||||||
# local docker registry
|
# local docker registry
|
||||||
if ! docker ps -a | grep registry.localhost &>/dev/null; then
|
if ! docker ps -a | grep registry-localhost &>/dev/null; then
|
||||||
docker volume create local_registry
|
docker volume create local_registry
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name registry.localhost \
|
--name registry-localhost \
|
||||||
--volume local_registry:/var/lib/registry \
|
--volume local_registry:/var/lib/registry \
|
||||||
--restart always \
|
--restart always \
|
||||||
-p 5000:5000 \
|
-p 5000:5000 \
|
||||||
registry:2
|
registry:2
|
||||||
docker network connect "k3d-$cluster_name" registry.localhost
|
docker network connect "k3d-$cluster_name" registry-localhost
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# local mariadb database
|
# local mariadb database
|
||||||
if ! docker ps -a | grep mariadb.localhost &>/dev/null; then
|
if ! docker ps -a | grep mariadb-localhost &>/dev/null; then
|
||||||
docker volume create local_mariadb
|
docker volume create local_mariadb
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name mariadb.localhost \
|
--name mariadb-localhost \
|
||||||
|
--ip 172.18.1.0 \
|
||||||
--volume local_mariadb:/var/lib/mysql \
|
--volume local_mariadb:/var/lib/mysql \
|
||||||
--restart always \
|
--restart always \
|
||||||
--env MYSQL_ROOT_PASSWORD=changeme \
|
--env MYSQL_ROOT_PASSWORD=changeme \
|
||||||
-p 3306:3306 \
|
-p 3306:3306 \
|
||||||
mariadb:10.5
|
mariadb:10.5
|
||||||
docker network connect "k3d-$cluster_name" mariadb.localhost
|
docker network connect "k3d-$cluster_name" mariadb-localhost
|
||||||
sleep 10
|
sleep 10
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker exec mariadb.localhost mysql -vv -uroot -pchangeme -e "
|
# local nfs server
|
||||||
|
if ! docker ps -a | grep nfs-localhost &>/dev/null; then
|
||||||
|
docker volume create local_nfs
|
||||||
|
docker run -d \
|
||||||
|
--name nfs-localhost \
|
||||||
|
--ip 172.18.1.1 \
|
||||||
|
--volume nfs_local:/data \
|
||||||
|
--volume /lib/modules:/lib/modules:ro \
|
||||||
|
--restart always \
|
||||||
|
--cap-add SYS_ADMIN \
|
||||||
|
--cap-add SYS_MODULE \
|
||||||
|
--env NFS_EXPORT_0='/data *(rw,async,insecure,no_subtree_check,no_root_squash,fsid=0)' \
|
||||||
|
--env NFS_DISABLE_VERSION_3=YES \
|
||||||
|
--env NFS_LOG_LEVEL=DEBUG \
|
||||||
|
-p 2049:2049 \
|
||||||
|
erichough/nfs-server:2.2.1
|
||||||
|
docker network connect "k3d-$cluster_name" nfs-localhost
|
||||||
|
sleep 10
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker exec mariadb-localhost mysql -vv -uroot -pchangeme -e "
|
||||||
CREATE DATABASE IF NOT EXISTS gitea;
|
CREATE DATABASE IF NOT EXISTS gitea;
|
||||||
CREATE USER IF NOT EXISTS 'gitea'@'%' IDENTIFIED BY 'changeme';
|
CREATE USER IF NOT EXISTS 'gitea'@'%' IDENTIFIED BY 'changeme';
|
||||||
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'%';
|
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'%';
|
||||||
|
@ -77,4 +98,4 @@ FLUSH PRIVILEGES;
|
||||||
|
|
||||||
k3d kubeconfig merge "$cluster_name" --switch-context >/dev/null
|
k3d kubeconfig merge "$cluster_name" --switch-context >/dev/null
|
||||||
kubectl apply -f "$auto_deploy_manifest"
|
kubectl apply -f "$auto_deploy_manifest"
|
||||||
kubectl get nodes
|
kubectl get nodes
|
||||||
|
|
Loading…
Reference in New Issue