Ejemplo n.º 1
0
        /// <summary>
        /// CreateConnectedCluster creates a connected cluster
        /// </summary>
        /// <param name="resourceManagementClient"></param>
        /// <param name="kubernetesServiceClient"></param>
        /// <param name="location"></param>
        /// <param name="clusterName"></param>
        /// <param name="resourceGroupName"></param>
        /// <returns></returns>
        internal async static Task <ConnectedCluster> CreateConnectedCluster(
            MockContext context,
            ResourceManagementClient resourceManagementClient,
            ConnectedKubernetesClient kubernetesServiceClient,
            string location,
            string clusterName,
            string resourceGroupName)
        {
            TestEnvironment testEnvironment = TestEnvironmentFactory.GetTestEnvironment();

            var connectedClusterIdentity = new ConnectedClusterIdentity();

            connectedClusterIdentity.Type = ResourceIdentityType.SystemAssigned;

            ConnectedCluster desiredConnectedCluster = new ConnectedCluster
            {
                Location = location,
                Identity = connectedClusterIdentity,
                AgentPublicKeyCertificate = "testpubkey",
                Distribution   = "generic",
                Infrastructure = "generic"
            };

            var cluster = await kubernetesServiceClient.ConnectedCluster.CreateAsync(resourceGroupName, clusterName, desiredConnectedCluster);

            return(cluster);
        }
        public async Task CreateConnectedClusterTest()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                InitializeClients(context);

                string location = KubernetesServiceTestUtilities.GetLocationFromProvider(resourceManagementClient);

                var resourceGroup = resourceManagementClient.TryGetResourceGroup(location);
                if (string.IsNullOrWhiteSpace(resourceGroup))
                {
                    resourceGroup = TestUtilities.GenerateName(KubernetesServiceTestUtilities.ResourceGroupPrefix);
                    resourceManagementClient.TryRegisterResourceGroup(location, resourceGroup);
                }

                string clusterName = TestUtilities.GenerateName();

                // Create a connected cluster
                ConnectedCluster connectedClusterResult = await KubernetesServiceTestUtilities.CreateConnectedCluster(
                    context,
                    ResourceManagementClient,
                    ConnectedKubernetesClient,
                    location,
                    clusterName,
                    resourceGroup);

                Assert.NotNull(connectedClusterResult);
                Assert.Equal(clusterName, connectedClusterResult.Name);
                Assert.Equal(connectedClusterResult.ProvisioningState, ProvisioningState.Succeeded);

                // Clean up our Azure resources
                ResourceManagementClient.ResourceGroups.DeleteAsync(resourceGroup).Wait();
            }
        }
        public async Task DeleteConnectedClusterTest()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                InitializeClients(context);

                string location = KubernetesServiceTestUtilities.GetLocationFromProvider(resourceManagementClient);

                var resourceGroup = resourceManagementClient.TryGetResourceGroup(location);
                if (string.IsNullOrWhiteSpace(resourceGroup))
                {
                    resourceGroup = TestUtilities.GenerateName(KubernetesServiceTestUtilities.ResourceGroupPrefix);
                    resourceManagementClient.TryRegisterResourceGroup(location, resourceGroup);
                }

                string clusterName = TestUtilities.GenerateName();

                // Create a connected cluster
                ConnectedCluster managedClusterResult = await KubernetesServiceTestUtilities.CreateConnectedCluster(
                    context,
                    ResourceManagementClient,
                    ConnectedKubernetesClient,
                    location,
                    clusterName,
                    resourceGroup);

                // Wait for 10 seconds a sanity check
                TestUtilities.Wait(10000);

                // Delete the cluster
                kubernetesServiceClient.ConnectedCluster.DeleteAsync(resourceGroup, clusterName).Wait();

                // List clusters by resource group
                var listConnectedCluster = await kubernetesServiceClient.ConnectedCluster.ListByResourceGroupAsync(resourceGroup);

                Assert.True(!listConnectedCluster.IsAny());

                // Clean up our Azure resources
                ResourceManagementClient.ResourceGroups.DeleteAsync(resourceGroup).Wait();
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Register a new Kubernetes cluster with Azure Resource Manager.
 /// </summary>
 /// <remarks>
 /// API to register a new Kubernetes cluster and create a tracked resource in
 /// Azure Resource Manager (ARM).
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='clusterName'>
 /// The name of the Kubernetes cluster on which get is called.
 /// </param>
 /// <param name='connectedCluster'>
 /// Parameters supplied to Create a Connected Cluster.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <ConnectedCluster> CreateAsync(this IConnectedClusterOperations operations, string resourceGroupName, string clusterName, ConnectedCluster connectedCluster, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, clusterName, connectedCluster, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Register a new Kubernetes cluster with Azure Resource Manager.
 /// </summary>
 /// <remarks>
 /// API to register a new Kubernetes cluster and create a tracked resource in
 /// Azure Resource Manager (ARM).
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='clusterName'>
 /// The name of the Kubernetes cluster on which get is called.
 /// </param>
 /// <param name='connectedCluster'>
 /// Parameters supplied to Create a Connected Cluster.
 /// </param>
 public static ConnectedCluster Create(this IConnectedClusterOperations operations, string resourceGroupName, string clusterName, ConnectedCluster connectedCluster)
 {
     return(operations.CreateAsync(resourceGroupName, clusterName, connectedCluster).GetAwaiter().GetResult());
 }