Git Product home page Git Product logo

k8s-demo's Introduction

KinD: Kubernetes cluster in Docker

https://kubernetes.io/blog/2020/05/21/wsl-docker-kubernetes-on-the-windows-desktop/
https://spring.io/guides/gs/spring-boot-kubernetes/
https://spring.io/guides/gs/spring-boot-docker/
https://spring.io/guides/topicals/spring-boot-docker/
https://spring.io/blog/2020/06/18/what-s-new-in-spring-boot-2-3

  1. Install KinD
# Download the latest version of KinD
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.8.1/kind-linux-amd64
# Make the binary executable
chmod +x ./kind
# Move the binary to your executable path
sudo mv ./kind /usr/local/bin/
  1. Create 3-node k8s-cluster
kind create cluster --name wslkindmultinodes --config k8s/kind-3nodes.yaml
  1. Build the demo app
mvn package -Dmaven.test.skip=true
  1. Build and push your docker image

    • Build the image with Dockerfile
    docker build -t <you docker-hub profile>/k8s-demo:dockerfile .    
    mvn spring-boot:build-image -Dspring-boot.build-image.imageName=<you docker-hub profile>/k8s-demo:buildpack
    • Push the image
    docker push <you docker-hub profile>/k8s-demo:<dockerfile or buildpack>
  2. Deploy your app to k8s cluster

    • Create deployment.yml
    kubectl create deployment k8s-demo --image=<you docker-hub profile>/k8s-demo:<dockerfile or buildpack> --dry-run -o=yaml > k8s/deployment.yaml &&
    echo --- >> k8s/deployment.yaml &&
    kubectl create service clusterip k8s-demo --tcp=8080:8080 --dry-run -o=yaml >> k8s/deployment.yaml    
    • Deploy
    kubectl apply -f k8s/deployment.yaml
    • Test deployment (wait for status = Running of pod/k8s-demo-*)
    kubectl get all
    • Port forward to your application
    kubectl port-forward svc/k8s-demo 8080:8080 
    • Test your app (in another terminal)
    curl localhost:8080/actuator/health
  3. Remove the k8s-cluster

kind delete cluster --name $(kind get clusters)

k8s-demo's People

Contributors

cepr0 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.