1
0
Fork 0

setup nfs

This commit is contained in:
Massaki Archambault 2020-08-29 00:54:40 -04:00
parent 6711667af8
commit 8e91aa8936
11 changed files with 103 additions and 49 deletions

View File

@ -1,7 +1,6 @@
#!/bin/bash -e
k3d cluster delete local
# docker stop registry.localhost
# docker container rm registry.localhost
# docker stop mariadb.localhost
# docker container rm mariadb.localhost
docker rm -f registry-localhost
docker rm -f mariadb-localhost
docker rm -f nfs-localhost

View File

@ -57,31 +57,45 @@ spec:
- name: ssh
containerPort: 22
volumeMounts:
- name: gitea-pvc
- name: gitea-data
mountPath: /data
# - name: gitea-app-ini
# mountPath: /data/gitea/conf/
# readOnly: true
volumes:
- name: gitea-pvc
- name: gitea-data
persistentVolumeClaim:
claimName: gitea-pvc
# - name: gitea-app-ini
# secret:
# secretName: gitea-app-ini-secret
claimName: gitea-data
---
apiVersion: v1
kind: PersistentVolumeClaim
kind: PersistentVolume
metadata:
name: gitea-pvc
name: gitea-data-nfs
labels:
app: gitea
spec:
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:
requests:
storage: 20Gi
storage: 100Mi
selector:
matchLabels:
app: gitea
---
apiVersion: v1
kind: Service

View File

@ -7,7 +7,7 @@ secretGenerator:
type: Opaque
behavior: create
literals:
- host=mariadb.localhost:3306
- host=172.18.1.0:3306
- database=gitea
- username=gitea
- password=changeme

View File

@ -12,7 +12,7 @@ secretGenerator:
type: Opaque
behavior: create
literals:
- host=mariadb.localhost:3306
- host=172.18.1.0:3306
- database=grafana
- username=grafana
- password=changeme

View File

@ -8,7 +8,7 @@ secretGenerator:
type: Opaque
behavior: create
literals:
- host=mariadb.localhost:3306
- host=172.18.1.0:3306
- database=nextcloud
- username=nextcloud
- password=changeme

View File

@ -16,13 +16,13 @@ spec:
runAsUser: 33
runAsGroup: 33
volumeMounts:
- name: nextcloud-pvc
- name: nextcloud-data
mountPath: /var/www/html
command:
- php
- -f
- /var/www/html/cron.php
volumes:
- name: nextcloud-pvc
- name: nextcloud-data
persistentVolumeClaim:
claimName: nextcloud-pvc
claimName: nextcloud-data

View File

@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: nextcloud
image: nextcloud:18.0.4
image: nextcloud:19.0.2
env:
- name: TRUSTED_PROXIES
value: 10.0.0.0/8
@ -43,25 +43,45 @@ spec:
- name: http
containerPort: 80
volumeMounts:
- name: nextcloud-pvc
- name: nextcloud-data
mountPath: /var/www/html
volumes:
- name: nextcloud-pvc
- name: nextcloud-data
persistentVolumeClaim:
claimName: nextcloud-pvc
claimName: nextcloud-data
---
apiVersion: v1
kind: PersistentVolumeClaim
kind: PersistentVolume
metadata:
name: nextcloud-pvc
name: nextcloud-data-nfs
labels:
app: nextcloud
spec:
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:
requests:
storage: 50Gi
storage: 100Mi
selector:
matchLabels:
app: nextcloud
---
apiVersion: v1
kind: Service

View File

@ -16,7 +16,7 @@ spec:
solvers:
- selector:
dnsZones:
- badjware.dev
- local.badjware.dev
dns01:
cnameStrategy: Follow
digitalocean:

View File

@ -1,6 +1,6 @@
bases:
- ../../namespaces/gitea
- ../../namespaces/grafana
# - ../../namespaces/grafana
- ../../namespaces/nextcloud
resources:

View File

@ -1,5 +1,5 @@
DRONE_EXTERNAL_HOST=drone.localhost
GITEA_EXTERNAL_HOST=gitea.localhost
GRAFANA_EXTERNAL_HOST=grafana.localhost
KUBERNETES_DASHBOARD_EXTERNAL_HOST=kubernetes-dashboard.localhost
NEXTCLOUD_EXTERNAL_HOST=nextcloud.localhost
DRONE_EXTERNAL_HOST=drone.local.badjware.dev
GITEA_EXTERNAL_HOST=gitea.local.badjware.dev
GRAFANA_EXTERNAL_HOST=grafana.local.badjware.dev
KUBERNETES_DASHBOARD_EXTERNAL_HOST=kubernetes-dashboard.local.badjware.dev
NEXTCLOUD_EXTERNAL_HOST=nextcloud.local.badjware.dev

View File

@ -1,4 +1,4 @@
#!/bin/bash -e
#!/bin/bash -ex
cluster_name='local'
k3s_registry_config="$HOME/.config/k3d/registries.yaml"
@ -12,9 +12,9 @@ if [[ ! -f "$k3s_registry_cofing" ]]; then
mkdir -p "$(dirname "$k3s_registry_config")"
cat >"$k3s_registry_config" <<EOF
mirrors:
"registry.localhost:5000":
"registry-localhost:5000":
endpoint:
- http://registry.localhost:5000
- http://registry-localhost:5000
EOF
else
echo '~/.config/k3d/registries.yaml already exists, skipping generation'
@ -34,32 +34,53 @@ fi
# --volume ":/var/lib/rancher/k3s/server/manifests/auto-deploy.yaml" \
# 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 run -d \
--name registry.localhost \
--name registry-localhost \
--volume local_registry:/var/lib/registry \
--restart always \
-p 5000:5000 \
registry:2
docker network connect "k3d-$cluster_name" registry.localhost
docker network connect "k3d-$cluster_name" registry-localhost
fi
# 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 run -d \
--name mariadb.localhost \
--name mariadb-localhost \
--ip 172.18.1.0 \
--volume local_mariadb:/var/lib/mysql \
--restart always \
--env MYSQL_ROOT_PASSWORD=changeme \
-p 3306:3306 \
mariadb:10.5
docker network connect "k3d-$cluster_name" mariadb.localhost
docker network connect "k3d-$cluster_name" mariadb-localhost
sleep 10
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 USER IF NOT EXISTS 'gitea'@'%' IDENTIFIED BY 'changeme';
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'%';
@ -77,4 +98,4 @@ FLUSH PRIVILEGES;
k3d kubeconfig merge "$cluster_name" --switch-context >/dev/null
kubectl apply -f "$auto_deploy_manifest"
kubectl get nodes
kubectl get nodes