簡體   English   中英

Kube.netes - 如何引用文件共享以掛載卷?

[英]Kubernetes - how to reference file share in order to mount volume?

我們計划為 K8S 使用 Azure Kube.netes 服務。 我們有 Azure 文件共享。 是否可以在Pod 或部署yaml 定義中以某種方式引用 Azure 文件共享,以便可以在容器 (Pod) 級別上安裝卷? 這個引用是需要在 AKS 集群創建期間定義的東西,還是在我們執行kubectl apply命令部署我們的容器 Pod 時以某種方式引用它就足夠了。

謝謝

因此,根據@AndreyDonald 提供的將文件共享安裝為卷文檔,您可以這樣參考

apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
  - image: mcr.microsoft.com/oss/nginx/nginx:1.15.5-alpine
    name: mypod
    resources:
      requests:
        cpu: 100m
        memory: 128Mi
      limits:
        cpu: 250m
        memory: 256Mi
    volumeMounts:
      - name: azure
        mountPath: /mnt/azure
  volumes:
  - name: azure
    azureFile:
      secretName: azure-secret
      shareName: aksshare
      readOnly: false

但在此之前,您應該創建一個 Kube.netes secret

kubectl create secret generic azure-secret --from-literal=azurestorageaccountname=$AKS_PERS_STORAGE_ACCOUNT_NAME --from-literal=azurestorageaccountkey=$STORAGE_KEY

為了創建該秘密,您應該使用 assign correct values to vars

$AKS_PERS_STORAGE_ACCOUNT_NAME
$STORAGE_KEY

您不必創建新的文件共享,只需

# Get storage account key
STORAGE_KEY=$(az storage account keys list --resource-group $AKS_PERS_RESOURCE_GROUP --account-name $AKS_PERS_STORAGE_ACCOUNT_NAME --query "[0].value" -o tsv)

並使用它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM