Giter Site home page Giter Site logo

zy475459736 / java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kubernetes-client/java

0.0 2.0 0.0 4.59 MB

Official Java client library for kubernetes

Home Page: http://kubernetes.io/

License: Apache License 2.0

Scala 0.01% Java 99.98% Shell 0.02%

java's Introduction

Kubernetes Java Client

Build Status Client Capabilities Client Support Level

Java client for the kubernetes API.

Installation

To install the Java client library to your local Maven repository, simply execute:

git clone --recursive https://github.com/kubernetes-client/java
cd java
mvn install

Refer to the official documentation for more information.

Maven users

Add this dependency to your project's POM:

<dependency>
    <groupId>io.kubernetes</groupId>
    <artifactId>client-java</artifactId>
    <version>3.0.0</version>
    <scope>compile</scope>
</dependency>

Gradle users

compile 'io.kubernetes:client-java:3.0.0'

Others

At first generate the JAR by executing:

git clone --recursive https://github.com/kubernetes-client/java
cd java
cd kubernetes
mvn package

Then manually install the following JARs:

  • target/client-java-api-4.0.0-beta1-SNAPSHOT.jar
  • target/lib/*.jar

Example

list all pods:

import io.kubernetes.client.ApiClient;
import io.kubernetes.client.ApiException;
import io.kubernetes.client.Configuration;
import io.kubernetes.client.apis.CoreV1Api;
import io.kubernetes.client.models.V1Pod;
import io.kubernetes.client.models.V1PodList;
import io.kubernetes.client.util.Config;

import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException, ApiException{
        ApiClient client = Config.defaultClient();
        Configuration.setDefaultApiClient(client);

        CoreV1Api api = new CoreV1Api();
        V1PodList list = api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null);
        for (V1Pod item : list.getItems()) {
            System.out.println(item.getMetadata().getName());
        }
    }
}

watch on namespace object:

import com.google.gson.reflect.TypeToken;
import io.kubernetes.client.ApiClient;
import io.kubernetes.client.ApiException;
import io.kubernetes.client.Configuration;
import io.kubernetes.client.apis.CoreV1Api;
import io.kubernetes.client.models.V1Namespace;
import io.kubernetes.client.util.Config;
import io.kubernetes.client.util.Watch;

import java.io.IOException;

public class WatchExample {
    public static void main(String[] args) throws IOException, ApiException{
        ApiClient client = Config.defaultClient();
        Configuration.setDefaultApiClient(client);

        CoreV1Api api = new CoreV1Api();

        Watch<V1Namespace> watch = Watch.createWatch(
                client,
                api.listNamespaceCall(null, null, null, null, null, 5, null, null, Boolean.TRUE, null, null),
                new TypeToken<Watch.Response<V1Namespace>>(){}.getType());

        for (Watch.Response<V1Namespace> item : watch) {
            System.out.printf("%s : %s%n", item.type, item.object.getMetadata().getName());
        }
    }
}

More examples can be found in examples folder. To run examples, run this command:

mvn exec:java -Dexec.mainClass="io.kubernetes.client.examples.Example"

Documentation

All APIs and Models' documentation can be found at the Generated client's README file

Compatibility

client version 1.8 1.9 1.10 1.11
1.0.0 - - -
2.0.0 + - -
3.0.0 + + +

Key:

  • Exactly the same features / API objects in both java-client and the Kubernetes version.
  • + java-client has features or api objects that may not be present in the Kubernetes cluster, but everything they have in common will work.
  • - The Kubernetes cluster has features the java-client library can't use (additional API objects, etc).

See the CHANGELOG for a detailed description of changes between java-client versions.

Contributing

Please see CONTRIBUTING.md for instructions on how to contribute.

Code of Conduct

Participation in the Kubernetes community is governed by the CNCF Code of Conduct.

Development

Update the generated code.

The code is generated by the swagger-codegen project.

We have built general purpose cross-language tools for generating code, it is hosted in the kubernetes-client/gen repository.

To get started, in a root directory that is not your java client directory, for example your directory layout could be:

${HOME}/
        src/
             gen/
             java/
...

Then to clone the gen repository, you would run:

cd ${HOME}/src
git clone https://github.com/kubernetes-client/gen
export GEN_ROOT=${PWD}

Then to update the client:

cd ${HOME}/src/java
${GEN_ROOT}/gen/openapi/java.sh kubernetes ./settings

This should run through a long-ish build process involving docker and eventually result in a new set of generated code in the kubernetes directory.

java's People

Contributors

brendandburns avatar mbohlool avatar brendanburns avatar karthikkondapally avatar lewisheadden avatar k8s-ci-robot avatar yoshioterada avatar rjeberhard avatar lwander avatar archcosmo avatar ukclivecox avatar elek avatar jzwlqx avatar scholzj avatar iocanel avatar davidxia avatar takashima0411 avatar fbalicchia avatar yu-shiba avatar rrayst avatar timothyjosefik avatar westse avatar saskiawagenaar avatar russgold avatar remmeier avatar nikhita avatar nicolaferraro avatar mmmaks avatar jac-stripe avatar joelhandwell avatar

Watchers

James Cloos avatar DrewZ avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.