Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for cloud-based platforms #7

Merged
merged 15 commits into from
Sep 1, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
This version has been adapter to Spring Boot 2.3 support for docker i…
…mages, and supports deploying to Cloud Foundry and Kubernetes with free Wavefront monitoring.
odedia committed Aug 2, 2020
commit 035fa2327259b8a222e6c59f6c9cabc52a35c18e
315 changes: 282 additions & 33 deletions README.md

Large diffs are not rendered by default.

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
tag: latest

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
@@ -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"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With layered Jar of Spring Boot 2.3, don't we have to use the `org.springframework.boot.loader.JarLauncher?

ports:
- 8761:8761

@@ -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

@@ -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

@@ -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

@@ -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

@@ -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

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.
50 changes: 50 additions & 0 deletions k8s/api-gateway-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: api-gateway
name: api-gateway
namespace: spring-pet-clinic
spec:
replicas: 1
selector:
matchLabels:
app: api-gateway
strategy: {}
template:
metadata:
labels:
app: api-gateway
spec:
containers:
- image: ${REPOSITORY_PREFIX}/api-gateway:latest
name: api-gateway
imagePullPolicy: Always
livenessProbe:
httpGet:
port: 8080
path: /actuator/health
initialDelaySeconds: 90
periodSeconds: 2
readinessProbe:
httpGet:
port: 8080
path: /actuator/health
initialDelaySeconds: 15
resources:
limits:
memory: 1Gi
requests:
cpu: 2000m
memory: 1Gi
env:
- 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: {}
restartPolicy: Always
status: {}
60 changes: 60 additions & 0 deletions k8s/customers-service-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
labels:
app: customers-service
name: customers-service
namespace: spring-pet-clinic
spec:
replicas: 1
selector:
matchLabels:
app: customers-service
strategy: {}
template:
metadata:
labels:
app: customers-service
spec:
containers:
- image: ${REPOSITORY_PREFIX}/customers-service:latest
name: customers-service
imagePullPolicy: Always
livenessProbe:
httpGet:
port: 8080
path: /actuator/health
initialDelaySeconds: 90
periodSeconds: 2
readinessProbe:
httpGet:
port: 8080
path: /actuator/health
initialDelaySeconds: 15
resources:
limits:
memory: 1Gi
requests:
cpu: 2000m
memory: 1Gi
env:
- 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
- name: SPRING_DATASOURCE_USERNAME
value: root
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
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: {}
restartPolicy: Always
status: {}
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
108 changes: 108 additions & 0 deletions k8s/init-services/02-config-map.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
kind: ConfigMap
apiVersion: v1
metadata:
name: pet-clinic-config
namespace: spring-pet-clinic
data:
application.yaml: |-
server:
port: 8080
compression:
enabled: true
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:
restart:
enabled: true
metrics:
enabled: true
prometheus:
enabled: true
endpoints:
web:
exposure:
include: '*'
metrics:
export:
prometheus:
enabled: true
wavefront:
enabled: true
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: vists

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks.

spring:
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
config:
# 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
cloud:
kubernetes:
discovery:
enabled: true
loadbalancer:
ribbon:
enabled: false
gateway:
x-forwarded:
enabled: true
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
vets:
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