ボリュームrbd configを使ってcephイメージにフォルダをマウントしたいとします。 しかし、コンテナがホストパスをマウントしているようです。rbdボリュームの設定がkubernetesで
私はデーモン "https://github.com/kubernetes/kubernetes/tree/master/examples/rbd"を使用しました。 ポッドとコンテナが正常に起動します。
- 「docker exec」を使用してコンテナにログインし、/ mntフォルダを監視します。
[email protected]:/usr/local/tomcat# findmnt /mnt
TARGET SOURCE FSTYPE OPTIONS /mnt /dev/vda1[/var/lib/kubelet/pods/****/volumes/kubernetes.io~rbd/rbd] xfs rw,relatime,attr2,inode64,noquota [email protected]:/usr/local/tomcat# ls /mnt/ [email protected]:/usr/local/tomcat# その後、私はセフにマウントするホストパスを見ます。
1.txt
はceph画像上に存在していました。[20:52 [email protected]:/home] # mount |grep kubelet /dev/rbd0 on /var/lib/kubelet/plugins/kubernetes.io/rbd/rbd/wujianlin-image-zlh_test type ext4 (ro,relatime,stripe=1024,data=ordered) /dev/rbd0 on /var/lib/kubelet/pods/****/volumes/kubernetes.io~rbd/rbd type ext4 (ro,relatime,stripe=1024,data=ordered) [20:53 [email protected]:/home] # ll /var/lib/kubelet/pods/****/volumes/kubernetes.io~rbd/rbd total 20K drwx------ 2 root root 16K Mar 18 09:49 lost+found -rw-r--r-- 1 root root 4 Mar 18 09:53 1.txt [20:53 [email protected]:/home] # rbd showmapped id pool image snap device
0 wujianlin zlh_test - /dev/rbd0それは、コンテナフォルダ
/mnt
は、ホストパス/var/lib/kubelet/pods/ * * * */volumes/kubernetes.io~rbd/rbd
と同じであるが、それはなかったこと以外はすべきです。 `そして、私はMNT /にファイルを書き込もうと、それはまた、
だから私のいくつかの設定が間違っている、あるいはいろいろ書い誤解である
/var/lib/kubelet/pods/* * * */volumes/kubernetes.io~rbd/rbd
の変更を見ることができませんか?K8Sバージョン:リリースV1.2.0 ここに私の設定です:
apiVersion: v1 kind: Pod metadata: name: test-rbd-read-01 spec: containers: - name: tomcat-read-only-01 image: tomcat volumeMounts: - name: rbd mountPath: /mnt volumes: - name: rbd rbd: monitors: - 10.63.90.177:6789 pool: wujianlin image: zlh_test user: wujianlin secretRef: name: ceph-client-admin-keyring keyring: /etc/ceph/ceph.client.wujianlin.keyring fsType: ext4 readOnly: true
ドッカーを再起動すると、コンテナはファイルを見ることができます。 – zhulinhong