sparse-intern-71089
04/13/2022, 12:52 AMbillowy-army-68599
able-train-72108
04/13/2022, 2:22 AMable-train-72108
04/13/2022, 7:58 PMbillowy-army-68599
able-train-72108
04/13/2022, 8:04 PMbillowy-army-68599
able-train-72108
04/13/2022, 8:04 PMable-train-72108
04/13/2022, 8:05 PMvar vnet = new AzureNative.Network.VirtualNetwork("cluster-network", new AzureNative.Network.VirtualNetworkArgs
        {
            Tags = tags,
            VirtualNetworkName = $"akp-{stack}-vnet",
            ResourceGroupName = resourceGroup.Name,
            AddressSpace = new AzureNative.Network.Inputs.AddressSpaceArgs
            {
                AddressPrefixes = new[] { "10.0.0.0/8" }
            }
        });
        this.VNetName = vnet.Name;
        this.VNetId = vnet.Id;
        var subnet = new AzureNative.Network.Subnet("cluster-subnet", new AzureNative.Network.SubnetArgs
        {
            Name = $"akp-{stack}-cluster-subnet",
            ResourceGroupName = resourceGroup.Name,
            VirtualNetworkName = vnet.Name,
            AddressPrefix = "10.0.0.0/16" // nodes and pods are using this, by default Azure creates a /16
        });able-train-72108
04/13/2022, 8:06 PMvar agentProfile = new InputList<ManagedClusterAgentPoolProfileArgs>
        {
            new ManagedClusterAgentPoolProfileArgs
            {
                MaxPods = 50,
                EnableAutoScaling = true,
                Count = 3,
                MinCount = 3,
                MaxCount = 10,
                Mode = AgentPoolMode.System,
                Name = "agentpool",
                OsDiskSizeGB = 30,
                OsType = OSType.Linux,
                Type = AgentPoolType.VirtualMachineScaleSets,
                VmSize = "Standard_D4s_v4",
                AvailabilityZones = new[] { "1", "2", "3" },
                VnetSubnetID = subnet.Id,
                Tags = tags,
            },
        };able-train-72108
04/19/2022, 1:54 PMable-train-72108
04/19/2022, 1:54 PMinternal class MyStack : Stack
{
    public MyStack()
    {
        var stack = Pulumi.Deployment.Instance.StackName;
        var resourceGroup = new ResourceGroup($"rgSubnetDeletionBug", new ResourceGroupArgs());
        var vnet = new AzureNative.Network.VirtualNetwork("a-vnet", new AzureNative.Network.VirtualNetworkArgs
        {
            VirtualNetworkName = $"a-vnet",
            ResourceGroupName = resourceGroup.Name,
            AddressSpace = new AzureNative.Network.Inputs.AddressSpaceArgs
            {
                AddressPrefixes = new[] { "10.0.0.0/8" }
            },
            //run pulumi up once. then uncomment this and run pulumi up again
            /*Subnets =
            {
                new AzureNative.Network.Inputs.SubnetArgs
                {
                    AddressPrefix = "10.1.0.0/24",
                    Name = "subnet-created-with-vnet",
                },
            },*/
        });
        var subnet = new AzureNative.Network.Subnet("this-subnet-gets-deleted", new AzureNative.Network.SubnetArgs
        {
            Name = $"this-subnet-gets-deleted",
            ResourceGroupName = resourceGroup.Name,
            VirtualNetworkName = vnet.Name,
            AddressPrefix = "10.0.0.0/16"
        });
        //create a NIC attached to this-subnet-gets-deleted to get azure to throw error when it tries to delete this-subnet-gets-deleted
        var networkInterface = new AzureNative.Network.NetworkInterface("networkInterface", new AzureNative.Network.NetworkInterfaceArgs
        {
            EnableAcceleratedNetworking = true,
            IpConfigurations =
            {
                new AzureNative.Network.Inputs.NetworkInterfaceIPConfigurationArgs
                {
                    Name = "ipconfig1",
                    Subnet = new AzureNative.Network.Inputs.SubnetArgs
                    {
                        Id = subnet.Id
                    },
                },
            },
            NetworkInterfaceName = "test-nic",
            ResourceGroupName = resourceGroup.Name,
        });
    }
}able-train-72108
04/19/2022, 1:56 PMable-train-72108
04/19/2022, 1:57 PMable-train-72108
04/22/2022, 1:40 PM