Commit 635db4e1 authored by mengxue's avatar mengxue
Browse files

add kubectl commands in ListServices

parent 69acd9da
......@@ -56,13 +56,10 @@ object ListServices extends App{
f"${clusterInfo.map{_.ports.mkString(",")}.getOrElse("None")}" + "/" +
f"${clusterInfo.map{_.protocol.mkString}.getOrElse("None")}")
//iplist.foreach {i => println(i.name)}
println("service info "+ service.spec)
}
}
// Some(Spec(List(Port(https,TCP,443,Some(Left(6443)),0)),Map(),10.96.0.1,ClusterIP,List(),,None,)) // service.spec
// Spec(List(Port(https,TCP,443,Some(Left(6443)),0)),Map(),10.96.0.1,ClusterIP,List(),,None,) // sp <- service.spec
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
// implicit val dispatcher = ExecutionContext.fromExecutorService(Executors.newCachedThreadPool())
......@@ -70,27 +67,31 @@ object ListServices extends App{
val k8s = k8sInit
System.out.println("\n======================================= kubectl get service =======================================")
System.out.println("\nGetting list of services in namespace of current context ==>")
val currNsServices: Future[ServiceList] = k8s list[ServiceList]()
// val printCurrNsPods = currNsPods map { podList => listPods(podList.items) }
val printCurrNsServices = currNsServices map { serviceList => listServices(serviceList.items) }
printCurrNsServices onFailure { case ex: Exception => System.err.println("Failed => " + ex) }
printCurrNsServices onComplete {
case Success(value) => Success(value)
case Failure(ex) => System.err.println("Failed => " + ex)
}
Await.ready(printCurrNsServices, 30 seconds)
System.out.println("\n=============================== kubectl get service --all-namespaces ===============================")
System.out.println("\nGetting lists of services in all namespaces in the cluster ==>")
val allNsServicesMapFut: Future[Map[String, ServiceList]] = k8s.listByNamespace[ServiceList]()
val allNsServices: Future[List[Service]] = allNsServicesMapFut map { allNsServicesMap =>
allNsServicesMap.values.flatMap(_.items).toList
}
// val printCurrNsPods = currNsPods map { podList => listPods(podList.items) }
val printAllNsServices = allNsServices map { serviceList => listServices(serviceList) }
// printCurrNsPods onFailure { case ex: Exception => System.err.println("Failed => " + ex) }
printAllNsServices onFailure { case ex: Exception => System.err.println("Failed => " + ex) }
printAllNsServices onComplete {
case Success(value) => Success(value)
case Failure(ex) => System.err.println("Failed => " + ex)
}
Await.ready(printAllNsServices, 30 seconds)
k8s.close
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment