-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update POMs. Create examples-release-12
- Loading branch information
1 parent
3618425
commit 16cbecf
Showing
40 changed files
with
2,804 additions
and
20 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
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
Empty file.
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,7 @@ | ||
FROM openjdk:8-jre | ||
|
||
COPY target/client-java-examples-*-SNAPSHOT-jar-with-dependencies.jar /examples.jar | ||
|
||
CMD ["java", "-jar", "/examples.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,13 @@ | ||
# Running examples | ||
|
||
```sh | ||
export REPO_ROOT=/path/to/client-java/repo | ||
|
||
cd ${REPO_ROOT}/kubernetes | ||
mvn install | ||
|
||
cd ${REPO_ROOT}/examples | ||
mvn package | ||
mvn exec:java -Dexec.mainClass="io.kubernetes.client.examples.Example" | ||
``` | ||
|
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,26 @@ | ||
#!/bin/bash | ||
|
||
# creates a pod and runs | ||
# Example.java(list pods for all namespaces) on starting of pod | ||
|
||
# Exit on any error. | ||
set -e | ||
|
||
if ! which minikube > /dev/null; then | ||
echo "This script requires minikube installed." | ||
exit 100 | ||
fi | ||
|
||
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
export REPO_ROOT=${dir}/.. | ||
|
||
cd ${REPO_ROOT} | ||
mvn install | ||
|
||
cd ${REPO_ROOT}/examples | ||
mvn package | ||
|
||
eval $(minikube docker-env) | ||
docker build -t test/examples:1.0 . | ||
kubectl apply -f test.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,91 @@ | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.kubernetes</groupId> | ||
<artifactId>client-java-examples-parent</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>client-java-examples-release-12</artifactId> | ||
<packaging>bundle</packaging> | ||
<name>client-java-examples-release-12</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.prometheus</groupId> | ||
<artifactId>simpleclient</artifactId> | ||
<version>0.9.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.prometheus</groupId> | ||
<artifactId>simpleclient_httpserver</artifactId> | ||
<version>0.9.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.kubernetes</groupId> | ||
<artifactId>client-java-api</artifactId> | ||
<version>${kubernetes.client.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.kubernetes</groupId> | ||
<artifactId>client-java</artifactId> | ||
<version>${kubernetes.client.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.kubernetes</groupId> | ||
<artifactId>client-java-extended</artifactId> | ||
<version>${kubernetes.client.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.kubernetes</groupId> | ||
<artifactId>client-java-spring-integration</artifactId> | ||
<version>${kubernetes.client.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.kubernetes</groupId> | ||
<artifactId>client-java-proto</artifactId> | ||
<version>${kubernetes.client.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-cli</groupId> | ||
<artifactId>commons-cli</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.kubernetes</groupId> | ||
<artifactId>client-java-cert-manager-models</artifactId> | ||
<version>0.16.1-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.kubernetes</groupId> | ||
<artifactId>client-java-prometheus-operator-models</artifactId> | ||
<version>0.38.1-SNAPSHOT</version> | ||
</dependency> | ||
<!-- test dependencies --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.tomakehurst</groupId> | ||
<artifactId>wiremock</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<!--for spring controller example--> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
<version>${spring.boot.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-actuator</artifactId> | ||
<version>${spring.boot.version}</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
|
||
</project> |
77 changes: 77 additions & 0 deletions
77
examples/examples-release-12/src/main/java/io/kubernetes/client/examples/AttachExample.java
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,77 @@ | ||
/* | ||
Copyright 2020 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package io.kubernetes.client.examples; | ||
|
||
import io.kubernetes.client.Attach; | ||
import io.kubernetes.client.openapi.ApiClient; | ||
import io.kubernetes.client.openapi.ApiException; | ||
import io.kubernetes.client.openapi.Configuration; | ||
import io.kubernetes.client.util.Config; | ||
import io.kubernetes.client.util.Streams; | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.io.OutputStream; | ||
|
||
/** | ||
* A simple example of how to use the Java API | ||
* | ||
* <p>Easiest way to run this: mvn exec:java | ||
* -Dexec.mainClass="io.kubernetes.client.examples.AttachExample" | ||
* | ||
* <p>From inside $REPO_DIR/examples | ||
*/ | ||
public class AttachExample { | ||
public static void main(String[] args) throws IOException, ApiException, InterruptedException { | ||
ApiClient client = Config.defaultClient(); | ||
Configuration.setDefaultApiClient(client); | ||
|
||
Attach attach = new Attach(); | ||
final Attach.AttachResult result = attach.attach("default", "nginx-4217019353-k5sn9", true); | ||
|
||
new Thread( | ||
new Runnable() { | ||
public void run() { | ||
BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); | ||
OutputStream output = result.getStandardInputStream(); | ||
try { | ||
while (true) { | ||
String line = in.readLine(); | ||
output.write(line.getBytes()); | ||
output.write('\n'); | ||
output.flush(); | ||
} | ||
} catch (IOException ex) { | ||
ex.printStackTrace(); | ||
} | ||
} | ||
}) | ||
.start(); | ||
|
||
new Thread( | ||
new Runnable() { | ||
public void run() { | ||
try { | ||
Streams.copy(result.getStandardOutputStream(), System.out); | ||
} catch (IOException ex) { | ||
ex.printStackTrace(); | ||
} | ||
} | ||
}) | ||
.start(); | ||
|
||
Thread.sleep(10 * 1000); | ||
result.close(); | ||
System.exit(0); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...s/examples-release-12/src/main/java/io/kubernetes/client/examples/CertManagerExample.java
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,45 @@ | ||
/* | ||
Copyright 2020 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package io.kubernetes.client.examples; | ||
|
||
import io.cert.manager.models.V1alpha2IssuerSpecSelfSigned; | ||
import io.cert.manager.models.V1beta1Issuer; | ||
import io.cert.manager.models.V1beta1IssuerList; | ||
import io.cert.manager.models.V1beta1IssuerSpec; | ||
import io.kubernetes.client.openapi.models.V1ObjectMeta; | ||
import io.kubernetes.client.util.ClientBuilder; | ||
import io.kubernetes.client.util.generic.GenericKubernetesApi; | ||
import java.io.IOException; | ||
|
||
/** | ||
* This sample creates a self signed issuer "self-signed-issuer" in default namespace on a | ||
* Kubernetes cluster where cert-manager is installed | ||
*/ | ||
public class CertManagerExample { | ||
public static void main(String[] args) throws IOException { | ||
GenericKubernetesApi<V1beta1Issuer, V1beta1IssuerList> issuerApi = | ||
new GenericKubernetesApi<>( | ||
V1beta1Issuer.class, | ||
V1beta1IssuerList.class, | ||
"cert-manager.io", | ||
"v1beta1", | ||
"issuers", | ||
ClientBuilder.defaultClient()); | ||
issuerApi.create( | ||
new V1beta1Issuer() | ||
.metadata(new V1ObjectMeta().namespace("default").name("self-signed-issuer")) | ||
.kind("Issuer") | ||
.apiVersion("cert-manager.io/v1beta1") | ||
.spec(new V1beta1IssuerSpec().selfSigned(new V1alpha2IssuerSpecSelfSigned()))); | ||
} | ||
} |
Oops, something went wrong.