Skip to content

cbezmen/microservices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

actions codecov

Spring Kubernetes Example

Example Spring cloud kubernetes project. Run in local&kubernetes environment.

Compile Projects

You can compile projects via:

Local Development:

You need docker up and running in local environment.

  1. Before Running apps from you favorite IDE apply configs in local kube env
    $ bash build.sh apply-config-k8
    You can remove config via
    $ bash build.sh remove-config-k8
  2. Check applications on local environment
    1. Address Endpoint
      $ curl http://localhost:8081/address/1
    2. User Endpoint which calls address domain
      $ curl http://localhost:8080/users/1
    3. Get environment configs
      $ curl http://localhost:8080/config

Kubernetes:

Please check ingress for kubernetes environment. Check Adding Ingress

  1. Compile project and build docker images
    $ bash build.sh compile
  2. Start Kubernetes deployments, services and ingress
    $ bash build.sh start-k8
  3. Scale Kubernetes deployments
    $ bash build.sh start-k8 scale=2
  4. Stop Kubernetes deployments, services and ingress
    $ bash build.sh stop-k8
  5. Check applications on kubernetes
    1. Address Endpoint
      $ curl http://localhost:31001/address/1
    2. User Endpoint which calls address domain
      $ curl http://localhost:31000/users/1
    3. Get environment configs
      $ curl http://localhost:31000/config
  6. Access via Ingress
    1. Address Endpoint
      $ curl http://localhost/address-api/address/1
    2. User Endpoint which calls address domain
      $ curl http://localhost/user-api/users/1
    3. Get environment configs
      $ curl http://localhost/user-api/config
  7. Update Configuration
    1. Update configuration file in user-docker config and refresh actuator via endpoint.
    $ curl -X POST http://localhost/user-api/actuator/refresh

Add Ingress

Please read documentation for adding ingress if you are not using mac https://kubernetes.github.io/ingress-nginx/deploy/#docker-for-mac

This command add ingress to your docker desktop kubernetes.

$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.46.0/deploy/static/provider/cloud/deploy.yaml 

Cli Versions

Cli Version
docker 20.10.5
docker desktop kubernetes v1.19.7
mvn 3.8.1

Deadline gif