Make all k8s platform examples use Minikube
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -79,3 +79,5 @@ crashlytics-build.properties
|
||||
.project
|
||||
.classpath
|
||||
.factorypath
|
||||
.attach_pid*
|
||||
.vscode/
|
||||
|
||||
@@ -487,11 +487,11 @@ configuration. We can create a Kubernetes secret by using the following command:
|
||||
====
|
||||
[source]
|
||||
----
|
||||
oc create secret generic db-secret --from-literal=username=user --from-literal=password=p455w0rd
|
||||
kubectl create secret generic db-secret --from-literal=username=user --from-literal=password=p455w0rd
|
||||
----
|
||||
====
|
||||
|
||||
The preceding command would create the following secret (which you can see by using `oc get secrets db-secret -o yaml`):
|
||||
The preceding command would create the following secret (which you can see by using `kubectl get secrets db-secret -o yaml`):
|
||||
|
||||
====
|
||||
[source,yaml]
|
||||
|
||||
@@ -318,11 +318,11 @@ configuration. We can create a Kubernetes secret by using the following command:
|
||||
====
|
||||
[source]
|
||||
----
|
||||
oc create secret generic db-secret --from-literal=username=user --from-literal=password=p455w0rd
|
||||
kubectl create secret generic db-secret --from-literal=username=user --from-literal=password=p455w0rd
|
||||
----
|
||||
====
|
||||
|
||||
The preceding command would create the following secret (which you can see by using `oc get secrets db-secret -o yaml`):
|
||||
The preceding command would create the following secret (which you can see by using `kubectl get secrets db-secret -o yaml`):
|
||||
|
||||
====
|
||||
[source,yaml]
|
||||
|
||||
@@ -5,7 +5,7 @@ As the Ribbon Kubernetes client is configured within this example, it will fetch
|
||||
|
||||
### Running the example
|
||||
|
||||
This project example runs on ALL the Kubernetes or OpenShift environments, but for development purposes you can use [Minishift - OpenShift](https://github.com/minishift/minishift) or [Minikube - Kubernetes](https://kubernetes.io/docs/getting-started-guides/minikube/) tool
|
||||
This project example runs on ALL the Kubernetes environments, but for development purposes you can use [Kind](https://github.com/kubernetes-sigs/kind) or [Minikube - Kubernetes](https://kubernetes.io/docs/getting-started-guides/minikube/) tool
|
||||
to install the platform locally within a virtual machine managed by VirtualBox, Xhyve or KVM, with no fuss.
|
||||
|
||||
### Build/Deploy using Minikube
|
||||
@@ -104,116 +104,4 @@ and next issue a new curl request to get the response from the greeting service
|
||||
```
|
||||
Hello from Fallback!
|
||||
```
|
||||
|
||||
### Build/Deploy using Minishift
|
||||
|
||||
First, create a new virtual machine provisioned with OpenShift on your laptop using the command `minishift start`.
|
||||
|
||||
Next, log on to the OpenShift platform and next within your terminal use the `oc` client to create a project where
|
||||
we will install the circuit breaker and load balancing application
|
||||
|
||||
```
|
||||
oc new-project circuit-loadbalancing
|
||||
```
|
||||
|
||||
When using OpenShift, you must assign the `view` role to the *default* service account in the current project in orde to allow our Java Kubernetes Api to access
|
||||
the API Server :
|
||||
|
||||
```
|
||||
oc policy add-role-to-user view --serviceaccount=default
|
||||
```
|
||||
|
||||
You can now compile your project and generate the OpenShift resources (yaml files containing the definition of the pod, deployment, build, service and route to be created)
|
||||
like also to deploy the application on the OpenShift platform in one maven line :
|
||||
|
||||
```
|
||||
mvn clean install fabric8:deploy -Pkubernetes
|
||||
```
|
||||
|
||||
### Call the Greeting service
|
||||
|
||||
When maven has finished to compile the code but also to call the platform in order to deploy the yaml files generated and tell to the platform to start the process
|
||||
to build/deploy the docker image and create the containers where the Spring Boot application will run 'greeting-service" and "name-service", you will be able to
|
||||
check if the pods have been created using this command :
|
||||
|
||||
```
|
||||
oc get pods --selector=project=greeting-service
|
||||
```
|
||||
|
||||
If the status of the Spring Boot pod application is `running` and ready state `1`, then you can
|
||||
get the external address IP/Hostname to be used to call the service from your laptop
|
||||
|
||||
```
|
||||
oc get route/greeting-service
|
||||
```
|
||||
|
||||
and then call the service using the curl client
|
||||
|
||||
```
|
||||
curl https://IP_OR_HOSTNAME/greeting
|
||||
```
|
||||
|
||||
to get a response as such
|
||||
|
||||
```
|
||||
Hello from name-service-1-0dzb4!d
|
||||
```
|
||||
|
||||
### Verify the load balancing
|
||||
|
||||
First, scale the number of pods of the `name service` to 2
|
||||
|
||||
```
|
||||
oc scale --replicas=2 dc name-service
|
||||
```
|
||||
|
||||
Wait a few minutes before to issue the curl request to call the Greeting Service to let the platform to create the new pod.
|
||||
|
||||
```
|
||||
oc get pods --selector=project=name-service
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
name-service-1-0ss0r 1/1 Running 0 3m
|
||||
name-service-1-fblp1 1/1 Running 0 36m
|
||||
```
|
||||
|
||||
If you issue the curl request to access the greeting service, you should see that the message response
|
||||
contains a different id end of the message which corresponds to the name of the pod.
|
||||
|
||||
```
|
||||
Hello from name-service-1-0ss0r!
|
||||
```
|
||||
|
||||
As Ribbon will question the Kubernetes API to get, base on the `name-service` name, the list of IP Addresses assigned to the service as endpoints,
|
||||
you should see that you will get a different response from one of the 2 pods running
|
||||
|
||||
```
|
||||
oc get endpoints/name-service
|
||||
NAME ENDPOINTS AGE
|
||||
name-service 172.17.0.2:8080,172.17.0.3:8080 40m
|
||||
```
|
||||
|
||||
Here is an example about what you will get
|
||||
|
||||
```
|
||||
curl https://IP_OR_HOSTNAME/greeting
|
||||
Hello from name-service-1-0ss0r!
|
||||
curl https://IP_OR_HOSTNAME/greeting
|
||||
Hello from name-service-1-fblp1!
|
||||
...
|
||||
```
|
||||
|
||||
### Test the fall back
|
||||
|
||||
In order to test the circuit breaker and the fallback option, you will scale the `name-service` to 0 pods as such
|
||||
|
||||
```
|
||||
oc scale --replicas=0 dc name-service
|
||||
```
|
||||
|
||||
and next issue a new curl request to get the response from the greeting service
|
||||
|
||||
```
|
||||
Hello from Fallback!
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
This project demonstrates how a Spring Boot application generating statistics as Spring Cloud Sleuth Spans/Traces can send them to a ZipKin server deployed in Kubernetes without the need to
|
||||
configure the baseUrl of the ZipKin server deployed as the server will be discovered. The spans/traces generated can be viewed within the Zipkin dashboard under the `serviceName=sleuth-zipkin`
|
||||
|
||||
The Zipkin server is deployed according to the steps described within the `Minishift` or `Minikube` section.
|
||||
The Zipkin server is deployed according to the steps described within the `Minikube` section.
|
||||
|
||||
The project exposes under the `TraceController` 2 endpoints `/` and `/hi` that you can play with in order to generate traces. When you call the root endpoint `/`, then
|
||||
it will issue a call against the second endpoint `/hi` and you will receive `/hi/hello` as response. If you look to the Zipkin dashboard, you will be able to get 2 traces recorded.
|
||||
@@ -31,7 +31,7 @@ it will issue a call against the second endpoint `/hi` and you will receive `/hi
|
||||
|
||||
### Running the example
|
||||
|
||||
This project example runs on ALL the Kubernetes or OpenShift environments, but for development purposes you can use [Minishift - OpenShift](https://github.com/minishift/minishift) or [Minikube - Kubernetes](https://kubernetes.io/docs/getting-started-guides/minikube/) tool
|
||||
This project example runs on ALL the Kubernetes environments, but for development purposes you can use [Kind](https://github.com/kubernetes-sigs/kind) or [Minikube - Kubernetes](https://kubernetes.io/docs/getting-started-guides/minikube/) tool
|
||||
to install the platform locally within a virtual machine managed by VirtualBox, Xhyve or KVM, with no fuss.
|
||||
|
||||
### Build/Deploy using Minikube
|
||||
@@ -96,64 +96,3 @@ export ENDPOINT=$(minikube service kubernetes-zipkin --url)
|
||||
curl $ENDPOINT
|
||||
curl $ENDPOINT/hi
|
||||
```
|
||||
|
||||
### Build/Deploy using Minishift
|
||||
|
||||
First, create a new virtual machine provisioned with OpenShift on your laptop using the command `minishift start`.
|
||||
|
||||
Next, log on to the OpenShift platform and next within your terminal use the `oc` client to create a project where
|
||||
we will install the circuit breaker and load balancing application
|
||||
|
||||
```
|
||||
oc new-project zipkin
|
||||
```
|
||||
|
||||
When using OpenShift, you must assign the `view` role to the *default* service account in the current project in order to allow our Java Kubernetes Api to access
|
||||
the API Server :
|
||||
|
||||
```
|
||||
oc policy add-role-to-user view --serviceaccount=default
|
||||
```
|
||||
|
||||
To deploy the Zipkin server and store the traces under a MySQL server, execute the following commands to deploy the Zipkin application
|
||||
|
||||
```
|
||||
oc create -f https://repo1.maven.org/maven2/io/fabric8/zipkin/zipkin-starter-minimal/0.1.9/zipkin-starter-minimal-0.1.9-openshift.yml
|
||||
oc delete pvc/mysql-data
|
||||
|
||||
cat << EOF | oc create -f -
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: mysql-data
|
||||
labels:
|
||||
type: local
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
EOF
|
||||
```
|
||||
|
||||
You can now compile your project and generate the OpenShift resources (yaml files containing the definition of the pod, deployment, build, service and route to be created)
|
||||
like also to deploy the application on the OpenShift platform in one maven line :
|
||||
|
||||
```
|
||||
mvn clean install fabric8:deploy -Pkubernetes
|
||||
```
|
||||
|
||||
You can find the address of the Zipkin server to be opened within your browser using this command
|
||||
|
||||
```
|
||||
oc get route/zipkin --template='{{.spec.host}}'
|
||||
```
|
||||
|
||||
like also the endpoint to call to generate traces
|
||||
|
||||
```
|
||||
export ENDPOINT=$(oc get route/kubernetes-zipkin --template='{{.spec.host}}')
|
||||
curl $ENDPOINT
|
||||
curl $ENDPOINT/hi
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user