use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.
the class CoreV1Api method patchNamespacedPodEphemeralcontainersWithHttpInfo.
/**
* partially update ephemeralcontainers of the specified Pod
*
* @param name name of the Pod (required)
* @param namespace object name and auth scope, such as for teams and projects (required)
* @param body (required)
* @param pretty If 'true', then the output is pretty printed. (optional)
* @param dryRun When present, indicates that modifications should not be persisted. An invalid or
* unrecognized dryRun directive will result in an error response and no further processing of
* the request. Valid values are: - All: all dry run stages will be processed (optional)
* @param fieldManager fieldManager is a name associated with the actor or entity that is making
* these changes. The value must be less than or 128 characters long, and only contain
* printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint. This field is
* required for apply requests (application/apply-patch) but optional for non-apply patch
* types (JsonPatch, MergePatch, StrategicMergePatch). (optional)
* @param fieldValidation fieldValidation determines how the server should respond to
* unknown/duplicate fields in the object in the request. Introduced as alpha in 1.23, older
* servers or servers with the `ServerSideFieldValidation` feature disabled will
* discard valid values specified in this param and not perform any server side field
* validation. Valid values are: - Ignore: ignores unknown/duplicate fields. - Warn: responds
* with a warning for each unknown/duplicate field, but successfully serves the request. -
* Strict: fails the request on unknown/duplicate fields. (optional)
* @param force Force is going to \"force\" Apply requests. It means user will
* re-acquire conflicting fields owned by other people. Force flag must be unset for non-apply
* patch requests. (optional)
* @return ApiResponse<V1Pod>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the
* response body
* @http.response.details
* <table summary="Response Details" border="1">
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 200 </td><td> OK </td><td> - </td></tr>
* <tr><td> 201 </td><td> Created </td><td> - </td></tr>
* <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
* </table>
*/
public ApiResponse<V1Pod> patchNamespacedPodEphemeralcontainersWithHttpInfo(String name, String namespace, V1Patch body, String pretty, String dryRun, String fieldManager, String fieldValidation, Boolean force) throws ApiException {
okhttp3.Call localVarCall = patchNamespacedPodEphemeralcontainersValidateBeforeCall(name, namespace, body, pretty, dryRun, fieldManager, fieldValidation, force, null);
Type localVarReturnType = new TypeToken<V1Pod>() {
}.getType();
return localVarApiClient.execute(localVarCall, localVarReturnType);
}
use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.
the class FluentExample method main.
public static void main(String[] args) throws IOException, ApiException {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
CoreV1Api api = new CoreV1Api();
V1Pod pod = new V1PodBuilder().withNewMetadata().withName("apod").endMetadata().withNewSpec().addNewContainer().withName("www").withImage("nginx").endContainer().endSpec().build();
api.createNamespacedPod("default", pod, null, null, null, null);
V1Pod pod2 = new V1Pod().metadata(new V1ObjectMeta().name("anotherpod")).spec(new V1PodSpec().containers(Arrays.asList(new V1Container().name("www").image("nginx"))));
api.createNamespacedPod("default", pod2, null, null, null, null);
V1PodList list = api.listNamespacedPod("default", null, null, null, null, null, null, null, null, null, null);
for (V1Pod item : list.getItems()) {
System.out.println(item.getMetadata().getName());
}
}
use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.
the class InClusterClientExample method main.
public static void main(String[] args) throws IOException, ApiException {
// loading the in-cluster config, including:
// 1. service-account CA
// 2. service-account bearer-token
// 3. service-account namespace
// 4. master endpoints(ip, port) from pre-set environment variables
ApiClient client = ClientBuilder.cluster().build();
// if you prefer not to refresh service account token, please use:
// ApiClient client = ClientBuilder.oldCluster().build();
// set the global default api-client to the in-cluster one from above
Configuration.setDefaultApiClient(client);
// the CoreV1Api loads default api-client from global configuration.
CoreV1Api api = new CoreV1Api();
// invokes the CoreV1Api client
V1PodList list = api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null, null);
for (V1Pod item : list.getItems()) {
System.out.println(item.getMetadata().getName());
}
}
use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.
the class KubectlTop method topPods.
private List<Pair<ApiType, MetricsType>> topPods(CoreV1Api api, ApiClient apiClient, String metricName) throws KubectlException, ApiException, IOException {
V1PodList pods = api.listNamespacedPod(namespace, null, null, null, null, null, null, null, null, null, null);
PodMetricsList metrics = new Metrics(apiClient).getPodMetrics(namespace);
List<V1Pod> items = pods.getItems();
Collections.sort(items, new Comparator<V1Pod>() {
@Override
public int compare(V1Pod arg0, V1Pod arg1) {
double m0 = podMetricSum(findPodMetric(arg0.getMetadata().getName(), metrics), metricName);
double m1 = podMetricSum(findPodMetric(arg1.getMetadata().getName(), metrics), metricName);
// sort high to low
return Double.compare(m0, m1) * -1;
}
});
List<Pair<ApiType, MetricsType>> result = new ArrayList<>();
for (V1Pod pod : items) {
result.add(new ImmutablePair<>((ApiType) pod, (MetricsType) findPodMetric(pod, metrics)));
}
return result;
}
use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.
the class LogsExample method main.
public static void main(String[] args) throws IOException, ApiException, InterruptedException {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
CoreV1Api coreApi = new CoreV1Api(client);
PodLogs logs = new PodLogs();
V1Pod pod = coreApi.listNamespacedPod("default", "false", null, null, null, null, null, null, null, null, null).getItems().get(0);
InputStream is = logs.streamNamespacedPodLog(pod);
Streams.copy(is, System.out);
}
Aggregations