Search in sources :

Example 1 with V1StatefulSet

use of io.kubernetes.client.openapi.models.V1StatefulSet in project heron by twitter.

the class V1Controller method submit.

/**
 * Configures all components required by a <code>topology</code> and submits it to the Kubernetes scheduler.
 * @param packingPlan Used to configure the StatefulSets <code>Resource</code>s and replica count.
 * @return Success indicator.
 */
@Override
boolean submit(PackingPlan packingPlan) {
    final String topologyName = getTopologyName();
    if (!topologyName.equals(topologyName.toLowerCase())) {
        throw new TopologySubmissionException("K8S scheduler does not allow upper case topology's.");
    }
    final Resource containerResource = getContainerResource(packingPlan);
    final V1Service topologyService = createTopologyService();
    try {
        coreClient.createNamespacedService(getNamespace(), topologyService, null, null, null);
    } catch (ApiException e) {
        KubernetesUtils.logExceptionWithDetails(LOG, "Error creating topology service", e);
        throw new TopologySubmissionException(e.getMessage());
    }
    // Find the max number of instances in a container so that 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 V1StatefulSet executors = createStatefulSet(containerResource, numberOfInstances, true);
    final V1StatefulSet manager = createStatefulSet(containerResource, numberOfInstances, false);
    try {
        appsClient.createNamespacedStatefulSet(getNamespace(), executors, null, null, null);
        appsClient.createNamespacedStatefulSet(getNamespace(), manager, null, null, null);
    } catch (ApiException e) {
        final String message = String.format("Error creating topology: %s%n", e.getResponseBody());
        KubernetesUtils.logExceptionWithDetails(LOG, message, e);
        throw new TopologySubmissionException(message);
    }
    return true;
}
Also used : TopologySubmissionException(org.apache.heron.scheduler.TopologySubmissionException) V1StatefulSet(io.kubernetes.client.openapi.models.V1StatefulSet) PackingPlan(org.apache.heron.spi.packing.PackingPlan) Resource(org.apache.heron.spi.packing.Resource) V1Service(io.kubernetes.client.openapi.models.V1Service) ApiException(io.kubernetes.client.openapi.ApiException)

Example 2 with V1StatefulSet

use of io.kubernetes.client.openapi.models.V1StatefulSet in project heron by twitter.

the class V1Controller method addContainers.

/**
 * Adds a specified number of Pods to a <code>topology</code>'s <code>Executors</code>.
 * @param containersToAdd Set of containers to be added.
 * @return The passed in <code>Packing Plan</code>.
 */
@Override
public Set<PackingPlan.ContainerPlan> addContainers(Set<PackingPlan.ContainerPlan> containersToAdd) {
    final V1StatefulSet statefulSet;
    try {
        statefulSet = getStatefulSet();
    } catch (ApiException ae) {
        final String message = ae.getMessage() + "\ndetails:" + ae.getResponseBody();
        throw new TopologyRuntimeManagementException(message, ae);
    }
    final V1StatefulSetSpec v1StatefulSet = Objects.requireNonNull(statefulSet.getSpec());
    final int currentContainerCount = Objects.requireNonNull(v1StatefulSet.getReplicas());
    final int newContainerCount = currentContainerCount + containersToAdd.size();
    try {
        patchStatefulSetReplicas(newContainerCount);
    } catch (ApiException ae) {
        throw new TopologyRuntimeManagementException(ae.getMessage() + "\ndetails\n" + ae.getResponseBody());
    }
    return containersToAdd;
}
Also used : TopologyRuntimeManagementException(org.apache.heron.scheduler.TopologyRuntimeManagementException) V1StatefulSet(io.kubernetes.client.openapi.models.V1StatefulSet) V1StatefulSetSpec(io.kubernetes.client.openapi.models.V1StatefulSetSpec) ApiException(io.kubernetes.client.openapi.ApiException)

Example 3 with V1StatefulSet

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

the class AppsV1Api method readNamespacedStatefulSetStatusWithHttpInfo.

/**
 * read 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 pretty If &#39;true&#39;, then the output is pretty printed. (optional)
 * @return ApiResponse&lt;V1StatefulSet&gt;
 * @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> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
 * </table>
 */
