首页 > 其他分享 >AKS (11) AKS挂载NFS File Share (静态创建)

AKS (11) AKS挂载NFS File Share (静态创建)

时间:2024-08-21 17:50:16浏览次数:4  
标签:11 AKS 创建 Share mnt Azure azure pod

  《Windows Azure Platform 系列文章目录

 

  本文介绍的是静态创建存储账户,即用户需要提前创建好存储账户

 

  1.我们首先创建Azure AKS集群,步骤略。我们的AKS集群名称为:aks1-27-9

 

  2.Azure AKS 通过NFS File Share挂载的时候,NFS 4.1只支持高级性能层的Azure存储账户。

  我们首先创建1个新的存储账户,如下图:

  注意:Performance必须选择Premium

  

 

  3.存储账户创建完毕后,点击File Share,创建1个File Share名称为nfs

  请注意创建的协议为NFS,另外我这里创建的容量最小为100GB

  

 

 

 

  4.上面的存储账户创建完毕后,选择Access Control,点击Add Role Assignment

  

 

  5.Role选择Storage Account Contributor,Members选择Managed Identity

  

 

  6.在Managed Identity里,选择Kubernetes Service,然后勾选我们之前创建的AKS服务实例

  

 

  7.分配完Managed Identiy之后,把Azure Storage Account的安全传输关闭。我们点击Configuration,然后在Secure transfer required选择Disabled

  

 

  8.在Azure Storage Account的Networking里,选择Enabled from select virtual network and IP Address,然后允许AKS所在的子网访问

  

 

 

  9.在创建Azure存储账户的时候,获得他的访问秘钥

 

  10.执行下面的命令,登录Azure

az login
az aks get-credentials -g 资源组名字 -n aks集群名字

 

  11.先创建secret

  下面azurestorageaccountname=后面输入你的环境的存储账户名称

  azurestorageaccountkey=存储账户秘钥

kubectl create secret generic azure-secret --from-literal=azurestorageaccountname=leistoragepremium01 --from-literal=azurestorageaccountkey=存储账户的秘钥

 

  12.执行下面的脚本,创建PV

apiVersion: v1
kind: PersistentVolume
metadata:
  annotations:
    pv.kubernetes.io/provisioned-by: file.csi.azure.com
  name: azurefile
spec:
  capacity:
    storage: 100Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  storageClassName: azurefile-csi-premium
  csi:
    driver: file.csi.azure.com
    volumeHandle: "leistoragepremium01"  # make sure this volumeid is unique for every identical share in the cluster
    volumeAttributes:
      protocol: nfs
      storageAccount: leistoragepremium01
      resourceGroup: aks-rg  # optional, only set this when storage account is not in the same resource group as node
      shareName: nfs
  mountOptions:
  - nconnect=4
  - noresvport
  - actimeo=30

 

  13.执行下面的脚本,创建PVC

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: azurefile
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: azurefile-csi-premium
  volumeName: azurefile
  resources:
    requests:
      storage: 100Gi

 

  14.执行下面的脚本,创建pod

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

 

  15.创建完毕后,pod应该会创建成功

root@Leilaptop6:/mnt/d/work/github/k8s/1.27.9/2.premiumnfs-static# kubectl get pod
NAME    READY   STATUS    RESTARTS   AGE
mypod   1/1     Running   0          5s

  

  16.然后我们进入到pod里面

kubectl exec -it pod/mypod -- /bin/sh

  

  17.创建1个新的文件

root@Leilaptop6:/mnt/d/work/github/k8s/1.27.9/2.premiumnfs-static# kubectl exec -it pod/mypod -- /bin/sh
/ # cd /mnt/azure
/mnt/azure # ll
/bin/sh: ll: not found
/mnt/azure # ls
/mnt/azure # touch 1.txt
/mnt/azure # exit

 

  18.把pod删除后,重建pod,然后再次exec进入pod,会发现上次创建的1.txt还会继续保留

 

 

  

 

  

