ADD: added a podcontroller and test for the first basic usage
This commit is contained in:
@@ -89,6 +89,10 @@ target_include_directories(kubecontrol PUBLIC
|
||||
add_custom_command(TARGET kubecontrol POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_SOURCE_DIR}/config $<TARGET_FILE_DIR:${PROJECT_NAME}>/config)
|
||||
|
||||
add_custom_command(TARGET kubecontrol POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_SOURCE_DIR}/docs $<TARGET_FILE_DIR:${PROJECT_NAME}>/docs)
|
||||
#
|
||||
# Everything TEST related
|
||||
#
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEozCCAwugAwIBAgIBATANBgkqhkiG9w0BAQsFADA+MRwwGgYDVQQKDBNUSS5V
|
||||
TklCVy1IQU1CVVJHLkRFMR4wHAYDVQQDDBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkw
|
||||
HhcNMjIwOTA4MTMyNTE2WhcNNDIwOTA4MTMyNTE2WjA+MRwwGgYDVQQKDBNUSS5V
|
||||
TklCVy1IQU1CVVJHLkRFMR4wHAYDVQQDDBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkw
|
||||
ggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDY1Q3atDj9YtgC1ktcGD7Y
|
||||
7frSmtspbP1W+rjJr/E5/Jm83tc0nSnE9BqnzGaEF/tuAq2yJRxf+vJlgcyUkd19
|
||||
XY6+Ow8d1XJuUKuuN0P3Lq9RtdTAhhQuYU5RmuQGQ5cy+PCm6Xy4BY3j+/T4z/Tf
|
||||
extD4DHsm63bNK9fRgrFIy4KtwXRlCOYSzT60jPjDArNBzYHLkFpN+U1h1cdBgYk
|
||||
ynA2hiPv86X96l5aMqXCNjMR2RuksGD+tkwOamSL+YwdK0wh7Szy7B+hMX3EPMBj
|
||||
6+c6VM/N84K/RoGks7eXR3I/nGPk0BBPmDlx1n86segQOFFgLC1e+ZZMHS7FRt7E
|
||||
3Pa7YL/l2rocoyxq3Y1ScVue7ffCJ11kjW+kVf7XpAl23cF6yxtfn7yY9CSXIaMH
|
||||
UcUeAF9hplYE9yluygWnHGJ8jQ62OB6Z6J2R8FuE9jxWtZcdpPec6TvwLbH3z4xz
|
||||
nJBUvcalKC7rpagvMkiK3HR/ReQo2L6cnYTJmAyXWm8CAwEAAaOBqzCBqDAfBgNV
|
||||
HSMEGDAWgBTAhqAZ30RPD9W8Dkk/fAAGWRH56zAPBgNVHRMBAf8EBTADAQH/MA4G
|
||||
A1UdDwEB/wQEAwIBxjAdBgNVHQ4EFgQUwIagGd9ETw/VvA5JP3wABlkR+eswRQYI
|
||||
KwYBBQUHAQEEOTA3MDUGCCsGAQUFBzABhilodHRwOi8vaXBhLWNhLnRpLnVuaWJ3
|
||||
LWhhbWJ1cmcuZGUvY2Evb2NzcDANBgkqhkiG9w0BAQsFAAOCAYEAdb89O6+MmSHM
|
||||
gF2YBBQRXpuZzeWFvcDOai+mhBW5yT2a7ycQt6vL1jiGbdP8HDi0p++ELqNYoGM+
|
||||
0sCjFFM4Su6I0qUSeXAWgGip/b0Yba1zGm+fQSMqVRtlFZduAVb+sIvWciYjXY7h
|
||||
VQrCkjAa8khj9dqPV1Yndx9dUR7qv4KluUNLc6SMEZ4WdGL4xGIvSc/Mp49UwP3f
|
||||
p7kio88qGTygpvO6rMcfwtkvhz1rb5s1tg+c9OkPBkTSyWIzg/6sNVB2n2I3mSJz
|
||||
F7fruyS6SfmgK+FWtKBvyD6htFPuBJrS9HFVHSHIgvE36xIOCWC50L1k4ZVOykoq
|
||||
dhu/v4HRrGZp9AkQjMzm3bqoua62YitF5LOAQb9idz7w2b7KwwqINHti186cxsv3
|
||||
9dpMlJVPIrf9Y97YAK2aV4OdEaDjWXVjfuJ2jrqOAV9gWqUCx6AxN4kCaaZ70NIp
|
||||
PtsUQZvheUOcmH/XWA+3R5iv6bFUfUYKBCagc5f7N9I+0p/OovwH
|
||||
-----END CERTIFICATE-----
|
||||
1
config/curl_command.txt
Normal file
1
config/curl_command.txt
Normal file
@@ -0,0 +1 @@
|
||||
curl -k https://10.96.0.1:443/api/v1/namespaces/hwinkel/pods -H "Authorization: Bearer $TOKEN"
|
||||
@@ -1,23 +0,0 @@
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = @PROJECT_NAME@
|
||||
PROJECT_NUMBER = "@GIT_BRANCH@ @GIT_COMMIT_HASH@"
|
||||
PROJECT_BRIEF = "library implementing a floats to libcms gateway"
|
||||
OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@/doxygen/
|
||||
OUTPUT_LANGUAGE = English
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = YES
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
TAB_SIZE = 4
|
||||
MARKDOWN_SUPPORT = YES
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
INPUT = @CMAKE_CURRENT_SOURCE_DIR@/README.md @CMAKE_CURRENT_SOURCE_DIR@/src/ @CMAKE_CURRENT_SOURCE_DIR@/tests/ @CMAKE_CURRENT_SOURCE_DIR@/docs @CMAKE_CURRENT_SOURCE_DIR@/include
|
||||
INPUT_ENCODING = UTF-8
|
||||
FILE_PATTERNS = *.hpp *.cpp *.md
|
||||
USE_MDFILE_AS_MAINPAGE = README.md
|
||||
RECURSIVE = YES
|
||||
@@ -1,99 +0,0 @@
|
||||
{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"v1\",\"kind\":\"Pod\",\"metadata\":{\"annotations\":{},\"labels\":{\"app.kubernetes.io/name\":\"plaindebian\"},\"name\":\"debug-debian\",\"namespace\":\"hwinkel\"},\"spec\":{\"containers\":[{\"args\":[\"-c\",\"while true; do echo hello; sleep 5;done\"],\"command\":[\"/bin/sh\"],\"env\":[{\"name\":\"OWN_SHIP_SERVER\",\"value\":\"127.0.0.1\"}],\"image\":\"kmaster.ti.unibw-hamburg.de:30808/debugdebianhenry:0.1.2\",\"name\":\"debug-debian-container\"}],\"restartPolicy\":\"Never\"}}\n"},
|
||||
"creationTimestamp":"2023-08-07T09:01:18Z",
|
||||
"labels":{"app.kubernetes.io/name":"plaindebian"},
|
||||
"managedFields":[
|
||||
{"apiVersion":"v1",
|
||||
"fieldsType":"FieldsV1",
|
||||
"fieldsV1":{
|
||||
"f:metadata":{
|
||||
"f:annotations":{
|
||||
".":{},
|
||||
"f:kubectl.kubernetes.io/last-applied-configuration":{}
|
||||
},
|
||||
"f:labels":{
|
||||
".":{},
|
||||
"f:app.kubernetes.io/name":{}
|
||||
}
|
||||
},
|
||||
"f:spec":{
|
||||
"f:containers":{
|
||||
"k:{\"name\":\"debug-debian-container\"}":{
|
||||
".":{},
|
||||
"f:args":{},
|
||||
"f:command":{},
|
||||
"f:env":{
|
||||
".":{},
|
||||
"k:{\"name\":\"OWN_SHIP_SERVER\"}":{
|
||||
".":{},"f:name":{},"f:value":{}
|
||||
}
|
||||
},
|
||||
"f:image":{},
|
||||
"f:imagePullPolicy":{},
|
||||
"f:name":{},
|
||||
"f:resources":{},
|
||||
"f:terminationMessagePath":{},
|
||||
"f:terminationMessagePolicy":{}
|
||||
}
|
||||
},
|
||||
"f:dnsPolicy":{},
|
||||
"f:enableServiceLinks":{},
|
||||
"f:restartPolicy":{},
|
||||
"f:schedulerName":{},
|
||||
"f:securityContext":{},
|
||||
"f:terminationGracePeriodSeconds":{}
|
||||
}
|
||||
},
|
||||
"manager":"kubectl-client-side-apply",
|
||||
"operation":"Update",
|
||||
"time":"2023-08-07T09:01:18Z"
|
||||
},
|
||||
{"apiVersion":"v1",
|
||||
"fieldsType":"FieldsV1",
|
||||
"fieldsV1":{
|
||||
"f:status":{
|
||||
"f:conditions":{
|
||||
"k:{\"type\":\"ContainersReady\"}":{
|
||||
".":{},
|
||||
"f:lastProbeTime":{},
|
||||
"f:lastTransitionTime":{},
|
||||
"f:status":{},
|
||||
"f:type":{}
|
||||
},
|
||||
"k:{\"type\":\"Initialized\"}":{
|
||||
".":{},
|
||||
"f:lastProbeTime":{},
|
||||
"f:lastTransitionTime":{},
|
||||
"f:status":{},
|
||||
"f:type":{}
|
||||
},
|
||||
"k:{\"type\":\"Ready\"}":{
|
||||
".":{},
|
||||
"f:lastProbeTime":{},
|
||||
"f:lastTransitionTime":{},
|
||||
"f:status":{},
|
||||
"f:type":{}
|
||||
}
|
||||
},
|
||||
"f:containerStatuses":{},
|
||||
"f:hostIP":{},
|
||||
"f:phase":{},
|
||||
"f:podIP":{},
|
||||
"f:podIPs":{
|
||||
".":{},
|
||||
"k:{\"ip\":\"10.0.3.70\"}":{
|
||||
".":{},
|
||||
"f:ip":{}
|
||||
}
|
||||
},
|
||||
"f:startTime":{}
|
||||
}
|
||||
},
|
||||
"manager":"kubelet",
|
||||
"operation":"Update",
|
||||
"subresource":"status",
|
||||
"time":"2023-08-07T09:01:20Z"}
|
||||
],
|
||||
"name":"debug-debian",
|
||||
"namespace":"hwinkel",
|
||||
"resourceVersion":"170886884",
|
||||
"uid":"f9df752e-2404-433f-b377-6e03721a5044"}
|
||||
@@ -28,9 +28,9 @@ namespace kubecontrol
|
||||
std::string* GetEnvironmentVar(std::string key);
|
||||
|
||||
std::string createYAML();
|
||||
nlohmann::json start(std::string apiAddress,std::string token);
|
||||
nlohmann::json stop(std::string apiAddress,std::string token);
|
||||
nlohmann::json getInfo(std::string apiAddress,std::string token);
|
||||
std::string start(std::string apiAddress,std::string token);
|
||||
std::string stop(std::string apiAddress,std::string token);
|
||||
std::string getInfo(std::string apiAddress,std::string token);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -11,10 +11,14 @@ namespace kubecontrol
|
||||
std::string getServerAddress();
|
||||
|
||||
void startPod(KubePod Pod);
|
||||
void stopPod(std::string Label);
|
||||
void stopAllPods();
|
||||
|
||||
std::string getPodsInfo();
|
||||
std::string getInfoForPod(std::string Label);
|
||||
|
||||
private:
|
||||
std::vector<KubePod> PodList;
|
||||
std::vector<KubePod> PodList_;
|
||||
|
||||
std::string BearerToken_;
|
||||
std::string ServerAddress_;
|
||||
|
||||
@@ -63,11 +63,12 @@ namespace kubecontrol
|
||||
|
||||
node["spec"]["containers"][0]["name"] = this->Label_+"-container";
|
||||
node["spec"]["containers"][0]["image"] = this->ContainerRegistry_ + "/" + this->ContainerImage_;
|
||||
node["spec"]["containers"][0]["imagePullPolicy"] = "Always";
|
||||
|
||||
int i = 0;
|
||||
for (auto item :EnvirmonentVars_) {
|
||||
node["spec"]["containers"][0]["env"][i]["name"] = item.first;
|
||||
node["spec"]["containers"][0]["env"][i]["value"] = R"(item.second)";
|
||||
node["spec"]["containers"][0]["env"][i]["value"] = item.second;
|
||||
|
||||
}
|
||||
|
||||
@@ -82,7 +83,7 @@ namespace kubecontrol
|
||||
|
||||
}
|
||||
|
||||
nlohmann::json KubePod::start(std::string apiAddress,std::string token)
|
||||
std::string KubePod::start(std::string apiAddress,std::string token)
|
||||
{
|
||||
std::string curlURL = apiAddress;
|
||||
std::string AuthString = "Authorization: Bearer " + token;
|
||||
@@ -109,28 +110,30 @@ namespace kubecontrol
|
||||
request.setOpt(new curlpp::options::Post(true));
|
||||
|
||||
|
||||
if(std::filesystem::exists(this->PathToYaml_) != true)
|
||||
{
|
||||
this->createYAML();
|
||||
}
|
||||
std::ifstream is;
|
||||
is.open (this->PathToYaml_, std::ios::binary );
|
||||
is.seekg (0, std::ios::end);
|
||||
long length = is.tellg();
|
||||
is.seekg (0, std::ios::beg);
|
||||
char *buffer = new char [length];
|
||||
is.read (buffer,length);
|
||||
|
||||
this->createYAML();
|
||||
|
||||
LOG_S(ERROR)<< this->PathToYaml_;
|
||||
|
||||
std::ifstream is;
|
||||
is.open (this->PathToYaml_, std::ios::binary );
|
||||
is.seekg (0, std::ios::end);
|
||||
long length = is.tellg();
|
||||
is.seekg (0, std::ios::beg);
|
||||
char *buffer = new char [length];
|
||||
is.read(buffer,length);
|
||||
is.close();
|
||||
|
||||
request.setOpt(new curlpp::options::PostFields(buffer));
|
||||
|
||||
request.perform();
|
||||
|
||||
request.reset();
|
||||
auto response = mWriterChunk.getResponse();
|
||||
return nlohmann::json::parse(response);
|
||||
return nlohmann::json::parse(response).dump();
|
||||
}
|
||||
|
||||
nlohmann::json KubePod::stop(std::string apiAddress,std::string token)
|
||||
std::string KubePod::stop(std::string apiAddress,std::string token)
|
||||
{
|
||||
std::string curlURL = apiAddress+ this->Uuid_;
|
||||
std::string AuthString = "Authorization: Bearer " + token;
|
||||
@@ -160,12 +163,12 @@ namespace kubecontrol
|
||||
|
||||
request.perform();
|
||||
auto response = mWriterChunk.getResponse();
|
||||
return nlohmann::json::parse(response);
|
||||
return nlohmann::json::parse(response).dump();
|
||||
}
|
||||
|
||||
nlohmann::json KubePod::getInfo(std::string apiAddress,std::string token)
|
||||
std::string KubePod::getInfo(std::string apiAddress,std::string token)
|
||||
{
|
||||
std::string curlURL = apiAddress;
|
||||
std::string curlURL = apiAddress+"/"+Uuid_;
|
||||
std::string AuthString = "Authorization: Bearer " + token;
|
||||
|
||||
std::list<std::string> headers;
|
||||
@@ -191,7 +194,7 @@ namespace kubecontrol
|
||||
|
||||
request.perform();
|
||||
auto response = mWriterChunk.getResponse();
|
||||
return nlohmann::json::parse(response);
|
||||
return nlohmann::json::parse(response).dump();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <kubecontrol/PodController.hpp>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace kubecontrol
|
||||
@@ -9,7 +12,20 @@ namespace kubecontrol
|
||||
YAML::Node config = YAML::LoadFile(pathToKubectlConfig);
|
||||
|
||||
BearerToken_ = config["users"][0]["user"]["token"].as<std::string>();
|
||||
ServerAddress_ = config["clusters"][0]["cluster"]["server"].as<std::string>();
|
||||
|
||||
char * KUBERNETES_SERVICE_HOST = std::getenv("KUBERNETES_SERVICE_HOST");
|
||||
char * KUBERNETES_SERVICE_PORT = std::getenv("KUBERNETES_SERVICE_PORT");
|
||||
|
||||
if (KUBERNETES_SERVICE_HOST != nullptr && KUBERNETES_SERVICE_PORT!= nullptr)
|
||||
{
|
||||
ServerAddress_ = std::string(KUBERNETES_SERVICE_HOST)+":"+std::string(KUBERNETES_SERVICE_PORT);
|
||||
} else
|
||||
{
|
||||
LOG_S(INFO)<<"Taking Serveraddress out of the provided YAML file";
|
||||
|
||||
ServerAddress_ = config["clusters"][0]["cluster"]["server"].as<std::string>();
|
||||
}
|
||||
|
||||
ApiCall_ = "/api/v1/namespaces/hwinkel/pods/";
|
||||
}
|
||||
|
||||
@@ -19,4 +35,83 @@ namespace kubecontrol
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PodController::startPod(KubePod Pod)
|
||||
{
|
||||
PodList_.emplace_back(Pod);
|
||||
LOG_S(INFO)<< "starting pod: "<<Pod.getUUID();
|
||||
|
||||
Pod.start(ServerAddress_+ApiCall_, BearerToken_);
|
||||
|
||||
}
|
||||
|
||||
void PodController::stopPod(std::string Label)
|
||||
{
|
||||
for (auto item : PodList_)
|
||||
{
|
||||
if (Label == item.getLabel())
|
||||
{
|
||||
item.stop(ServerAddress_+ApiCall_, BearerToken_);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PodController::stopAllPods()
|
||||
{
|
||||
for (auto item : PodList_)
|
||||
{
|
||||
item.stop(ServerAddress_+ApiCall_, BearerToken_);
|
||||
LOG_S(INFO)<< "stopping pod: "<<item.getUUID();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string PodController::getPodsInfo()
|
||||
{
|
||||
std::string curlURL = ServerAddress_+ApiCall_;
|
||||
std::string AuthString = "Authorization: Bearer " + BearerToken_;
|
||||
|
||||
std::list<std::string> headers;
|
||||
headers.push_back(AuthString);
|
||||
|
||||
curlpp::Easy request;
|
||||
|
||||
WriterMemoryClass mWriterChunk;
|
||||
curlpp::types::WriteFunctionFunctor functor = std::bind(&WriterMemoryClass::WriteMemoryCallback, &mWriterChunk, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
curlpp::options::WriteFunction *test = new curlpp::options::WriteFunction(functor);
|
||||
request.setOpt(test);
|
||||
|
||||
request.setOpt(new curlpp::options::HttpHeader(headers));
|
||||
|
||||
request.setOpt(new curlpp::options::Url(curlURL));
|
||||
// request.setOpt(new curlpp::options::SslEngineDefault());
|
||||
// request.setOpt(new curlpp::options::CaPath("config/ca.crt"));
|
||||
request.setOpt(new curlpp::options::SslVerifyPeer(false));
|
||||
|
||||
|
||||
// request.setOpt(new curlpp::options::Verbose(true));
|
||||
|
||||
|
||||
request.perform();
|
||||
auto response = mWriterChunk.getResponse();
|
||||
|
||||
auto j = nlohmann::json::parse(response);
|
||||
return j.dump();
|
||||
}
|
||||
|
||||
|
||||
std::string PodController::getInfoForPod(std::string Label)
|
||||
{
|
||||
for (auto item : PodList_)
|
||||
{
|
||||
if (Label == item.getLabel())
|
||||
{
|
||||
return item.getInfo(ServerAddress_+ApiCall_, BearerToken_);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
#include "nlohmann/json_fwd.hpp"
|
||||
#include "yaml-cpp/binary.h"
|
||||
#include "yaml-cpp/emitter.h"
|
||||
#include "yaml-cpp/emitterdef.h"
|
||||
#include "yaml-cpp/emittermanip.h"
|
||||
#include "yaml-cpp/emitterstyle.h"
|
||||
#include "yaml-cpp/node/convert.h"
|
||||
#include "yaml-cpp/node/node.h"
|
||||
#include <iomanip>
|
||||
#include <kubecontrol/kubecontrol.hpp>
|
||||
|
||||
|
||||
@@ -10,6 +15,7 @@
|
||||
#include <curlpp/Options.hpp>
|
||||
#include <curlpp/Exception.hpp>
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <yaml-cpp/yaml.h>
|
||||
@@ -109,6 +115,12 @@ namespace kubecontrol
|
||||
|
||||
|
||||
auto yaml = createYAML();
|
||||
|
||||
// YAML::Node node = YAML::LoadFile("config/pods_deployment.yaml");
|
||||
// YAML::Binary node = YAML::LoadFile("config/pods_deployment.yaml");
|
||||
// LOG_S(INFO)<< node["spec"]["containers"][0]["imagePullPolicy"];
|
||||
// YAML::Binary binary = node.as<YAML::Binary>();
|
||||
|
||||
std::ifstream is;
|
||||
is.open ("config/pods_deployment.yaml", std::ios::binary );
|
||||
|
||||
@@ -137,7 +149,7 @@ namespace kubecontrol
|
||||
|
||||
request.perform();
|
||||
auto response = mWriterChunk.getResponse();
|
||||
// LOG_S(INFO)<<response;
|
||||
LOG_S(INFO)<<response;
|
||||
}
|
||||
|
||||
|
||||
@@ -188,17 +200,24 @@ namespace kubecontrol
|
||||
|
||||
|
||||
YAML::Node node;
|
||||
|
||||
node["apiVersion"] = "v1";
|
||||
node["kind"] = "Pod";
|
||||
node["metadata"]["name"] = "debug-debian";
|
||||
node["metadata"]["labels"]["app.kubernetes.io/name"] = "plaindebian";
|
||||
|
||||
node["spec"]["containers"][0]["name"] = "debug-debian-container";
|
||||
node["spec"]["containers"][0]["image"] = "kmaster.ti.unibw-hamburg.de:30808/debugdebianhenry:0.1.2";
|
||||
node["spec"]["containers"][0]["image"] = "kmaster.ti.unibw-hamburg.de:30808/debugdebianhenry:0.1.3";
|
||||
|
||||
|
||||
// node["spec"]["containers"][0]["imagePullPolicy"] = "\"Always\"";
|
||||
|
||||
node["spec"]["containers"][0]["env"][0]["name"] = "OWN_SHIP_SERVER";
|
||||
node["spec"]["containers"][0]["env"][0]["value"] = "127.0.0.1";
|
||||
|
||||
node["spec"]["containers"][0]["env"][1]["name"] = "TOKEN";
|
||||
node["spec"]["containers"][0]["env"][1]["value"] = BearerToken_;
|
||||
|
||||
|
||||
node["spec"]["containers"][0]["args"].SetStyle(YAML::EmitterStyle::Flow);
|
||||
node["spec"]["containers"][0]["args"].push_back("-c");
|
||||
node["spec"]["containers"][0]["args"].push_back("while true; do echo hello; sleep 5;done");
|
||||
@@ -210,7 +229,10 @@ namespace kubecontrol
|
||||
|
||||
|
||||
std::ofstream fout("config/pods_deployment.yaml");
|
||||
fout << node;
|
||||
std::stringstream ss;
|
||||
ss <<node;
|
||||
LOG_S(INFO)<< node;
|
||||
fout << ss.str();
|
||||
fout.close();
|
||||
|
||||
return "config/pods_deployment.yaml";
|
||||
|
||||
@@ -20,13 +20,13 @@ SCENARIO("Testing the SimCore Sensor")
|
||||
|
||||
// std::string uuid = "random" + std::to_string(random);
|
||||
|
||||
kubecontrol::KubePod pod1("debug-debian",uuid,"debugdebianhenry:0.1.2");
|
||||
kubecontrol::KubePod pod1("debug-debian",uuid,"debugdebianhenry:0.1.3");
|
||||
pod1.setEnvironmentVar("OWN_SHIP_SERVER", "127.0.0.1");
|
||||
LOG_S(INFO)<<pod1.createYAML();
|
||||
|
||||
pod1.start(api,token);
|
||||
LOG_S(INFO)<< pod1.getInfo(api, token).dump();
|
||||
pod1.stop(api,token);
|
||||
LOG_S(INFO)<<pod1.start(api,token);
|
||||
LOG_S(INFO)<< pod1.getInfo(api, token);
|
||||
// pod1.stop(api,token);
|
||||
|
||||
WHEN("constructing Track Object with data")
|
||||
{
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
|
||||
|
||||
|
||||
#include "yaml-cpp/binary.h"
|
||||
#include "yaml-cpp/emitter.h"
|
||||
#include "yaml-cpp/node/node.h"
|
||||
#include "yaml-cpp/node/parse.h"
|
||||
#include <string>
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include <kubecontrol/kubecontrol.hpp>
|
||||
|
||||
#include <loguru.hpp>
|
||||
|
||||
SCENARIO("Testing the SimCore Sensor")
|
||||
{
|
||||
@@ -16,7 +21,7 @@ kubecontrol::kubecontrol kc("../docs/config");
|
||||
kc.createYAML();
|
||||
kc.startPod();
|
||||
// kc.getPods();
|
||||
kc.deletePod("debug-debian");
|
||||
// kc.deletePod("debug-debian");
|
||||
kc.getPods();
|
||||
|
||||
WHEN("constructing Track Object with data")
|
||||
|
||||
@@ -1,19 +1,36 @@
|
||||
|
||||
|
||||
|
||||
#include "kubecontrol/KubePod.hpp"
|
||||
#include "nlohmann/json_fwd.hpp"
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include <kubecontrol/PodController.hpp>
|
||||
#include <crossguid/guid.hpp>
|
||||
|
||||
|
||||
SCENARIO("Testing the SimCore Sensor")
|
||||
{
|
||||
kubecontrol::PodController podc("../docs/config");
|
||||
kubecontrol::PodController podc("docs/config");
|
||||
|
||||
|
||||
kubecontrol::KubePod pod1("pod1",xg::newGuid().str(),"debugdebianhenry:0.1.3");
|
||||
|
||||
kubecontrol::KubePod pod2("pod2",xg::newGuid().str(),"debugdebianhenry:0.1.3");
|
||||
|
||||
podc.startPod(pod1);
|
||||
podc.startPod(pod2);
|
||||
std::string info1 = "";
|
||||
info1 = podc.getInfoForPod("pod1");
|
||||
nlohmann::json j1 = nlohmann::json::parse(info1);
|
||||
|
||||
nlohmann::json jall = nlohmann::json::parse(podc.getPodsInfo());
|
||||
|
||||
// podc.stopAllPods();
|
||||
|
||||
GIVEN("different Attributes for a Track in different forms")
|
||||
{
|
||||
LOG_S(INFO)<< podc.getServerAddress();
|
||||
WHEN("constructing Track Object with data")
|
||||
{
|
||||
|
||||
@@ -21,6 +38,8 @@ kubecontrol::PodController podc("../docs/config");
|
||||
{
|
||||
REQUIRE(true == true);
|
||||
|
||||
// REQUIRE(info1 != "");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user