無法在 kubernetes pod 內掛載主目錄

無法在 kubernetes pod 內掛載主目錄

我們有一臺本地機器 NVIDIA DGX1,ip 10。.* 我們透過 ssh 使用使用者 ID 登入.. 一旦我們輸入帳戶。然後我們運行 pod Creation.sh 檔案(如下所示)。

echo "Enter container image name"
read container

echo "Enter container name"
read name

echo "Enter the number of GPus required"
read gpu
cat <<EOF >$HOME/${name}-pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: $name
spec:
  volumes:
  - name: shared-data
    emptyDir: {}
  securityContext:
    runAsUser: $(id -u)
    fsGroup: $(id -g)
  containers:
  - name: $name
    image: $container
    resources:
      limits:
        nvidia.com/gpu: $gpu
    command: [ "/bin/bash", "-c", "--" ]
    args: [ "while true; do sleep 1; done;" ]
    volumeMounts:
    - name: ${name}-data
      mountPath: /workspace
  volumes:
  - name: ${name}-data
    hostPath:
      path: /raid/$(whoami)
      type: Directory
  hostNetwork: true
  dnsPolicy: Default
EOF

cd $HOME
kubectl create -f ${name}-pod.yaml 
rm $name-pod.yaml

進入 Kubernetes Pod 後,主目錄未掛載,這是將目錄掛載到 Pod 中的正確方法。我應該創建秘密並安裝它嗎?我希望將主目錄安裝在我的 pod 內

相關內容