Class ExpandedExample

java.lang.Object
io.kubernetes.client.examples.ExpandedExample

public class ExpandedExample extends Object
A simple example of how to use the Java API

Easiest way to run this: mvn exec:java -Dexec.mainClass="io.kubernetes.client.examples.ExpandedExample"

From inside $REPO_DIR/examples

  • Constructor Details

    • ExpandedExample

      public ExpandedExample()
  • Method Details

    • main

      public static void main(String[] args)
      Main method
      Parameters:
      args -
    • getAllNameSpaces

      public static List<String> getAllNameSpaces() throws io.kubernetes.client.openapi.ApiException
      Get all namespaces in k8s cluster
      Returns:
      Throws:
      io.kubernetes.client.openapi.ApiException
    • getPods

      public static List<String> getPods() throws io.kubernetes.client.openapi.ApiException
      List all pod names in all namespaces in k8s cluster
      Returns:
      Throws:
      io.kubernetes.client.openapi.ApiException
    • getNamespacedPod

      public static List<String> getNamespacedPod() throws io.kubernetes.client.openapi.ApiException
      List all pod in the default namespace
      Returns:
      Throws:
      io.kubernetes.client.openapi.ApiException
    • getNamespacedPod

      public static List<String> getNamespacedPod(String namespace) throws io.kubernetes.client.openapi.ApiException
      List pod in specific namespace
      Parameters:
      namespace -
      Returns:
      Throws:
      io.kubernetes.client.openapi.ApiException
    • getNamespacedPod

      public static List<String> getNamespacedPod(String namespace, String label) throws io.kubernetes.client.openapi.ApiException
      List pod in specific namespace with label
      Parameters:
      namespace -
      label -
      Returns:
      Throws:
      io.kubernetes.client.openapi.ApiException
    • getServices

      public static List<String> getServices() throws io.kubernetes.client.openapi.ApiException
      List all Services in default namespace
      Returns:
      Throws:
      io.kubernetes.client.openapi.ApiException
    • scaleDeployment

      public static void scaleDeployment(String deploymentName, int numberOfReplicas) throws io.kubernetes.client.openapi.ApiException
      Scale up/down the number of pod in Deployment
      Parameters:
      deploymentName -
      numberOfReplicas -
      Throws:
      io.kubernetes.client.openapi.ApiException
    • printLog

      public static void printLog(String namespace, String podName) throws io.kubernetes.client.openapi.ApiException
      Print out the Log for specific Pods
      Parameters:
      namespace -
      podName -
      Throws:
      io.kubernetes.client.openapi.ApiException