Skip to content

Commit 5a967a4

Browse files
author
Dave Syer
committed
Make all k8s platform examples use Minikube
1 parent 9519e2c commit 5a967a4

File tree

5 files changed

+9
-180
lines changed

5 files changed

+9
-180
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ crashlytics-build.properties
7979
.project
8080
.classpath
8181
.factorypath
82+
.attach_pid*
83+
.vscode/

README.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,11 +487,11 @@ configuration. We can create a Kubernetes secret by using the following command:
487487
====
488488
[source]
489489
----
490-
oc create secret generic db-secret --from-literal=username=user --from-literal=password=p455w0rd
490+
kubectl create secret generic db-secret --from-literal=username=user --from-literal=password=p455w0rd
491491
----
492492
====
493493

494-
The preceding command would create the following secret (which you can see by using `oc get secrets db-secret -o yaml`):
494+
The preceding command would create the following secret (which you can see by using `kubectl get secrets db-secret -o yaml`):
495495

496496
====
497497
[source,yaml]

docs/src/main/asciidoc/property-source-config.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,11 @@ configuration. We can create a Kubernetes secret by using the following command:
318318
====
319319
[source]
320320
----
321-
oc create secret generic db-secret --from-literal=username=user --from-literal=password=p455w0rd
321+
kubectl create secret generic db-secret --from-literal=username=user --from-literal=password=p455w0rd
322322
----
323323
====
324324

325-
The preceding command would create the following secret (which you can see by using `oc get secrets db-secret -o yaml`):
325+
The preceding command would create the following secret (which you can see by using `kubectl get secrets db-secret -o yaml`):
326326

327327
====
328328
[source,yaml]

spring-cloud-kubernetes-examples/kubernetes-circuitbreaker-ribbon-example/readme.md

Lines changed: 1 addition & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ As the Ribbon Kubernetes client is configured within this example, it will fetch
55

66
### Running the example
77

8-
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
8+
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
99
to install the platform locally within a virtual machine managed by VirtualBox, Xhyve or KVM, with no fuss.
1010

1111
### Build/Deploy using Minikube
@@ -104,116 +104,4 @@ and next issue a new curl request to get the response from the greeting service
104104
```
105105
Hello from Fallback!
106106
```
107-
108-
### Build/Deploy using Minishift
109-
110-
First, create a new virtual machine provisioned with OpenShift on your laptop using the command `minishift start`.
111-
112-
Next, log on to the OpenShift platform and next within your terminal use the `oc` client to create a project where
113-
we will install the circuit breaker and load balancing application
114-
115-
```
116-
oc new-project circuit-loadbalancing
117-
```
118-
119-
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
120-
the API Server :
121-
122-
```
123-
oc policy add-role-to-user view --serviceaccount=default
124-
```
125-
126-
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)
127-
like also to deploy the application on the OpenShift platform in one maven line :
128-
129-
```
130-
mvn clean install fabric8:deploy -Pkubernetes
131-
```
132-
133-
### Call the Greeting service
134-
135-
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
136-
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
137-
check if the pods have been created using this command :
138-
139-
```
140-
oc get pods --selector=project=greeting-service
141-
```
142-
143-
If the status of the Spring Boot pod application is `running` and ready state `1`, then you can
144-
get the external address IP/Hostname to be used to call the service from your laptop
145-
146-
```
147-
oc get route/greeting-service
148-
```
149-
150-
and then call the service using the curl client
151-
152-
```
153-
curl https://IP_OR_HOSTNAME/greeting
154-
```
155-
156-
to get a response as such
157-
158-
```
159-
Hello from name-service-1-0dzb4!d
160-
```
161-
162-
### Verify the load balancing
163-
164-
First, scale the number of pods of the `name service` to 2
165-
166-
```
167-
oc scale --replicas=2 dc name-service
168-
```
169-
170-
Wait a few minutes before to issue the curl request to call the Greeting Service to let the platform to create the new pod.
171-
172-
```
173-
oc get pods --selector=project=name-service
174-
NAME READY STATUS RESTARTS AGE
175-
name-service-1-0ss0r 1/1 Running 0 3m
176-
name-service-1-fblp1 1/1 Running 0 36m
177-
```
178-
179-
If you issue the curl request to access the greeting service, you should see that the message response
180-
contains a different id end of the message which corresponds to the name of the pod.
181-
182-
```
183-
Hello from name-service-1-0ss0r!
184-
```
185-
186-
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,
187-
you should see that you will get a different response from one of the 2 pods running
188-
189-
```
190-
oc get endpoints/name-service
191-
NAME ENDPOINTS AGE
192-
name-service 172.17.0.2:8080,172.17.0.3:8080 40m
193-
```
194-
195-
Here is an example about what you will get
196-
197-
```
198-
curl https://IP_OR_HOSTNAME/greeting
199-
Hello from name-service-1-0ss0r!
200-
curl https://IP_OR_HOSTNAME/greeting
201-
Hello from name-service-1-fblp1!
202-
...
203-
```
204-
205-
### Test the fall back
206-
207-
In order to test the circuit breaker and the fallback option, you will scale the `name-service` to 0 pods as such
208-
209-
```
210-
oc scale --replicas=0 dc name-service
211-
```
212-
213-
and next issue a new curl request to get the response from the greeting service
214-
215-
```
216-
Hello from Fallback!
217-
```
218-
219107

spring-cloud-kubernetes-examples/kubernetes-zipkin-example/README.md

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
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
44
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`
55

6-
The Zipkin server is deployed according to the steps described within the `Minishift` or `Minikube` section.
6+
The Zipkin server is deployed according to the steps described within the `Minikube` section.
77

88
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
99
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
3131

3232
### Running the example
3333

34-
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
34+
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
3535
to install the platform locally within a virtual machine managed by VirtualBox, Xhyve or KVM, with no fuss.
3636

3737
### Build/Deploy using Minikube
@@ -96,64 +96,3 @@ export ENDPOINT=$(minikube service kubernetes-zipkin --url)
9696
curl $ENDPOINT
9797
curl $ENDPOINT/hi
9898
```
99-
100-
### Build/Deploy using Minishift
101-
102-
First, create a new virtual machine provisioned with OpenShift on your laptop using the command `minishift start`.
103-
104-
Next, log on to the OpenShift platform and next within your terminal use the `oc` client to create a project where
105-
we will install the circuit breaker and load balancing application
106-
107-
```
108-
oc new-project zipkin
109-
```
110-
111-
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
112-
the API Server :
113-
114-
```
115-
oc policy add-role-to-user view --serviceaccount=default
116-
```
117-
118-
To deploy the Zipkin server and store the traces under a MySQL server, execute the following commands to deploy the Zipkin application
119-
120-
```
121-
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
122-
oc delete pvc/mysql-data
123-
124-
cat << EOF | oc create -f -
125-
apiVersion: v1
126-
kind: PersistentVolumeClaim
127-
metadata:
128-
name: mysql-data
129-
labels:
130-
type: local
131-
spec:
132-
accessModes:
133-
- ReadWriteOnce
134-
resources:
135-
requests:
136-
storage: 1Gi
137-
EOF
138-
```
139-
140-
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)
141-
like also to deploy the application on the OpenShift platform in one maven line :
142-
143-
```
144-
mvn clean install fabric8:deploy -Pkubernetes
145-
```
146-
147-
You can find the address of the Zipkin server to be opened within your browser using this command
148-
149-
```
150-
oc get route/zipkin --template='{{.spec.host}}'
151-
```
152-
153-
like also the endpoint to call to generate traces
154-
155-
```
156-
export ENDPOINT=$(oc get route/kubernetes-zipkin --template='{{.spec.host}}')
157-
curl $ENDPOINT
158-
curl $ENDPOINT/hi
159-
```

0 commit comments

Comments
 (0)