Search in sources :

Example 21 with V1beta1StatefulSet

use of io.kubernetes.client.models.V1beta1StatefulSet in project java by kubernetes-client.

the class AppsV1beta1Api method replaceNamespacedStatefulSetWithHttpInfo.

/**
 * replace the specified StatefulSet
 * @param name name of the StatefulSet (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)
 * @return ApiResponse<V1beta1StatefulSet>
 * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
 */
public ApiResponse<V1beta1StatefulSet> replaceNamespacedStatefulSetWithHttpInfo(String name, String namespace, V1beta1StatefulSet body, String pretty) throws ApiException {
    com.squareup.okhttp.Call call = replaceNamespacedStatefulSetValidateBeforeCall(name, namespace, body, pretty, null, null);
    Type localVarReturnType = new TypeToken<V1beta1StatefulSet>() {
    }.getType();
    return apiClient.execute(call, localVarReturnType);
}
Also used : Type(java.lang.reflect.Type) V1beta1StatefulSet(io.kubernetes.client.models.V1beta1StatefulSet)

Example 22 with V1beta1StatefulSet

use of io.kubernetes.client.models.V1beta1StatefulSet in project java by kubernetes-client.

the class AppsV1beta1Api method patchNamespacedStatefulSetStatusWithHttpInfo.

/**
 * partially update status of the specified StatefulSet
 * @param name name of the StatefulSet (required)
 * @param namespace object name and auth scope, such as for teams and projects (required)
 * @param body  (required)
 * @param pretty If &#39;true&#39;, then the output is pretty printed. (optional)
 * @return ApiResponse&lt;V1beta1StatefulSet&gt;
 * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
 */
public ApiResponse<V1beta1StatefulSet> patchNamespacedStatefulSetStatusWithHttpInfo(String name, String namespace, Object body, String pretty) throws ApiException {
    com.squareup.okhttp.Call call = patchNamespacedStatefulSetStatusValidateBeforeCall(name, namespace, body, pretty, null, null);
    Type localVarReturnType = new TypeToken<V1beta1StatefulSet>() {
    }.getType();
    return apiClient.execute(call, localVarReturnType);
}
Also used : Type(java.lang.reflect.Type) V1beta1StatefulSet(io.kubernetes.client.models.V1beta1StatefulSet)

Example 23 with V1beta1StatefulSet

use of io.kubernetes.client.models.V1beta1StatefulSet in project java by kubernetes-client.

the class AppsV1beta1Api method createNamespacedStatefulSetWithHttpInfo.

/**
 * create a StatefulSet
 * @param namespace object name and auth scope, such as for teams and projects (required)
 * @param body  (required)
 * @param pretty If &#39;true&#39;, then the output is pretty printed. (optional)
 * @return ApiResponse&lt;V1beta1StatefulSet&gt;
 * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
 */
public ApiResponse<V1beta1StatefulSet> createNamespacedStatefulSetWithHttpInfo(String namespace, V1beta1StatefulSet body, String pretty) throws ApiException {
    com.squareup.okhttp.Call call = createNamespacedStatefulSetValidateBeforeCall(namespace, body, pretty, null, null);
    Type localVarReturnType = new TypeToken<V1beta1StatefulSet>() {
    }.getType();
    return apiClient.execute(call, localVarReturnType);
}
Also used : Type(java.lang.reflect.Type) V1beta1StatefulSet(io.kubernetes.client.models.V1beta1StatefulSet)

Example 24 with V1beta1StatefulSet

use of io.kubernetes.client.models.V1beta1StatefulSet in project incubator-heron by apache.

the class AppsV1beta1Controller method submit.

