Skip to content

Commit c0f71f5

Browse files
committed
fixes
1 parent bb54279 commit c0f71f5

File tree

13 files changed

+60
-46
lines changed

13 files changed

+60
-46
lines changed

examples-bootiful-gcp/guestbook-service/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
<groupId>org.springframework.cloud</groupId>
5151
<artifactId>spring-cloud-gcp-starter-trace</artifactId>
5252
</dependency>
53+
<dependency>
54+
<groupId>io.micrometer</groupId>
55+
<artifactId>micrometer-registry-prometheus</artifactId>
56+
</dependency>
5357

5458
<dependency>
5559
<groupId>org.springframework.boot</groupId>

examples-bootiful-gcp/guestbook-service/src/main/resources/application.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ spring:
2020
sleuth:
2121
sampler:
2222
probability: 1.0
23+
management:
24+
endpoints:
25+
web:
26+
exposure:
27+
include: health,prometheus

examples-bootiful-gcp/helloworld-service/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
<groupId>org.springframework.cloud</groupId>
4343
<artifactId>spring-cloud-gcp-starter-trace</artifactId>
4444
</dependency>
45+
<dependency>
46+
<groupId>io.micrometer</groupId>
47+
<artifactId>micrometer-registry-prometheus</artifactId>
48+
</dependency>
4549

4650
<dependency>
4751
<groupId>org.springframework.boot</groupId>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
greeting=Hello $name from $hostname with $version
22
spring.application.name=helloworld-service
33
spring.sleuth.sampler.probability=1.0
4+
management.endpoints.web.exposure.include=health,prometheus

examples-bootiful-gcp/helloworld-ui/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
<groupId>org.springframework.session</groupId>
4242
<artifactId>spring-session-data-redis</artifactId>
4343
</dependency>
44+
<dependency>
45+
<groupId>io.lettuce</groupId>
46+
<artifactId>lettuce-core</artifactId>
47+
</dependency>
4448

4549
<dependency>
4650
<groupId>org.springframework.cloud</groupId>
@@ -50,6 +54,10 @@
5054
<groupId>org.springframework.cloud</groupId>
5155
<artifactId>spring-cloud-gcp-starter-trace</artifactId>
5256
</dependency>
57+
<dependency>
58+
<groupId>io.micrometer</groupId>
59+
<artifactId>micrometer-registry-prometheus</artifactId>
60+
</dependency>
5361

5462
<dependency>
5563
<groupId>org.springframework.boot</groupId>

examples-bootiful-gcp/helloworld-ui/src/main/java/com/example/guestbook/ApplicationConfig.java

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -34,53 +34,25 @@
3434
* Created by rayt on 5/1/17.
3535
*/
3636
@Configuration
37-
@EnableRedisHttpSession
3837
public class ApplicationConfig {
39-
@Value("#{systemEnvironment['HELLOWORLDSERVICE_PORT']}")
38+
@Value("${helloworldservice.endpoint:http://localhost:8081}/hello")
4039
private String helloworldServiceEndpoint;
4140

42-
@Value("#{systemEnvironment['GUESTBOOKSERVICE_PORT']}")
41+
@Value("${guestbookservice.endpoint:http://localhost:8082}/api/messages")
4342
private String guestbookServiceEndpoint;
4443

45-
@Value("#{systemEnvironment['REDIS_PORT']}")
46-
private String redisEndpoint;
47-
4844
@Bean
4945
RestTemplate restTemplate() {
5046
return new RestTemplate();
5147
}
5248

5349
@Bean
5450
HelloworldService helloworldService(RestTemplate restTemplate) {
55-
String endpoint = helloworldServiceEndpoint.trim().replace("tcp:", "http:") + "/hello";
56-
return new HelloworldService(restTemplate, endpoint);
51+
return new HelloworldService(restTemplate, helloworldServiceEndpoint);
5752
}
5853

5954
@Bean
6055
GuestbookService guestbookService(RestTemplate restTemplate) {
61-
String endpoint = guestbookServiceEndpoint.trim().replace("tcp:", "http:") + "/api/messages";
62-
return new GuestbookService(restTemplate, endpoint);
63-
}
64-
65-
@Bean
66-
@Order(value = 0)
67-
FilterRegistrationBean sessionRepositoryFilterRegistration(
68-
SessionRepositoryFilter filter) {
69-
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(
70-
new DelegatingFilterProxy(filter));
71-
filterRegistrationBean.setUrlPatterns(Arrays.asList("/*"));
72-
73-
return filterRegistrationBean;
56+
return new GuestbookService(restTemplate, guestbookServiceEndpoint);
7457
}
75-
76-
@Bean
77-
JedisConnectionFactory jedisConnectionFactory() throws URISyntaxException {
78-
URI uri = new URI(redisEndpoint);
79-
JedisConnectionFactory factory = new JedisConnectionFactory();
80-
factory.setHostName(uri.getHost());
81-
factory.setPort(uri.getPort());
82-
83-
return factory;
84-
}
85-
8658
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
spring.application.name=ui
22
spring.sleuth.sampler.probability=1.0
3+
spring.session.store-type=redis
4+
management.endpoints.web.exposure.include=health,prometheus

examples-bootiful-gcp/kubernetes/guestbook-deployment.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
###############################################################################
16-
apiVersion: extensions/v1beta1
16+
apiVersion: apps/v1
1717
kind: Deployment
1818
metadata:
1919
name: guestbook-service
@@ -35,13 +35,16 @@ spec:
3535
visualize: "true"
3636
annotations:
3737
visualizer/uses: mysql
38+
prometheus.io/scrape: "true"
39+
prometheus.io/port: "8080"
40+
promteheus.io/path: /actuator/prometheus
3841
spec:
3942
containers:
4043
- name: guestbook-service
41-
image: saturnism/guestbook-service:latest
44+
image: gcr.io/wise-coyote-827/bootiful-guestbook-service:latest
4245
readinessProbe:
4346
httpGet:
44-
path: /health
47+
path: /actuator/health
4548
port: 8080
4649
ports:
4750
- name: http

examples-bootiful-gcp/kubernetes/helloworld-deployment.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
###############################################################################
16-
apiVersion: extensions/v1beta1
16+
apiVersion: apps/v1
1717
kind: Deployment
1818
metadata:
1919
name: helloworld-service
@@ -33,13 +33,17 @@ spec:
3333
version: "latest"
3434
serving: "true"
3535
visualize: "true"
36+
annotations:
37+
prometheus.io/scrape: "true"
38+
prometheus.io/port: "8080"
39+
promteheus.io/path: /actuator/prometheus
3640
spec:
3741
containers:
3842
- name: helloworld-service
39-
image: saturnism/helloworld-service:latest
43+
image: gcr.io/wise-coyote-827/bootiful-helloworld-service:latest
4044
readinessProbe:
4145
httpGet:
42-
path: /health
46+
path: /actuator/health
4347
port: 8080
4448
ports:
4549
- name: http

examples-bootiful-gcp/kubernetes/mysql-deployment.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: extensions/v1beta1
1+
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: mysql
@@ -7,6 +7,9 @@ metadata:
77
visualize: "true"
88
spec:
99
replicas: 1
10+
selector:
11+
matchLabels:
12+
app: mysql
1013
template:
1114
metadata:
1215
labels:

0 commit comments

Comments
 (0)