K8s-Finding_PVC_then_mounting _and_copy_files
find volumemounts & volumes
kubectl get pod pod-configurations-8678b4f97d-dvfzl -n pod-services -o yaml
- mountPath: /etc/nginx/conf.d/default.conf
name: config-volume
subPath: default.conf
- mountPath: /assets/api/podConfigurationManagement/v1/configFile
name: pvc-persistent-volume
- mountPath: /images
name: pvc-persistent-volume
- mountPath: /deviceLogs
name: device-logs-volume
volumes:
- configMap:
defaultMode: 420
name: pod-configurations
name: config-volume
- name: pvc-persistent-volume
persistentVolumeClaim:
claimName: pvc-software-artefacts
#create a pod & mount the same path to copy files
pod-server1-49-6551-301-7kd0:~ # cat image-helper.yaml
apiVersion: v1
kind: Pod
metadata:
name: image-helper
namespace: pod-services
spec:
restartPolicy: Never
containers:
- name: helper
image: busybox
command: ["sh", "-c", "sleep 1d"]
volumeMounts:
- name: pvc-persistent-volume
mountPath: /images
volumes:
- name: pvc-persistent-volume
persistentVolumeClaim:
claimName: pvc-software-artefacts
pod-server1-49-6551-301-7kd0:~ # cat image-helper.yaml
apiVersion: v1
kind: Pod
metadata:
name: image-helper
namespace: pod-services
spec:
restartPolicy: Never
containers:
- name: helper
image: busybox
command: ["sh", "-c", "sleep 1d"]
volumeMounts:
- name: pvc-persistent-volume
mountPath: /images
volumes:
- name: pvc-persistent-volume
persistentVolumeClaim:
claimName: pvc-software-artefacts
kubectl apply -f image-helper.yaml
Generate-TAR file
kubectl exec -n pod-services image-helper -- tar -C /images -cf /tmp/CONFIG_TEMPLATE.tar CONFIG_TEMPLATE
copy files
kubectl cp -n pod-services image-helper:/tmp/CONFIG_TEMPLATE.tar ./CONFIG_TEMPLATE.tar
Comments
Post a Comment