public void addPod(Pod pod) { String id = getId(pod); if (Strings.isNotBlank(id)) { pods.put(id, pod); } }
public void addService(Service service) { String id = getId(service); if (Strings.isNotBlank(id)) { services.put(id, service); } }
@Override public String getReplicationControllerIdForPod(String podId) { ReplicationController replicationController = kubernetes.getReplicationControllerForPod(podId); if (replicationController != null) { return getId(replicationController); } return null; }
public void addController(ReplicationController controller) { String id = getId(controller); if (Strings.isNotBlank(id)) { controllers.put(id, controller); // now lets find all the pods that are active for this List<Pod> pods = snapshot.podsForReplicationController(controller); for (Pod pod : pods) { addPod(pod); } } }
public static void deleteReplicationControllers(KubernetesClient client, Session session) throws MultiException { List<Throwable> errors = new ArrayList<>(); for (ReplicationController replicationController : client.getReplicationControllers(session.getNamespace()).getItems()) { try { session.getLogger().info("Deleting replication controller:" + getId(replicationController)); client.deleteReplicationController(replicationController.getId(), session.getNamespace()); } catch (Exception e) { e.printStackTrace(); } } if (!errors.isEmpty()) { throw new MultiException("Error while deleting replication controllers", errors); } }
public static void deleteServices(KubernetesClient client, Session session) throws MultiException { List<Throwable> errors = new ArrayList<>(); for (Service service : client.getServices(session.getNamespace()).getItems()) { try { session.getLogger().info("Deleting service:" + getId(service)); client.deleteService(service.getId(), session.getNamespace()); } catch (Exception e) { e.printStackTrace(); } } if (!errors.isEmpty()) { throw new MultiException("Error while deleting services", errors); } }
public static void deletePods(KubernetesClient client, Session session) throws MultiException { List<Throwable> errors = new ArrayList<>(); for (Pod pod : client.getPods(session.getNamespace()).getItems()) { try { session.getLogger().info("Deleting pod:" + getId(pod)); client.deletePod(pod.getId(), session.getNamespace()); } catch (Exception e) { errors.add(e); } } if (!errors.isEmpty()) { throw new MultiException("Error while deleting pods", errors); } }
public AppServiceSummaryDTO(Service service) { this.id = KubernetesHelper.getId(service); this.name = KubernetesHelper.getName(service); this.namespace = service.getNamespace(); this.portalIP = KubernetesHelper.getPortalIP(service); this.port = KubernetesHelper.getPort(service); this.labels = service.getLabels(); }
public AppReplicationControllerSummaryDTO(ReplicationController controller) { this.id = KubernetesHelper.getId(controller); this.namespace = controller.getNamespace(); this.labels = controller.getLabels(); ReplicationControllerState desiredState = controller.getDesiredState(); if (desiredState != null) { this.replicas = desiredState.getReplicas(); this.replicaSelector = desiredState.getReplicaSelector(); } }
String appPath = getAppPath(getId(service)); if (appPath != null) { AppViewDetails dto = snapshot.getOrCreateAppView(appPath, service.getNamespace()); String appPath = getAppPath(getId(controller)); if (appPath != null) { AppViewDetails dto = snapshot.getOrCreateAppView(appPath, controller.getNamespace());
public static void displaySessionStatus(KubernetesClient client, Session session) throws MultiException { for (ReplicationController replicationController : client.getReplicationControllers(session.getNamespace()).getItems()) { session.getLogger().info("Replication controller:" + getId(replicationController)); } for (Pod pod : client.getPods(session.getNamespace()).getItems()) { session.getLogger().info("Pod:" + getId(pod) + " Status:" + pod.getCurrentState().getStatus()); } for (Service service : client.getServices(session.getNamespace()).getItems()) { session.getLogger().info("Service:" + getId(service) + " IP:" + getPortalIP(service) + " Port:" + getPort(service)); } }
public AppPodSummaryDTO(Pod pod) { this.id = KubernetesHelper.getId(pod); this.namespace = pod.getNamespace(); this.status = KubernetesHelper.getPodStatus(pod);