Coder Social home page Coder Social logo

spring-microservices-using-spring-kubernetes's Introduction

Spring Microservice K8s Build Status

This sample application is to test spring apps service discovery with spring-cloud-kubernetes in K8 env. For other envs you can use Eureka(which is actually the default).

Build and Dockerize

mvn clean install -Ddocker

Build and Dockerize but Skip Docker Push

mvn clean install -Ddocker -Ddocker.skip.push

Endpoints

Gateway

Standard actuator endpoints

User service

  • /user/public-address

and standard actuator endpoints

Contant Us service

  • /contact-us/address
  • /contact-us/hello

and standard actuator endpoints

Spring Cloud Kubernetes requires access to the Kubernetes API in order to be able to retrieve a list of addresses for pods running for a single service. If you use Kubernetes, you should just execute the following command:

kubectl create clusterrolebinding admin --clusterrole=cluster-admin --serviceaccount=default:default

This is only done for testing. In production, it can be something like - https://cloud.spring.io/spring-cloud-kubernetes/reference/html/#service-account

Properties required for K8

The properties required to switch from Eureka to K8s are:

        - name: EUREKA_CLIENT_ENABLED
          value: "false"
        - name: SPRING_CLOUD_KUBERNETES_ENABLED
          value: "true"
        - name: SPRING_CLOUD_KUBERNETES_RELOAD_ENABLED
          value: "true"
        - name: SPRING_AUTOCONFIGURE_EXCLUDE
          value: "org.springframework.cloud.netflix.eureka.loadbalancer.LoadBalancerEurekaAutoConfiguration"

Copy data.csv to the volume created

Google Cloud

Login to your google account using gcloud and then set the project and region. Then set the cluster using following command:

gcloud container clusters get-credentials spring-k8s

Then copy the file using following command

kubectl cp data.csv <namespace>/<pod-name>:/app/data

where /app/data is the mount path of the container.

NOTE: If you refer the official Google Documentation, you will notice that in ReadWriteMany access type, PersistentVolumes that are backed by Compute Engine persistent disks are not supported. There are alternative solutions for this like Google Filestore or Network File System(NFS).

spring-microservices-using-spring-kubernetes's People

Contributors

dhananjay12 avatar

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.