ApplicationInsights-Kubernetes/dev/F5WebApi
..
Controllers
Properties
.gitignore
F5WebApi.csproj
Program.cs
Readme.md
WeatherForecast.cs
appsettings.Development.json
appsettings.json
dockerfile
k8s-namespace.yml
k8s.yml

Readme.md

How to deploy to K8s environment

Build docker image

  1. Set docker hub account, for example

    docker_account=your_docker_hub_account_name
    
  2. Build Release locally

    dotnet publish -c Release
    
  3. Build docker image

    docker build -t f5webapi .
    
  4. Test it locally

    docker run -it f5webapi
    
  5. Tag the image

    docker tag f5webapi $docker_account/f5webapi
    
  6. Push the image

    docker push $docker_account/f5webapi
    
  7. Deploy a namespace if it isn't there already:

    kubectl create -f ./k8s-namespace.yml
    
  8. Update K8s.yml with the proper image name, then deploy

    kubectl create -f ./k8s.yml
    
  9. Port forward to the pod for local testing:

    // Port forwarding from 127.0.0.1:8080 => 80
    kubectl port-forward <podName> 8080:80
    
  10. Access the WeatherForecast endpoint:

    curl http://localhost:8080/weatherforecast
    

    If the traffic went through, it will show a message like: Handling connection for 8080.