Example #1
0
        static async Task CreateKubeJob(KubeClient kubeClient, ConfigurationKubernetes configuration, string label, int jobCount = 1)
        {
            if (jobCount <= 0)
            {
                return;
            }

            var configMap = await kubeClient.GetConfigMapListAsync(configuration.K8Namespace, configuration.JobConfigMapName);

            if (configMap == null)
            {
                throw new ApplicationException($"Configuration Map '{configuration.JobConfigMapName}' for the nanny queue");
            }

            var job_name = Guid.NewGuid().ToString();

            Console.WriteLine($"Job {job_name} has been created!");
            var job = await kubeClient.CreateJobAsync(job_name, jobCount, 1, configuration.ContainerName, configuration.ContainerImage, configuration.K8Secret, label, configMap.Data, configuration.K8Namespace, configuration.JobCpuRequest, configuration.JobMemRequest, configuration.JobCpuLimit, configuration.JobMemLimit);
        }