Skip to content

Commit 0d5b366

Browse files
committed
Repo Init
0 parents  commit 0d5b366

Some content is hidden

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

63 files changed

+6275
-0
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
charset = utf-8
6+
trim_trailing_whitespace = false
7+
insert_final_newline = false
8+
9+
[*.java]
10+
indent_style = space
11+
indent_size = 4
12+
13+
[*.xml]
14+
indent_style = space
15+
indent_size = 2

.gitignore

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
*.iml
2+
.idea
3+
target/
4+
build/
5+
.gradle/
6+
pom.xml.tag
7+
pom.xml.releaseBackup
8+
pom.xml.versionsBackup
9+
pom.xml.next
10+
release.properties
11+
dependency-reduced-pom.xml
12+
buildNumber.properties
13+
.mvn/timing.properties
14+
15+
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
16+
!/.mvn/wrapper/maven-wrapper.jar
17+
.settings
18+
.vscode
19+
.project
20+
.classpath
21+
docs/output/*
22+
/hello.txt
23+
.idea/
24+
25+
#
26+
04-build/knative/maven-build.yaml
27+
04-build/knative/maven-build-template.yaml
28+
04-build/knative/service-build.yaml
29+
04-build/knative/service-build-template.yaml
30+
04-build/knative/docker-secret.yaml
31+
+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
*/
19+
20+
import java.net.*;
21+
import java.io.*;
22+
import java.nio.channels.*;
23+
import java.util.Properties;
24+
25+
public class MavenWrapperDownloader {
26+
27+
/**
28+
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
29+
*/
30+
private static final String DEFAULT_DOWNLOAD_URL =
31+
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
32+
33+
/**
34+
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
35+
* use instead of the default one.
36+
*/
37+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
38+
".mvn/wrapper/maven-wrapper.properties";
39+
40+
/**
41+
* Path where the maven-wrapper.jar will be saved to.
42+
*/
43+
private static final String MAVEN_WRAPPER_JAR_PATH =
44+
".mvn/wrapper/maven-wrapper.jar";
45+
46+
/**
47+
* Name of the property which should be used to override the default download url for the wrapper.
48+
*/
49+
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
50+
51+
public static void main(String args[]) {
52+
System.out.println("- Downloader started");
53+
File baseDirectory = new File(args[0]);
54+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
55+
56+
// If the maven-wrapper.properties exists, read it and check if it contains a custom
57+
// wrapperUrl parameter.
58+
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
59+
String url = DEFAULT_DOWNLOAD_URL;
60+
if(mavenWrapperPropertyFile.exists()) {
61+
FileInputStream mavenWrapperPropertyFileInputStream = null;
62+
try {
63+
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
64+
Properties mavenWrapperProperties = new Properties();
65+
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
66+
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
67+
} catch (IOException e) {
68+
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
69+
} finally {
70+
try {
71+
if(mavenWrapperPropertyFileInputStream != null) {
72+
mavenWrapperPropertyFileInputStream.close();
73+
}
74+
} catch (IOException e) {
75+
// Ignore ...
76+
}
77+
}
78+
}
79+
System.out.println("- Downloading from: : " + url);
80+
81+
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
82+
if(!outputFile.getParentFile().exists()) {
83+
if(!outputFile.getParentFile().mkdirs()) {
84+
System.out.println(
85+
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
86+
}
87+
}
88+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
89+
try {
90+
downloadFileFromURL(url, outputFile);
91+
System.out.println("Done");
92+
System.exit(0);
93+
} catch (Throwable e) {
94+
System.out.println("- Error downloading");
95+
e.printStackTrace();
96+
System.exit(1);
97+
}
98+
}
99+
100+
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
101+
URL website = new URL(urlString);
102+
ReadableByteChannel rbc;
103+
rbc = Channels.newChannel(website.openStream());
104+
FileOutputStream fos = new FileOutputStream(destination);
105+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
106+
fos.close();
107+
rbc.close();
108+
}
109+
110+
}

.mvn/wrapper/maven-wrapper.jar

47.2 KB
Binary file not shown.

.mvn/wrapper/maven-wrapper.properties

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip

01-basics/.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
charset = utf-8
6+
trim_trailing_whitespace = false
7+
insert_final_newline = false
8+
9+
[*.java]
10+
indent_style = space
11+
indent_size = 4
12+
13+
[*.xml]
14+
indent_style = space
15+
indent_size = 2

01-basics/bin/call.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
INGRESSGATEWAY=istio-ingressgateway
4+
IP_ADDRESS="$(minishift ip):$(kubectl get svc $INGRESSGATEWAY --namespace istio-system --output 'jsonpath={.spec.ports[?(@.port==80)].nodePort}')"
5+
6+
curl -H "Host: greeter.myproject.example.com" $IP_ADDRESS

