Commit b4661a25 authored by Mathieu's avatar Mathieu
Browse files

Implements OpenMOLE pod deletion

parent a4693c48
......@@ -14,6 +14,7 @@ class AdminApiImpl(kubeOff: Boolean) extends shared.AdminApi {
def delete(userData: UserData): Seq[UserData] = {
val id = DB.uuid(Email(userData.email))
id.foreach { i =>
K8sService.deleteOpenMOLE(i)
DB.delete(toUser(i, userData))
}
users
......
......@@ -18,6 +18,10 @@ import scala.util.{Failure, Success}
object K8sService {
object Namespace {
val openmole = "openmole"
val connect = "connect"
}
def listPods = {
withK8s { k8s =>
......@@ -105,17 +109,23 @@ object K8sService {
def deployOpenMOLE(uuid: UUID) = {
withK8s { k8s =>
val podName = s"${uuid.value}"
val podName = uuid.value
val openmoleContainer = Container(
name = "openmole",
image = "openmole/openmole",
command = List("bin/bash", "-c", "openmole --port 80 --password password --http --remote --mem 1G")).exposePort(80)
val openmolePod = Pod(spec = Some(Pod.Spec().addContainer(openmoleContainer)), metadata = ObjectMeta(name = podName, namespace = "openmole"))
val openmolePod = Pod(podName, Pod.Spec().addContainer(openmoleContainer))
k8s create openmolePod
k8s.usingNamespace(Namespace.openmole) create openmolePod
}
}
def deleteOpenMOLE(uuid: UUID) = {
withK8s { k8s =>
k8s.usingNamespace(Namespace.openmole).delete[Pod](uuid.value)
}
}
......
Markdown is supported
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