Пример #1
0
        public V1Pod CreateCadReaderPod(string _PodName, string _Namespace, Dictionary <string, string> _PythonWorkerVars, Dictionary <string, string> _FileWorkerVars, Action <string> _ErrorMessageAction = null)
        {
            PodBuilder Builder = new PodBuilder();

            Builder.SetName(_PodName)
            .SetNamespace(_Namespace)
            .SetRestartPolicy("Never")
            .AddLabel("pod-type", "batch-pod")
            .AddAnnotation("cluster-autoscaler.kubernetes.io/safe-to-evict", "true")
            .AddNodeSelector("batch-node", "true")
            .AddToleration("NoSchedule", "reserved-pool", "true", "Equal")
            .AddPodAntiAffinity("kubernetes.io/hostname", "pod-type", "In", new List <string>()
            {
                "batch-pod"
            })
            .AddPodAntiAffinityPreference("kubernetes.io/hostname", "pod-type", "In", new List <string>()
            {
                "optimizer-pod-ue"
            })
            .AddContainer("redis", "redis", "IfNotPresent", new int[] { 6379 }, new Dictionary <string, string>())
            .AddContainer("cad-reader", CadReaderReaderImage, "IfNotPresent", new int[] { 8080 }, _PythonWorkerVars)
            .AddContainer("worker", WorkerImage, "IfNotPresent", new int[] { 8081 }, _FileWorkerVars);

            try
            {
                return(KClient.CreateNamespacedPod(Builder.GetPod(), Builder.GetNamespace()));
            }
            catch (Exception ex)
            {
                _ErrorMessageAction?.Invoke($"Failed to start Pod {_PodName} : {ex.Message}\n{ex.StackTrace}");
                return(null);
            }
        }
Пример #2
0
        public V1Pod CreateFileOptimizerPod(string _PodName, string _Namespace, Dictionary <string, string> _OptimizerEnvVars, Dictionary <string, List <string> > Command, Action <string> _ErrorMessageAction = null)
        {
            PodBuilder Builder = new PodBuilder();

            Builder.SetName(_PodName)
            .SetNamespace(_Namespace)
            .SetRestartPolicy("Never")
            .AddLabel("pod-type", "optimizer-pod")
            .AddAnnotation("cluster-autoscaler.kubernetes.io/safe-to-evict", "true")
            .AddNodeSelector("batch-node", "true")
            .AddToleration("NoSchedule", "reserved-pool", "true", "Equal")
            .AddPodAntiAffinity("kubernetes.io/hostname", "pod-type", "In", new List <string>()
            {
                "optimizer-pod"
            })
            .AddContainer("file-optimizer", FileOptimizerImage, "IfNotPresent", new int[] { 8082 }, _OptimizerEnvVars, Command);


            return(KClient.CreateNamespacedPod(Builder.GetPod(), Builder.GetNamespace()));
        }