标签:11,AKS,创建,Share,mnt,Azure,azure,pod
From: https://www.cnblogs.com/threestone/p/18369373

相关文章

  • 18118 勇者斗恶龙
    ###详细分析为了最小化雇佣骑士的花费,我们可以使用贪心算法。具体步骤如下:1.**排序**:将恶龙的头直径和骑士的能力值分别排序。2.**匹配**:从最小的头开始,找到第一个能够砍掉这个头的骑士,并记录花费。继续匹配下一个头,直到所有头都被砍掉或没有合适的骑士为止。3.**判断......
  • STAT 311 Programming
    Programming Assignment 8STAT 311Pleasecompletethefollowingproblemsand submit a file named STAT311-HW8 .R to Gradescope.Youshouldstart from the provided STAT311-HW8 .R file on Canvas.OverviewAddress each of the following que......
  • 全球创新药商业化服务平台市场展望:2030年预计达到113660百万美元
    随着全球医药行业的快速发展和创新药物研发的不断涌现,创新药商业化服务平台行业作为支持新药上市和商业化的关键服务领域,其市场前景受到业界广泛关注。据恒州恒思(YHresearch)团队研究的数据显示,2023年全球创新药商业化服务平台市场规模已达到33210百万美元,并预计在未来六年内,该......
  • T113i工业套件文章合集
    T113i工业套件提示:此开发板的任何问题都可以在我们的论坛交流讨论 https://forums.100ask.net/c/aw/15文章目录汇总教程共计5章,下面是章节汇总:第0章_T113i工业套件硬件简述第1章_源码工具文档手册第2章_安装并配置开发环境第3章_快速启用开发板第4章_Tina-SDK开发 ......
  • [题解]P3311 [SDOI2014] 数数
    P3311[SDOI2014]数数看到多模式匹配,我们考虑先对所有模式串建立AC自动机。然后发现这道题和P4052文本生成器(题解)挺像的,后者让求包含至少一个模式串的个数,这道题让求一个也不包含的个数,这个就是一个用不用\(26^m\)去减的问题,很好处理。但这道题还多了一个条件,“幸运数”必须\(......
  • BT5 2011.4.社会工程学.1.JAVA
    4.社会工程学工具 内容简介第一部分:JavaAppletAttackMethod第二部分:CredentialHarvesterAttackMethod 第一部分JavaAppletAttackMethod 拓扑介绍 SET介绍TheSETisanadvanced,multi-function,andeasytousecomputerassistedsocialengineering......
  • BT5 2011.1.信息收集
    BT502111.信息收集2.扫描工具3.漏洞发现4.设备工程学工具5.运用层攻击MSF6.局域网攻击7.密码破解8.维持访问 内容简介第一部分:DNS信息收集第二部分:路由信息收集第三部分:All-in-one智能收集 第一部分DNS信息收集 1.Dnsmap介绍1.Getextranamesandsubdoma......
  • BT5 2011.3.漏洞发现.3(nessus)
    第四部分SMB工具 1.SamrdumpTheSamrdumpisanapplicationthatretrievessensitiveinformationaboutthespecifiedtargetusingSecurityAccountManager(SAM),aremoteinterfacewhichisaccessibleundertheDistributedComputingEnvironment/RemoteProced......
  • BT5 2011.3.漏洞发现.2(http smb)
    第三部分HTTP工具 1.BurpSuite(1)BurpSuiteisacombinationofpowerfulwebapplicationsecuritytools.Thesetoolsdemonstratethereal-worldcapabilitiesofanattackerpenetratingthewebapplications.Itcanscan,analyze,andexploitthewebapplications......
  • BT5 2011.3.漏洞发现.1(cisco snmp)
    3.漏洞发现 内容简介第一部分:Cisco工具第二部分:SNMP工具第三部分:HTTP工具第四部分:SMB工具第五部分:综合漏洞发现工具Nessus 第一部分Cisco工具 拓扑介绍 1.CiscoAuditingToolCiscoAuditingTool(CAT)isaminisecurityauditingtool.ItscanstheCiscor......