-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[k8s] Set resource limits and requests for Edge runtime components (#…
…3666) * Make agent config a configMap: Helm and Rust portion. * Make agent config a configMap. csharp unit tests pass. * Mounting agent config map as optional * Make sure resources are not set if null in Values. * Explain what the appsettings and its fields are used for.
- Loading branch information
Showing
15 changed files
with
656 additions
and
56 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...-agent/src/Microsoft.Azure.Devices.Edge.Agent.Kubernetes/KubernetesApplicationSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
namespace Microsoft.Azure.Devices.Edge.Agent.Kubernetes | ||
{ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using k8s.Models; | ||
using Microsoft.Azure.Devices.Edge.Agent.Kubernetes.EdgeDeployment.Service; | ||
using Microsoft.Azure.Devices.Edge.Util; | ||
|
||
/// <summary> | ||
/// Application settings, derived from "appsetting_k8s.json" and environment | ||
/// variables, loaded from autofac. These setting are used to allow edgeAgent | ||
/// to properly construct proxy container settings and for agent to build itself. | ||
/// </summary> | ||
public class KubernetesApplicationSettings | ||
{ | ||
// Location of "appsetting_k8s.json" in container | ||
public string AgentConfigPath { get; set; } | ||
// Name of configmap containing "appsetting_k8s.json" | ||
public string AgentConfigMapName { get; set; } | ||
// Name of volume to use when mounting configmap, used in PodSpec | ||
public string AgentConfigVolume { get; set; } | ||
// Proxy Image | ||
public string ProxyImage { get; set; } | ||
// Name of volume to use when mounting proxy's configmap | ||
public string ProxyConfigVolume { get; set; } | ||
// Name of configmap containing "config.yaml" | ||
public string ProxyConfigMapName { get; set; } | ||
// Location of "config.yaml" in proxy container | ||
public string ProxyConfigPath { get; set; } | ||
// Location of trustbundle in proxy container | ||
public string ProxyTrustBundlePath { get; set; } | ||
// Name of volume to use when mounting trustbundle | ||
public string ProxyTrustBundleVolume { get; set; } | ||
// Map of configmap containing trustbundle | ||
public string ProxyTrustBundleConfigMapName { get; set; } | ||
// Resource requirements for proxy. | ||
public ResourceSettings ProxyResourceRequests { get; set; } | ||
// Resource requirements for agent. | ||
public ResourceSettings AgentResourceRequests { get; set; } | ||
|
||
public Option<V1ResourceRequirements> GetProxyResourceRequirements() => | ||
Option.Maybe(this.ProxyResourceRequests).Map(rr => rr.ToResourceRequirements()); | ||
public Option<V1ResourceRequirements> GetAgentResourceRequirements() => | ||
Option.Maybe(this.AgentResourceRequests).Map(rr => rr.ToResourceRequirements()); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Kubernetes/ResourceSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
namespace Microsoft.Azure.Devices.Edge.Agent.Kubernetes | ||
{ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using k8s.Models; | ||
using Microsoft.Azure.Devices.Edge.Util; | ||
|
||
/// <summary> | ||
/// K8s Resource requirements as read in by autofac | ||
/// </summary> | ||
public class ResourceSettings | ||
{ | ||
public Dictionary<string, string> Limits { get; set; } | ||
public Dictionary<string, string> Requests { get; set; } | ||
|
||
public V1ResourceRequirements ToResourceRequirements() | ||
{ | ||
Dictionary<string, ResourceQuantity> limits = Option.Maybe(this.Limits).Map(limitMap => | ||
limitMap.ToDictionary(pair => pair.Key, pair => new ResourceQuantity(pair.Value))).OrDefault(); | ||
Dictionary<string, ResourceQuantity> requests = Option.Maybe(this.Requests).Map(limitMap => | ||
limitMap.ToDictionary(pair => pair.Key, pair => new ResourceQuantity(pair.Value))).OrDefault(); | ||
return new V1ResourceRequirements(limits, requests); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.