dotnet new webapi -o HelloCode.API
- Run the web api using the Run and Debug section of VS Code or using "dotnet run" command
- https://localhost:5001/swagger/index.html
- To automatically oprn the swagger page while running the project, add the below JSON to launch.json:
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}/swagger",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}/swagger"
}
}
- Add a Dockerfile using the command palette of VS Code
- Verify launch.json
- Add the following json snippet to open swagger page by default
"dockerServerReadyAction": {
"uriFormat": "%s://localhost:%s/swagger"
- Run HelloCode.API using command palette or using the "docker run" command
- Inspect the container image and container using Docker Extention and Docker Desktop
- Install using Helm
$Namespace = 'ingress-basic'
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install ingress-nginx ingress-nginx/ingress-nginx --create-namespace --namespace $Namespace
-------------------Demo Starts Here----------------------------------------
- Verify external IP
kubectl --namespace ns-ingress get services -o wide -w ingress-nginx-controller
- Add ingress.yml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hellocode-ingress
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/cors-allow-methods: '*'
nginx.ingress.kubernetes.io/cors-allow-origin: '*'
nginx.ingress.kubernetes.io/cors-allow-headers: access-token,Authorization,Content-Type,Postman-Token,cache-control
spec:
rules:
- http:
paths:
- pathType: Prefix
backend:
service:
name: hellocode-svc
port:
number: 80
path: /WeatherForecast/
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
kubectl apply -f ingress.yaml