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;
}
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;
}
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 'true', then the output is pretty printed. (optional)
* @return ApiResponse<V1StatefulSet>
* @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);
}
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 '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. (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 _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;
}
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 '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. (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)
* @return ApiResponse<V1StatefulSet>
* @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);
}
Aggregations