Skip to content

Commit cda1b55

Browse files
author
Ollie Hughes
committed
Fix some imports and added some changes to K8S deployment
1 parent cc4754e commit cda1b55

File tree

10 files changed

+70
-66
lines changed

10 files changed

+70
-66
lines changed

README.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
= Overview
22

3-
This project implements a sample service broker that adheres to the https://www.openservicebrokerapi.org/[Open Service Broker API] using the https://cloud.spring.io/spring-cloud-open-service-broker/[Spring Cloud Open Service Broker] framework. It can be deployed to either Cloud Foundry or Kubernetes, and can be registered as a service broker to either platform.
3+
This project demonstrates how the https://cloud.spring.io/spring-cloud-open-service-broker/[Spring Cloud Open Service Broker]
4+
framework can be used to easily build an https://www.openservicebrokerapi.org/[Open Service Broker API] compliant service broker.
5+
It can be deployed and registered as a service broker using either Cloud Foundry or Kubernetes.
46

57
== Compatibility
68

@@ -27,7 +29,7 @@ The project is built with Gradle. The https://docs.gradle.org/current/userguide/
2729
./gradlew build
2830

2931
== Deploy
30-
32+
3133
Once the project is built, it can be deployed and registered to either Cloud Foundry or Kubernetes.
3234

