-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAzureKubernetesCluster.cs
57 lines (51 loc) · 2.29 KB
/
AzureKubernetesCluster.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using Azure.Storage.Files.Shares;
using Microsoft.Extensions.Logging;
using Snd.Sdk.Storage.Azure;
using Snd.Sdk.Storage.Base;
namespace Snd.Sdk.Kubernetes.Azure
{
/// <summary>
/// A Kubernetes Cluster with Azure cloud backend (AKS). Only use this class if you use Azure-specific configurations.
/// </summary>
public class AzureKubernetesCluster : KubernetesCluster
{
/// <summary>
/// Creates an instance of <see cref="AzureKubernetesCluster"/>.
/// </summary>
/// <param name="kubeConfigLocation"></param>
/// <param name="loggerFactory"></param>
public AzureKubernetesCluster(string kubeConfigLocation, ILoggerFactory loggerFactory) : base(
kubeConfigLocation, loggerFactory)
{
this.InitSfs(loggerFactory);
}
/// <inheritdoc />
public override ISharedFileSystemService SharedFileSystem()
{
return this.sharedFileSystem;
}
private void InitSfs(ILoggerFactory loggerFactory)
{
var accountName =
Environment.GetEnvironmentVariable($"PROTEUS__K8S_AZURE_RWMPV_ACCOUNT_NAME") ??
Environment.GetEnvironmentVariable(
$"PROTEUS__K8S_{this.ClusterName.Replace("-", "_").ToUpperInvariant()}_AZURE_RWMPV_ACCOUNT_NAME");
var accountKey =
Environment.GetEnvironmentVariable($"PROTEUS__K8S_AZURE_RWMPV_ACCOUNT_KEY") ??
Environment.GetEnvironmentVariable(
$"PROTEUS__K8S_{this.ClusterName.Replace("-", "_").ToUpperInvariant()}_AZURE_RWMPV_ACCOUNT_KEY");
if (accountKey != null && accountName != null)
{
var mountResourceConnectionString =
$"DefaultEndpointsProtocol=https;AccountName={accountName};AccountKey={accountKey};EndpointSuffix=core.windows.net";
this.sharedFileSystem = new AzureSharedFSService(new ShareServiceClient(mountResourceConnectionString),
loggerFactory.CreateLogger<AzureSharedFSService>());
return;
}
this.logger.LogWarning(
"Missing configuration for external access to RMW mount on AKS cluster {clusterName}",
this.ClusterName);
}
}
}