Plumeの移行
blogs.kitaitimakoto.netで動かしている(と言うか落ち続けている)Plumeを移行したい。
今はGKEで動いているが、これをさくらのVPSに移す。
構成
サイトをVPSへ移行に従う。
Docker Composeで動かす
データベースもDocker Compose
PeerTubeに一旦倣う
ホストで動かしてPeerTubeとかと共有してもいいけど
PostgreSQLのホスティングサービスはみんな高いんだよな・・・
要検討
カスタムテーマの追加方法
今はボリュームコンテナーを作っている
Plumeコンテナーの起動時に、rsassとRubyが入っているコンテナーをマウント
そのコンテナーの起動時にリポジトリーをクローンし、Rake経由でrsassを使ってSCSSをコンパイル
移行後もこれでいい気がするな。
ボリュームを使うよりも/srv/plume以下のディレクトリーを使うのがいいかも
でもそれだと、別にホスト側で用意すればいいような・・・
まあrsass入れたりしないで済むのでいい、ということにしておくか。
コンパイル済みのテーマを入れたDockerイメージを作っておくのでもいいな
それぐらいならテーマのアーカイブファイルを何処かに置いておいて、Plumeコンテナーの起動スクリプトでダウンロードするんでもいいか
めんどくさいのでGitLab Pagesでパッケージファイルを作って、それをダウンロード、展開、マウントすることにした。
ストレージ
連合から来る画像を保存しているのでめちゃめちゃ増える。
制限を設けるのは確定だが、制限方法を要検討
Linuxのディレクトリーでのサイズ制限を使う
追加ストレージ(NFS) — さくらの VPS マニュアル
取り敢えずはローカルでいいか
ファイルの移行方法
今はGKE上のNFSポッドにある
このNFSって外から繋げるようにできるのかな。繋げるなら一時的にマウントして、ローカルデバイス(かさくらのNFS)にコピーすればいい
Claude氏曰く:
To access an NFS pod running in GKE from an external VPS (Virtual Private Server), you need to follow these steps:
1. **Expose the NFS Service**
- Create a Kubernetes Service resource that exposes the NFS pod. You can use a LoadBalancer service type to provision an external IP address.
- Alternatively, you can use an Ingress resource to expose the NFS service using an Ingress controller.
2. **Configure Network Access**
- Ensure that the VPS can reach the external IP address or the Ingress endpoint over the network.
- Configure firewall rules in GKE to allow inbound traffic from the VPS to the exposed NFS service.
3. **Mount the NFS Share**
- From the VPS, use the standard NFS client mount command to mount the NFS share exposed by the GKE service.
- The mount command will look similar to: mount -t nfs <EXTERNAL_IP>:</nfs/share> </mount/path>
- Replace <EXTERNAL_IP> with the external IP address or the Ingress endpoint, and /nfs/share with the appropriate NFS share path.
Here's an example of exposing an NFS server Pod in GKE using a LoadBalancer Service:
1. Create an NFS Server Deployment and Service:
`yaml
# nfs-server-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nfs-server
spec:
replicas: 1
selector:
matchLabels:
app: nfs-server
template:
metadata:
labels:
app: nfs-server
spec:
containers:
- name: nfs-server
image: k8s.gcr.io/volume-nfs:0.8
ports:
- name: nfs
containerPort: 2049
securityContext:
privileged: true
volumeMounts:
- name: export
mountPath: /export
volumes:
- name: export
emptyDir: {}
# nfs-server-service.yaml
apiVersion: v1
kind: Service
metadata:
name: nfs-server
spec:
type: LoadBalancer
selector:
app: nfs-server
ports:
- port: 2049
`
2. Get the external IP address of the LoadBalancer Service: kubectl get svc nfs-server
3. From the VPS, mount the NFS share using the external IP: mount -t nfs <EXTERNAL_IP>:/export /mount/path
Note that directly exposing NFS shares over the internet may have security implications. It's recommended to use appropriate network security measures, such as restricting access using firewall rules or a VPN connection between the VPS and the GKE cluster.
https://claude.ai/chat/8c2814d5-65c3-44ad-991f-e1f0a9942f76
GKE上のNFSに外部からアクセスする
ファイルが1GiB程度なのでローカルに落としてからVPSに上げることにした。
データベースデータの移行方法
別に「要検討」ということは無いな。普通にダンプして入れればいいだけ。
移行
ループバックデバイスを追加 DONE
10GiBから始める
GKEからファイルを移行 DONE
Plumeコンテナーを追加 DONE
DNSレコードの変更 DONE
カスタムテーマの追加 DONE
ビルド済みのファイルを何処かに上げて、それを使うようにする
データベースを移行 DONE
バックアップスクリプト
何処へ?
さくらのVPS追加ストレージ
さくらのクラウド オブジェクトストレージ
GCS
R2
国内ファイルサーバー
InfiniCLOUD
何で?
シェルスクリプトからDockerコンテナーを起動