ADD: added setting of namespace in to KubePod class

This commit is contained in:
Henry Winkel
2023-09-27 09:20:04 +02:00
parent 5d3dcb25db
commit f95542b893
2 changed files with 10 additions and 6 deletions

View File

@@ -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_;

View File

@@ -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<std::string, std::string>();
@@ -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<std::string, std::string>();
@@ -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_) {