From f95542b8936a5f812e61d7b15b85fb7d70082cbb Mon Sep 17 00:00:00 2001 From: Henry Winkel Date: Wed, 27 Sep 2023 09:20:04 +0200 Subject: [PATCH] ADD: added setting of namespace in to KubePod class --- include/kubecontrol/KubePod.hpp | 5 +++-- src/kubecontrol/KubePod.cpp | 11 +++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/kubecontrol/KubePod.hpp b/include/kubecontrol/KubePod.hpp index 7848cc4..4860fcf 100644 --- a/include/kubecontrol/KubePod.hpp +++ b/include/kubecontrol/KubePod.hpp @@ -26,8 +26,8 @@ namespace kubecontrol class KubePod { public: - KubePod(std::string Owner, std::string Uuid, std::string ContainerImage); - KubePod(std::string Owner, std::string Uuid, std::string Component, std::string ContainerImage); + KubePod(std::string Owner, std::string Uuid, std::string ContainerImage,std::string Namespace = "simulator"); + KubePod(std::string Owner, std::string Uuid, std::string Component, std::string ContainerImage,std::string Namespace = "simulator"); std::string getUUID(); std::string getOwner(); @@ -62,6 +62,7 @@ namespace kubecontrol std::string ContainerImage_; std::string ContainerRegistry_; std::string PathToYaml_; + std::string Namespace_; std::string PodCommand_; diff --git a/src/kubecontrol/KubePod.cpp b/src/kubecontrol/KubePod.cpp index 3b2f073..515f04f 100644 --- a/src/kubecontrol/KubePod.cpp +++ b/src/kubecontrol/KubePod.cpp @@ -22,8 +22,8 @@ namespace kubecontrol - KubePod::KubePod(std::string Owner, std::string Uuid, std::string ContainerImage):Owner_(Utils::to_lower(Owner)),Uuid_(Utils::to_lower(Uuid)), - ContainerImage_(ContainerImage),EnvirmonentVars_() + KubePod::KubePod(std::string Owner, std::string Uuid, std::string ContainerImage,std::string Namespace):Owner_(Utils::to_lower(Owner)),Uuid_(Utils::to_lower(Uuid)), + ContainerImage_(ContainerImage),Namespace_(Namespace),EnvirmonentVars_() { ContainerRegistry_ = "kmaster.ti.unibw-hamburg.de:30808"; EnvirmonentVars_ = std::map(); @@ -42,8 +42,8 @@ namespace kubecontrol } - KubePod::KubePod(std::string Owner, std::string Uuid, std::string Component, std::string ContainerImage):Owner_(Utils::to_lower(Owner)), - Uuid_(Utils::to_lower(Uuid)),Component_(Utils::to_lower(Component)), ContainerImage_(ContainerImage),EnvirmonentVars_() + KubePod::KubePod(std::string Owner, std::string Uuid, std::string Component, std::string ContainerImage,std::string Namespace):Owner_(Utils::to_lower(Owner)), + Uuid_(Utils::to_lower(Uuid)),Component_(Utils::to_lower(Component)), ContainerImage_(ContainerImage),Namespace_(Namespace),EnvirmonentVars_() { ContainerRegistry_ = "kmaster.ti.unibw-hamburg.de:30808"; EnvirmonentVars_ = std::map(); @@ -133,6 +133,7 @@ namespace kubecontrol node["apiVersion"] = "v1"; node["kind"] = "Pod"; node["metadata"]["name"] = this->Uuid_; + node["metadata"]["namespace"] = this->Namespace_; node["metadata"]["labels"]["app.kubernetes.io/name"] = this->Uuid_; node["metadata"]["labels"]["app.kubernetes.io/part-of"] = this->Owner_; @@ -143,6 +144,8 @@ namespace kubecontrol node["spec"]["containers"][0]["name"] = this->Uuid_+"-container"; node["spec"]["containers"][0]["image"] = this->ContainerRegistry_ + "/" + this->ContainerImage_; node["spec"]["containers"][0]["imagePullPolicy"] = "Always"; + node["spec"]["containers"][0]["ports"][0]["containerPort"] = 10000; + node["spec"]["containers"][0]["ports"][0]["protocol"] = "UDP"; int i = 0; for (auto item :EnvirmonentVars_) {