Skip to content

Commit

Permalink
get working on k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-posta committed Sep 21, 2017
1 parent d274512 commit 0c570d1
Show file tree
Hide file tree
Showing 20 changed files with 699 additions and 323 deletions.
31 changes: 31 additions & 0 deletions deployment/kubernetes/core/orders/mysql-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: mysql-orders
spec:
strategy:
type: Recreate
template:
metadata:
labels:
app: ticketmonster
component: orders
spec:
containers:
- image: mysql:5.6
name: mysql
env:
# Use secret in real usage
- name: MYSQL_ROOT_PASSWORD
value: admin
- name: MYSQL_DATABASE
value: orders
- name: MYSQL_USER
value: ticket
- name: MYSQL_PASSWORD
value: monster
ports:
- containerPort: 3306
name: mysql

11 changes: 11 additions & 0 deletions deployment/kubernetes/core/orders/mysql-svc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: v1
kind: Service
metadata:
name: mysql-orders
spec:
ports:
- port: 3306
selector:
app: ticketmonster
component: orders
70 changes: 70 additions & 0 deletions deployment/kubernetes/core/orders/orders-service-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
fabric8.io/git-commit: d274512765d69ebdd100ca68c1180a7a2bc59753
fabric8.io/iconUrl: img/icons/spring-boot.svg
fabric8.io/git-branch: migrate-workshop
fabric8.io/metrics-path: dashboard/file/kubernetes-pods.json/?var-project=orders-service&var-version=1.0.0-SNAPSHOT
labels:
app: orders-service
provider: fabric8
version: 1.0.0-SNAPSHOT
group: org.ticketmonster.orders
name: orders-service
spec:
replicas: 1
selector:
matchLabels:
app: orders-service
provider: fabric8
group: org.ticketmonster.orders
template:
metadata:
annotations:
fabric8.io/git-commit: d274512765d69ebdd100ca68c1180a7a2bc59753
fabric8.io/iconUrl: img/icons/spring-boot.svg
fabric8.io/git-branch: migrate-workshop
fabric8.io/metrics-path: dashboard/file/kubernetes-pods.json/?var-project=orders-service&var-version=1.0.0-SNAPSHOT
labels:
app: orders-service
provider: fabric8
version: 1.0.0-SNAPSHOT
group: org.ticketmonster.orders
spec:
containers:
- env:
- name: SPRING_PROFILES_ACTIVE
value: kube
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: ceposta/orders-service:latest
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /health
port: 8080
scheme: HTTP
initialDelaySeconds: 180
name: spring-boot
ports:
- containerPort: 8080
name: http
protocol: TCP
- containerPort: 9779
name: prometheus
protocol: TCP
- containerPort: 8778
name: jolokia
protocol: TCP
readinessProbe:
httpGet:
path: /health
port: 8080
scheme: HTTP
initialDelaySeconds: 10
securityContext:
privileged: false
27 changes: 27 additions & 0 deletions deployment/kubernetes/core/orders/orders-service-svc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
apiVersion: v1
kind: Service
metadata:
annotations:
fabric8.io/git-commit: d274512765d69ebdd100ca68c1180a7a2bc59753
fabric8.io/iconUrl: img/icons/spring-boot.svg
fabric8.io/git-branch: migrate-workshop
prometheus.io/scrape: "true"
prometheus.io/port: "9779"
labels:
expose: "true"
app: orders-service
provider: fabric8
version: 1.0.0-SNAPSHOT
group: org.ticketmonster.orders
name: orders-service
spec:
ports:
- name: http
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: orders-service
provider: fabric8
group: org.ticketmonster.orders
8 changes: 6 additions & 2 deletions orders-service/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ Or run with spring boot:
mvn -Pmysql spring-boot:run -Dspring.profiles.active=mysql
```

To build and run with teiid:

Or to build for kubernetes (and skip Integration tests)

```
mvn -Pmysql,teiid spring-boot:run -Dspring.profiles.active=teiid
mvn clean install -Pmysql,kubernetes
```


A curl command you can use to test everything:

```
curl -X POST -H "Content-Type: application/json" -d "{\"ticketRequests\":[{\"ticketPrice\":4,\"quantity\":3}],\"email\":\"[email protected]\",\"performance\":1}" http://localhost:8080/rest/bookings
```
25 changes: 25 additions & 0 deletions orders-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<mysql.port>3306</mysql.port>
<mysql.init.timeout>60000</mysql.init.timeout>
<skipITs>true</skipITs>
<fabric8.maven.plugin.version>3.5.25</fabric8.maven.plugin.version>
<docker.image.name>ceposta/%a:%l</docker.image.name>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -251,12 +253,35 @@
<activeByDefault>false</activeByDefault>
<property>
<name>skipITs</name>
<value>true</value>
</property>
</activation>
<properties>
<docker.skip>true</docker.skip>
</properties>
</profile>
<profile>
<id>kubernetes</id>
<properties>
<fabric8.generator.name>${docker.image.name}</fabric8.generator.name>
</properties>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8.maven.plugin.version}</version>
<executions>
<execution>
<goals>
<goal>resource</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>


Expand Down
Loading

0 comments on commit 0c570d1

Please sign in to comment.