Skip to content

Commit bed5ae8

Browse files
authored
Add files via upload
1 parent 6b065ec commit bed5ae8

File tree

41 files changed

+1304
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1304
-1
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
# docker-kubernetes-java-project
1+
# docker-Java-kubernetes-project
2+
Deploying Java Applications with Docker and Kubernetes
3+
4+
Credit: https://github.com/danielbryantuk/oreilly-docker-java-shopping/
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: productcatalogue
6+
labels:
7+
app: productcatalogue
8+
spec:
9+
type: NodePort
10+
selector:
11+
app: productcatalogue
12+
ports:
13+
- protocol: TCP
14+
port: 8020
15+
name: http
16+
17+
---
18+
apiVersion: apps/v1
19+
kind: Deployment
20+
metadata:
21+
name: productcatalogue
22+
spec:
23+
selector:
24+
matchLabels:
25+
app: productcatalogue
26+
replicas: 1
27+
template:
28+
metadata:
29+
labels:
30+
app: productcatalogue
31+
spec:
32+
containers:
33+
- name: productcatalogue
34+
image: taniaduggal60/productcatalogue:latest
35+
ports:
36+
- containerPort: 8020
37+
livenessProbe:
38+
httpGet:
39+
path: /healthcheck
40+
port: 8025
41+
initialDelaySeconds: 30
42+
timeoutSeconds: 1

kubernetes/shopfront-service.yaml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: shopfront
6+
labels:
7+
app: shopfront
8+
spec:
9+
type: NodePort
10+
selector:
11+
app: shopfront
12+
ports:
13+
- protocol: TCP
14+
port: 8010
15+
name: http
16+
17+
---
18+
apiVersion: apps/v1
19+
kind: Deployment
20+
metadata:
21+
name: shopfront
22+
spec:
23+
selector:
24+
matchLabels:
25+
app: shopfront
26+
replicas: 1
27+
template:
28+
metadata:
29+
labels:
30+
app: shopfront
31+
spec:
32+
containers:
33+
<<<<<<< HEAD
34+
- name: shopfront
35+
image: taniaduggal60/shopfront:latest
36+
ports:
37+
- containerPort: 8010
38+
livenessProbe:
39+
httpGet:
40+
path: /health
41+
port: 8010
42+
initialDelaySeconds: 30
43+
timeoutSeconds: 1
44+
=======
45+
- name: shopfront
46+
image: taniaduggal60/shopfront:latest
47+
ports:
48+
- containerPort: 8010
49+
livenessProbe:
50+
httpGet:
51+
path: /health
52+
port: 8010
53+
initialDelaySeconds: 30
54+
timeoutSeconds: 1
55+
>>>>>>> 0a33241a7ef6870469dcde517a493fa33c2cf955

kubernetes/stockmanager-service.yaml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: stockmanager
6+
labels:
7+
app: stockmanager
8+
spec:
9+
type: NodePort
10+
selector:
11+
app: stockmanager
12+
ports:
13+
- protocol: TCP
14+
port: 8030
15+
name: http
16+
17+
---
18+
apiVersion: apps/v1
19+
kind: Deployment
20+
metadata:
21+
name: stockmanager
22+
spec:
23+
spec:
24+
selector:
25+
matchLabels:
26+
app: stockmanager
27+
replicas: 1
28+
template:
29+
metadata:
30+
labels:
31+
app: stockmanager
32+
spec:
33+
containers:
34+
- name: stockmanager
35+
image: taniaduggal60/stockmanager:latest
36+
ports:
37+
- containerPort: 8030
38+
livenessProbe:
39+
httpGet:
40+
path: /health
41+
port: 8030
42+
initialDelaySeconds: 30
43+
timeoutSeconds: 1

productcatalogue/Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM openjdk:8-jre
2+
ADD target/productcatalogue-0.0.1-SNAPSHOT.jar app.jar
3+
ADD product-catalogue.yml app-config.yml
4+
EXPOSE 8020
5+
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","app.jar", "server", "app-config.yml"]

