Skip to content

Instantly share code, notes, and snippets.

@ilyesAj
Last active January 25, 2023 12:32

Revisions

  1. @ilyes-elajroud ilyes-elajroud revised this gist Jan 25, 2023. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions storageclaim.yaml
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ spec:
    secretRef:
    name: sc-secret
    volumeAttributes:
    clusterID: CLUSTER_ID
    clusterID: CLUSTER_ID # get infos from onecloud portal
    fsName: cephFS
    monitors: MON1:6789,MON2:6789,MON3:6789,MON4:6789,MON5:6789
    rootPath: /volumes/TENANT_NAME/VOLUME_NAME/VOLUME_ID
    monitors: MON1:6789,MON2:6789,MON3:6789,MON4:6789,MON5:6789 # get infos from onecloud portal
    rootPath: /volumes/TENANT_NAME/VOLUME_NAME/VOLUME_ID # get infos from onecloud portal
  2. @ilyes-elajroud ilyes-elajroud created this gist Jan 25, 2023.
    48 changes: 48 additions & 0 deletions busybox.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: pv-mounter
    spec:
    selector:
    matchLabels:
    app: pv-mounter
    template:
    metadata:
    labels:
    app: pv-mounter
    spec:
    imagePullSecrets:
    - name: harbor-bot
    terminationGracePeriodSeconds: 5
    securityContext:
    fsGroup: 1000
    runAsGroup: 1000
    runAsNonRoot: true
    runAsUser: 1000
    containers:
    - name: sandbox
    securityContext:
    allowPrivilegeEscalation: false
    capabilities:
    drop:
    - all
    privileged: false
    readOnlyRootFilesystem: true
    command: [ "/bin/sh", "-c", "--" ]
    args: [ "while true; do sleep 30; done;" ]
    image: registry-euc1.r-local.net/dockerhub/library/busybox:latest
    volumeMounts:
    - name: data
    mountPath: /data
    resources:
    requests:
    cpu: 200m
    memory: 180Mi
    limits:
    cpu: 300m
    memory: 300Mi
    volumes:
    - name: data
    persistentVolumeClaim:
    claimName: pv-mount
    22 changes: 22 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    This Yamls files will help you mount a PV volume in Caas and copy a file from local machine to the PV.

    > Note that this type of manipulation is helpful for mac users how can't moun directly the volume due to incompatibility .
    ## pre-requesties
    - you already have a tenant
    - you already have a namespace
    - you already have a file storage created .

    ## Run all manifests

    1. copy all the above manifests and change all the required infos
    2. create all the resources within your namespaces.
    ```
    kubectl create -f .
    ```

    ## Copy your files
    You can now copy your files from local machine to the persistent volume
    ```
    export POD_NAME=$(kubectl get pod -l app=pv-mounter -o jsonpath="{.items[0].metadata.name}")
    kubectl cp YOUR_FILE_OR_FOLDER $POD_NAME:/data
    9 changes: 9 additions & 0 deletions sc-secret.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    ---
    apiVersion: v1
    data:
    userID: XXX # tenant name | base64
    userKey: XXX # keyID | base64
    kind: Secret
    metadata:
    name: sc-secret
    type: Opaque
    20 changes: 20 additions & 0 deletions storageclaim.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    apiVersion: storage.cpd.rakuten.com/v1
    kind: StorageClaim
    ---
    metadata:
    name: pv-mount
    spec:
    volumeType: cephFS
    createdBy: ilyes.elajroud@rakuten.com # e.g. xxx.yyy@rakuten.com
    provisioningMode: static
    accessModes:
    - ReadWriteMany
    capacity:
    storage: 10Gi
    secretRef:
    name: sc-secret
    volumeAttributes:
    clusterID: CLUSTER_ID
    fsName: cephFS
    monitors: MON1:6789,MON2:6789,MON3:6789,MON4:6789,MON5:6789
    rootPath: /volumes/TENANT_NAME/VOLUME_NAME/VOLUME_ID