Skip to content

Commit

Permalink
Update POMs. Create examples-release-12
Browse files Browse the repository at this point in the history
  • Loading branch information
brendandburns committed Dec 21, 2020
1 parent 3618425 commit 16cbecf
Show file tree
Hide file tree
Showing 40 changed files with 2,804 additions and 20 deletions.
17 changes: 9 additions & 8 deletions examples/examples-release-10/pom.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<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>

<groupId>io.kubernetes</groupId>
<artifactId>client-java-examples-release-10</artifactId>
<packaging>bundle</packaging>
<name>client-java-examples-release-10</name>

<version>1.0.0</version>
<properties>
<kubernetes.client.version>10.0.0</kubernetes.client.version>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<junit.version>4.13</junit.version>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -54,6 +52,7 @@
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
Expand All @@ -69,11 +68,13 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>2.27.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
18 changes: 11 additions & 7 deletions examples/examples-release-11/pom.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<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-11</artifactId>
<packaging>bundle</packaging>
<name>client-java-examples-release-11</name>
<version>1.0.0</version>
<properties>
<kubernetes.client.version>10.0.0</kubernetes.client.version>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<junit.version>4.13</junit.version>
</properties>

<dependencies>
<dependency>
Expand Down Expand Up @@ -51,6 +52,7 @@
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
Expand All @@ -66,11 +68,13 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>2.27.2</version>
<scope>test</scope>
</dependency>
<!--for spring controller example-->
Expand Down
Empty file.
7 changes: 7 additions & 0 deletions examples/examples-release-12/Dockerfile
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"]


13 changes: 13 additions & 0 deletions examples/examples-release-12/README.md
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"
```

26 changes: 26 additions & 0 deletions examples/examples-release-12/createPod.sh
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
91 changes: 91 additions & 0 deletions examples/examples-release-12/pom.xml
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>
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);
}
}
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())));
}
}

0 comments on commit 16cbecf

Please sign in to comment.