Ejemplo n.º 1
0
 /// <summary>
 /// Creates or updates a Kubernetes Environment.
 /// </summary>
 /// <remarks>
 /// Description for Creates or updates a Kubernetes Environment.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Name of the resource group to which the resource belongs.
 /// </param>
 /// <param name='name'>
 /// Name of the Kubernetes Environment.
 /// </param>
 /// <param name='kubeEnvironmentEnvelope'>
 /// Configuration details of the Kubernetes Environment.
 /// </param>
 public static KubeEnvironment BeginCreateOrUpdate(this IKubeEnvironmentsOperations operations, string resourceGroupName, string name, KubeEnvironment kubeEnvironmentEnvelope)
 {
     return(operations.BeginCreateOrUpdateAsync(resourceGroupName, name, kubeEnvironmentEnvelope).GetAwaiter().GetResult());
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates or updates a Kubernetes Environment.
 /// </summary>
 /// <remarks>
 /// Description for Creates or updates a Kubernetes Environment.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Name of the resource group to which the resource belongs.
 /// </param>
 /// <param name='name'>
 /// Name of the Kubernetes Environment.
 /// </param>
 /// <param name='kubeEnvironmentEnvelope'>
 /// Configuration details of the Kubernetes Environment.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <KubeEnvironment> BeginCreateOrUpdateAsync(this IKubeEnvironmentsOperations operations, string resourceGroupName, string name, KubeEnvironment kubeEnvironmentEnvelope, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, name, kubeEnvironmentEnvelope, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Ejemplo n.º 3
0
    public MyStack()
    {
        var resourceGroup = new ResourceGroup("rg");

        var workspace = new Workspace("loganalytics", new WorkspaceArgs
        {
            ResourceGroupName = resourceGroup.Name,
            Sku = new WorkspaceSkuArgs {
                Name = "PerGB2018"
            },
            RetentionInDays = 30,
        });

        var workspaceSharedKeys = Output.Tuple(resourceGroup.Name, workspace.Name).Apply(items =>
                                                                                         GetSharedKeys.InvokeAsync(new GetSharedKeysArgs
        {
            ResourceGroupName = items.Item1,
            WorkspaceName     = items.Item2,
        }));

        var kubeEnv = new KubeEnvironment("env", new KubeEnvironmentArgs
        {
            ResourceGroupName = resourceGroup.Name,
            Type = "Managed",
            AppLogsConfiguration = new AppLogsConfigurationArgs
            {
                Destination = "log-analytics",
                LogAnalyticsConfiguration = new LogAnalyticsConfigurationArgs
                {
                    CustomerId = workspace.CustomerId,
                    SharedKey  = workspaceSharedKeys.Apply(r => r.PrimarySharedKey)
                }
            }
        });

        var registry = new Registry("registry", new RegistryArgs
        {
            ResourceGroupName = resourceGroup.Name,
            Sku = new SkuArgs {
                Name = "Basic"
            },
            AdminUserEnabled = true
        });

        var credentials = Output.Tuple(resourceGroup.Name, registry.Name).Apply(items =>
                                                                                ListRegistryCredentials.InvokeAsync(new ListRegistryCredentialsArgs
        {
            ResourceGroupName = items.Item1,
            RegistryName      = items.Item2
        }));
        var adminUsername = credentials.Apply(credentials => credentials.Username);
        var adminPassword = credentials.Apply(credentials => credentials.Passwords[0].Value);

        var customImage = "node-app";
        var myImage     = new Image(customImage, new ImageArgs
        {
            ImageName = Output.Format($"{registry.LoginServer}/{customImage}:v1.0.0"),
            Build     = new DockerBuild {
                Context = $"./{customImage}"
            },
            Registry = new ImageRegistry
            {
                Server   = registry.LoginServer,
                Username = adminUsername,
                Password = adminPassword
            }
        });

        var containerApp = new ContainerApp("app", new ContainerAppArgs
        {
            ResourceGroupName = resourceGroup.Name,
            KubeEnvironmentId = kubeEnv.Id,
            Configuration     = new ConfigurationArgs
            {
                Ingress = new IngressArgs
                {
                    External   = true,
                    TargetPort = 80
                },
                Registries =
                {
                    new RegistryCredentialsArgs
                    {
                        Server            = registry.LoginServer,
                        Username          = adminUsername,
                        PasswordSecretRef = "pwd",
                    }
                },
                Secrets =
                {
                    new SecretArgs
                    {
                        Name  = "pwd",
                        Value = adminPassword
                    }
                },
            },
            Template = new TemplateArgs
            {
                Containers =
                {
                    new ContainerArgs
                    {
                        Name  = "myapp",
                        Image = myImage.ImageName,
                    }
                }
            }
        });

        this.Url = Output.Format($"https://{containerApp.Configuration.Apply(c => c.Ingress).Apply(i => i.Fqdn)}");
    }