网站建设资讯

NEWS

网站建设资讯

kubernetes挂载cephfs-创新互联

1 生成ceph-secret
cat /etc/ceph/ceph.client.admin.keyring
[client.admin]
key = AQDlG99ZVJhfExAAFVT/ttJBgqOKcyY5INX5Cw==
将key base64处理
echo "AQDlG99ZVJhfExAAFVT/ttJBgqOKcyY5INX5Cw=="|base64
QVFEbEc5OVpWSmhmRXhBQUZWVC90dEpCZ3FPS2N5WTVJTlg1Q3c9PQo=
2 创建secret
cat ceph-secret.yml
apiVersion: v1
kind: Secret
metadata:
  name: ceph-secret
data:
  key: QVFEbEc5OVpWSmhmRXhBQUZWVC90dEpCZ3FPS2N5WTVJTlg1Q3c9PQo=
3 创建pvc
cat ceph-pvc.yml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: cephfs
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 8Gi
4 创建pv
cat ceph-pv.yml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: cephfs
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  cephfs:
    monitors:
    - 192.168.100.96:6789
    path: /
    user: admin
    secretRef:
      name: ceph-secret
5 创建RC
cat app-rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:
  name: rc-fish
  labels:
    name: fish
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: fish
    spec:
      containers:
      - name: fish
        image: registry:5000/fish:7.5
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 80
          protocol: TCP
        resources:
          limits:
            cpu: 100m
            memory: 128Mi
        volumeMounts:
        - name: cephfs
          mountPath: /var/log/nginx
      volumes:
      - name: cephfs
        persistentVolumeClaim:
          claimName: cephfs
依次创建secret,pvc,pv,RC
kubectl create -f ceph-secret.yml
kubectl create -f ceph-pvc.yml
kubectl create -f ceph-pv.yml
kubectl create -f app-rc.yaml
查看创建的secret,pvc,pv
root@mon2:~# kubectl get secrets
NAME                  TYPE                                  DATA      AGE
ceph-secret           Opaque                                1         3d
default-token-50p5c   kubernetes.io/service-account-token   3         3d
root@mon2:~# kubectl get pvc
NAME      STATUS    VOLUME    CAPACITY   ACCESSMODES   STORAGECLASS   AGE
cephfs    Bound     cephfs    10Gi       RWX                          3d
root@mon2:~# kubectl get pv
NAME      CAPACITY   ACCESSMODES   RECLAIMPOLICY   STATUS    CLAIM            STORAGECLASS   REASON    AGE
cephfs    10Gi       RWX           Retain          Bound     default/cephfs                            3d

网站名称:kubernetes挂载cephfs-创新互联
标题来源:http://cdweb.net/article/csjpdo.html