public class KubernetesHelper extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_DOCKER_HOST |
Constructor and Description |
---|
KubernetesHelper() |
Modifier and Type | Method and Description |
---|---|
static com.fasterxml.jackson.databind.JsonNode |
combineJson(Object... objects)
Combines the JSON objects into a config object
|
static String |
containerNameToPodId(String containerName)
Returns the pod id for the given container id
|
protected static com.fasterxml.jackson.databind.node.JsonNodeFactory |
createNodeFactory() |
static io.fabric8.utils.Filter<PodSchema> |
createPodFilter(Map<String,String> labelSelector)
Creates a filter on a pod using the given set of labels
|
static io.fabric8.utils.Filter<PodSchema> |
createPodFilter(String textFilter)
Creates a filter on a pod using the given text string
|
static io.fabric8.utils.Filter<ReplicationControllerSchema> |
createReplicationControllerFilter(Map<String,String> labelSelector)
Creates a filter on a replicationController using the given text string
|
static io.fabric8.utils.Filter<ReplicationControllerSchema> |
createReplicationControllerFilter(String textFilter)
Creates a filter on a replicationController using the given text string
|
static io.fabric8.utils.Filter<ServiceSchema> |
createServiceFilter(Map<String,String> labelSelector)
Creates a filter on a service using the given text string
|
static io.fabric8.utils.Filter<ServiceSchema> |
createServiceFilter(String textFilter)
Creates a filter on a service using the given text string
|
static boolean |
filterLabels(Map<String,String> filterLabels,
Map<String,String> labels)
Returns true if the given filterLabels matches the actual labels
|
static boolean |
filterMatchesIdOrLabels(String textFilter,
String id,
Map<String,String> labels)
Returns true if the given textFilter matches either the id or the labels
|
static Port |
findContainerPort(PodSchema pod,
Integer portNumber)
Returns the port for the given port number on the pod
|
static Port |
findContainerPortByName(PodSchema pod,
String name)
Returns the port for the given port name
|
static Port |
findContainerPortByNumberOrName(PodSchema pod,
String numberOrName)
Returns the port for the given port number or name
|
protected static com.fasterxml.jackson.databind.JsonNode |
findOrCreateConfig(Object[] objects) |
static int |
getContainerPort(ServiceSchema service)
Returns the container port number for the given service
|
static List<ManifestContainer> |
getContainers(ControllerDesiredState desiredState)
Returns all the containers from the given Replication Controller's desiredState
|
static List<ManifestContainer> |
getContainers(DesiredState desiredState)
Returns all the manifest containers from the given desiredState
|
static List<ManifestContainer> |
getContainers(Manifest manifest) |
static List<ManifestContainer> |
getContainers(PodSchema pod)
Returns all the containers from the given pod
|
static List<ManifestContainer> |
getContainers(PodTemplate podTemplate) |
static List<ManifestContainer> |
getContainers(PodTemplateDesiredState podTemplateDesiredState) |
static List<ManifestContainer> |
getContainers(ReplicationControllerSchema replicationController)
Returns all the containers from the given Replication Controller
|
static Map<String,PodCurrentContainerInfo> |
getCurrentContainers(CurrentState currentState)
Returns all the current containers from the given currentState
|
static Map<String,PodCurrentContainerInfo> |
getCurrentContainers(PodSchema pod)
Returns all the current containers from the given currentState
|
static List<ManifestContainer> |
getCurrentContainers(ReplicationControllerSchema replicationController)
Returns all the containers from the given Replication Controller
|
static String |
getDockerIp() |
static String |
getHost(PodSchema pod)
Returns the host of the pod
|
static Map<String,PodSchema> |
getPodMap(Kubernetes kubernetes) |
static Map<String,PodSchema> |
getPodMap(Kubernetes kubernetes,
String selector) |
static Map<String,ReplicationControllerSchema> |
getReplicationControllerMap(Kubernetes kubernetes) |
static Map<String,ReplicationControllerSchema> |
getReplicationControllerMap(Kubernetes kubernetes,
String selector) |
static Map<String,ServiceSchema> |
getServiceMap(Kubernetes kubernetes) |
static String |
getServiceURL(ServiceSchema service)
Returns the URL to access the service; using the service portalIP and port
|
static Object |
loadJson(byte[] json)
Returns the given json data as a DTO such as
PodSchema , ReplicationControllerSchema or
ServiceSchema
from the Kubernetes REST API or
JsonNode if it cannot be recognised. |
static Object |
loadJson(File file)
Returns the given json data as a DTO such as
PodSchema , ReplicationControllerSchema or
ServiceSchema
from the Kubernetes REST API or
JsonNode if it cannot be recognised. |
static Object |
loadJson(InputStream in)
Returns the given json data as a DTO such as
PodSchema , ReplicationControllerSchema or
ServiceSchema
from the Kubernetes REST API or
JsonNode if it cannot be recognised. |
static Object |
loadJson(String json) |
static void |
removeEmptyPods(PodListSchema podSchema)
Removes empty pods returned by Kubernetes
|
static String |
resolveDockerHost() |
static void |
saveJson(File json,
Object object)
Saves the json object to the given file
|
static String |
toJson(Object dto) |
static com.fasterxml.jackson.databind.JsonNode |
toJsonNode(Object object)
Converts the DTO to a JsonNode
|
static String |
toLabelsString(Map<String,String> labelMap)
Returns a string for the labels using "," to separate values
|
protected static Integer |
toOptionalNumber(String text)
Returns the number if it can be parsed or null
|
static Map<String,PodSchema> |
toPodMap(List<PodSchema> pods)
Returns a map indexed by pod id of the pods
|
static Map<String,PodSchema> |
toPodMap(PodListSchema podSchema)
Returns a map indexed by pod id of the pods
|
static Map<String,PodSchema> |
toPodMap(PodListSchema podSchema,
String selector)
Returns a map indexed by pod id of the pods
|
static String |
toPositiveNonZeroText(Integer port)
For positive non-zero values return the text of the number or return blank
|
static Map<String,ReplicationControllerSchema> |
toReplicationControllerMap(List<ReplicationControllerSchema> replicationControllers)
Returns a map indexed by replicationController id of the replicationControllers
|
static Map<String,ReplicationControllerSchema> |
toReplicationControllerMap(ReplicationControllerListSchema replicationControllerSchema)
Returns a map indexed by replicationController id of the replicationControllers
|
static Map<String,ServiceSchema> |
toServiceMap(List<ServiceSchema> services)
Returns a map indexed by service id of the services
|
static Map<String,ServiceSchema> |
toServiceMap(ServiceListSchema serviceSchema)
Returns a map indexed by service id of the services
|
public static final String DEFAULT_DOCKER_HOST
public static String getDockerIp()
public static String resolveDockerHost()
public static String toJson(Object dto) throws com.fasterxml.jackson.core.JsonProcessingException
com.fasterxml.jackson.core.JsonProcessingException
public static Object loadJson(File file) throws IOException
PodSchema
, ReplicationControllerSchema
or
ServiceSchema
from the Kubernetes REST API or
JsonNode
if it cannot be recognised.IOException
public static Object loadJson(InputStream in) throws IOException
PodSchema
, ReplicationControllerSchema
or
ServiceSchema
from the Kubernetes REST API or
JsonNode
if it cannot be recognised.IOException
public static Object loadJson(String json) throws IOException
IOException
public static Object loadJson(byte[] json) throws IOException
PodSchema
, ReplicationControllerSchema
or
ServiceSchema
from the Kubernetes REST API or
JsonNode
if it cannot be recognised.IOException
public static void saveJson(File json, Object object) throws IOException
IOException
public static Map<String,PodSchema> toPodMap(PodListSchema podSchema)
public static Map<String,PodSchema> toPodMap(PodListSchema podSchema, String selector)
public static Map<String,PodSchema> toPodMap(List<PodSchema> pods)
public static Map<String,ServiceSchema> toServiceMap(ServiceListSchema serviceSchema)
public static Map<String,ServiceSchema> toServiceMap(List<ServiceSchema> services)
public static Map<String,ReplicationControllerSchema> toReplicationControllerMap(ReplicationControllerListSchema replicationControllerSchema)
public static Map<String,ReplicationControllerSchema> toReplicationControllerMap(List<ReplicationControllerSchema> replicationControllers)
public static Map<String,PodSchema> getPodMap(Kubernetes kubernetes)
public static Map<String,PodSchema> getPodMap(Kubernetes kubernetes, String selector)
public static Map<String,ServiceSchema> getServiceMap(Kubernetes kubernetes)
public static Map<String,ReplicationControllerSchema> getReplicationControllerMap(Kubernetes kubernetes)
public static Map<String,ReplicationControllerSchema> getReplicationControllerMap(Kubernetes kubernetes, String selector)
public static void removeEmptyPods(PodListSchema podSchema)
public static String containerNameToPodId(String containerName)
public static String toLabelsString(Map<String,String> labelMap)
public static io.fabric8.utils.Filter<PodSchema> createPodFilter(String textFilter)
public static io.fabric8.utils.Filter<PodSchema> createPodFilter(Map<String,String> labelSelector)
public static io.fabric8.utils.Filter<ServiceSchema> createServiceFilter(String textFilter)
public static io.fabric8.utils.Filter<ServiceSchema> createServiceFilter(Map<String,String> labelSelector)
public static io.fabric8.utils.Filter<ReplicationControllerSchema> createReplicationControllerFilter(String textFilter)
public static io.fabric8.utils.Filter<ReplicationControllerSchema> createReplicationControllerFilter(Map<String,String> labelSelector)
public static boolean filterMatchesIdOrLabels(String textFilter, String id, Map<String,String> labels)
public static boolean filterLabels(Map<String,String> filterLabels, Map<String,String> labels)
public static String toPositiveNonZeroText(Integer port)
public static List<ManifestContainer> getContainers(PodSchema pod)
public static List<ManifestContainer> getContainers(ReplicationControllerSchema replicationController)
public static List<ManifestContainer> getContainers(ControllerDesiredState desiredState)
public static List<ManifestContainer> getContainers(PodTemplate podTemplate)
public static List<ManifestContainer> getContainers(PodTemplateDesiredState podTemplateDesiredState)
public static List<ManifestContainer> getContainers(Manifest manifest)
public static List<ManifestContainer> getCurrentContainers(ReplicationControllerSchema replicationController)
public static List<ManifestContainer> getContainers(DesiredState desiredState)
public static Map<String,PodCurrentContainerInfo> getCurrentContainers(PodSchema pod)
public static Map<String,PodCurrentContainerInfo> getCurrentContainers(CurrentState currentState)
public static int getContainerPort(ServiceSchema service)
public static com.fasterxml.jackson.databind.JsonNode combineJson(Object... objects) throws IOException
IOException
protected static com.fasterxml.jackson.databind.node.JsonNodeFactory createNodeFactory()
protected static com.fasterxml.jackson.databind.JsonNode findOrCreateConfig(Object[] objects)
public static com.fasterxml.jackson.databind.JsonNode toJsonNode(Object object) throws IOException
IOException
public static String getServiceURL(ServiceSchema service)
public static Port findContainerPort(PodSchema pod, Integer portNumber)
public static Port findContainerPortByName(PodSchema pod, String name)
public static Port findContainerPortByNumberOrName(PodSchema pod, String numberOrName)
Copyright © 2011–2014 Red Hat. All rights reserved.