如何将现有的Azure文件共享安装到Kubernetes中的Pod

时间:2018-03-20 14:09:03

标签: kubernetes azure-storage-files azure-files

有人可以告诉我安装包含文件的Azure文件共享需要遵循的步骤,并且需要将其安装在Kubernetes的pod中。

1 个答案:

答案 0 :(得分:0)

正如我在documentation中看到的那样,Azure使用SMB协议来访问数据:

  

Azure文件可以通过SMB 2.1和SMB 3.0安装。对于来自本地客户端或其他Azure区域的连接,Azure文件将拒绝SMB 2.1(或不加密的SMB 3.0)。如果为存储帐户启用了所需的安全传输,则Azure文件将仅允许使用带有加密的SMB 3.0进行连接。

Kubernetes不直接支持SMB,但支持特殊类型的卷 - public IHttpActionResult GenerateValidationCSVFiles(string submissionId) { try { //Based on the SubmissionID, we get data //Account Table DataTable tblAccount = new DataTable(); tblAccount.Columns.Add("AccountID", typeof(int)); tblAccount.Columns.Add("NAME", typeof(string)); tblAccount.Columns.Add("Email", typeof(string)); tblAccount.Rows.Add(111, "John", "John@abc.com"); tblAccount.Rows.Add(222, "Mike", "Mike@xyz.com"); tblAccount.Rows.Add(102, "Meghan", "Meghan@123.com"); //Location Table DataTable tblLocation = new DataTable(); tblLocation.Columns.Add("AccountID", typeof(int)); tblLocation.Columns.Add("LocName", typeof(string)); tblLocation.Columns.Add("Address", typeof(string)); tblLocation.Columns.Add("CITY", typeof(string)); tblLocation.Columns.Add("Zipcode", typeof(string)); tblLocation.Rows.Add(111, "John", "123 Lake Dr", "Newyork", "12345"); tblLocation.Rows.Add(222, "Mike", "456 test Dr", "Kansas", ""); tblLocation.Rows.Add(102, "Meghan", "345 Texico Pl", "San Francisco", ""); tblLocation.Rows.Add(212, "Steve", "8989 Williow Cir", "Chicago", ""); //Write logic to render as CSV File data } catch (Exception ex) { ILog Log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); Log.Error("ERROR : " + ex.ToString()); return Ok(ex.ToString()); } } ,它将自动为您提供SMB配置。

接下来,要安装存储,您需要to

  1. 将包安装到您的节点:AzureFile。如果你使用像Ubuntu这样的类似Debian的发行版,请检查如何在你的操作系统中安装这些软件包(可能它们有相同的名称)。

  2. 不,你需要:

      

    获取Microsoft Azure存储帐户并创建包含base64编码的Azure存储帐户名和密钥的密码。在机密文件中,对Azure存储帐户名进行base64编码,并将其与名称azurestorageaccountname配对,并使用base64编码Azure存储访问密钥,并将其与名称azurestorageaccountkey配对。

    之后,您可以使用该文件创建Kubernetes秘密:

  3. yum -y install cifs-utils

    1. 现在您可以将共享安装到您的pod:
    2. apiVersion: v1 kind: Secret metadata: name: azure-secret type: Opaque data: azurestorageaccountname: azhzdGVzdA== azurestorageaccountkey: eElGMXpKYm5ub2pGTE1Ta0JwNTBteDAyckhzTUsyc2pVN21GdDRMMTNob0I3ZHJBYUo4akQ2K0E0NDNqSm9nVjd5MkZVT2hRQ1dQbU02WWFOSHk3cWc9PQ==