-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added form controller, configured azure dev spaces for SimpleCalculat…
…orClient for making calls to SimpleCalculator Service.
- Loading branch information
Showing
20 changed files
with
440 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using SimpleCalculatorClient.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
|
||
namespace SimpleCalculatorClient.Controllers | ||
{ | ||
[Route("api/[controller]")] | ||
public class FormController : Controller | ||
{ | ||
[HttpGet] | ||
public IActionResult Index() | ||
{ | ||
return View(); | ||
} | ||
|
||
[HttpPost] | ||
public async Task<IActionResult> Index(FormModel model) | ||
{ | ||
using (var client = new HttpClient()) | ||
{ | ||
// Call *mywebapi*, and display its response in the page | ||
var request = new HttpRequestMessage(); | ||
var uri = new Uri($"http://default.simplecalculator.z26kl7w9th.weu.azds.io/api/calculator/add?x={model.NumbOne}&y={model.NumbTwo}"); | ||
request.RequestUri = uri; | ||
if (this.Request.Headers.ContainsKey("azds-route-as")) | ||
{ | ||
// Propagate the dev space routing header | ||
request.Headers.Add("azds-route-as", this.Request.Headers["azds-route-as"] as IEnumerable<string>); | ||
} | ||
var response = await client.SendAsync(request); | ||
var content = await response.Content.ReadAsStringAsync(); | ||
ViewData["Message"] += " and " + content; | ||
} | ||
|
||
return Content($"First: {model.NumbOne}\nSecond: {model.NumbTwo}"); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,20 @@ | ||
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS base | ||
WORKDIR /app | ||
EXPOSE 80 | ||
|
||
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build | ||
WORKDIR /src | ||
COPY ["SimpleCalculatorClient/SimpleCalculatorClient.csproj", "SimpleCalculatorClient/"] | ||
|
||
RUN dotnet restore "SimpleCalculatorClient/SimpleCalculatorClient.csproj" | ||
COPY . . | ||
WORKDIR "/src/SimpleCalculatorClient" | ||
RUN dotnet build "SimpleCalculatorClient.csproj" -c Release -o /app | ||
|
||
FROM build AS publish | ||
RUN dotnet publish "SimpleCalculatorClient.csproj" -c Release -o /app | ||
|
||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /app . | ||
ENTRYPOINT ["dotnet", "SimpleCalculatorClient.dll"] |
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,17 @@ | ||
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 | ||
ARG BUILD_CONFIGURATION=Debug | ||
ENV ASPNETCORE_ENVIRONMENT=Development | ||
ENV DOTNET_USE_POLLING_FILE_WATCHER=true | ||
EXPOSE 80 | ||
|
||
WORKDIR /src | ||
COPY ["SimpleCalculatorClient/SimpleCalculatorClient.csproj", "SimpleCalculatorClient/"] | ||
|
||
RUN dotnet restore "SimpleCalculatorClient/SimpleCalculatorClient.csproj" | ||
COPY . . | ||
WORKDIR "/src/SimpleCalculatorClient" | ||
RUN dotnet build --no-restore "SimpleCalculatorClient.csproj" -c $BUILD_CONFIGURATION | ||
|
||
RUN echo "exec dotnet run --no-build --no-launch-profile -c $BUILD_CONFIGURATION --" > /entrypoint.sh | ||
|
||
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] |
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,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace SimpleCalculatorClient.Models | ||
{ | ||
public class FormModel | ||
{ | ||
public int NumbOne { get; set; } | ||
public int NumbTwo { get; set; } | ||
} | ||
} |
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,13 @@ | ||
@model SimpleCalculatorClient.Models.FormModel; | ||
@{ | ||
ViewData["Title"] = "Index"; | ||
} | ||
|
||
<form method="POST"> | ||
<label for="numbOne">First number</label> | ||
<input type="text" id="numbOne" placeholder="first number" name="numbOne" /> | ||
<br /> | ||
<label for="numbTwo">Second number</label> | ||
<input type="text" id="numbTwo" placeholder="second number" name="numbTwo" /> | ||
<input type="submit" /> | ||
</form> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,42 @@ | ||
kind: helm-release | ||
apiVersion: 1.1 | ||
build: | ||
context: .. | ||
dockerfile: Dockerfile | ||
install: | ||
chart: charts/simplecalculatorclient | ||
values: | ||
- values.dev.yaml? | ||
- secrets.dev.yaml? | ||
set: | ||
replicaCount: 1 | ||
image: | ||
repository: simplecalculatorclient | ||
tag: $(tag) | ||
pullPolicy: Never | ||
ingress: | ||
annotations: | ||
kubernetes.io/ingress.class: traefik-azds | ||
hosts: | ||
# This expands to form the service's public URL: [space.s.][rootSpace.]simplecalculatorclient.<random suffix>.<region>.azds.io | ||
# Customize the public URL by changing the 'simplecalculatorclient' text between the $(rootSpacePrefix) and $(hostSuffix) tokens | ||
# For more information see https://aka.ms/devspaces/routing | ||
- $(spacePrefix)$(rootSpacePrefix)simplecalculatorclient$(hostSuffix) | ||
configurations: | ||
develop: | ||
build: | ||
dockerfile: Dockerfile.develop | ||
useGitIgnore: true | ||
args: | ||
BUILD_CONFIGURATION: ${BUILD_CONFIGURATION:-Debug} | ||
container: | ||
sync: | ||
- "**/Pages/**" | ||
- "**/Views/**" | ||
- "**/wwwroot/**" | ||
- "!**/*.{sln,csproj}" | ||
command: [dotnet, run, --no-restore, --no-build, --no-launch-profile, -c, "${BUILD_CONFIGURATION:-Debug}"] | ||
iterate: | ||
processesToKill: [dotnet, vsdbg] | ||
buildCommands: | ||
- [dotnet, build, --no-restore, -c, "${BUILD_CONFIGURATION:-Debug}"] |
21 changes: 21 additions & 0 deletions
21
SimpleCalculatorClient/charts/simplecalculatorclient/.helmignore
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,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 |
5 changes: 5 additions & 0 deletions
5
SimpleCalculatorClient/charts/simplecalculatorclient/Chart.yaml
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,5 @@ | ||
apiVersion: v1 | ||
appVersion: "1.0" | ||
description: A Helm chart for Kubernetes | ||
name: simplecalculatorclient | ||
version: 0.1.0 |
19 changes: 19 additions & 0 deletions
19
SimpleCalculatorClient/charts/simplecalculatorclient/templates/NOTES.txt
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,19 @@ | ||
1. Get the application URL by running these commands: | ||
{{- if .Values.ingress.enabled }} | ||
{{- range .Values.ingress.hosts }} | ||
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} | ||
{{- end }} | ||
{{- else if contains "NodePort" .Values.service.type }} | ||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "simplecalculatorclient.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 "simplecalculatorclient.fullname" . }}' | ||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "simplecalculatorclient.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={{ template "simplecalculatorclient.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:80 | ||
{{- end }} |
32 changes: 32 additions & 0 deletions
32
SimpleCalculatorClient/charts/simplecalculatorclient/templates/_helpers.tpl
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,32 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "simplecalculatorclient.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 "simplecalculatorclient.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 "simplecalculatorclient.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} |
72 changes: 72 additions & 0 deletions
72
SimpleCalculatorClient/charts/simplecalculatorclient/templates/deployment.yaml
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,72 @@ | ||
apiVersion: apps/v1beta2 | ||
kind: Deployment | ||
metadata: | ||
name: {{ template "simplecalculatorclient.fullname" . }} | ||
labels: | ||
app: {{ template "simplecalculatorclient.name" . }} | ||
chart: {{ template "simplecalculatorclient.chart" . }} | ||
draft: {{ default "draft-app" .Values.draft }} | ||
release: {{ .Release.Name }} | ||
heritage: {{ .Release.Service }} | ||
spec: | ||
replicas: {{ .Values.replicaCount }} | ||
selector: | ||
matchLabels: | ||
app: {{ template "simplecalculatorclient.name" . }} | ||
release: {{ .Release.Name }} | ||
template: | ||
metadata: | ||
labels: | ||
app: {{ template "simplecalculatorclient.name" . }} | ||
draft: {{ default "draft-app" .Values.draft }} | ||
release: {{ .Release.Name }} | ||
annotations: | ||
buildID: {{ .Values.buildID }} | ||
spec: | ||
containers: | ||
- name: {{ .Chart.Name }} | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
ports: | ||
- name: http | ||
containerPort: 80 | ||
protocol: TCP | ||
{{- if .Values.probes.enabled }} | ||
livenessProbe: | ||
httpGet: | ||
path: / | ||
port: http | ||
readinessProbe: | ||
httpGet: | ||
path: / | ||
port: http | ||
{{- end }} | ||
env: | ||
{{- $root := . }} | ||
{{- range $ref, $values := .Values.secrets }} | ||
{{- range $key, $value := $values }} | ||
- name: {{ $ref }}_{{ $key }} | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ template "simplecalculatorclient.fullname" $root }}-{{ $ref | lower }} | ||
key: {{ $key }} | ||
{{- end }} | ||
{{- end }} | ||
resources: | ||
{{ toYaml .Values.resources | indent 12 }} | ||
{{- with .Values.imagePullSecrets }} | ||
imagePullSecrets: | ||
{{ toYaml . | indent 8 }} | ||
{{- end }} | ||
{{- with .Values.nodeSelector }} | ||
nodeSelector: | ||
{{ toYaml . | indent 8 }} | ||
{{- end }} | ||
{{- with .Values.affinity }} | ||
affinity: | ||
{{ toYaml . | indent 8 }} | ||
{{- end }} | ||
{{- with .Values.tolerations }} | ||
tolerations: | ||
{{ toYaml . | indent 8 }} | ||
{{- end }} |
Oops, something went wrong.