Esempio n. 1
0
        public async Task <IActionResult> DeleteHPAAsync
            ([FromRoute] string hpaName,
            [FromRoute] string tenantName,
            [FromRoute] string groupName)
        {
            var serviceController = new MTAHPAController(hpaName, string.Empty, tenantName, groupName);
            var respondeModel     = await serviceController.DeleteHPAAsync(_k8sClient);

            if (respondeModel != null)
            {
                return(BadRequest(respondeModel));
            }

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> CreateHPAAsync
            ([FromBody] MTAHPAModel hpaBody,
            [FromRoute] string hpaName,
            [FromRoute] string tenantName,
            [FromRoute] string groupName)
        {
            var path    = string.Concat(GetTemplatesPath(), "/template-hpa.yaml");
            var hpaList = await Yaml.LoadAllFromFileAsync(path);

            var yamlBody      = hpaList[0] as V1HorizontalPodAutoscaler;
            var deployName    = hpaBody.DeploymentName;
            var hpaController = new MTAHPAController(hpaName, deployName, tenantName, groupName);
            var respondeModel = await hpaController.CreateHPAAsync
                                    (_k8sClient, yamlBody, hpaBody);

            if (respondeModel.Item2 != null)
            {
                return(BadRequest(respondeModel.Item2));
            }

            return(Created(Url.RouteUrl("CreateService", new { hpaName, groupName }),
                           respondeModel.Item1));
        }