productcatalogue/pom.xml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>uk.co.danielbryant.djshopping</groupId>
8+
<artifactId>productcatalogue</artifactId>
9+
<version>0.0.1-SNAPSHOT</version>
10+
11+
<properties>
12+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13+
<dropwizard.version>1.3.27</dropwizard.version>
14+
<guice.version>4.2.3</guice.version>
15+
</properties>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>io.dropwizard</groupId>
20+
<artifactId>dropwizard-core</artifactId>
21+
<version>${dropwizard.version}</version>
22+
</dependency>
23+
<dependency>
24+
<groupId>com.google.inject</groupId>
25+
<artifactId>guice</artifactId>
26+
<version>${guice.version}</version>
27+
</dependency>
28+
</dependencies>
29+
30+
31+
<build>
32+
<plugins>
33+
<plugin>
34+
<groupId>org.apache.maven.plugins</groupId>
35+
<artifactId>maven-compiler-plugin</artifactId>
36+
<configuration>
37+
<source>1.8</source>
38+
<target>1.8</target>
39+
</configuration>
40+
</plugin>
41+
<plugin>
42+
<groupId>org.apache.maven.plugins</groupId>
43+
<artifactId>maven-shade-plugin</artifactId>
44+
<version>1.6</version>
45+
<configuration>
46+
<createDependencyReducedPom>true</createDependencyReducedPom>
47+
<filters>
48+
<filter>
49+
<artifact>*:*</artifact>
50+
<excludes>
51+
<exclude>META-INF/*.SF</exclude>
52+
<exclude>META-INF/*.DSA</exclude>
53+
<exclude>META-INF/*.RSA</exclude>
54+
</excludes>
55+
</filter>
56+
</filters>
57+
</configuration>
58+
<executions>
59+
<execution>
60+
<phase>package</phase>
61+
<goals>
62+
<goal>shade</goal>
63+
</goals>
64+
<configuration>
65+
<transformers>
66+
<transformer
67+
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
68+
<transformer
69+
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
70+
<mainClass>uk.co.danielbryant.djshopping.productcatalogue.ProductServiceApplication</mainClass>
71+
</transformer>
72+
</transformers>
73+
</configuration>
74+
</execution>
75+
</executions>
76+
</plugin>
77+
</plugins>
78+
</build>
79+
</project>
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 1.0-SNAPSHOT
2+
3+
4+
server:
5+
applicationConnectors:
6+
- type: http
7+
port: 8020
8+
adminConnectors:
9+
- type: http
10+
port: 8025
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package uk.co.danielbryant.djshopping.productcatalogue;
2+
3+
import com.google.inject.Guice;
4+
import com.google.inject.Injector;
5+
import io.dropwizard.Application;
6+
import io.dropwizard.setup.Bootstrap;
7+
import io.dropwizard.setup.Environment;
8+
import uk.co.danielbryant.djshopping.productcatalogue.healthchecks.BasicHealthCheck;
9+
import uk.co.danielbryant.djshopping.productcatalogue.configuration.ProductServiceConfiguration;
10+
import uk.co.danielbryant.djshopping.productcatalogue.resources.ProductResource;
11+
12+
public class ProductServiceApplication extends Application<ProductServiceConfiguration> {
13+
public static void main(String[] args) throws Exception {
14+
new ProductServiceApplication().run(args);
15+
}
16+
17+
@Override
18+
public String getName() {
19+
return "product-list-service";
20+
}
21+
22+
@Override
23+
public void initialize(Bootstrap<ProductServiceConfiguration> bootstrap) {
24+
// nothing to do yet
25+
}
26+
27+
@Override
28+
public void run(ProductServiceConfiguration config,
29+
Environment environment) {
30+
final BasicHealthCheck healthCheck = new BasicHealthCheck(config.getVersion());
31+
environment.healthChecks().register("template", healthCheck);
32+
33+
Injector injector = Guice.createInjector();
34+
environment.jersey().register(injector.getInstance(ProductResource.class));
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package uk.co.danielbryant.djshopping.productcatalogue.configuration;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import io.dropwizard.Configuration;
5+
import org.hibernate.validator.constraints.NotEmpty;
6+
7+
public class ProductServiceConfiguration extends Configuration {
8+
9+
@NotEmpty
10+
private String version;
11+
12+
@JsonProperty
13+
public String getVersion() {
14+
return version;
15+
}
16+
17+
@JsonProperty
18+
public void setVersion(String version) {
19+
this.version = version;
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package uk.co.danielbryant.djshopping.productcatalogue.healthchecks;
2+
3+
import com.codahale.metrics.health.HealthCheck;
4+
5+
public class BasicHealthCheck extends HealthCheck {
6+
7+
private final String version;
8+
9+
public BasicHealthCheck(String version) {
10+
this.version = version;
11+
}
12+
13+
@Override
14+
protected Result check() throws Exception {
15+
return Result.healthy("Ok with version: " + version);
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package uk.co.danielbryant.djshopping.productcatalogue.model;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
import java.math.BigDecimal;
6+
7+
public class Product {
8+
private String id;
9+
private String name;
10+
private String description;
11+
private BigDecimal price;
12+
13+
public Product() {
14+
// Needed for Jackson deserialization
15+
}
16+
17+
public Product(String id, String name, String description, BigDecimal price) {
18+
this.id = id;
19+
this.name = name;
20+
this.description = description;
21+
this.price = price;
22+
}
23+
24+
@JsonProperty
25+
public String getId() {
26+
return id;
27+
}
28+
29+
@JsonProperty
30+
public String getName() {
31+
return name;
32+
}
33+
34+
@JsonProperty
35+
public String getDescription() {
36+
return description;
37+
}
38+
39+
@JsonProperty
40+
public BigDecimal getPrice() {
41+
return price;
42+
}
43+
}

0 commit comments

Comments
 (0)