コード例 #1
0
        public async Task <bool> CreateNamespaceAsync(string name)
        {
            logger.LogInformation("Getting cluster information - client - CreateNamespaceAsync");
            var kubernetes = await client.LoadBasedOnConfigurationAsync();

            logger.LogInformation("Creating namespace");

            var ns = new V1Namespace
            {
                Metadata = new V1ObjectMeta {
                    Name = name
                }
            };

            try
            {
                var result = kubernetes.CreateNamespace(ns);
                return(true);
            }
            catch (Exception e)
            {
                logger.LogError(e.Message);
            }

            return(false);
        }
コード例 #2
0
        public async Task <IEnumerable <V1Namespace> > ListNamespacesAsync()
        {
            logger.LogInformation("Getting cluster information - client - ListNamespacesAsync");
            var kubernetes = await client.LoadBasedOnConfigurationAsync();

            logger.LogInformation("Listining namespaces");
            try
            {
                var list = await kubernetes.ListNamespaceAsync();

                return(list.Items);
            }
            catch (Exception e)
            {
                logger.LogError(e.Message);
            }
            return(new List <V1Namespace>());
        }