01-basics/knative/service-env.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: serving.knative.dev/v1alpha1
2+
kind: Service
3+
metadata:
4+
name: greeter
5+
spec:
6+
runLatest:
7+
configuration:
8+
revisionTemplate:
9+
spec:
10+
container:
11+
image: dev.local/rhdevelopers/greeter:0.0.1
12+
env:
13+
- name: MESSAGE_PREFIX
14+
value: Hello
15+
livenessProbe:
16+
httpGet:
17+
path: /healthz
18+
readinessProbe:
19+
httpGet:
20+
path: /healthz
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: serving.knative.dev/v1alpha1
2+
kind: Service
3+
metadata:
4+
name: greeter
5+
spec:
6+
pinned:
7+
revisionName: greeter-00001
8+
configuration:
9+
revisionTemplate:
10+
spec:
11+
container:
12+
image: dev.local/rhdevelopers/greeter:0.0.1
13+
env:
14+
- name: MESSAGE_PREFIX
15+
value: Hello
16+
livenessProbe:
17+
httpGet:
18+
path: /healthz
19+
readinessProbe:
20+
httpGet:
21+
path: /healthz
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: serving.knative.dev/v1alpha1
2+
kind: Service
3+
metadata:
4+
name: greeter
5+
spec:
6+
pinned:
7+
revisionName: greeter-00002
8+
configuration:
9+
revisionTemplate:
10+
spec:
11+
container:
12+
image: dev.local/rhdevelopers/greeter:0.0.1
13+
env:
14+
- name: MESSAGE_PREFIX
15+
value: Hello
16+
livenessProbe:
17+
httpGet:
18+
path: /healthz
19+
readinessProbe:
20+
httpGet:
21+
path: /healthz

01-basics/knative/service.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: serving.knative.dev/v1alpha1
2+
kind: Service
3+
metadata:
4+
name: greeter
5+
spec:
6+
runLatest:
7+
configuration:
8+
revisionTemplate:
9+
spec:
10+
container:
11+
image: dev.local/rhdevelopers/greeter:0.0.1
12+
livenessProbe:
13+
httpGet:
14+
path: /healthz
15+
readinessProbe:
16+
httpGet:
17+
path: /healthz

02-configs-and-routes/bin/call.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
INGRESSGATEWAY=istio-ingressgateway
6+
IP_ADDRESS="$(minishift ip):$(kubectl get svc $INGRESSGATEWAY --namespace istio-system --output 'jsonpath={.spec.ports[?(@.port==80)].nodePort}')"
7+
8+
while true
9+
do
10+
curl -H "Host: greeter.knativetutorial.example.com" $IP_ADDRESS
11+
echo ""
12+
sleep .2
13+
done;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: serving.knative.dev/v1alpha1
2+
kind: Configuration
3+
metadata:
4+
name: greeter
5+
spec:
6+
revisionTemplate:
7+
metadata:
8+
labels:
9+
app: greeter
10+
spec:
11+
container:
12+
image: dev.local/rhdevelopers/greeter:0.0.1
13+
livenessProbe:
14+
httpGet:
15+
path: /healthz
16+
readinessProbe:
17+
httpGet:
18+
path: /healthz
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: serving.knative.dev/v1alpha1
2+
kind: Configuration
3+
metadata:
4+
name: greeter
5+
spec:
6+
revisionTemplate:
7+
metadata:
8+
labels:
9+
app: greeter
10+
spec:
11+
container:
12+
image: dev.local/rhdevelopers/greeter:0.0.1
13+
env:
14+
- name: MESSAGE_PREFIX
15+
value: Hello
16+
livenessProbe:
17+
httpGet:
18+
path: /healthz
19+
readinessProbe:
20+
httpGet:
21+
path: /healthz
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: serving.knative.dev/v1alpha1
2+
kind: Route
3+
metadata:
4+
name: greeter
5+
spec:
6+
traffic:
7+
- revisionName: greeter-00001
8+
percent: 100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: serving.knative.dev/v1alpha1
2+
kind: Route
3+
metadata:
4+
name: greeter
5+
spec:
6+
traffic:
7+
- revisionName: greeter-00002
8+
percent: 100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: serving.knative.dev/v1alpha1
2+
kind: Route
3+
metadata:
4+
name: greeter
5+
spec:
6+
traffic:
7+
- configurationName: greeter
8+
percent: 100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: serving.knative.dev/v1alpha1
2+
kind: Route
3+
metadata:
4+
name: greeter
5+
spec:
6+
traffic:
7+
- revisionName: greeter-00001
8+
percent: 10
9+
- revisionName: greeter-00002
10+
percent: 90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: serving.knative.dev/v1alpha1
2+
kind: Route
3+
metadata:
4+
name: greeter
5+
spec:
6+
traffic:
7+
- revisionName: greeter-00001
8+
percent: 50
9+
- revisionName: greeter-00002
10+
percent: 50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: serving.knative.dev/v1alpha1
2+
kind: Route
3+
metadata:
4+
name: greeter
5+
spec:
6+
traffic:
7+
- revisionName: greeter-00001
8+
percent: 75
9+
- revisionName: greeter-00002
10+
percent: 25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data.scale-to-zero-grace-period: 1m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data.scale-to-zero-grace-period: 2m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data.scale-to-zero-grace-period: 30s

0 commit comments

Comments
 (0)