Exception HTTP Handler: https://github.com/charroux/st2scl/blob/main/rentalService/src/main/java/com/example/rentalService/web/CarNotFoundException.java
Change the code.
Compile the Java project:
./gradlew build
Under Linux, or
.\gradlew build
Under Windows
Build the docker image:
docker build -t myservice .
Check the image:
docker images
Start the container:
docker run -p 4000:8080 -t myservice
8080 is the port of the web service, while 4000 is the port for accessing the container. Test the web service using a web browser: http://localhost:4000 It displays hello.
Ctrl-C to stop the Web Service.
Check the containerID:
docker ps
Stop the container:
docker stop containerID
Retreive the image ID:
docker images
Tag the docker image:
docker tag imageID yourDockerHubName/imageName:version
Example: docker tag 1dsd512s0d myDockerID/myservice:1
Login to docker hub:
docker login
or
docker login http://hub.docker.com
or
docker login -u username -p password
Push the image to the docker hub:
docker push yourDockerHubName/imageName:version
Example: docker push myDockerID/myservice:1
https://github.com/charroux/lsi1/blob/main/deployment.yml
kubectl apply -f deployement.yml
The script is there: https://github.com/charroux/lsi1/blob/main/.github/workflows/action.yml
Create a new branch:
git branch newcarservice
Move to the new branch:
git checkout newcarservice
Update the code and commit changes:
git commit -a -m "newcarservice"
Push the changes to GitHub:
git push -u origin newcarservice
Create a Pull request on GitHub and follow the workflow.
Merge the branch on Github is everything is OK.
Then pull the new main version:
git checkout main
git pull origin main
If necessary delete the branch:
git branch -D newcarservice
git push origin --delete newcarservice
Start Docker Desktop
Use Minikube or Kubernetes via docker
Minikube installation: https://minikube.sigs.k8s.io/docs/start/?arch=%2Fwindows%2Fx86-64%2Fstable%2F.exe+download
Start Kubernetes minikube:
minikube start --cpus=2 --memory=5000 --driver=docker
kubectl create deployment rentalservice --image=charroux/rentalservice:1
Change the image from the Docker Hub.
Add a service:
kubeclt expose deployment rentalservice --type=LoadBalancer ```
Get the URL of the service:
minikube service rentalService --url
Test in a browser
http://127.0.0.1:51300/cars
Take care at the address
Launch the deployment:
kubectl apply -f deployment.yml
Notice the image used at line 23. You should use your onw image from the Docker Hub
Chek is the pods is running:
kubectl get pods
Get the URL of the service:
minikube service rentalService --url
Test in a browser
http://127.0.0.1:51300/cars
Take care at the address
https://istio.io/latest/docs/setup/getting-started/
Download Istio (take care at the version 1.17 here).
cd istio-1.17.0
export PATH=$PWD/bin:$PATH
istioctl install --set profile=demo -y
cd ..
Enable auto-injection of the Istio side-cars when the pods are started:
kubectl label namespace default istio-injection=enabled
Install the Istio addons (Kiali, Prometheus, Jaeger, Grafana):
kubectl apply -f samples/addons
Enable auto-injection of the Istio side-cars when the pods are started:
kubectl label namespace default istio-injection=enabled
Configure Docker so that it uses the Kubernetes cluster:
minikube docker-env
eval $(minikube -p minikube docker-env)
eval $(minikube docker-env)
Check the configuration at 54: https://github.com/charroux/lsi1/blob/main/deployment.yml
Check also where the Kubernetes service is registered in the gataway at line 72.
Then get the address of the gateway:
kubectl -n istio-system port-forward deployment/istio-ingressgateway 31380:8080
and finally test in your browser: http://localhost:31380/rentalservice/cars
Kiali is a console for Istio service mesh.
kubectl -n istio-system port-forward deployment/kiali 20001:20001
Launch the console: http://localhost:20001/
Active again carservice:
http://localhost:31380/rentalservice/cars
Then inspect the cluster in Kiali.
kubectl -n istio-system port-forward deployment/grafana 3000:3000