Code Monkey home page Code Monkey logo

k8s-spring-boot's Introduction

Microservices

Spring Boot Microservices labs on K8s

  1. Install Docker Desktop and enable kubernetes service

Note : For new versions of Docker Desktop, run the below command

Spring Cloud Kubernetes requires access to Kubernetes API in order to be able to retrieve a list of addresses of 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

  1. execute the below steps to run the applications on K8s
    kubectl create deployment simple-rest-api --image=jbossramana/microservices:simple
    kubectl expose deployment simple-rest-api --type=LoadBalancer --port=8080
    kubectl create deployment other-rest-api --image=jbossramana/microservices:other
    kubectl expose deployment other-rest-api --type=LoadBalancer --port=8081
  • Take a replication controller, service or pod and expose it as a new Kubernetes Service
  1. Test the appliction url's

http://localhost:8080/simple
http://localhost:8081/other [this service calls simple service using Ribbon Client and K8s service registry]

  1. Explain K8s commands

kubectl explain deployment(s)
kubectl explain pod(s)
kubectl explain service(s)

  1. K8s commands to get deployment, service and pods information :

kubectl get pod(s)
kubectl get service(s)
kubectl get deployment(s) kubectl get event(s)
kubectl get replicaset(s)

  1. To edit the deployment kubectl edit deployment simple-rest-api #minReadySeconds: 15

  2. K8s commands to delete the deployment and services
    kubectl delete service other-rest-api
    kubectl delete deployment other-rest-api

  3. To scale the application
    kubectl scale deployment simple-rest-api --replicas=3

To autoscale: kubectl autoscale deployment simple-rest-api --max=5 --cpu-percent=50

  1. Finding a Pod’s Cluster IP kubectl get pod -o wide

  2. Finding a Service’s IP kubectl get service --all-namespaces

  3. Other useful K8s commands

kubectl explain pods
kubectl describe pod simple-rest-api-678ddff668-d9pmt
kubectl get componentstatuses
kubectl get all
kubectl get all -o wide
kubectl rollout history deployment simple-rest-api
kubectl logs simple-rest-api-678ddff668-d9pmt
kubectl delete all -l app=hello-world-rest-api
kubectl delete all -l app=simple-rest-api

Steps to install Docker in windows 10 professional:

  1. Enable virtualization @ BIOS
  2. In windows -> Advanced settings -> Advanced -> Performance -> Data Execution Prevention -> Turn on DEP for all programs and sevices except those i select
  3. uncheck Hyper-V
  4. uncheck Windows Hypervisor Platform
  5. uncheck Virtual Machine Platform
  6. uninstall vmware
  7. restart the server
  8. enable Hyper-V
  9. restart the server
  10. Install docker desktop

Steps to enable K8s and dashboard

  1. right click -> docker-desktop
  2. select settings
  3. kubernetes -> select all options

Verify the Kubectl

kubectl version

Setting up Kubernetes Dashboard

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml

We can access Dashboard using the kubectl command-line tool by running the following command:

kubectl proxy Starting to serve on 127.0.0.1:8001

using curl

curl http://localhost:8001/api

access from browser

Go to http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/ on Browser

Run the below command to set token:

kubectl apply -f dashboard-adminuser.yml
kubectl apply -f admin-role-binding.yml

To get the token

kubectl -n kube-system describe secret
$(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')

Copy the data -> token In the browser => select token option -> paste the above token

k8s-spring-boot's People

Contributors

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