Build Customer Spring Boot
If you want to build Customer from the Spring Boot sources type the following commands
cd customer/java/springboot/
mvn clean package -DskipTests
docker build -t example/customer .
docker images | grep customer
cd ../../..
To deploy to Kubernetes use:
kubectl apply -f <(istioctl kube-inject -f customer/kubernetes/Deployment_jvm.yml) -n tutorial
kubectl create -f customer/kubernetes/Service.yml -n tutorial
Build Customer
If you want to build Customer from the sources type the following commands
The tag v1.1 at the end of the image name matters.
|
eval $(minikube docker-env -p istio)
cd customer/java/quarkus
mvn clean package -DskipTests -Pnative -Dquarkus.native.container-build=true
docker build -t quay.io/rhdevelopers/istio-tutorial-customer:v1.1 .
docker images | grep customer
cd ../../..
To deploy to Kubernetes use:
kubectl apply -f <(istioctl kube-inject -f customer/kubernetes/Deployment.yml) -n tutorial
kubectl create -f customer/kubernetes/Service.yml -n tutorial
Build Preference Spring Boot
If you want to build Preference from the sources type the following commands
eval $(minikube docker-env -p istio)
cd preference/java/springboot/
mvn clean package -DskipTests
docker build -t example/preference:v1 .
docker images | grep preference
cd ../../..
Then to deploy to Kubernetes use:
kubectl apply -f <(istioctl kube-inject -f preference/kubernetes/Deployment_jvm.yml) -n tutorial
kubectl create -f preference/kubernetes/Service.yml -n tutorial
Build Preference
If you want to build Preference from the sources type the following commands
The tag v1.1 at the end of the image name matters.
|
eval $(minikube docker-env -p istio)
cd preference/java/quarkus
mvn clean package -DskipTests -Pnative -Dquarkus.native.container-build=true
docker build -t quay.io/rhdevelopers/istio-tutorial-preference:v1.1 .
docker images | grep preference
cd ../../..
To deploy to Kubernetes use:
kubectl apply -f <(istioctl kube-inject -f preference/kubernetes/Deployment.yml) -n tutorial
kubectl create -f preference/kubernetes/Service.yml -n tutorial
Build Recommendation Spring Boot
It is not necessary to build the service as they are already built and published in Quay public Docker registry so you can deploy to Kubernetes directly.
eval $(minikube docker-env -p istio)
cd recommendation/java/springboot/
mvn clean package -DskipTests
docker build -t example/recommendation:v1 .
docker images | grep recommendation
cd ../../..
Then to deploy to Kubernetes use:
kubectl apply -f <(istioctl kube-inject -f recommendation/kubernetes/Deployment_jvm.yml) -n tutorial
kubectl create -f recommendation/kubernetes/Service.yml -n tutorial
kubectl get pods -w -n tutorial
Build Recommendation
It is not necessary to build the service as they are already built and published in Quay public Docker registry so you can deploy to Kubernetes directly.
The tag v1.1 at the end of the image name matters. We will be creating a v2 version of recommendation later in this tutorial. Having both a v1 and v2 version of the recommendation code will allow us to exercise some interesting aspects of Istio’s capabilities.
|
eval $(minikube docker-env -p istio)
cd recommendation/java/quarkus
mvn clean package -DskipTests -Pnative -Dquarkus.native.container-build=true
docker build -t quay.io/rhdevelopers/istio-tutorial-recommendation:v1.1 .
docker images | grep recommendation
cd ../../..
To deploy to Kubernetes use:
kubectl apply -f <(istioctl kube-inject -f recommendation/kubernetes/Deployment.yml) -n tutorial
kubectl create -f recommendation/kubernetes/Service.yml -n tutorial
kubectl get pods -w -n tutorial
Create recommendation:v2 Spring Boot
We can experiment with Istio controlling traffic by making a change to RecommendationResource.java like the following and creating a "v2" docker image.
private static final String RESPONSE_STRING_FORMAT = "recommendation v2 from '%s': %d\n";
eval $(minikube docker-env -p istio)
cd recommendation/java/springboot/
mvn clean package -DskipTests
docker build -t example/recommendation:v2 .
docker images | grep recommendation
cd ../../..
The "v2" tag during the Docker build is significant.
There is also a second Deployment-v2_jvm.yml file to deploy this second version.
To deploy to Kubernetes use:
kubectl apply -f <(istioctl kube-inject -f recommendation/kubernetes/Deployment-v2_jvm.yml) -n tutorial
kubectl get pods -w -n tutorial
Create recommendation:v2
We can experiment with Istio controlling traffic by making a change to RecommendationResource.java like the following and creating a "v2" docker image.
private static final String RESPONSE_STRING_FORMAT = "recommendation v2 from '%s': %d\n";
The "v2" tag during the Docker build is significant.
There is also a second Deployment-v2.yml file to label things correctly
eval $(minikube docker-env -p istio)
cd recommendation/java/quarkus
mvn clean package -DskipTests -Pnative -Dquarkus.native.container-build=true
docker build -t quay.io/rhdevelopers/istio-tutorial-recommendation:v2.1 .
docker images | grep recommendation
quay.io/rhdevelopers/istio-tutorial-recommendation v2 46d2aa9d46c4 3 seconds ago 454MB
quay.io/rhdevelopers/istio-tutorial-recommendation v1 5db0e5dee4f6 About an hour ago 454MB
cd ../../..
To deploy to Kubernetes use:
kubectl apply -f <(istioctl kube-inject -f recommendation/kubernetes/Deployment-v2.yml) -n tutorial
Modify recommendation:v2 Spring Boot to have timeout
First, introduce some wait time in recommendation v2 by uncommenting the line that calls the timeout() method. Update RecommendationResource.java making it a slow performer with a 3 second delay.
@GET
public Response recommendations() {
count++;
logger.debug(String.format("recommendation request from %s: %d", HOSTNAME, count));
timeout();
logger.debug("recommendation service ready to return");
if (misbehave) {
return doMisbehavior();
}
return Response.ok(String.format(RESPONSE_STRING_FORMAT, HOSTNAME, count)).build();
}
Rebuild and redeploy
eval $(minikube docker-env -p istio)
cd recommendation/java/springboot/
mvn clean package -DskipTests
docker build -t example/recommendation:v2 .
docker images | grep recommendation
kubectl delete pod --force --grace-period=0 -l app=recommendation,version=v2 -n tutorial
cd ../../..
Modify recommendation:v2 to have timeout
First, introduce some wait time in recommendation v2 by uncommenting the line that calls the timeout() method. Update RecommendationResource.java making it a slow performer with a 3 second delay.
@GET
public Response recommendations() {
count++;
logger.debug(String.format("recommendation request from %s: %d", HOSTNAME, count));
timeout();
logger.debug("recommendation service ready to return");
if (misbehave) {
return doMisbehavior();
}
return Response.ok(String.format(RESPONSE_STRING_FORMAT, HOSTNAME, count)).build();
}
Rebuild and redeploy
cd recommendation/java/quarkus
mvn clean package -DskipTests -Pnative -Dquarkus.native.container-build=true
eval $(minikube docker-env -p istio)
docker build -t quay.io/rhdevelopers/istio-tutorial-recommendation:v2.1-timeout .
docker images | grep recommendation
kubectl delete pod --force --grace-period=0 -l app=recommendation,version=v2 -n tutorial
cd ../../..
Modify recommendation:v2 Spring Boot to remove timeout
First, introduce some wait time in recommendation v2 by uncommenting the line that calls the timeout() method. Update RecommendationResource.java making it a slow performer with a 3 second delay.
@GET
public Response recommendations() {
count++;
logger.debug(String.format("recommendation request from %s: %d", HOSTNAME, count));
// timeout();
logger.debug("recommendation service ready to return");
if (misbehave) {
return doMisbehavior();
}
return Response.ok(String.format(RESPONSE_STRING_FORMAT, HOSTNAME, count)).build();
}
Rebuild and redeploy
eval $(minikube docker-env -p istio)
cd recommendation/java/springboot/
mvn clean package -DskipTests
docker build -t example/recommendation:v2 .
docker images | grep recommendation
kubectl delete pod --force --grace-period=0 -l app=recommendation,version=v2 -n tutorial
cd ../../..
Modify recommendation:v2 to remove timeout
First, let’s comment the timeout() method again on recommendation v2.
@GET
public Response recommendations() {
count++;
logger.debug(String.format("recommendation request from %s: %d", HOSTNAME, count));
// timeout();
logger.debug("recommendation service ready to return");
if (misbehave) {
return doMisbehavior();
}
return Response.ok(String.format(RESPONSE_STRING_FORMAT, HOSTNAME, count)).build();
}
And rebuild and redeploy the service again:
cd recommendation/java/quarkus
mvn clean package -DskipTests -Pnative -Dquarkus.native.container-build=true
eval $(minikube docker-env -p istio)
docker build -t quay.io/rhdevelopers/istio-tutorial-recommendation:v2.1 .
docker images | grep recommendation
kubectl delete pod --force --grace-period=0 -l app=recommendation,version=v2 -n tutorial
cd ../../..
Create recommendation:v3 Spring Boot
We can experiment with Egress service entry by making two changes to RecommendationResource.java like the following and creating a "v3" docker image.
Change the default output to make a call to http://worldclockapi.com/api/json/cet/now.
From:
return Response.ok(String.format(RESPONSE_STRING_FORMAT, HOSTNAME, count)).build();
// return Response.ok(String.format(RESPONSE_STRING_NOW_FORMAT, getNow(), HOSTNAME, count)).build();
To:
// return Response.ok(String.format(RESPONSE_STRING_FORMAT, HOSTNAME, count)).build();
return Response.ok(String.format(RESPONSE_STRING_NOW_FORMAT, getNow(), HOSTNAME, count)).build();
The "v3" tag during the Docker build is significant.
eval $(minikube docker-env -p istio)
cd recommendation/java/springboot/
mvn clean package -DskipTests
docker build -t example/recommendation:v3 .
docker images | grep recommendation
cd ../../..
There is also a third Deployment-v3_jvm.yml file to deploy this second version.
kubectl apply -f <(istioctl kube-inject -f link:{github-repo}/{recommendation-repo}/kubernetes/Deployment-v3_jvm.yml[{recommendation-repo}/kubernetes/Deployment-v3_jvm.yml]) -n tutorial
Create recommendation:v3
We can experiment with Egress service entry by making two changes to RecommendationResource.java like the following and creating a "v3" docker image.
Change the default output to make a call to http://worldclockapi.com/api/json/cet/now.
From:
return Response.ok(String.format(RESPONSE_STRING_FORMAT, HOSTNAME, count)).build();
// return Response.ok(String.format(RESPONSE_STRING_NOW_FORMAT, getNow(), HOSTNAME, count)).build();
To:
// return Response.ok(String.format(RESPONSE_STRING_FORMAT, HOSTNAME, count)).build();
return Response.ok(String.format(RESPONSE_STRING_NOW_FORMAT, getNow(), HOSTNAME, count)).build();
The "v3" tag during the Docker build is significant.
cd recommendation/java/quarkus
mvn clean package -DskipTests -Pnative -Dquarkus.native.container-build=true
eval $(minikube docker-env -p istio)
docker build -t quay.io/rhdevelopers/istio-tutorial-recommendation:v3.1 .
docker images | grep recommendation
cd ../../..
To deploy to Kubernetes use:
kubectl apply -f <(istioctl kube-inject -f recommendation/kubernetes/Deployment-v3.yml) -n tutorial