#pragma once #include "kubecontrol/KubernetesAPI.hpp" #include #include #include #include #include #include namespace kubecontrol { class PodController { public: /** * @brief constructs the podcontroller * @param pathToKubectlConfig - string path to the kubectl config file */ explicit PodController(std::string pathToKubectlConfig); /** * @brief returns the Server Address of the given kubernetes api * @return string */ std::string getServerAddress(); /** * @brief starts a pod * @param Pod - pod objet * @param WaitTillRunning - bool (default: true) indicates if the controller should wait till the pod is startet */ void startPod(KubePod Pod,bool WaitTillRunning = true ); /** * @brief starts a pod * @param Pod - std::shared_ptr objet * @param WaitTillRunning - bool (default: true) indicates if the controller should wait till the pod is startet */ void startPod(std::shared_ptr Pod,bool WaitTillRunning = true ); /** * @brief stops a pod referenced by its uuid * @param uuid - string */ void stopPod(std::string uuid); /** * @brief stops all pods the controller knows */ void stopAllPods(); /** * @brief returns a vector of PodInfos of all pod * @return std::vector */ std::vector getInfoForAllPods(); /** * @brief returns a PodInfo object of a specific pod * @param uuid - string * @return PodInfo */ PodInfos getInfoForPod(std::string uuid); /** * @brief retursn a copy of ne current used kubernetes API */ KubernetesAPI getKubernetesAPI(); private: /// @brief object of the kubernetes api object KubernetesAPI APIInterface_; /// @brief vector of unique poitners of owned KubePod objects std::vector> PodList_; /// @brief current namespace std::string Namespace_; /// @brief base apiCall (default: "/api/v1/namespaces/Simulator/pods/") std::string ApiCall_; /** * @brief gets infos for specific pod */ PodInfos extractInfosFromKubePod(KubePod *pod); /// @brief mutex mutable std::mutex mx_; }; } // namespace ku