public ApiResponse<V1StatefulSet> readNamespacedStatefulSetStatusWithHttpInfo(String name, String namespace, String pretty) throws ApiException {
    okhttp3.Call localVarCall = readNamespacedStatefulSetStatusValidateBeforeCall(name, namespace, pretty, null);
    Type localVarReturnType = new TypeToken<V1StatefulSet>() {
    }.getType();
    return localVarApiClient.execute(localVarCall, localVarReturnType);
}
Also used : Type(java.lang.reflect.Type) V1StatefulSet(io.kubernetes.client.openapi.models.V1StatefulSet)

Example 4 with V1StatefulSet

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

the class AppsV1Api method replaceNamespacedStatefulSetStatusAsync.

/**
 * (asynchronously) replace 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)
 * @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. (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 &#x60;ServerSideFieldValidation&#x60; 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 _callback The callback to be executed when the API call finishes
 * @return The request call
 * @throws ApiException If fail to process the API call, e.g. serializing the request body object
 * @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 okhttp3.Call replaceNamespacedStatefulSetStatusAsync(String name, String namespace, V1StatefulSet body, String pretty, String dryRun, String fieldManager, String fieldValidation, final ApiCallback<V1StatefulSet> _callback) throws ApiException {
    okhttp3.Call localVarCall = replaceNamespacedStatefulSetStatusValidateBeforeCall(name, namespace, body, pretty, dryRun, fieldManager, fieldValidation, _callback);
    Type localVarReturnType = new TypeToken<V1StatefulSet>() {
    }.getType();
    localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
    return localVarCall;
}
Also used : Type(java.lang.reflect.Type) V1StatefulSet(io.kubernetes.client.openapi.models.V1StatefulSet)

Example 5 with V1StatefulSet

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

the class AppsV1Api 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)
 * @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. (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 &#x60;ServerSideFieldValidation&#x60; 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)
 * @return ApiResponse&lt;V1StatefulSet&gt;
 * @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> 202 </td><td> Accepted </td><td>  -  </td></tr>
 * <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
 * </table>
 */
public ApiResponse<V1StatefulSet> createNamespacedStatefulSetWithHttpInfo(String namespace, V1StatefulSet body, String pretty, String dryRun, String fieldManager, String fieldValidation) throws ApiException {
    okhttp3.Call localVarCall = createNamespacedStatefulSetValidateBeforeCall(namespace, body, pretty, dryRun, fieldManager, fieldValidation, null);
    Type localVarReturnType = new TypeToken<V1StatefulSet>() {
    }.getType();
    return localVarApiClient.execute(localVarCall, localVarReturnType);
}
Also used : Type(java.lang.reflect.Type) V1StatefulSet(io.kubernetes.client.openapi.models.V1StatefulSet)

Aggregations

V1StatefulSet (io.kubernetes.client.openapi.models.V1StatefulSet)23 Type (java.lang.reflect.Type)14 V1StatefulSetSpec (io.kubernetes.client.openapi.models.V1StatefulSetSpec)5 ApiException (io.kubernetes.client.openapi.ApiException)3 V1LabelSelector (io.kubernetes.client.openapi.models.V1LabelSelector)3 V1ObjectMeta (io.kubernetes.client.openapi.models.V1ObjectMeta)3 V1PodTemplateSpec (io.kubernetes.client.openapi.models.V1PodTemplateSpec)3 TopologyRuntimeManagementException (org.apache.heron.scheduler.TopologyRuntimeManagementException)2 JobAPI (edu.iu.dsc.tws.proto.system.job.JobAPI)1 IntOrString (io.kubernetes.client.custom.IntOrString)1 V1ConfigMap (io.kubernetes.client.openapi.models.V1ConfigMap)1 V1Service (io.kubernetes.client.openapi.models.V1Service)1 V1Volume (io.kubernetes.client.openapi.models.V1Volume)1 V1VolumeMount (io.kubernetes.client.openapi.models.V1VolumeMount)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 TopologySubmissionException (org.apache.heron.scheduler.TopologySubmissionException)1 Config (org.apache.heron.spi.common.Config)1