K8S结合CephFS使用

在ceph查看密钥

 ceph auth get-key client.admin |base64

在k8s-master上面创建secret

#vim ceph-secret.yaml
apiVersion: v1
kind: Secret
metadata:
  name: ceph-secret
data:
  key: QVFDa2R0cGhiZlZXRWhBQVd3VDAxWnl5OWlaU3BWN3NlcTk3bWc9PQ==

创建PV

#vim pv.yaml
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

#vim PVC.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: cephfs-pvc
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Gi
  selector:
    matchLabels:
      pv: cephfs-pv
     

创建测试pod

#vim nginx-pod.yaml
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
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