K8S结合CephFS使用
在ceph查看密钥
ceph auth get-key client.admin |base64
在k8s-master上面创建secret
apiVersion: v1
kind: Secret
metadata:
name: ceph-secret
data:
key: QVFDa2R0cGhiZlZXRWhBQVd3VDAxWnl5OWlaU3BWN3NlcTk3bWc9PQ==
创建PV
apiVersion: v1
kind: PersistentVolume
metadata:
name: cephfs-pv
labels:
pv: cephfs-pv
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteMany
cephfs:
monitors:
- 10.66.66.106:6789
user: admin
secretRef:
name: ceph-secret
readOnly: false
persistentVolumeReclaimPolicy: Delete
创建PVC
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: cephfs-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
selector:
matchLabels:
pv: cephfs-pv
创建测试pod
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod1
labels:
name: nginx-pod1
spec:
containers:
- name: nginx-pod1
image: nginx:alpine
ports:
- name: web
containerPort: 80
volumeMounts:
- name: cephfs-pvc
mountPath: /usr/share/nginx/html
volumes:
- name: cephfs-pvc
persistentVolumeClaim:
claimName: cephfs-pvc