Adding the AKS with diagnostics example for the updated blog post
ADD
azure-ts-aks-with-diagnostics/.gitignore
+/bin/
+/node_modules/
+key.rsa
+key.rsa.pub

ADD
azure-ts-aks-with-diagnostics/Pulumi.yaml
+name: azure-ts-aks-with-diagnostics
+runtime: nodejs
+description: Create an Azure Kubernetes Service (AKS) cluster and enable diagnostics
+template:
+ config:
+ azure:environment:
+ description: The Azure environment to use (`public`, `usgovernment`, `german`, `china`)
+ default: public
+ password:
+ description: Your cluster password
+ secret: true
+ sshPublicKey:
+ description: Your SSH public key (generate with `ssh-keygen -t rsa -f key.rsa`)

ADD
azure-ts-aks-with-diagnostics/README.md
+[![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new)
+
+# Azure Kubernetes Service (AKS) Cluster with Diagnostics
+
+This example demonstrates creating an Azure Kubernetes Service (AKS) Cluster, and enables diagnostics for the cluster.
+Please see https://docs.microsoft.com/en-us/azure/aks/ for more information about AKS.
+
+## Prerequisites
+
+Ensure you have [downloaded and installed the Pulumi CLI](https://www.pulumi.com/docs/get-started/install/).
+
+We will be deploying to Azure, so you will need an Azure account. If you don't have an account,
+[sign up for free here](https://azure.microsoft.com/en-us/free/).
+[Follow the instructions here](https://www.pulumi.com/docs/intro/cloud-providers/azure/setup/) to connect Pulumi to your Azure account.
+
+## Running the Example
+
+After cloning this repo, `cd` into it and run these commands. A Kubernetes cluster and Apache web server will appear!
+
+1. Create a new stack, which is an isolated deployment target for this example:
+
+ ```bash
+ $ pulumi stack init
+ ```
+
+2. Set the required configuration variables for this program:
+
+ ```bash
+ $ pulumi config set azure:environment public
+ $ pulumi config set password --secret [your-cluster-password-here]
+ $ ssh-keygen -t rsa -f key.rsa
+ $ pulumi config set sshPublicKey < key.rsa.pub
+ ```
+
+3. Deploy everything with the `pulumi up` command. This provisions all the Azure resources necessary, including
+ an Active Directory service principal, AKS cluster, and then enables diagnostics for the cluster, all in a single gesture:
+
+ ```bash
+ $ pulumi up
+ ```
+
+4. After a couple minutes, your cluster and Apache server will be ready. Your `kubeconfig` will be the application output and
+ you may also configure your `kubectl` client using the `kubeconfig` configuration:
+
+ ```bash
+ $ pulumi stack output kubeconfig > kubeconfig.yaml
+ $ kubectl get namespaces
+ ....
+ ```
+
+5. At this point, you have a running cluster. Feel free to modify your program, and run `pulumi up` to redeploy changes.
+ The Pulumi CLI automatically detects what has changed and makes the minimal edits necessary to accomplish these
+ changes. This could be altering the existing chart, adding new Azure or Kubernetes resources, or anything, really.
+
+6. Once you are done, you can destroy all of the resources, and the stack:
+
+ ```bash
+ $ pulumi destroy
+ $ pulumi stack rm
+ ```

ADD
azure-ts-aks-with-diagnostics/index.ts
+// Copyright 2016-2019, Pulumi Corporation. All rights reserved.
+
+import * as azure from "@pulumi/azure";
+import * as azuread from "@pulumi/azuread";
+import * as k8s from "@pulumi/kubernetes";
+import * as pulumi from "@pulumi/pulumi";
+
+const config = new pulumi.Config();
+const password = config.require("password");
+const location = config.get("location") || "East US";
+const nodeCount = config.getNumber("nodeCount") || 2;
+const nodeSize = config.get("nodeSize") || "Standard_D2_v2";
+const sshPublicKey = config.require("sshPublicKey");
+
+const resourceGroup = new azure.core.ResourceGroup("aks", { location });
+const loganalytics = new azure.operationalinsights.AnalyticsWorkspace("aksloganalytics", {
+ resourceGroupName: resourceGroup.name,
+ location: resourceGroup.location,
+ sku: "PerGB2018",
+ retentionInDays: 30,
+});
+
+// Step 2: Create the AD service principal for the k8s cluster.
+const adApp = new azuread.Application("aks");
+const adSp = new azuread.ServicePrincipal("aksSp", { applicationId: adApp.applicationId });
+const adSpPassword = new azuread.ServicePrincipalPassword("aksSpPassword", {
+ servicePrincipalId: adSp.id,
+ value: password,
+ endDate: "2099-01-01T00:00:00Z",
+});
+
+// Wait for the Service Principle to be initialized. The ServicePrincipal will be used to initialize the AKS cluster during creation
+const applicationId = adApp.applicationId.apply(async (adAppId) => {
+ let count = 0;
+ while (true) {
+ try {
+ await azuread.getServicePrincipal({
+ applicationId: adAppId,
+ });
+ break;
+ } catch (e) {
+ console.log("retrying");
+ count++;
+ if (count > 5) {
+ throw e;
+ }
+ }
+ }
+ return adAppId;
+});
+
+// Step 3: This step creates an AKS cluster.
+const k8sCluster = new azure.containerservice.KubernetesCluster("aksCluster", {
+ resourceGroupName: resourceGroup.name,
+ location: location,
+ defaultNodePool: {
+ name: "aksagentpool",
+ nodeCount: nodeCount,
+ vmSize: nodeSize,
+ },
+ dnsPrefix: `${pulumi.getStack()}-kube`,
+ linuxProfile: {
+ adminUsername: "aksuser",
+ sshKey: { keyData: sshPublicKey},
+ },
+ servicePrincipal: {
+ clientId: applicationId,
+ clientSecret: adSpPassword.value,
+ },
+ addonProfile: {
+ omsAgent: {
+ enabled: true,
+ logAnalyticsWorkspaceId: loganalytics.id,
+ },
+ },
+});
+
+// Step 4: Enables the Monitoring Diagonostic control plane component logs and AllMetrics
+const azMonitoringDiagnostic = new azure.monitoring.DiagnosticSetting("aks", {
+ logAnalyticsWorkspaceId: loganalytics.id,
+ targetResourceId: k8sCluster.id,
+ logs: [{
+ category: "kube-apiserver",
+ enabled : true,
+
+ retentionPolicy: {
+ enabled: true,
+ },
+ }],
+ metrics: [{
+ category: "AllMetrics",
+
+ retentionPolicy: {
+ enabled: true,
+ },
+ }],
+});
+
+// Step 5: Expose a k8s provider instance using our custom cluster instance.
+const k8sProvider = new k8s.Provider("aksK8s", {
+ kubeconfig: k8sCluster.kubeConfigRaw,
+});
+
+// Export the kubeconfig
+export const kubeconfig = k8sCluster.kubeConfigRaw;

ADD
azure-ts-aks-with-diagnostics/package.json
+{
+ "name": "azure-ts-aks-with-diagnostics",
+ "version": "0.1.0",
+ "devDependencies": {
+ "@types/node": "^8.0.0"
+ },
+ "dependencies": {
+ "@pulumi/azure": "^3.0.0",
+ "@pulumi/azuread": "^2.0.0",
+ "@pulumi/kubernetes": "^2.0.0",
+ "@pulumi/pulumi": "^2.0.0"
+ },
+ "license": "Apache-2.0"
+}

ADD
azure-ts-aks-with-diagnostics/tsconfig.json
+{
+ "compilerOptions": {
+ "outDir": "bin",
+ "target": "es2016",
+ "module": "commonjs",
+ "moduleResolution": "node",
+ "declaration": true,
+ "sourceMap": true,
+ "stripInternal": true,
+ "experimentalDecorators": true,
+ "pretty": true,
+ "noFallthroughCasesInSwitch": true,
+ "noImplicitAny": true,
+ "noImplicitReturns": true,
+ "forceConsistentCasingInFileNames": true,
+ "strictNullChecks": true
+ },
+ "files": [
+ "index.ts",
+ "config.ts"
+ ]
+}

Adding the AKS with diagnostics example for the updated blog post (#783)