diff --git a/.vscode/settings.json b/.vscode/settings.json
index 31436e3f430..779876663cc 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -18,5 +18,11 @@
"**/publish/**": true,
"**/Debug": true
},
- "typescript.surveys.enabled": false
+ "typescript.surveys.enabled": false,
+ "cSpell.words": [
+ "api",
+ "i",
+ "kubernetes",
+ "wrapper"
+ ]
}
diff --git a/Settings.StyleCop b/Settings.StyleCop
index 06d70348f66..fd124ef0269 100644
--- a/Settings.StyleCop
+++ b/Settings.StyleCop
@@ -58,7 +58,7 @@
orderby
Oppgaveregister
Seres
- reportees
+ reportees
10000
diff --git a/src/Altinn.Apps/Altinn.Apps.sln b/src/Altinn.Apps/Altinn.Apps.sln
new file mode 100644
index 00000000000..0eb70c40b69
--- /dev/null
+++ b/src/Altinn.Apps/Altinn.Apps.sln
@@ -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
diff --git a/src/Altinn.Apps/Altinn3.ruleset b/src/Altinn.Apps/Altinn3.ruleset
new file mode 100644
index 00000000000..6cd17ce192f
--- /dev/null
+++ b/src/Altinn.Apps/Altinn3.ruleset
@@ -0,0 +1,177 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Altinn.Apps/KubernetesWrapper/.dockerignore b/src/Altinn.Apps/KubernetesWrapper/.dockerignore
new file mode 100644
index 00000000000..fe2b1838db3
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/.dockerignore
@@ -0,0 +1,2 @@
+bin\
+obj\
diff --git a/src/Altinn.Apps/KubernetesWrapper/Controllers/DeploymentsController.cs b/src/Altinn.Apps/KubernetesWrapper/Controllers/DeploymentsController.cs
new file mode 100644
index 00000000000..f1ce1b58603
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/Controllers/DeploymentsController.cs
@@ -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
+{
+ ///
+ /// Controller containing all actions related to kubernetes deployments
+ ///
+ [Route("api/v1/[controller]")]
+ [ApiController]
+ public class DeploymentsController : ControllerBase
+ {
+ private readonly IKubernetesAPIWrapper _apiWrapper;
+ private readonly ILogger _logger;
+
+ ///
+ /// Initializes a new instance of the class
+ ///
+ /// The kubernetes api wrapper client
+ /// The logger
+ public DeploymentsController(IKubernetesAPIWrapper apiWrapper, ILogger logger)
+ {
+ _apiWrapper = apiWrapper;
+ _logger = logger;
+ }
+
+ ///
+ /// Get a list of deployments. For a more detailed spec of parameters see Kubernetes API DOC
+ ///
+ /// A selector to restrict the list of returned objects by their labels. Defaults to everything.
+ /// A selector to restrict the list of returned objects by their fields. Defaults to everything.
+ /// A list of deployments in the cluster
+ [HttpGet]
+ [EnableCors]
+ public async Task 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);
+ }
+ }
+ }
+}
diff --git a/src/Altinn.Apps/KubernetesWrapper/Dockerfile b/src/Altinn.Apps/KubernetesWrapper/Dockerfile
new file mode 100644
index 00000000000..71e3c2c63ef
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/Dockerfile
@@ -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"]
diff --git a/src/Altinn.Apps/KubernetesWrapper/KubernetesWrapper.csproj b/src/Altinn.Apps/KubernetesWrapper/KubernetesWrapper.csproj
new file mode 100644
index 00000000000..cab7d928703
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/KubernetesWrapper.csproj
@@ -0,0 +1,31 @@
+
+
+
+ netcoreapp2.2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+
+ $(SolutionDir)Altinn3.ruleset
+
+
+ bin\Debug\netcoreapp2.2\KubernetesWrapper.xml
+
+
+
diff --git a/src/Altinn.Apps/KubernetesWrapper/Program.cs b/src/Altinn.Apps/KubernetesWrapper/Program.cs
new file mode 100644
index 00000000000..e16373d688d
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/Program.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
+using Serilog;
+using Serilog.Extensions.Logging;
+
+namespace KubernetesWrapper
+{
+ ///
+ /// This is the main entry point
+ ///
+ public class Program
+ {
+ ///
+ /// The main method
+ ///
+ /// The Arguments
+ public static void Main(string[] args)
+ {
+ CreateWebHostBuilder(args).Build().Run();
+ }
+
+ ///
+ /// Configure the configuration builder
+ ///
+ /// arguments for creating build configuration
+ /// The web host builder
+ public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
+ WebHost.CreateDefaultBuilder(args)
+ .ConfigureLogging((hostingContext, logging) =>
+ {
+ logging.ClearProviders();
+ Serilog.ILogger logger = new LoggerConfiguration()
+ .WriteTo.Console()
+ .CreateLogger();
+
+ logging.AddProvider(new SerilogLoggerProvider(logger));
+ })
+ .UseStartup();
+
+ }
+}
diff --git a/src/Altinn.Apps/KubernetesWrapper/Properties/launchSettings.json b/src/Altinn.Apps/KubernetesWrapper/Properties/launchSettings.json
new file mode 100644
index 00000000000..134864a20a4
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/Properties/launchSettings.json
@@ -0,0 +1,30 @@
+{
+ "$schema": "http://json.schemastore.org/launchsettings.json",
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:20960",
+ "sslPort": 44375
+ }
+ },
+ "profiles": {
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "launchUrl": "api/pods",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "KubernetesWrapper": {
+ "commandName": "Project",
+ "launchBrowser": true,
+ "launchUrl": "api/pods",
+ "applicationUrl": "https://localhost:5003;http://localhost:5004",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/src/Altinn.Apps/KubernetesWrapper/Services/Implementation/IKubernetesAPIWrapperSI.cs b/src/Altinn.Apps/KubernetesWrapper/Services/Implementation/IKubernetesAPIWrapperSI.cs
new file mode 100644
index 00000000000..1cde3290ed2
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/Services/Implementation/IKubernetesAPIWrapperSI.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Threading.Tasks;
+using k8s;
+using KubernetesWrapper.Services.Interfaces;
+using Microsoft.Extensions.Logging;
+
+namespace KubernetesWrapper.Services.Implementation
+{
+ ///
+ /// An implementation of the kubernetes api wrapper
+ ///
+ public class IKubernetesAPIWrapperSI : IKubernetesAPIWrapper
+ {
+ private Kubernetes client;
+ private ILogger _logger;
+
+ ///
+ /// Initializes a new instance of the class
+ ///
+ /// The logger
+ public IKubernetesAPIWrapperSI(ILogger logger)
+ {
+ _logger = logger;
+ try
+ {
+ var config = KubernetesClientConfiguration.InClusterConfig();
+ client = new Kubernetes(config);
+ }
+ catch (Exception exception)
+ {
+ _logger.LogError(exception, "Unable to initialize IKubernetesAPIWrapperSI");
+ }
+ }
+
+ ///
+ /// Gets a list of deployments on the cluster. Parameters are described in further detail in the kubernetes api doc.
+ ///
+ /// Continue parameter. Defaults to null.
+ /// A selector to restrict the list of returned objects by their labels. Defaults to everything
+ /// A selector to restrict the list of returned objects by their fields. Defaults to everything
+ /// Limits the response length.
+ /// Resource versions type
+ /// Timeout in seconds
+ /// Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.
+ /// If 'true', then the output is pretty printed.
+ /// A V1DeploymentList
+ async Task IKubernetesAPIWrapper.GetDeployments(
+ string continueParameter,
+ string fieldSelector,
+ string labelSelector,
+ int? limit,
+ string resourceVersion,
+ int? timeoutSeconds,
+ bool? watch,
+ string pretty)
+ {
+ var deployments = await client.ListNamespacedDeploymentAsync("default", continueParameter, fieldSelector, labelSelector, limit, resourceVersion, timeoutSeconds, watch, pretty);
+ return deployments;
+ }
+ }
+}
diff --git a/src/Altinn.Apps/KubernetesWrapper/Services/Interfaces/IKubernetesAPIWrapper.cs b/src/Altinn.Apps/KubernetesWrapper/Services/Interfaces/IKubernetesAPIWrapper.cs
new file mode 100644
index 00000000000..be123824e83
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/Services/Interfaces/IKubernetesAPIWrapper.cs
@@ -0,0 +1,33 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace KubernetesWrapper.Services.Interfaces
+{
+ ///
+ /// Interface for the kubernetes api wrapper
+ ///
+ public interface IKubernetesAPIWrapper
+ {
+ ///
+ /// Gets a list of deployments on the cluster. Parameters are described in further detail in the kubernetes api doc.
+ ///
+ /// Continue parameter. Defaults to null.
+ /// A selector to restrict the list of returned objects by their labels. Defaults to everything
+ /// A selector to restrict the list of returned objects by their fields. Defaults to everything
+ /// Limits the response length.
+ /// Resource versions type
+ /// Timeout in seconds
+ /// Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.
+ /// If 'true', then the output is pretty printed.
+ /// A V1DeploymentList
+ Task GetDeployments(
+ string continueParameter = null,
+ string fieldSelector = null,
+ string labelSelector = null,
+ int? limit = null,
+ string resourceVersion = null,
+ int? timeoutSeconds = null,
+ bool? watch = null,
+ string pretty = null);
+ }
+}
diff --git a/src/Altinn.Apps/KubernetesWrapper/Settings.StyleCop b/src/Altinn.Apps/KubernetesWrapper/Settings.StyleCop
new file mode 100644
index 00000000000..bb05f99bc1a
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/Settings.StyleCop
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/Altinn.Apps/KubernetesWrapper/Startup.cs b/src/Altinn.Apps/KubernetesWrapper/Startup.cs
new file mode 100644
index 00000000000..000f1c025a3
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/Startup.cs
@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using KubernetesWrapper.Services.Implementation;
+using KubernetesWrapper.Services.Interfaces;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.HttpsPolicy;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+
+namespace KubernetesWrapper
+{
+ ///
+ /// This is the class that set up the application during startup
+ ///
+ ///
+ public class Startup
+ {
+ ///
+ /// Initializes a new instance of the class
+ ///
+ /// the configuration for designer
+ public Startup(IConfiguration configuration)
+ {
+ Configuration = configuration;
+ }
+
+ ///
+ /// Gets the application configuration
+ ///
+ public IConfiguration Configuration { get; }
+
+ ///
+ /// Configures the services available for the asp.net Core application
+ ///
+ ///
+ /// The services available for asp.net Core
+ public void ConfigureServices(IServiceCollection services)
+ {
+ services.AddCors(options =>
+ {
+ options.AddDefaultPolicy(builder =>
+ {
+ builder.AllowAnyOrigin();
+ builder.WithMethods("GET");
+ builder.AllowAnyHeader();
+ });
+ });
+ services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
+
+ // dependency injection
+ services.AddSingleton();
+ }
+
+ ///
+ /// Configure the application.
+ ///
+ ///
+ /// The application builder
+ /// Hosting environment
+ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
+ {
+ if (env.IsDevelopment())
+ {
+ app.UseDeveloperExceptionPage();
+ }
+ else
+ {
+ app.UseHsts();
+ }
+
+ //app.UseHttpsRedirection();
+ app.UseCors();
+ app.UseMvc();
+ }
+ }
+}
diff --git a/src/Altinn.Apps/KubernetesWrapper/appsettings.Development.json b/src/Altinn.Apps/KubernetesWrapper/appsettings.Development.json
new file mode 100644
index 00000000000..e203e9407e7
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/appsettings.Development.json
@@ -0,0 +1,9 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Debug",
+ "System": "Information",
+ "Microsoft": "Information"
+ }
+ }
+}
diff --git a/src/Altinn.Apps/KubernetesWrapper/appsettings.json b/src/Altinn.Apps/KubernetesWrapper/appsettings.json
new file mode 100644
index 00000000000..def9159a7d9
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/appsettings.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Warning"
+ }
+ },
+ "AllowedHosts": "*"
+}
diff --git a/src/Altinn.Apps/KubernetesWrapper/deployment/.helmignore b/src/Altinn.Apps/KubernetesWrapper/deployment/.helmignore
new file mode 100644
index 00000000000..f0c13194444
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/deployment/.helmignore
@@ -0,0 +1,21 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
diff --git a/src/Altinn.Apps/KubernetesWrapper/deployment/Chart.yaml b/src/Altinn.Apps/KubernetesWrapper/deployment/Chart.yaml
new file mode 100644
index 00000000000..52f01da4ddd
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/deployment/Chart.yaml
@@ -0,0 +1,5 @@
+apiVersion: v1
+description: A Helm chart for the kubernetes api wrapper
+# name can only be lowercase. It is used in the templats.
+name: kubernetes-api-wrapper
+version: 1.1.0
diff --git a/src/Altinn.Apps/KubernetesWrapper/deployment/role.yaml b/src/Altinn.Apps/KubernetesWrapper/deployment/role.yaml
new file mode 100644
index 00000000000..1ed20414b30
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/deployment/role.yaml
@@ -0,0 +1,9 @@
+kind: Role
+apiVersion: rbac.authorization.k8s.io/v1
+metadata:
+ namespace: default
+ name: kubernetes-read-role
+rules:
+- apiGroups: ["apps"]
+ resources: ["deployments"]
+ verbs: ["get", "list"]
diff --git a/src/Altinn.Apps/KubernetesWrapper/deployment/rolebinding.yaml b/src/Altinn.Apps/KubernetesWrapper/deployment/rolebinding.yaml
new file mode 100644
index 00000000000..127cb3bf1c6
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/deployment/rolebinding.yaml
@@ -0,0 +1,13 @@
+apiVersion: rbac.authorization.k8s.io/v1
+kind: RoleBinding
+metadata:
+ name: kubernetes-read-role-binding
+ namespace: default
+roleRef:
+ apiGroup: rbac.authorization.k8s.io
+ kind: Role
+ name: kubernetes-read-role
+subjects:
+ - kind: ServiceAccount
+ name: kuberneteswrappersa
+ namespace: default
diff --git a/src/Altinn.Apps/KubernetesWrapper/deployment/serviceaccount.yaml b/src/Altinn.Apps/KubernetesWrapper/deployment/serviceaccount.yaml
new file mode 100644
index 00000000000..77f9c4f7816
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/deployment/serviceaccount.yaml
@@ -0,0 +1,6 @@
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: kuberneteswrappersa
+ namespace: default
+
diff --git a/src/Altinn.Apps/KubernetesWrapper/deployment/templates/NOTES.txt b/src/Altinn.Apps/KubernetesWrapper/deployment/templates/NOTES.txt
new file mode 100644
index 00000000000..ccfecb7ea5d
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/deployment/templates/NOTES.txt
@@ -0,0 +1,19 @@
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range .Values.ingress.hosts }}
+ http://{{ . }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "fullname" . }})
+ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
+ echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+ NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+ You can watch the status of by running 'kubectl get svc -w {{ template "fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
+ echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ echo "Visit http://127.0.0.1:8080 to use your application"
+ kubectl port-forward $POD_NAME 8080:{{ .Values.service.externalPort }}
+{{- end }}
diff --git a/src/Altinn.Apps/KubernetesWrapper/deployment/templates/_helpers.tpl b/src/Altinn.Apps/KubernetesWrapper/deployment/templates/_helpers.tpl
new file mode 100644
index 00000000000..f0d83d2edba
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/deployment/templates/_helpers.tpl
@@ -0,0 +1,16 @@
+{{/* vim: set filetype=mustache: */}}
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+*/}}
+{{- define "fullname" -}}
+{{- $name := default .Chart.Name .Values.nameOverride -}}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
diff --git a/src/Altinn.Apps/KubernetesWrapper/deployment/templates/deployment.yaml b/src/Altinn.Apps/KubernetesWrapper/deployment/templates/deployment.yaml
new file mode 100644
index 00000000000..67694d77824
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/deployment/templates/deployment.yaml
@@ -0,0 +1,39 @@
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+ name: {{ template "fullname" . }}
+ labels:
+ app: {{ template "name" . }}
+ chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ release: {{ .Release.Name }}
+ heritage: {{ .Release.Service }}
+spec:
+ replicas: {{ .Values.replicaCount }}
+ template:
+ metadata:
+ labels:
+ app: {{ template "name" . }}
+ release: {{ .Release.Name }}
+ spec:
+ {{- if .Values.image.serviceAccount}}
+ serviceAccountName: {{ .Values.image.serviceAccount }}
+ {{- end }}
+ {{- if .Values.image.pullSecrets }}
+ imagePullSecrets:
+ {{- range $secret := .Values.image.pullSecrets }}
+ - name : {{ $secret.name }}
+ {{- end }}
+ {{- end }}
+ containers:
+ - name: {{ .Chart.Name }}
+ image: "{{ required "A valid image.repository value is required!" .Values.image.repository }}:{{ .Values.image.tag }}"
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
+ {{- if .Values.image.environment}}
+ env:
+ {{- range $environment := .Values.image.environment}}
+ - name: {{ $environment.name }}
+ value: {{ quote $environment.value }}
+ {{- end }}
+ {{- end }}
+ ports:
+ - containerPort: {{ .Values.service.internalPort }}
diff --git a/src/Altinn.Apps/KubernetesWrapper/deployment/templates/ingress.yaml b/src/Altinn.Apps/KubernetesWrapper/deployment/templates/ingress.yaml
new file mode 100644
index 00000000000..55e29d8ac5c
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/deployment/templates/ingress.yaml
@@ -0,0 +1,35 @@
+{{- if .Values.ingress.enabled -}}
+{{- $serviceName := include "fullname" . -}}
+{{- $servicePort := .Values.service.externalPort -}}
+{{- $ingressPaths := .Values.ingress.paths -}}
+apiVersion: extensions/v1beta1
+kind: Ingress
+metadata:
+ name: {{ template "fullname" . }}
+ labels:
+ app: {{ template "name" . }}
+ chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ release: {{ .Release.Name }}
+ heritage: {{ .Release.Service }}
+ annotations:
+ {{- range $key, $value := .Values.ingress.annotations }}
+ {{ $key }}: {{ $value | quote }}
+ {{- end }}
+spec:
+ rules:
+ {{- range $host := .Values.ingress.hosts }}
+ - host: {{ $host }}
+ http:
+ paths:
+ {{- range $ingressPaths }}
+ - path: {{ .path | quote }}
+ backend:
+ serviceName: {{ $serviceName }}
+ servicePort: {{ $servicePort }}
+ {{- end }}
+ {{- end -}}
+ {{- if .Values.ingress.tls }}
+ tls:
+{{ toYaml .Values.ingress.tls | indent 4 }}
+ {{- end -}}
+{{- end -}}
diff --git a/src/Altinn.Apps/KubernetesWrapper/deployment/templates/service.yaml b/src/Altinn.Apps/KubernetesWrapper/deployment/templates/service.yaml
new file mode 100644
index 00000000000..f311d10a0d2
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/deployment/templates/service.yaml
@@ -0,0 +1,19 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ template "fullname" . }}
+ labels:
+ app: {{ template "name" . }}
+ chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ release: {{ .Release.Name }}
+ heritage: {{ .Release.Service }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.externalPort }}
+ targetPort: {{ .Values.service.internalPort }}
+ protocol: TCP
+ name: {{ .Values.service.name }}
+ selector:
+ app: {{ template "name" . }}
+ release: {{ .Release.Name }}
diff --git a/src/Altinn.Apps/KubernetesWrapper/deployment/values.yaml b/src/Altinn.Apps/KubernetesWrapper/deployment/values.yaml
new file mode 100644
index 00000000000..954eb59ff53
--- /dev/null
+++ b/src/Altinn.Apps/KubernetesWrapper/deployment/values.yaml
@@ -0,0 +1,31 @@
+replicaCount: 1
+
+image:
+ # Set "repository" name of your image for manual Helm install and upgrade.
+ repository: tddregistry.azurecr.io/kuberneteswrapper
+ tag: latest
+ pullPolicy: Always
+ pullSecrets:
+ # Change this to the name of your pull secret
+ - name: acr-secret
+ serviceAccount: kuberneteswrappersa
+
+service:
+ name: kuberneteswrapper
+ type: ClusterIP
+ externalPort: 80
+ # If your application is running on another port, change only the internal port.
+ internalPort: 80
+
+ingress:
+ enabled: true
+ annotations:
+ traefik.ingress.kubernetes.io/rewrite-target: /
+ paths:
+ # The first path will automatically be overwritten during deploy
+ # Additional paths needs to be configured manually
+ - path: /kuberneteswrapper
+ hosts:
+ # The first hosts entry host is configured automatically during deployment in Altinn Studio
+ # For manual deploy, or more hosts, configure hosts
+ - tdd.apps.at21.altinn.cloud
diff --git a/src/Altinn.Apps/global.json b/src/Altinn.Apps/global.json
new file mode 100644
index 00000000000..0a37afd5d2b
--- /dev/null
+++ b/src/Altinn.Apps/global.json
@@ -0,0 +1,5 @@
+{
+ "sdk": {
+ "version": "2.2.105"
+ }
+}