forked from Apress/Kubernetes-Native-Development
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7a21eb2
Showing
559 changed files
with
49,665 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
tryche/ | ||
dev/env/helm-chart-sonarqube |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Local News Application | ||
|
||
## Overview | ||
|
||
The Local News application is used as a sample in the book | ||
[Kubernetes Native Development](https://www.amazon.de/Kubernetes-Native-Development-Develop-Applications/dp/1484279417) by Benjamin Schmeling and Max Dargatz. It serves to demonstrate a wealth of concepts to use Kubernetes along the software lifecycle. | ||
![](localnews-sample.png) | ||
|
||
As the name implies, it is about displaying news. The location where the respective news is placed on the map depends on the location mentioned in the news' text. An example would be a news article with the following title: "Next Sunday, there will be the Museum Embankment Festival in Frankfurt". The Local News application will analyze the text based on Natural Language Processing (NLP), will find out that the news refers to Frankfurt, and will place it into the city of Frankfurt on the map. Figure 2-1 shows a screenshot of the user interface for the local news application. The pins represent the respective news and when the user clicks on it it will display the details about the news. | ||
|
||
![](localnews-app.png) | ||
The above image provides a brief overview of the components. | ||
First of all, there is a Feed-Scraper which is regularly polling a set of given news feeds and will send the news data such as title and description to the News-Backend. The News-Backend first stores the news data in a database and then sends a request to the Location-Extractor in order to analyze the text, extract the name of the location (only the first location that is found is considered), and return it to the backend. The response will contain the longitude and latitude of the location which will then be added to original news data and updated in the database. If a user wants to see the map with the news, she can use the News-Frontend. This web application renders the map with the news by requesting the news, in the bounds defined by the map's current clipping, from the News-Backend. The backend queries its database and returns the news with the stored location. The front end marks the map with the news' location and if the user hovers over the markers she will see the news text. | ||
|
||
## Container Registry | ||
https://quay.io/organization/k8snativedev | ||
|
||
## Trying it out | ||
The easiest way is to deploy it with Helm and access the frontend via NodePort. | ||
|
||
kubectl create ns localnews | ||
helm install localnews k8s/helm-chart -n localnews |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
version: "3" | ||
services: | ||
news-frontend: | ||
build: | ||
context: news-frontend/. | ||
dockerfile: Dockerfile.dev | ||
restart: always | ||
ports: | ||
- 4200:4200 | ||
environment: | ||
- NODE_IP=localhost | ||
- NODE_PORT=8080 | ||
volumes: | ||
- ./news-frontend/src:/opt/app-root/src/src | ||
news-backend: | ||
build: | ||
context: news-backend/. | ||
dockerfile: Dockerfile.dev | ||
ports: | ||
- '8080:8080' | ||
restart: always | ||
depends_on: | ||
- postgis | ||
environment: | ||
- quarkus.datasource.jdbc.url=jdbc:postgresql://postgis:5432/news?user=postgres&password=banane | ||
- backend.nlp.url=http://location-extractor:5000/get_loc | ||
- quarkus.http.host=0.0.0.0 | ||
- quarkus-profile=dev | ||
- quarkus.datasource.devservices=false | ||
volumes: | ||
- ./news-backend/src:/app/src/ | ||
location-extractor: | ||
build: | ||
context: location_extractor/. | ||
dockerfile: Dockerfile.dev | ||
ports: | ||
- '5000:5000' | ||
restart: always | ||
volumes: | ||
- ./location_extractor/src:/app/src/ | ||
feed-scraper: | ||
build: | ||
context: feed-scraper/. | ||
dockerfile: Dockerfile.build-multi | ||
restart: always | ||
depends_on: | ||
- news-backend | ||
environment: | ||
- SCRAPER_FEEDS_URL=http://feeds.bbci.co.uk/news/world/rss.xml | ||
- SCRAPER_FEED_BACKEND_HOST=news-backend | ||
entrypoint: ["java","-jar","/usr/local/lib/feed-scraper.jar"] | ||
postgis: | ||
image: postgis/postgis:12-master | ||
ports: | ||
- 5432:5432 | ||
environment: | ||
- POSTGRESQL_DATABASE=news | ||
- PGDATA=/tmp/pgdata | ||
- POSTGRES_USER=postgres | ||
- POSTGRES_PASSWORD=banane | ||
- POSTGRES_DB=news | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
version: "3" | ||
services: | ||
news-frontend: | ||
image: quay.io/k8snativedev/news-frontend | ||
restart: always | ||
environment: | ||
- NODE_IP=localhost | ||
- NODE_PORT=8080 | ||
ports: | ||
- 4200:80 | ||
news-backend: | ||
image: quay.io/k8snativedev/news-backend | ||
ports: | ||
- '8080:8080' | ||
restart: always | ||
depends_on: | ||
- postgis | ||
environment: | ||
- quarkus.datasource.jdbc.url=jdbc:postgresql://postgis:5432/news?user=postgres&password=banane | ||
- backend.nlp.url=http://location-extractor:80/get_loc | ||
location-extractor: | ||
image: quay.io/k8snativedev/location_extractor | ||
ports: | ||
- '5000:80' | ||
restart: always | ||
feed-scraper: | ||
image: quay.io/k8snativedev/feed-scraper | ||
restart: always | ||
depends_on: | ||
- news-backend | ||
environment: | ||
- SCRAPER_FEEDS_URL=http://feeds.bbci.co.uk/news/world/rss.xml | ||
- SCRAPER_FEED_BACKEND_HOST=news-backend | ||
entrypoint: ["java","-jar","/usr/local/lib/feed-scraper.jar"] | ||
postgis: | ||
image: postgis/postgis:12-master | ||
ports: | ||
- 5432:5432 | ||
environment: | ||
- PGDATA=/tmp/pgdata | ||
- POSTGRES_USER=postgres | ||
- POSTGRES_PASSWORD=banane | ||
- POSTGRES_DB=news | ||
# networks: | ||
# - postgis | ||
# networks: | ||
# postgis: | ||
# driver: bridge | ||
|
||
|
||
|
3 changes: 3 additions & 0 deletions
3
components/feed-analysis-crd-controller/target/classes/META-INF/MANIFEST.MF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Manifest-Version: 1.0 | ||
Class-Path: | ||
|
10 changes: 10 additions & 0 deletions
10
components/feed-analysis-crd-controller/target/classes/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# If the feed scraper api is not available how often we retry, -1 = infinite, 0 = never, default is 0 | ||
crd.analysis.controller.maximumRedeliveries=-1 | ||
# If maximumRedeliveries != 0 how long (in ms) to wait with retry (exponential backoff is used!), default is 10000 | ||
crd.analysis.controller.redeliveryDelay=10000 | ||
# Hostname of the feed scraper api, default: localhost | ||
crd.analysis.controller.scraperapi.host=localhost | ||
# Port of the feed-scraper service, default: 8080 | ||
crd.analysis.controller.scraperapi.port=8080 | ||
# One of direct or job | ||
crd.analysis.controller.backend=direct |
Binary file added
BIN
+872 Bytes
...nents/feed-analysis-crd-controller/target/classes/com/apress/kubdev/rss/Application.class
Binary file not shown.
Binary file added
BIN
+1.13 KB
.../feed-analysis-crd-controller/target/classes/com/apress/kubdev/rss/CrdRoute$Backend.class
Binary file not shown.
Binary file added
BIN
+6.47 KB
components/feed-analysis-crd-controller/target/classes/com/apress/kubdev/rss/CrdRoute.class
Binary file not shown.
Binary file added
BIN
+1.6 KB
...ents/feed-analysis-crd-controller/target/classes/com/apress/kubdev/rss/FeedAnalysis.class
Binary file not shown.
Binary file added
BIN
+900 Bytes
...d-analysis-crd-controller/target/classes/com/apress/kubdev/rss/FeedAnalysisMetadata.class
Binary file not shown.
Binary file added
BIN
+811 Bytes
.../feed-analysis-crd-controller/target/classes/com/apress/kubdev/rss/FeedAnalysisSpec.class
Binary file not shown.
20 changes: 20 additions & 0 deletions
20
components/feed-analysis-crd-controller/target/classes/k8s/feed-scraper-job.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: feed-scraper-job | ||
namespace: location-extractor-dev | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- command: | ||
- java | ||
- -Dscraper.feeds.url=http://rss.cnn.com/rss/edition_world.rss | ||
- -Dscraper.feed.backend.host=news-backend | ||
- -jar | ||
- /usr/local/lib/feed-scraper.jar | ||
image: quay.io/k8snativedev/feed-scraper | ||
name: feed-scraper | ||
imagePullPolicy: Always | ||
restartPolicy: Never | ||
backoffLimit: 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="test" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" path="target/generated-sources/annotations"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="ignore_optional_problems" value="true"/> | ||
<attribute name="m2e-apt" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="ignore_optional_problems" value="true"/> | ||
<attribute name="m2e-apt" value="true"/> | ||
<attribute name="test" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>feed-scraper-pure</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
<filteredResources> | ||
<filter> | ||
<id>1632489350570</id> | ||
<name></name> | ||
<type>30</type> | ||
<matcher> | ||
<id>org.eclipse.core.resources.regexFilterMatcher</id> | ||
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments> | ||
</matcher> | ||
</filter> | ||
</filteredResources> | ||
</projectDescription> |
2 changes: 2 additions & 0 deletions
2
components/feed-scraper-pure/.settings/org.eclipse.jdt.apt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.apt.aptEnabled=false |
9 changes: 9 additions & 0 deletions
9
components/feed-scraper-pure/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 | ||
org.eclipse.jdt.core.compiler.compliance=11 | ||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore | ||
org.eclipse.jdt.core.compiler.processAnnotations=disabled | ||
org.eclipse.jdt.core.compiler.release=disabled | ||
org.eclipse.jdt.core.compiler.source=11 |
4 changes: 4 additions & 0 deletions
4
components/feed-scraper-pure/.settings/org.eclipse.m2e.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
resolveWorkspaceProjects=true | ||
version=1 |
2 changes: 2 additions & 0 deletions
2
components/feed-scraper-pure/.settings/org.jboss.ide.eclipse.as.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
eclipse.preferences.version=1 | ||
org.jboss.ide.eclipse.as.core.singledeployable.deployableList= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# | ||
# Build stage | ||
# | ||
FROM docker.io/maven:3.6.0-jdk-11-slim AS build | ||
COPY src /home/app/src | ||
COPY pom.xml /home/app | ||
RUN mvn -f /home/app/pom.xml clean package | ||
# | ||
# Package stage | ||
# | ||
FROM docker.io/openjdk:11-jre-slim | ||
COPY --from=build /home/app/target/feed-scraper-jar-with-dependencies.jar /usr/local/lib/feed-scraper.jar | ||
ENTRYPOINT ["java","-jar","/usr/local/lib/feed-scraper.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM docker.io/openjdk:11-jre-slim | ||
COPY target/feed-scraper-jar-with-dependencies.jar /usr/local/lib/feed-scraper.jar | ||
ENTRYPOINT ["java","-jar","/usr/local/lib/feed-scraper.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.apress.kubdev</groupId> | ||
<artifactId>feed-scraper-pure</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<properties> | ||
<maven.compiler.source>11</maven.compiler.source> | ||
<maven.compiler.target>11</maven.compiler.target> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.rometools</groupId> | ||
<artifactId>rome</artifactId> | ||
<version>1.15.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.squareup.okhttp</groupId> | ||
<artifactId>okhttp</artifactId> | ||
<version>2.7.5</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.sun.xml.bind</groupId> | ||
<artifactId>jaxb-impl</artifactId> | ||
<version>3.0.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.persistence</groupId> | ||
<artifactId>org.eclipse.persistence.moxy</artifactId> | ||
<version>3.0.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<version>1.2.6</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<finalName>feed-scraper</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<version>3.3.0</version> | ||
<configuration> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
<archive> | ||
<manifest> | ||
<mainClass>com.apress.kubdev.rss.Application</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>make-assembly</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Oops, something went wrong.