Skip to content

Instantly share code, notes, and snippets.

@ilyesAj
Last active January 25, 2023 12:32
Show Gist options
  • Save ilyesAj/4d3fa8f5a60fdac28d9474ecdca05b14 to your computer and use it in GitHub Desktop.
Save ilyesAj/4d3fa8f5a60fdac28d9474ecdca05b14 to your computer and use it in GitHub Desktop.
copy file into file storage StatS using CaaS

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
---
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
---
apiVersion: v1
data:
userID: XXX # tenant name | base64
userKey: XXX # keyID | base64
kind: Secret
metadata:
name: sc-secret
type: Opaque
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 # get infos from onecloud portal
fsName: cephFS
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment