Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/1399-cluster-information-application (#1524)
* Created application skeleton. * Simple pod controller with DI for our kubernetes api wrapper. * Dockerized application. * Renamed to deploymentsController * Added dummy endpoint * Helm charts. * Added debug info. * Added cors + helm template setup with values * Removed unused controller. * StyleCop compliant. * Keeping role, rolebiding and SA as own files as of now. * Fixes after code review. * Trying to add stylecop. * Stylecop now working. * Added solution files. * Updated xml file path.
- Loading branch information
Showing
28 changed files
with
823 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.26124.0 | ||
MinimumVisualStudioVersion = 15.0.26124.0 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KubernetesWrapper", "KubernetesWrapper\KubernetesWrapper.csproj", "{423D0031-0DF0-4585-9FC9-5E8B6F6C7A2E}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CD2C173E-4183-4E63-85C2-0692BA375C91}" | ||
ProjectSection(SolutionItems) = preProject | ||
Altinn3.ruleset = Altinn3.ruleset | ||
..\..\stylecop.json = ..\..\stylecop.json | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|Any CPU = Release|Any CPU | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{423D0031-0DF0-4585-9FC9-5E8B6F6C7A2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{423D0031-0DF0-4585-9FC9-5E8B6F6C7A2E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{423D0031-0DF0-4585-9FC9-5E8B6F6C7A2E}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{423D0031-0DF0-4585-9FC9-5E8B6F6C7A2E}.Debug|x64.Build.0 = Debug|Any CPU | ||
{423D0031-0DF0-4585-9FC9-5E8B6F6C7A2E}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{423D0031-0DF0-4585-9FC9-5E8B6F6C7A2E}.Debug|x86.Build.0 = Debug|Any CPU | ||
{423D0031-0DF0-4585-9FC9-5E8B6F6C7A2E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{423D0031-0DF0-4585-9FC9-5E8B6F6C7A2E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{423D0031-0DF0-4585-9FC9-5E8B6F6C7A2E}.Release|x64.ActiveCfg = Release|Any CPU | ||
{423D0031-0DF0-4585-9FC9-5E8B6F6C7A2E}.Release|x64.Build.0 = Release|Any CPU | ||
{423D0031-0DF0-4585-9FC9-5E8B6F6C7A2E}.Release|x86.ActiveCfg = Release|Any CPU | ||
{423D0031-0DF0-4585-9FC9-5E8B6F6C7A2E}.Release|x86.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {14484280-61CE-4792-BE1C-CA330E0B1894} | ||
EndGlobalSection | ||
EndGlobal |
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,177 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RuleSet Name="New Rule Set" Description=" " ToolsVersion="15.0"> | ||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers"> | ||
<Rule Id="SA0001" Action="Error" /> | ||
<Rule Id="SA0002" Action="None" /> | ||
<Rule Id="SA1000" Action="Warning" /> | ||
<Rule Id="SA1001" Action="Warning" /> | ||
<Rule Id="SA1002" Action="Warning" /> | ||
<Rule Id="SA1003" Action="Warning" /> | ||
<Rule Id="SA1004" Action="Warning" /> | ||
<Rule Id="SA1005" Action="Warning" /> | ||
<Rule Id="SA1006" Action="Warning" /> | ||
<Rule Id="SA1007" Action="Warning" /> | ||
<Rule Id="SA1008" Action="Warning" /> | ||
<Rule Id="SA1009" Action="None" /> | ||
<Rule Id="SA1010" Action="Warning" /> | ||
<Rule Id="SA1011" Action="Warning" /> | ||
<Rule Id="SA1012" Action="Warning" /> | ||
<Rule Id="SA1013" Action="Warning" /> | ||
<Rule Id="SA1014" Action="Warning" /> | ||
<Rule Id="SA1015" Action="Warning" /> | ||
<Rule Id="SA1016" Action="Warning" /> | ||
<Rule Id="SA1017" Action="Warning" /> | ||
<Rule Id="SA1018" Action="Warning" /> | ||
<Rule Id="SA1019" Action="Warning" /> | ||
<Rule Id="SA1020" Action="Warning" /> | ||
<Rule Id="SA1021" Action="Warning" /> | ||
<Rule Id="SA1022" Action="Warning" /> | ||
<Rule Id="SA1023" Action="Warning" /> | ||
<Rule Id="SA1024" Action="None" /> | ||
<Rule Id="SA1025" Action="Warning" /> | ||
<Rule Id="SA1026" Action="Warning" /> | ||
<Rule Id="SA1027" Action="Warning" /> | ||
<Rule Id="SA1028" Action="None" /> | ||
<Rule Id="SA1100" Action="Error" /> | ||
<Rule Id="SA1101" Action="None" /> | ||
<Rule Id="SA1102" Action="Error" /> | ||
<Rule Id="SA1103" Action="Error" /> | ||
<Rule Id="SA1104" Action="Error" /> | ||
<Rule Id="SA1105" Action="Error" /> | ||
<Rule Id="SA1106" Action="Error" /> | ||
<Rule Id="SA1107" Action="Error" /> | ||
<Rule Id="SA1108" Action="Error" /> | ||
<Rule Id="SA1110" Action="Error" /> | ||
<Rule Id="SA1111" Action="Error" /> | ||
<Rule Id="SA1112" Action="Error" /> | ||
<Rule Id="SA1113" Action="Error" /> | ||
<Rule Id="SA1114" Action="Error" /> | ||
<Rule Id="SA1115" Action="Error" /> | ||
<Rule Id="SA1116" Action="Error" /> | ||
<Rule Id="SA1117" Action="Error" /> | ||
<Rule Id="SA1118" Action="Error" /> | ||
<Rule Id="SA1119" Action="Error" /> | ||
<Rule Id="SA1120" Action="Error" /> | ||
<Rule Id="SA1121" Action="Error" /> | ||
<Rule Id="SA1122" Action="Error" /> | ||
<Rule Id="SA1123" Action="None" /> | ||
<Rule Id="SA1124" Action="None" /> | ||
<Rule Id="SA1125" Action="Error" /> | ||
<Rule Id="SA1127" Action="Error" /> | ||
<Rule Id="SA1128" Action="None" /> | ||
<Rule Id="SA1129" Action="Error" /> | ||
<Rule Id="SA1130" Action="Error" /> | ||
<Rule Id="SA1131" Action="Error" /> | ||
<Rule Id="SA1132" Action="Error" /> | ||
<Rule Id="SA1133" Action="Error" /> | ||
<Rule Id="SA1134" Action="Error" /> | ||
<Rule Id="SA1135" Action="Error" /> | ||
<Rule Id="SA1136" Action="Error" /> | ||
<Rule Id="SA1137" Action="Warning" /> | ||
<Rule Id="SA1139" Action="None" /> | ||
<Rule Id="SA1200" Action="None" /> | ||
<Rule Id="SA1201" Action="None" /> | ||
<Rule Id="SA1202" Action="None" /> | ||
<Rule Id="SA1203" Action="None" /> | ||
<Rule Id="SA1204" Action="None" /> | ||
<Rule Id="SA1205" Action="None" /> | ||
<Rule Id="SA1206" Action="None" /> | ||
<Rule Id="SA1207" Action="None" /> | ||
<Rule Id="SA1208" Action="Error" /> | ||
<Rule Id="SA1209" Action="Error" /> | ||
<Rule Id="SA1210" Action="Error" /> | ||
<Rule Id="SA1211" Action="Error" /> | ||
<Rule Id="SA1212" Action="None" /> | ||
<Rule Id="SA1213" Action="None" /> | ||
<Rule Id="SA1214" Action="None" /> | ||
<Rule Id="SA1216" Action="Error" /> | ||
<Rule Id="SA1217" Action="Error" /> | ||
<Rule Id="SA1300" Action="Error" /> | ||
<Rule Id="SA1302" Action="Error" /> | ||
<Rule Id="SA1303" Action="Error" /> | ||
<Rule Id="SA1304" Action="Error" /> | ||
<Rule Id="SA1305" Action="Error" /> | ||
<Rule Id="SA1306" Action="Error" /> | ||
<Rule Id="SA1307" Action="Error" /> | ||
<Rule Id="SA1308" Action="Error" /> | ||
<Rule Id="SA1309" Action="None" /> | ||
<Rule Id="SA1310" Action="None" /> | ||
<Rule Id="SA1311" Action="Error" /> | ||
<Rule Id="SA1312" Action="Error" /> | ||
<Rule Id="SA1313" Action="None" /> | ||
<Rule Id="SA1314" Action="Error" /> | ||
<Rule Id="SA1400" Action="Warning" /> | ||
<Rule Id="SA1401" Action="Error" /> | ||
<Rule Id="SA1402" Action="None" /> | ||
<Rule Id="SA1403" Action="Error" /> | ||
<Rule Id="SA1404" Action="Error" /> | ||
<Rule Id="SA1405" Action="None" /> | ||
<Rule Id="SA1406" Action="None" /> | ||
<Rule Id="SA1407" Action="Error" /> | ||
<Rule Id="SA1408" Action="Error" /> | ||
<Rule Id="SA1410" Action="None" /> | ||
<Rule Id="SA1411" Action="None" /> | ||
<Rule Id="SA1413" Action="None" /> | ||
<Rule Id="SA1500" Action="Error" /> | ||
<Rule Id="SA1501" Action="Error" /> | ||
<Rule Id="SA1502" Action="Error" /> | ||
<Rule Id="SA1503" Action="Error" /> | ||
<Rule Id="SA1504" Action="Error" /> | ||
<Rule Id="SA1505" Action="Error" /> | ||
<Rule Id="SA1506" Action="Error" /> | ||
<Rule Id="SA1507" Action="Error" /> | ||
<Rule Id="SA1508" Action="Warning" /> | ||
<Rule Id="SA1509" Action="Warning" /> | ||
<Rule Id="SA1510" Action="Error" /> | ||
<Rule Id="SA1511" Action="Error" /> | ||
<Rule Id="SA1512" Action="Warning" /> | ||
<Rule Id="SA1513" Action="Error" /> | ||
<Rule Id="SA1514" Action="Error" /> | ||
<Rule Id="SA1515" Action="Error" /> | ||
<Rule Id="SA1516" Action="Error" /> | ||
<Rule Id="SA1517" Action="Error" /> | ||
<Rule Id="SA1518" Action="Error" /> | ||
<Rule Id="SA1519" Action="Error" /> | ||
<Rule Id="SA1520" Action="Error" /> | ||
<Rule Id="SA1600" Action="Warning" /> | ||
<Rule Id="SA1601" Action="Error" /> | ||
<Rule Id="SA1602" Action="Error" /> | ||
<Rule Id="SA1604" Action="Error" /> | ||
<Rule Id="SA1605" Action="Error" /> | ||
<Rule Id="SA1606" Action="Error" /> | ||
<Rule Id="SA1607" Action="Error" /> | ||
<Rule Id="SA1608" Action="Error" /> | ||
<Rule Id="SA1610" Action="Error" /> | ||
<Rule Id="SA1611" Action="None" /> | ||
<Rule Id="SA1612" Action="Error" /> | ||
<Rule Id="SA1613" Action="Error" /> | ||
<Rule Id="SA1614" Action="Error" /> | ||
<Rule Id="SA1615" Action="None" /> | ||
<Rule Id="SA1616" Action="None" /> | ||
<Rule Id="SA1617" Action="Error" /> | ||
<Rule Id="SA1618" Action="None" /> | ||
<Rule Id="SA1619" Action="None" /> | ||
<Rule Id="SA1620" Action="None" /> | ||
<Rule Id="SA1621" Action="Error" /> | ||
<Rule Id="SA1622" Action="None" /> | ||
<Rule Id="SA1623" Action="None" /> | ||
<Rule Id="SA1624" Action="Error" /> | ||
<Rule Id="SA1625" Action="Error" /> | ||
<Rule Id="SA1626" Action="Warning" /> | ||
<Rule Id="SA1627" Action="Error" /> | ||
<Rule Id="SA1629" Action="None" /> | ||
<Rule Id="SA1633" Action="None" /> | ||
<Rule Id="SA1634" Action="None" /> | ||
<Rule Id="SA1635" Action="None" /> | ||
<Rule Id="SA1636" Action="None" /> | ||
<Rule Id="SA1637" Action="None" /> | ||
<Rule Id="SA1638" Action="None" /> | ||
<Rule Id="SA1640" Action="None" /> | ||
<Rule Id="SA1641" Action="None" /> | ||
<Rule Id="SA1642" Action="None" /> | ||
<Rule Id="SA1643" Action="None" /> | ||
<Rule Id="SA1648" Action="Error" /> | ||
<Rule Id="SA1649" Action="Error" /> | ||
<Rule Id="SA1651" Action="Error" /> | ||
</Rules> | ||
</RuleSet> |
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,2 @@ | ||
bin\ | ||
obj\ |
56 changes: 56 additions & 0 deletions
56
src/Altinn.Apps/KubernetesWrapper/Controllers/DeploymentsController.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,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using KubernetesWrapper.Services.Interfaces; | ||
using Microsoft.AspNetCore.Cors; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace KubernetesWrapper.Controllers | ||
{ | ||
/// <summary> | ||
/// Controller containing all actions related to kubernetes deployments | ||
/// </summary> | ||
[Route("api/v1/[controller]")] | ||
[ApiController] | ||
public class DeploymentsController : ControllerBase | ||
{ | ||
private readonly IKubernetesAPIWrapper _apiWrapper; | ||
private readonly ILogger _logger; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="DeploymentsController"/> class | ||
/// </summary> | ||
/// <param name="apiWrapper">The kubernetes api wrapper client</param> | ||
/// <param name="logger">The logger</param> | ||
public DeploymentsController(IKubernetesAPIWrapper apiWrapper, ILogger<DeploymentsController> logger) | ||
{ | ||
_apiWrapper = apiWrapper; | ||
_logger = logger; | ||
} | ||
|
||
/// <summary> | ||
/// Get a list of deployments. For a more detailed spec of parameters see Kubernetes API DOC | ||
/// </summary> | ||
/// <param name="labelSelector">A selector to restrict the list of returned objects by their labels. Defaults to everything.</param> | ||
/// <param name="fieldSelector">A selector to restrict the list of returned objects by their fields. Defaults to everything.</param> | ||
/// <returns>A list of deployments in the cluster</returns> | ||
[HttpGet] | ||
[EnableCors] | ||
public async Task<ActionResult> GetDeployments(string labelSelector, string fieldSelector) | ||
{ | ||
try | ||
{ | ||
var deployments = await _apiWrapper.GetDeployments(null, fieldSelector, labelSelector); | ||
return Ok(deployments.Items); | ||
} | ||
catch (Exception exception) | ||
{ | ||
_logger.LogError(exception, "Unable to GetDeployments"); | ||
return StatusCode(500); | ||
} | ||
} | ||
} | ||
} |
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,16 @@ | ||
FROM microsoft/dotnet:sdk AS build-env | ||
WORKDIR /app | ||
|
||
# Copy csproj and restore as distinct layers | ||
COPY *.csproj ./ | ||
RUN dotnet restore | ||
|
||
# Copy everything else and build | ||
COPY . ./ | ||
RUN dotnet publish -c Release -o out | ||
|
||
# Build runtime image | ||
FROM microsoft/dotnet:aspnetcore-runtime | ||
WORKDIR /app | ||
COPY --from=build-env /app/out . | ||
ENTRYPOINT ["dotnet", "KubernetesWrapper.dll"] |
31 changes: 31 additions & 0 deletions
31
src/Altinn.Apps/KubernetesWrapper/KubernetesWrapper.csproj
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,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.2</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="wwwroot\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="KubernetesClient" Version="1.5.18" /> | ||
<PackageReference Include="Microsoft.AspNetCore.App" /> | ||
<PackageReference Include="Serilog.Extensions.Hosting" Version="2.0.0" /> | ||
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.2" /> | ||
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" /> | ||
<PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" /> | ||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.0.1" /> | ||
<PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.1.1.114"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> | ||
<CodeAnalysisRuleSet>$(SolutionDir)Altinn3.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<DocumentationFile>bin\Debug\netcoreapp2.2\KubernetesWrapper.xml</DocumentationFile> | ||
</PropertyGroup> | ||
|
||
</Project> |
Oops, something went wrong.