3335
* link:deploy/cloudfoundry/README.adoc[deploy to Cloud Foundry]

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ dependencies {
5858
runtime('org.springframework.boot:spring-boot-devtools')
5959

6060
compile('org.springframework.cloud:spring-cloud-open-service-broker-starter-webmvc:2.0.0.BUILD-SNAPSHOT')
61-
61+
6262
compile('org.springframework.data:spring-data-keyvalue')
6363

6464
testCompile('org.springframework.boot:spring-boot-starter-test')
@@ -75,4 +75,5 @@ docker {
7575
dockerfile file('deploy/docker/Dockerfile')
7676
files jar.archivePath
7777
buildArgs(['JAR_FILE': "${jar.archiveName}"])
78+
7879
}

deploy/kubernetes/README.adoc

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ Pivotal Container Service (PKS) can be used to deploy and manage production-qual
2424

2525
*NOTE*: Ensure that post-deploy scripts have been enabled in PCF Ops Manager as described on the https://docs.pivotal.io/runtimes/pks/1-0/troubleshoot-issues.html#timeouts[PKS Troubleshooting page].
2626

27+
=== Google Kubernetes Engine (GKE)
28+
29+
Google Cloud Platform provides a Kubernetes Engine (GKE) and installer tool for setting up the Service Catalog extension API.
30+
31+
The process of setting up GKE is documented at https://cloud.google.com/kubernetes-engine/docs/quickstart
32+
The service catalog installation tool can be installed here https://github.com/GoogleCloudPlatform/k8s-service-catalog#installation
33+
2734
== Service Catalog
2835

2936
Kubernetes support for service brokers via the Open Service Broker API is provided by the https://kubernetes.io/docs/concepts/service-catalog/[Service Catalog] project. Follow the https://github.com/kubernetes-incubator/service-catalog/blob/master/docs/install.md[project documentation] to install the service catalog into your Kubernetes cluster.
@@ -128,18 +135,18 @@ service "bookstore-broker" created
128135
Show the details of the created service:
129136

130137
----
131-
$ kubectl describe service bookstore-broker -n bookstore-broker
132-
Name: bookstore-broker
138+
$ kubectl describe service bookstore-broker -n bookstore-brokerName: bookstore-broker
133139
Namespace: bookstore-broker
134140
Labels: run=bookstore-broker
135141
Annotations: <none>
136142
Selector: run=bookstore-broker
137-
Type: NodePort
138-
IP: 10.107.161.81
143+
Type: LoadBalancer
144+
IP: 10.47.247.7
145+
LoadBalancer Ingress: 35.197.249.208
139146
Port: <unset> 80/TCP
140147
TargetPort: 8080/TCP
141-
NodePort: <unset> 32248/TCP
142-
Endpoints:
148+
NodePort: <unset> 30789/TCP
149+
Endpoints: 10.44.4.8:8080
143150
Session Affinity: None
144151
External Traffic Policy: Cluster
145152
Events: <none>
@@ -171,50 +178,29 @@ Show the details of the service broker application service again:
171178

172179
----
173180
$ kubectl describe service bookstore-broker -n bookstore-broker
174-
Name: bookstore-broker
175181
Namespace: bookstore-broker
176182
Labels: run=bookstore-broker
177183
Annotations: <none>
178184
Selector: run=bookstore-broker
179-
Type: NodePort
180-
IP: 10.107.161.81
185+
Type: LoadBalancer
186+
IP: 10.47.247.7
187+
LoadBalancer Ingress: 35.197.249.208
181188
Port: <unset> 80/TCP
182189
TargetPort: 8080/TCP
183-
NodePort: <unset> 32248/TCP
184-
Endpoints:
190+
NodePort: <unset> 30789/TCP
191+
Endpoints: 10.44.4.8:8080
185192
Session Affinity: None
186193
External Traffic Policy: Cluster
187194
Events: <none>
188195
----
189196

190-
Note the value of the `NodePort` row.
191-
192-
Show a list of Kubernetes pods running in the cluster:
193-
194-
----
195-
$ kubectl get pods -n bookstore-broker -o=wide
196-
NAME READY STATUS IP NODE
197-
bookstore-broker-68f88cbbfb-vvmn4 1/1 Running 10.200.37.3 8ce76de4-4cfc-4bcd-b860-043a69cd2402
198-
----
199-
200-
Note the value in the `NODE` column for the `bookstore-broker` pod.
201197

202-
Show a list of Kubernetes nodes running in the cluster:
203-
204-
----
205-
$ kubectl get nodes -n bookstore-broker -o=wide
206-
NAME STATUS AGE VERSION EXTERNAL-IP
207-
2e45b4e3-1f9a-439e-b830-e051135f9e52 Ready 1d v1.9.2 192.168.1.236
208-
8ce76de4-4cfc-4bcd-b860-043a69cd2402 Ready 1d v1.9.2 192.168.1.235
209-
cf353f58-bb1a-45cf-8b18-96976f818c5f Ready 1d v1.9.2 192.168.1.234
210-
----
211-
212-
Note the value in the `EXTERNAL-IP` column of the node whose `NAME` matches the node for the `bookstore-broker` pod.
198+
Note the value in the `LoadBalancer Ingress` column and the `Port` column below.
213199

214200
Construct a URL using the IP address of the node and the port of the service, and use the this URL to access the `/v2/catalog` endpoint of the service broker application:
215201

216202
----
217-
$ curl http://192.168.1.235:32248/v2/catalog -u admin:supersecret
203+
$ curl http://35.197.249.208/v2/catalog -u admin:supersecret
218204
{"services":[{"id":"bdb1be2e-360b-495c-8115-d7697f9c6a9e","name":"bookstore","description":"A simple book store service","bindable":true,"plan_updateable":false,"plans":[{"id":"b973fb78-82f3-49ef-9b8b-c1876974a6cd","name":"standard","description":"A simple book store plan","free":true}],"tags":["book-store","books","sample"]}]}
219205
----
220206

@@ -227,7 +213,7 @@ Now that the application has been deployed and verified, it can be registered to
227213
The Open Service Broker API endpoints in the service broker application are secured with a basic auth username and password. Create a Kubernetes secret to store these credentials:
228214

229215
----
230-
$ kubectl create -f deploy/kubernetes/service-broker-secret.yml
216+
$ kubectl create secret generic -n bookstore-broker bookstore-broker-secret --from-literal=username='admin' --from-literal=password='supersecret'
231217
secret "bookstore-broker-secret" created
232218
----
233219

@@ -481,4 +467,19 @@ uri: 67 bytes
481467
username: 4 bytes
482468
----
483469

470+
To test the Service Instance API, the URL can be constructed from the binding credentials;
471+
472+
---
473+
export SI_URI=$(kubectl get secret bookstore-binding -n test -o json | jq -r '.data.uri' | base64 --decode)
474+
export SI_USER=$($ kubectl get secret bookstore-binding -n test -o json | jq -r '.data.username' | base64 --decode)
475+
export SI_PASSWORD=$(kubectl get secret bookstore-binding -n test -o json | jq -r '.data.password' | base64 --decode)
476+
477+
export GET_BOOKS_URI=$(curl ${SI_URI} -u ${SI_USER}:${SI_PASSWORD} -H "Content-Type: application/json" -X PUT -d '{"isbn":"978-1617292545","title":"Spring Boot in Action", "author":"Craig Walls"}' | jq -r '.links | first | .href')
478+
curl ${GET_BOOKS_URI} -u ${SI_USER}:${SI_PASSWORD}
479+
---
480+
481+
== Current Issues
482+
* On GKE with a service catalog installed using `sc`, the service instance API only works when no authentication is provided
483+
* The service binding returns `localhost:8080` for the URI instead of the External IP address from the LoadBalancer service
484+
484485

deploy/kubernetes/deployment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: extensions/v1beta1
22
kind: Deployment
33
metadata:
44
name: bookstore-broker
5-
namespace: bookstore-broker
5+
namespace: service-catalog
66
labels:
77
run: bookstore-broker
88
spec:
@@ -16,7 +16,7 @@ spec:
1616
run: bookstore-broker
1717
spec:
1818
containers:
19-
- image: sample/bookstore-service-broker:0.0.1.BUILD-SNAPSHOT
19+
- image: eu.gcr.io/cf-sandbox-ohughes/bookstore-service-broker:0.0.1.BUILD-SNAPSHOT
2020
name: bookstore-broker
2121
ports:
2222
- containerPort: 8080

deploy/kubernetes/service-broker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ metadata:
55
labels:
66
run: bookstore-broker
77
spec:
8-
url: http://bookstore-broker.bookstore-broker.svc.cluster.local
8+
url: http://35.197.249.208
99
authInfo:
1010
basic:
1111
secretRef:
1212
name: bookstore-broker-secret
13-
namespace: bookstore-broker
13+
namespace: service-catalog
1414

deploy/kubernetes/service.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
name: bookstore-broker
5-
namespace: bookstore-broker
5+
namespace: service-catalog
66
labels:
77
run: bookstore-broker
88
spec:
@@ -12,4 +12,4 @@ spec:
1212
targetPort: 8080
1313
selector:
1414
run: bookstore-broker
15-
type: NodePort
15+
type: LoadBalancer

src/main/java/org/springframework/cloud/broker/bookstore/webmvc/service/BookStoreServiceInstanceBindingService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
import org.springframework.cloud.broker.bookstore.webmvc.model.ServiceBinding;
2121
import org.springframework.cloud.broker.bookstore.webmvc.repository.ServiceBindingRepository;
2222
import org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingDoesNotExistException;
23-
import org.springframework.cloud.servicebroker.model.bindings.CreateServiceInstanceAppBindingResponse;
24-
import org.springframework.cloud.servicebroker.model.bindings.CreateServiceInstanceAppBindingResponse.CreateServiceInstanceAppBindingResponseBuilder;
25-
import org.springframework.cloud.servicebroker.model.bindings.CreateServiceInstanceBindingRequest;
26-
import org.springframework.cloud.servicebroker.model.bindings.CreateServiceInstanceBindingResponse;
27-
import org.springframework.cloud.servicebroker.model.bindings.DeleteServiceInstanceBindingRequest;
23+
import org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceAppBindingResponse;
24+
import org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceAppBindingResponse.CreateServiceInstanceAppBindingResponseBuilder;
25+
import org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest;
26+
import org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingResponse;
27+
import org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstanceBindingRequest;
2828
import org.springframework.cloud.servicebroker.service.ServiceInstanceBindingService;
2929
import org.springframework.security.core.userdetails.User;
3030
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

src/main/java/org/springframework/cloud/broker/bookstore/webmvc/service/BookStoreServiceInstanceService.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
import org.springframework.cloud.broker.bookstore.webmvc.model.ServiceInstance;
2020
import org.springframework.cloud.broker.bookstore.webmvc.repository.ServiceInstanceRepository;
2121
import org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException;
22-
import org.springframework.cloud.servicebroker.model.instances.CreateServiceInstanceRequest;
23-
import org.springframework.cloud.servicebroker.model.instances.CreateServiceInstanceResponse;
24-
import org.springframework.cloud.servicebroker.model.instances.CreateServiceInstanceResponse.CreateServiceInstanceResponseBuilder;
25-
import org.springframework.cloud.servicebroker.model.instances.DeleteServiceInstanceRequest;
26-
import org.springframework.cloud.servicebroker.model.instances.DeleteServiceInstanceResponse;
27-
import org.springframework.cloud.servicebroker.model.instances.GetLastServiceOperationRequest;
28-
import org.springframework.cloud.servicebroker.model.instances.GetLastServiceOperationResponse;
29-
import org.springframework.cloud.servicebroker.model.instances.UpdateServiceInstanceRequest;
30-
import org.springframework.cloud.servicebroker.model.instances.UpdateServiceInstanceResponse;
22+
import org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceRequest;
23+
import org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceResponse;
24+
import org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceResponse.CreateServiceInstanceResponseBuilder;
25+
import org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceRequest;
26+
import org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceResponse;
27+
import org.springframework.cloud.servicebroker.model.instance.GetLastServiceOperationRequest;
28+
import org.springframework.cloud.servicebroker.model.instance.GetLastServiceOperationResponse;
29+
import org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceRequest;
30+
import org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceResponse;
3131
import org.springframework.cloud.servicebroker.service.ServiceInstanceService;
3232
import org.springframework.stereotype.Service;
3333

src/test/java/org/springframework/cloud/broker/bookstore/webmvc/service/BookstoreServiceInstanceBindingServiceTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
import org.springframework.cloud.broker.bookstore.webmvc.repository.ServiceBindingRepository;
2626
import org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingDoesNotExistException;
2727
import org.springframework.cloud.servicebroker.model.Context;
28-
import org.springframework.cloud.servicebroker.model.bindings.CreateServiceInstanceAppBindingResponse;
29-
import org.springframework.cloud.servicebroker.model.bindings.CreateServiceInstanceBindingRequest;
30-
import org.springframework.cloud.servicebroker.model.bindings.CreateServiceInstanceBindingResponse;
31-
import org.springframework.cloud.servicebroker.model.bindings.DeleteServiceInstanceBindingRequest;
28+
import org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceAppBindingResponse;
29+
import org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest;
30+
import org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingResponse;
31+
import org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstanceBindingRequest;
3232
import org.springframework.security.core.userdetails.User;
3333
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
3434

src/test/java/org/springframework/cloud/broker/bookstore/webmvc/service/BookstoreServiceInstanceServiceTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
import org.springframework.cloud.broker.bookstore.webmvc.repository.ServiceInstanceRepository;
2727
import org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException;
2828
import org.springframework.cloud.servicebroker.model.Context;
29-
import org.springframework.cloud.servicebroker.model.instances.CreateServiceInstanceRequest;
30-
import org.springframework.cloud.servicebroker.model.instances.CreateServiceInstanceResponse;
31-
import org.springframework.cloud.servicebroker.model.instances.DeleteServiceInstanceRequest;
32-
import org.springframework.cloud.servicebroker.model.instances.DeleteServiceInstanceResponse;
29+
import org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceRequest;
30+
import org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceResponse;
31+
import org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceRequest;
32+
import org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceResponse;
3333

3434
import static org.assertj.core.api.Assertions.assertThat;
3535
import static org.mockito.Mockito.verify;

0 commit comments

Comments
 (0)