GithubHelp home page GithubHelp logo

demo-docker-kubernetes's Introduction

Simple Demo for Docker & Kubernetes

Prerequisites

  • Maven
  • Java
  • Docker
  • Kubernetes
  • Curl

Install and run Docker & Kubernetes locally (Linux/Windows/Mac): https://docs.docker.com/get-docker/

Run app on your OS

REST endpoints:

  • GET localhost:8080/actuator/health: health endpoint
  • GET localhost:8080/api/ping: get PONG message

Get source code, compile app and run app:

> git clone https://github.com/pmgysel/demo-docker-kubernetes.git
> cd demo-docker-kubernetes
> mvn clean install
> java -jar target/demo-docker-kubernetes-0.0.1-SNAPSHOT.jar

Test running app in second terminal:

> curl -X GET localhost:8080/api/ping

Hello world, here is demo-docker-kubernetes version 0.0.1-SNAPSHOT

Docker demo

Option 1: Create Docker image from JAR

> docker build -t demo-docker-kubernetes:0.0.1 -f Dockerfile.from.artifact .

Option 2: Create Docker image from source

> docker build -t demo-docker-kubernetes:0.0.2 -f Dockerfile.from.source .

... then run the image inside a Docker container:

> docker run -p 8080:8080 demo-docker-kubernetes:0.0.1
> curl -X GET localhost:8080/api/ping

Hello world, here is demo-docker-kubernetes version 0.0.1-SNAPSHOT

Clean up everything:

> docker ps
CONTAINER ID     IMAGE                          COMMAND                  CREATED  ....
af2b2f9d190c     demo-docker-kubernetes:0.0.1   "/bin/sh -c 'java -jā€¦"   8 seconds ...
> docker stop af2b2f9d190c

Kubernetes demo

> cd kubernetes
> kubectl apply -f deployment.yaml
> kubectl get deployments
NAME              READY   UP-TO-DATE   AVAILABLE   AGE
demo-deployment   1/1     1            1           11s
> kubectl get pods
NAME                              READY   STATUS    RESTARTS   AGE
demo-deployment-5ffc866f6-4ffsg   1/1     Running   0          31s
> kubectl apply -f service.yaml
> kubectl get services
NAME           TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)          AGE
demo-service   NodePort    10.98.86.21   <none>        8080:30001/TCP   19s
> curl -X GET http://localhost:30001/api/ping

Hello world, here is demo-docker-kubernetes version 0.0.1-SNAPSHOT

Finally, clean up running pods and services:

> kubectl delete deployment demo-deployment
> kubectl delete service demo-service

demo-docker-kubernetes's People

Watchers

 avatar

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.