Search in sources :

Example 1 with V1DeploymentStatus

use of io.kubernetes.client.openapi.models.V1DeploymentStatus in project plugins by qlangtech.

the class FlinkK8SClusterManager method getRCDeployment.

@Override
public RcDeployment getRCDeployment() {
    RcDeployment deployment = new RcDeployment();
    K8sImage k8sImage = this.getK8SImage();
    ApiClient apiClient = k8sImage.createApiClient();
    AppsV1Api appsApi = new AppsV1Api(apiClient);
    CoreV1Api coreApi = new CoreV1Api(apiClient);
    // String name, String namespace, String pretty, Boolean exact, Boolean export
    try {
        V1Deployment deploy = appsApi.readNamespacedDeployment(this.clusterId, k8sImage.getNamespace(), "true", null, null);
        K8SController.fillSpecInfo(deployment, deploy.getSpec().getReplicas(), deploy.getSpec().getTemplate());
        V1DeploymentStatus status = deploy.getStatus();
        RcDeployment.ReplicationControllerStatus deploymentStatus = new RcDeployment.ReplicationControllerStatus();
        deploymentStatus.setAvailableReplicas(status.getAvailableReplicas());
        deploymentStatus.setFullyLabeledReplicas(0);
        deploymentStatus.setObservedGeneration(status.getObservedGeneration());
        deploymentStatus.setReadyReplicas(status.getReadyReplicas());
        deploymentStatus.setReplicas(status.getReplicas());
        deployment.setStatus(deploymentStatus);
        K8SController.fillCreateTimestamp(deployment, deploy.getMetadata());
        K8SController.fillPods(coreApi, k8sImage, deployment, new TargetResName(this.clusterId));
    } catch (ApiException e) {
        throw K8sExceptionUtils.convert(this.clusterId, e);
    }
    return deployment;
}
Also used : V1Deployment(io.kubernetes.client.openapi.models.V1Deployment) TargetResName(com.qlangtech.tis.coredefine.module.action.TargetResName) RcDeployment(com.qlangtech.tis.coredefine.module.action.impl.RcDeployment) AppsV1Api(io.kubernetes.client.openapi.apis.AppsV1Api) ApiClient(io.kubernetes.client.openapi.ApiClient) V1DeploymentStatus(io.kubernetes.client.openapi.models.V1DeploymentStatus) CoreV1Api(io.kubernetes.client.openapi.apis.CoreV1Api) K8sImage(com.qlangtech.tis.plugin.k8s.K8sImage) ApiException(io.kubernetes.client.openapi.ApiException)

Aggregations

TargetResName (com.qlangtech.tis.coredefine.module.action.TargetResName)1 RcDeployment (com.qlangtech.tis.coredefine.module.action.impl.RcDeployment)1 K8sImage (com.qlangtech.tis.plugin.k8s.K8sImage)1 ApiClient (io.kubernetes.client.openapi.ApiClient)1 ApiException (io.kubernetes.client.openapi.ApiException)1 AppsV1Api (io.kubernetes.client.openapi.apis.AppsV1Api)1 CoreV1Api (io.kubernetes.client.openapi.apis.CoreV1Api)1 V1Deployment (io.kubernetes.client.openapi.models.V1Deployment)1 V1DeploymentStatus (io.kubernetes.client.openapi.models.V1DeploymentStatus)1