Skip to content

Commit

Permalink
Merge pull request spring-petclinic#7 from odedia/master
Browse files Browse the repository at this point in the history
Support for cloud-based platforms
  • Loading branch information
arey committed Sep 1, 2020
2 parents b7b6540 + 2d4141c commit c72a4f3
Show file tree
Hide file tree
Showing 92 changed files with 5,281 additions and 1,198 deletions.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ target/

# Branch switching
generated/
.DS_Store
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
language: java
jdk: openjdk8
jdk: openjdk11
38 changes: 38 additions & 0 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
resource_types:
- name: cf-cli-resource
type: docker-image
source:
repository: nulldriver/cf-cli-resource
***REMOVED***

resources:
- name: cf
type: cf
source:
api: ((cf-api))
username: ((cf-username))
password: ((cf-password))
organization: ((cf-org))
space: ((cf-space))
- name: docker-image
type: docker-image
source:
repository: spring-petclinic/api-gateway

jobs:
- name: deploy
plan:
- get: docker-image
trigger: true
params:
globs: [ "((app)).jar", "manifest.yml" ]
- put: cf
params:
manifest: github-prerelease/manifest.yml
current_app_name: ((app))
- put: cf-add-network-policy
resource: cf-env
params:
command: add-network-policy
source_app: cloudnativepoll-webui
destination_app: cloudnativepoll-backend
12 changes: 6 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
mem_limit: 512M
depends_on:
- config-server
entrypoint: ["./dockerize","-wait=tcp://config-server:8888","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
entrypoint: ["./dockerize","-wait=tcp://config-server:8888","-timeout=60s","--","java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
ports:
- 8761:8761

Expand All @@ -25,7 +25,7 @@ services:
depends_on:
- config-server
- discovery-server
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
ports:
- 8081:8081

Expand All @@ -36,7 +36,7 @@ services:
depends_on:
- config-server
- discovery-server
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
ports:
- 8082:8082

Expand All @@ -47,7 +47,7 @@ services:
depends_on:
- config-server
- discovery-server
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
ports:
- 8083:8083

Expand All @@ -58,7 +58,7 @@ services:
depends_on:
- config-server
- discovery-server
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
ports:
- 8080:8080

Expand All @@ -78,7 +78,7 @@ services:
depends_on:
- config-server
- discovery-server
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"]
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
ports:
- 9090:9090

Expand Down
Binary file added docs/wavefront-k8s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/wavefront-summary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/wavefront-traces.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 0 additions & 15 deletions includes/kind.mk

This file was deleted.

Binary file added k8s/.DS_Store
Binary file not shown.
54 changes: 54 additions & 0 deletions k8s/api-gateway-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: api-gateway
name: api-gateway
namespace: spring-pet-clinic
***REMOVED***
replicas: 1
selector:
matchLabels:
app: api-gateway
strategy: {***REMOVED***
template:
metadata:
labels:
app: api-gateway
***REMOVED***
containers:
- image: ${REPOSITORY_PREFIX***REMOVED***/***REMOVED***latest
name: api-gateway
imagePullPolicy: Always
livenessProbe:
httpGet:
port: 8080
path: /actuator/health/liveness
initialDelaySeconds: 90
periodSeconds: 5
readinessProbe:
httpGet:
port: 8080
path: /actuator/health/readiness
initialDelaySeconds: 15
lifecycle:
preStop:
exec:
command: ["sh", "-c", "sleep 10"]
resources:
limits:
memory: 1Gi
requests:
cpu: 2000m
memory: 1Gi
***REMOVED***
- name: SPRING_PROFILES_ACTIVE
value: kubernetes
- name: MANAGEMENT_METRICS_EXPORT_WAVEFRONT_URI
value: proxy://wavefront-proxy.spring-pet-clinic.svc.cluster.local:2878
ports:
- containerPort: 8080
resources: {***REMOVED***
restartPolicy: Always
status: {***REMOVED***
64 changes: 64 additions & 0 deletions k8s/customers-service-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
labels:
app: customers-service
name: customers-service
namespace: spring-pet-clinic
***REMOVED***
replicas: 1
selector:
matchLabels:
app: customers-service
strategy: {***REMOVED***
template:
metadata:
labels:
app: customers-service
***REMOVED***
containers:
- image: ${REPOSITORY_PREFIX***REMOVED***/customers-service:latest
name: customers-service
imagePullPolicy: Always
livenessProbe:
httpGet:
port: 8080
path: /actuator/health/liveness
initialDelaySeconds: 90
periodSeconds: 5
readinessProbe:
httpGet:
port: 8080
path: /actuator/health/readiness
initialDelaySeconds: 15
lifecycle:
preStop:
exec:
command: ["sh", "-c", "sleep 10"]
resources:
limits:
memory: 1Gi
requests:
cpu: 2000m
memory: 1Gi
***REMOVED***
- name: SPRING_PROFILES_ACTIVE
value: kubernetes
- name: SPRING_DATASOURCE_URL
value: jdbc:mysql://customers-db-mysql.spring-pet-clinic.svc.cluster.local:3306/my_database?queryInterceptors=brave.mysql8.TracingQueryInterceptor&exceptionInterceptors=brave.mysql8.TracingExceptionInterceptor&zipkinServiceName=customers-db
***REMOVED***
value: root
***REMOVED***
***REMOVED***
***REMOVED***
name: customers-db-mysql
key: mysql-root-password
- name: MANAGEMENT_METRICS_EXPORT_WAVEFRONT_URI
value: proxy://wavefront-proxy.spring-pet-clinic.svc.cluster.local:2878
ports:
- containerPort: 8080
resources: {***REMOVED***
restartPolicy: Always
status: {***REMOVED***
Binary file added k8s/init-namespace/.DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions k8s/init-namespace/01-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: spring-pet-clinic
118 changes: 118 additions & 0 deletions k8s/init-services/02-config-map.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
kind: ConfigMap
apiVersion: v1
metadata:
name: pet-clinic-config
namespace: spring-pet-clinic
data:
application.yaml: |-
server:
shutdown: graceful
lifecycle:
timeout-per-shutdown-phase: 15
port: 8080
compression:
***REMOVED***
mime-types: application/json,text/css,application/javascript
min-response-size: 2048

wavefront:
application:
name: spring-pet-clinic-k8s
freemium-account: true

# Logging
logging.level.org.springframework: INFO

# Metrics
management:
endpoint:
health:
probes:
***REMOVED***
health:
livenessState:
***REMOVED***
readinessState:
***REMOVED***
restart:
***REMOVED***
metrics:
***REMOVED***
prometheus:
***REMOVED***
endpoints:
web:
exposure:
include: '*'
metrics:
export:
prometheus:
***REMOVED***
wavefront:
***REMOVED***

customers-service-id: http://customers-service.spring-pet-clinic.svc.cluster.local:8080
visits-service-id: http://vists-service.spring-pet-clinic.svc.cluster.local:8080

***REMOVED***
datasource:
schema: classpath*:db/mysql/schema.sql
data: classpath*:db/mysql/data.sql
platform: mysql
initialization-mode: always

jpa:
show-sql: true
hibernate:
ddl-auto: none
generate-ddl: false
sleuth:
sampler:
probability: 1.0
***REMOVED***
# Allow the microservices to override the remote properties with their own System properties or config file
allow-override: true
# Override configuration with any local property source
override-none: true
messages:
basename: messages/messages
***REMOVED***
***REMOVED***
discovery:
***REMOVED***
loadbalancer:
ribbon:
***REMOVED***
gateway:
x-forwarded:
***REMOVED***
for-enabled: true
proto-enabled: true
host-append: false
port-append: false
proto-append: false
routes:
- id: vets-service
uri: http://vets-service.spring-pet-clinic.svc.cluster.local:8080
predicates:
- Path=/api/vet/**
filters:
- StripPrefix=2
- id: visits-service
uri: http://visits-service.spring-pet-clinic.svc.cluster.local:8080
predicates:
- Path=/api/visit/**
filters:
- StripPrefix=2
- id: customers-service
uri: http://customers-service.spring-pet-clinic.svc.cluster.local:8080
predicates:
- Path=/api/customer/**
filters:
- StripPrefix=2
***REMOVED***
cache:
ttl: 60
heap-size: 101

25 changes: 25 additions & 0 deletions k8s/init-services/03-role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: spring-pet-clinic
name: namespace-reader
rules:
- apiGroups: ["", "extensions", "apps"]
resources: ["configmaps", "pods", "services", "endpoints", "secrets"]
verbs: ["get", "list", "watch"]

---

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: namespace-reader-binding
namespace: spring-pet-clinic
subjects:
- kind: ServiceAccount
name: default
apiGroup: ""
roleRef:
kind: Role
name: namespace-reader
apiGroup: ""
Loading

0 comments on commit c72a4f3

Please sign in to comment.