…
|
||
---|---|---|
.. | ||
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
-
Set docker hub account, for example
docker_account=your_docker_hub_account_name
-
Build
Release
locallydotnet publish -c Release
-
Build docker image
docker build -t f5webapi .
-
Test it locally
docker run -it f5webapi
-
Tag the image
docker tag f5webapi $docker_account/f5webapi
-
Push the image
docker push $docker_account/f5webapi
-
Deploy a namespace if it isn't there already:
kubectl create -f ./k8s-namespace.yml
-
Update K8s.yml with the proper image name, then deploy
kubectl create -f ./k8s.yml
-
Port forward to the pod for local testing:
// Port forwarding from 127.0.0.1:8080 => 80 kubectl port-forward <podName> 8080:80
-
Access the
WeatherForecast
endpoint:curl http://localhost:8080/weatherforecast
If the traffic went through, it will show a message like: Handling connection for 8080.