Coder Social home page Coder Social logo

berkanuslu / kubernetes-dotnet-webapi Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 10 KB

.NET Core 3.1 Web API Sample for Docker and Kubernetes

License: MIT License

C# 88.81% Dockerfile 11.19%
dotnet-core dotnetcore kubernetes docker webapi dotnet-framework csharp

kubernetes-dotnet-webapi's Introduction

.NET Core 3.1 Web API Sample for Docker and Kubernetes

You can create a new Web API Sample with new command of dotnet CLI.

You can show all possible options with --help parameter.

dotnet new --help

Create a folder and change directory in this folder.

mkdir kubernetesdotnetwebapi
cd kubernetesdotnetwebapi

Now you can create a new Web API project just write this command below.

dotnet new webapi

.NET CLI is created all your need for Web API project with sample controller. Then you can build and run the application on http://localhost:5000 or https://localhost:5001 addresses.

dotnet build
dotnet run

.NET Web API App on Docker

You can build an image of your application with Dockerfile in this repo. Then you can build with this command below.

docker build --rm -f "Dockerfile" -t DOCKER_HUB_USERNAME/kubernetesdotnetwebapi:latest "."

After build process, you have an image for your app. You can run with this command below with port mapping.

docker run -p 8080:80 berkanuslu/kubernetesdotnetwebapi

.NET Web API App on Kubernetes

You can deploy your docker image on Kubernetes with deploy.yaml file in this repo. Then you can create this deployment with this command below.

kubectl create -f deploy.yaml

You can see all your app logs from kubectl logs. First of all, you need the name of your pod.

kubectl get pods

This command above has a list about your Kubernetes configuration and you see your pod name. Then with logs command, you can see all your current pod's log in your terminal screen.

kubectl logs -f kubernetes-dotnet-webapi-7877ff4cf7-s49lk

Versions

.NET 3.1.200

Docker version 19.03.8, build afacb8b

kubectl v1.15.5

Happy coding! April 2020

kubernetes-dotnet-webapi's People

Watchers

 avatar

Forkers

ka2ya

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.