From f60db8352f1bedb4648f7f0045b1dfd83c53b7ae Mon Sep 17 00:00:00 2001 From: Mauro Bernal Date: Fri, 10 May 2024 21:14:40 -0300 Subject: [PATCH] feat:MB: add kub files add deployment and add service.yaml --- .kube/api.yaml | 30 ++++++++++++++++++++++++++ .kube/service.yaml | 12 +++++++++++ install.sh | 10 ++++----- src/Web/Endpoints/Test.cs | 23 ++++++++++++++++++++ src/Web/Properties/launchSettings.json | 13 ++++++++++- src/Web/wwwroot/api/specification.json | 13 +++++++++++ 6 files changed, 94 insertions(+), 7 deletions(-) create mode 100644 .kube/api.yaml create mode 100644 .kube/service.yaml create mode 100644 src/Web/Endpoints/Test.cs diff --git a/.kube/api.yaml b/.kube/api.yaml new file mode 100644 index 0000000..5a733a5 --- /dev/null +++ b/.kube/api.yaml @@ -0,0 +1,30 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: deploy-caapi + namespace: maurobernal +spec: + selector: + matchLabels: + app: ca-caapi + replicas: 1 + template: + metadata: + labels: + app: ca-caapi + spec: + imagePullSecrets: + - name: regcred + containers: + - name: container-caapi + image: maurobernal/ca:202405101923 + imagePullPolicy: Always + resources: + limits: + memory: 500Mi + cpu: 500m + requests: + cpu: 100m + memory: 200Mi + ports: + - containerPort: 443 \ No newline at end of file diff --git a/.kube/service.yaml b/.kube/service.yaml new file mode 100644 index 0000000..c2d44c5 --- /dev/null +++ b/.kube/service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: service-ca + namespace: maurobernal +spec: + ports: + - port: 443 + targetPort: 443 + selector: + app: ca-caapi + type: LoadBalancer \ No newline at end of file diff --git a/install.sh b/install.sh index 6daf194..05c9ec7 100644 --- a/install.sh +++ b/install.sh @@ -4,10 +4,8 @@ id=$(date +'%Y%m%d%H%M') imagename=$image:$id echo "========== Build image:$imagename==========" docker.exe build -t $imagename . -echo "========== Creating container image:$imagename==========" -docker.exe run -p8443:443 -p8080:80 -d $imagename - - -#docker.exe push $imagename +#echo "========== Creating container image:$imagename==========" +#docker.exe run -p8443:443 -p8080:80 -d $imagename +docker.exe push $imagename #echo "========== Deploy image:$imagename==========" - +kubectl.exe set image deployment/deploy-caapi container-caapi=$imagename -n maurobernal diff --git a/src/Web/Endpoints/Test.cs b/src/Web/Endpoints/Test.cs new file mode 100644 index 0000000..37b3be5 --- /dev/null +++ b/src/Web/Endpoints/Test.cs @@ -0,0 +1,23 @@ +using ca.Application.CQRS.Skills.Queries.GetSkillQueries; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http.HttpResults; + +namespace ca.Web.Endpoints; + +public class Test : EndpointGroupBase +{ + + public override void Map(WebApplication app) + { + app.MapGroup(this) + .MapGet(GetHostName); + } + + [AllowAnonymous] + public IResult GetHostName() + => Results.Ok(System.Net.Dns.GetHostName()); + + + + +} diff --git a/src/Web/Properties/launchSettings.json b/src/Web/Properties/launchSettings.json index 6ffb261..0a91662 100644 --- a/src/Web/Properties/launchSettings.json +++ b/src/Web/Properties/launchSettings.json @@ -22,6 +22,17 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } + }, + "Container (Dockerfile)": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "environmentVariables": { + "ASPNETCORE_HTTPS_PORTS": "8081", + "ASPNETCORE_HTTP_PORTS": "8080" + }, + "publishAllPorts": true, + "useSSL": true } }, "iisSettings": { @@ -32,4 +43,4 @@ "sslPort": 44312 } } -} +} \ No newline at end of file diff --git a/src/Web/wwwroot/api/specification.json b/src/Web/wwwroot/api/specification.json index f3a9b93..5f67dda 100644 --- a/src/Web/wwwroot/api/specification.json +++ b/src/Web/wwwroot/api/specification.json @@ -357,6 +357,19 @@ ] } }, + "/api/Test": { + "get": { + "tags": [ + "Test" + ], + "operationId": "GetHostName", + "responses": { + "200": { + "description": "" + } + } + } + }, "/api/TodoItems": { "get": { "tags": [