Manipulating the Kubernetes API with Java

Manipulating the Kubernetes API with Java

Kubernetes API.Objective of this paper

Based on the official kubernetes-client/java class library, the addition, deletion, modification and inspection or event monitoring (watch) of kubenetes native resource objects (pod, node, namespace, servcie , deployment) and custom resource objects (such as cluster) are realized through java .

k8s-client-java selection
Currently operating k8s through java, there are two open source versions:
Use of kubernetes-client/java
API resources use REST mode.
kube-apiserver supports both https (default listening on port 6443) and http API (default listening on port 8080 of The http API is a non-secure interface and does not do any authentication and authorization mechanism. It is not recommended to enable it in production environments. Both interfaces provide the same REST API format

1.GET / : Get a list of resources of a certain type, for example GET /pods returns a list of Pod resources.
2.POST / : Creates a resource from a user-provided JSON object.
3.GET // : Get a single resource by the given name (Name), for example GET /pods/first returns a Pod named "first".
4.DELETE // : delete a single resource by the given name, the graceful deletion time ( GracePeriodSeconds ) that can be specified in the delete option ( DeleteOptions ), this option indicates the slave service The time interval (in seconds) from when the client receives a delete request to when the resource is deleted.
5.PUT // : Update or create a resource with the given resource name and the JSON object provided by the client.
6.PATCH // : Select to modify the field specified by the resource details.
7.GET /watch/ : Continuously receive a series of JSON objects that change over time. These JSON objects record the changes of all resource objects in a given resource category.
8.GET /watch// : Over time, it continuously receives a series of JSON objects, which record the changes of a given resource object.
REST API Release Notes
In order to continuously upgrade new APIs while being compatible with older versions, Kubernetes supports multiple API versions, each with a different API path, such as / api /v1 or / apis /extensions/v1beta1 .
Alpha level:
•A version containing the alpha name (eg v1alpha1).
•This software may contain bugs. Enabling a feature may cause bugs. Features may be disabled by default.
Beta level:
•containing the beta name (eg v2beta3 ).
•The software is well tested. Enabling the feature is considered safe. The feature is enabled by default.
•After you have used the beta version, you can give more feedback to the community, if this version will not change much after subsequent updates.
Stable level:
•The version name is named by: vX where X is an integer.
•The features of the Stable version will appear in subsequent software versions.

Differences between Alpha, Beta, RC, and GA versions
•Alpha: It is an internal beta version, generally not released to the outside world, and there will be many bugs. Generally, it is only used by testers.
•Beta: It is also a beta version, and new functions will be added to the version at this stage. Launched after the Alpha version.
•RC: (Release Candidate) As the name suggests! It is a candidate version when used in software. The system platform is the release candidate version. The RC version will not add new functions, mainly focusing on debugging.
•GA: General Availability, the officially released version, in foreign countries, GA is used to describe the release version.

kubectl api -versions
View the interface exposed by apiserver
kubectl api -versions
1.https: kube-apiserver supports both https (default listening on port 6443) and http API (default listening on port 8080 of, because http api will not be authenticated and authorized, in the production environment, for security Consider that the recommendation is not enabled. : The IP address is the kubernetes master address. In the scenario where the cluster is highly available, the IP address is the vip address.
3.apis : kubernetes only has api and apis at this level , api has only preliminary core resources, including basic resources such as pod, node, namespace, etc.
4.apps: is the name of the api group, which is the integration of kubernetes with similar characteristics of resource types.
5.v1: As an api group version, when a new resource type is added to kubernetes , it will undergo version changes: v1alpha1-->v1alpha2--> ....-- >v1alphaN-->v1beta1-->v1beta2-->v1 .
6.deployment : is the resource name of kubernetes

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00

phone Contact Us