@Override
boolean submit(PackingPlan packingPlan) {
    final String topologyName = getTopologyName();
    if (!topologyName.equals(topologyName.toLowerCase())) {
        throw new TopologySubmissionException("K8S scheduler does not allow upper case topologies.");
    }
    final Resource containerResource = getContainerResource(packingPlan);
    // find the max number of instances in a container so we can open
    // enough ports if remote debugging is enabled.
    int numberOfInstances = 0;
    for (PackingPlan.ContainerPlan containerPlan : packingPlan.getContainers()) {
        numberOfInstances = Math.max(numberOfInstances, containerPlan.getInstances().size());
    }
    final V1beta1StatefulSet statefulSet = createStatefulSet(containerResource, numberOfInstances);
    try {
        final Response response = client.createNamespacedStatefulSetCall(getNamespace(), statefulSet, null, null, null).execute();
        if (!response.isSuccessful()) {
            LOG.log(Level.SEVERE, "Error creating topology message: " + response.message());
            KubernetesUtils.logResponseBodyIfPresent(LOG, response);
            // construct a message based on the k8s api server response
            throw new TopologySubmissionException(KubernetesUtils.errorMessageFromResponse(response));
        }
    } catch (IOException | ApiException e) {
        KubernetesUtils.logExceptionWithDetails(LOG, "Error creating topology", e);
        throw new TopologySubmissionException(e.getMessage());
    }
    return true;
}
Also used : TopologySubmissionException(com.twitter.heron.scheduler.TopologySubmissionException) Response(com.squareup.okhttp.Response) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) Resource(com.twitter.heron.spi.packing.Resource) IOException(java.io.IOException) V1beta1StatefulSet(io.kubernetes.client.models.V1beta1StatefulSet) ApiException(io.kubernetes.client.ApiException)

Example 25 with V1beta1StatefulSet

use of io.kubernetes.client.models.V1beta1StatefulSet in project incubator-heron by apache.

the class AppsV1beta1Controller method addContainers.

@Override
public Set<PackingPlan.ContainerPlan> addContainers(Set<PackingPlan.ContainerPlan> containersToAdd) {
    final V1beta1StatefulSet statefulSet;
    try {
        statefulSet = getStatefulSet();
    } catch (ApiException ae) {
        final String message = ae.getMessage() + "\ndetails:" + ae.getResponseBody();
        throw new TopologyRuntimeManagementException(message, ae);
    }
    final int currentContainerCount = statefulSet.getSpec().getReplicas();
    final int newContainerCount = currentContainerCount + containersToAdd.size();
    final V1beta1StatefulSetSpec newSpec = new V1beta1StatefulSetSpec();
    newSpec.setReplicas(newContainerCount);
    try {
        doPatch(newSpec);
    } catch (ApiException ae) {
        throw new TopologyRuntimeManagementException(ae.getMessage() + "\ndetails\n" + ae.getResponseBody());
    }
    return containersToAdd;
}
Also used : TopologyRuntimeManagementException(com.twitter.heron.scheduler.TopologyRuntimeManagementException) V1beta1StatefulSet(io.kubernetes.client.models.V1beta1StatefulSet) V1beta1StatefulSetSpec(io.kubernetes.client.models.V1beta1StatefulSetSpec) ApiException(io.kubernetes.client.ApiException)

Aggregations

V1beta1StatefulSet (io.kubernetes.client.models.V1beta1StatefulSet)25 Type (java.lang.reflect.Type)14 ProgressRequestBody (io.kubernetes.client.ProgressRequestBody)7 ProgressResponseBody (io.kubernetes.client.ProgressResponseBody)7 Test (org.junit.Test)7 ApiException (io.kubernetes.client.ApiException)3 V1beta1StatefulSetSpec (io.kubernetes.client.models.V1beta1StatefulSetSpec)3 TopologyRuntimeManagementException (com.twitter.heron.scheduler.TopologyRuntimeManagementException)2 Response (com.squareup.okhttp.Response)1 TopologySubmissionException (com.twitter.heron.scheduler.TopologySubmissionException)1 Config (com.twitter.heron.spi.common.Config)1 PackingPlan (com.twitter.heron.spi.packing.PackingPlan)1 Resource (com.twitter.heron.spi.packing.Resource)1 V1LabelSelector (io.kubernetes.client.models.V1LabelSelector)1 V1ObjectMeta (io.kubernetes.client.models.V1ObjectMeta)1 V1PodTemplateSpec (io.kubernetes.client.models.V1PodTemplateSpec)1 IOException (java.io.IOException)1