This repository was archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 301
Existing windows container #134
Merged
philon-msft
merged 1 commit into
Azure:master
from
Greenie0506:existingWindowsContainer
Jul 22, 2019
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
20 changes: 20 additions & 0 deletions
20
samples/existingWindowsBackend/mywebapi-windows/.dockerignore
This file contains hidden or 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,20 @@ | ||
| **/.dockerignore | ||
| **/.env | ||
| **/.git | ||
| **/.gitignore | ||
| **/.vs | ||
| **/.vscode | ||
| **/*.*proj.user | ||
| **/azds.yaml | ||
| **/charts | ||
| **/bin | ||
| **/obj | ||
| **/Dockerfile | ||
| **/Dockerfile.develop | ||
| **/docker-compose.yml | ||
| **/docker-compose.*.yml | ||
| **/*.dbmdl | ||
| **/*.jfm | ||
| **/secrets.dev.yaml | ||
| **/values.dev.yaml | ||
| **/.toolstarget |
44 changes: 44 additions & 0 deletions
44
samples/existingWindowsBackend/mywebapi-windows/Controllers/ValuesController.cs
This file contains hidden or 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,44 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.AspNetCore.Mvc; | ||
|
|
||
| namespace mywebapi.Controllers | ||
| { | ||
| [Route("api/[controller]")] | ||
| public class ValuesController : Controller | ||
| { | ||
| // GET api/values | ||
| [HttpGet] | ||
| public IEnumerable<string> Get() | ||
| { | ||
| return new string[] { System.Runtime.InteropServices.RuntimeInformation.OSDescription }; | ||
| } | ||
|
|
||
| // GET api/values/5 | ||
| [HttpGet("{id}")] | ||
| public string Get(int id) | ||
| { | ||
| return System.Runtime.InteropServices.RuntimeInformation.OSDescription; | ||
| } | ||
|
|
||
| // POST api/values | ||
| [HttpPost] | ||
| public void Post([FromBody]string value) | ||
| { | ||
| } | ||
|
|
||
| // PUT api/values/5 | ||
| [HttpPut("{id}")] | ||
| public void Put(int id, [FromBody]string value) | ||
| { | ||
| } | ||
|
|
||
| // DELETE api/values/5 | ||
| [HttpDelete("{id}")] | ||
| public void Delete(int id) | ||
| { | ||
| } | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
samples/existingWindowsBackend/mywebapi-windows/Dockerfile
This file contains hidden or 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,22 @@ | ||
| #Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed. | ||
| #For more information, please see https://aka.ms/containercompat | ||
|
|
||
| FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-nanoserver-1809 AS base | ||
| WORKDIR /app | ||
| EXPOSE 80 | ||
|
|
||
| FROM mcr.microsoft.com/dotnet/core/sdk:2.1-nanoserver-1809 AS build | ||
| WORKDIR /src | ||
| COPY ["mywebapi.csproj", ""] | ||
| RUN dotnet restore "mywebapi.csproj" | ||
| COPY . . | ||
| WORKDIR "/src/" | ||
| RUN dotnet build "mywebapi.csproj" -c Release -o /app | ||
|
|
||
| FROM build AS publish | ||
| RUN dotnet publish "mywebapi.csproj" -c Release -o /app | ||
|
|
||
| FROM base AS final | ||
| WORKDIR /app | ||
| COPY --from=publish /app . | ||
| ENTRYPOINT ["dotnet", "mywebapi.dll"] |
25 changes: 25 additions & 0 deletions
25
samples/existingWindowsBackend/mywebapi-windows/Program.cs
This file contains hidden or 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,25 @@ | ||
| 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; | ||
|
|
||
| namespace mywebapi | ||
| { | ||
| public class Program | ||
| { | ||
| public static void Main(string[] args) | ||
| { | ||
| BuildWebHost(args).Run(); | ||
| } | ||
|
|
||
| public static IWebHost BuildWebHost(string[] args) => | ||
| WebHost.CreateDefaultBuilder(args) | ||
| .UseStartup<Startup>() | ||
| .Build(); | ||
| } | ||
| } |
36 changes: 36 additions & 0 deletions
36
samples/existingWindowsBackend/mywebapi-windows/Properties/launchSettings.json
This file contains hidden or 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,36 @@ | ||
| { | ||
| "iisSettings": { | ||
| "windowsAuthentication": false, | ||
| "anonymousAuthentication": true, | ||
| "iisExpress": { | ||
| "applicationUrl": "http://localhost:62732/", | ||
| "sslPort": 0 | ||
| } | ||
| }, | ||
| "profiles": { | ||
| "IIS Express": { | ||
| "commandName": "IISExpress", | ||
| "launchBrowser": true, | ||
| "launchUrl": "api/values", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| } | ||
| }, | ||
| "mywebapi": { | ||
| "commandName": "Project", | ||
| "launchBrowser": true, | ||
| "launchUrl": "api/values", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| }, | ||
| "applicationUrl": "http://localhost:62733/" | ||
| }, | ||
| "Docker": { | ||
| "commandName": "Docker", | ||
| "launchBrowser": true, | ||
| "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/api/values", | ||
| "environmentVariables": {}, | ||
| "httpPort": 62733 | ||
| } | ||
| } | ||
| } |
40 changes: 40 additions & 0 deletions
40
samples/existingWindowsBackend/mywebapi-windows/Startup.cs
This file contains hidden or 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,40 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.AspNetCore.Builder; | ||
| using Microsoft.AspNetCore.Hosting; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.Extensions.Logging; | ||
| using Microsoft.Extensions.Options; | ||
|
|
||
| namespace mywebapi | ||
| { | ||
| public class Startup | ||
| { | ||
| public Startup(IConfiguration configuration) | ||
| { | ||
| Configuration = configuration; | ||
| } | ||
|
|
||
| public IConfiguration Configuration { get; } | ||
|
|
||
| // This method gets called by the runtime. Use this method to add services to the container. | ||
| public void ConfigureServices(IServiceCollection services) | ||
| { | ||
| services.AddMvc(); | ||
| } | ||
|
|
||
| // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | ||
| public void Configure(IApplicationBuilder app, IHostingEnvironment env) | ||
| { | ||
| if (env.IsDevelopment()) | ||
| { | ||
| app.UseDeveloperExceptionPage(); | ||
| } | ||
|
|
||
| app.UseMvc(); | ||
| } | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
samples/existingWindowsBackend/mywebapi-windows/appsettings.Development.json
This file contains hidden or 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,10 @@ | ||
| { | ||
| "Logging": { | ||
| "IncludeScopes": false, | ||
| "LogLevel": { | ||
| "Default": "Debug", | ||
| "System": "Information", | ||
| "Microsoft": "Information" | ||
| } | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
samples/existingWindowsBackend/mywebapi-windows/appsettings.json
This file contains hidden or 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,15 @@ | ||
| { | ||
| "Logging": { | ||
| "IncludeScopes": false, | ||
| "Debug": { | ||
| "LogLevel": { | ||
| "Default": "Warning" | ||
| } | ||
| }, | ||
| "Console": { | ||
| "LogLevel": { | ||
| "Default": "Warning" | ||
| } | ||
| } | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
samples/existingWindowsBackend/mywebapi-windows/charts/.helmignore
This file contains hidden or 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,22 @@ | ||
| # 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 | ||
| .vscode/ |
5 changes: 5 additions & 0 deletions
5
samples/existingWindowsBackend/mywebapi-windows/charts/Chart.yaml
This file contains hidden or 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,5 @@ | ||
| apiVersion: v1 | ||
| appVersion: "1.0" | ||
| description: A Helm chart for a Windows container backend API | ||
| name: mywebapi | ||
| version: 0.1.0 |
21 changes: 21 additions & 0 deletions
21
samples/existingWindowsBackend/mywebapi-windows/charts/templates/NOTES.txt
This file contains hidden or 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,21 @@ | ||
| 1. Get the application URL by running these commands: | ||
| {{- if .Values.ingress.enabled }} | ||
| {{- range $host := .Values.ingress.hosts }} | ||
| {{- range .paths }} | ||
| http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- else if contains "NodePort" .Values.service.type }} | ||
| export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "mywebapi.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 --namespace {{ .Release.Namespace }} svc -w {{ include "mywebapi.fullname" . }}' | ||
| export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "mywebapi.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') | ||
| echo http://$SERVICE_IP:{{ .Values.service.port }} | ||
| {{- else if contains "ClusterIP" .Values.service.type }} | ||
| export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "mywebapi.name" . }},app.kubernetes.io/instance={{ .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:80 | ||
| {{- end }} | ||
32 changes: 32 additions & 0 deletions
32
samples/existingWindowsBackend/mywebapi-windows/charts/templates/_helpers.tpl
This file contains hidden or 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,32 @@ | ||
| {{/* vim: set filetype=mustache: */}} | ||
| {{/* | ||
| Expand the name of the chart. | ||
| */}} | ||
| {{- define "mywebapi.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). | ||
| If release name contains chart name it will be used as a full name. | ||
| */}} | ||
| {{- define "mywebapi.fullname" -}} | ||
| {{- if .Values.fullnameOverride -}} | ||
| {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} | ||
| {{- else -}} | ||
| {{- $name := default .Chart.Name .Values.nameOverride -}} | ||
| {{- if contains $name .Release.Name -}} | ||
| {{- .Release.Name | trunc 63 | trimSuffix "-" -}} | ||
| {{- else -}} | ||
| {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| Create chart name and version as used by the chart label. | ||
| */}} | ||
| {{- define "mywebapi.chart" -}} | ||
| {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} | ||
| {{- end -}} |
57 changes: 57 additions & 0 deletions
57
samples/existingWindowsBackend/mywebapi-windows/charts/templates/deployment.yaml
This file contains hidden or 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,57 @@ | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: {{ include "mywebapi.fullname" . }} | ||
| labels: | ||
| app.kubernetes.io/name: {{ include "mywebapi.name" . }} | ||
| helm.sh/chart: {{ include "mywebapi.chart" . }} | ||
| app.kubernetes.io/instance: {{ .Release.Name }} | ||
| app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
| spec: | ||
| replicas: {{ .Values.replicaCount }} | ||
| selector: | ||
| matchLabels: | ||
| app.kubernetes.io/name: {{ include "mywebapi.name" . }} | ||
| app.kubernetes.io/instance: {{ .Release.Name }} | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app.kubernetes.io/name: {{ include "mywebapi.name" . }} | ||
| app.kubernetes.io/instance: {{ .Release.Name }} | ||
| spec: | ||
| nodeSelector: | ||
| "beta.kubernetes.io/os": windows | ||
| tolerations: | ||
| - key: "sku" | ||
| operator: "Equal" | ||
| value: "win-node" | ||
| containers: | ||
| - name: {{ .Chart.Name }} | ||
| image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" | ||
| imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
| ports: | ||
| - name: http | ||
| containerPort: 80 | ||
| protocol: TCP | ||
| livenessProbe: | ||
| httpGet: | ||
| path: /api/values | ||
| port: http | ||
| readinessProbe: | ||
| httpGet: | ||
| path: /api/values | ||
| port: http | ||
| resources: | ||
| {{- toYaml .Values.resources | nindent 12 }} | ||
| {{- with .Values.nodeSelector }} | ||
| nodeSelector: | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| {{- with .Values.affinity }} | ||
| affinity: | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| {{- with .Values.tolerations }} | ||
| tolerations: | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.