diff --git a/content/tutorials/creating-resources-aws/index.md b/content/tutorials/creating-resources-aws/index.md index 066ff68c9ebc..d69617277de5 100644 --- a/content/tutorials/creating-resources-aws/index.md +++ b/content/tutorials/creating-resources-aws/index.md @@ -51,7 +51,6 @@ collections: aliases: - /docs/using-pulumi/define-and-provision-resources/ - /tutorials/define-and-provision-resources/ - - /tutorials/pulumi-fundamentals/configure-and-provision/ --- ## Create a virtual machine diff --git a/content/tutorials/creating-resources-kubernetes/index.md b/content/tutorials/creating-resources-kubernetes/index.md index c67c665700f2..b0c682bc6f63 100644 --- a/content/tutorials/creating-resources-kubernetes/index.md +++ b/content/tutorials/creating-resources-kubernetes/index.md @@ -119,7 +119,7 @@ Then replace the default code with the following code snippet to scaffold your p // Create a service -{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="go" from="72" to="74" >}} +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="go" from="63" to="65" >}} ``` {{% /choosable %}} @@ -133,7 +133,7 @@ Then replace the default code with the following code snippet to scaffold your p // Create a service -{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="csharp" from="80" to="80" >}} +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="csharp" from="74" to="75" >}} ``` {{% /choosable %}} @@ -222,7 +222,7 @@ The first resource you will create will be a Kubernetes deployment. The [Pulumi // Create a service -{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="go" from="72" to="74" >}} +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="go" from="63" to="65" >}} ``` {{% /choosable %}} @@ -234,7 +234,7 @@ The first resource you will create will be a Kubernetes deployment. The [Pulumi // Create a service -{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="csharp" from="80" to="80" >}} +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="csharp" from="74" to="75" >}} ``` {{% /choosable %}} diff --git a/content/tutorials/stack-outputs-refs-k8s/index.md b/content/tutorials/stack-outputs-refs-k8s/index.md new file mode 100644 index 000000000000..884b2c5d34a9 --- /dev/null +++ b/content/tutorials/stack-outputs-refs-k8s/index.md @@ -0,0 +1,876 @@ +--- +title: "Reference Kubernetes Resources Across Stacks" +title_tag: "Reference Kubernetes Resources Across Stacks" +layout: single + +# A succinct description of the tutorial. It appears on the Tutorials home and collection pages. +description: Learn more about exporting and referencing stack outputs in Pulumi. + +# A similar description used for search results and social-media previews. +meta_desc: Learn more about exporting and referencing stack outputs in Pulumi. + +# An image for the tutorial. It appears on tutorial page and in social-media previews. +meta_image: k8s-stack-ref-meta.png + +# An optional video for the tutorial. When present, it appears at the top of the page, replacing +# the meta image. YouTube and HTML5 video sources are supported. +# video: +# url: /blog/drift-detection/drift.mp4 +# youtube: Q8tw6YTD3ac + +# The order in which the tutorial appears in most lists. Order is ascending, so higher numbers +# mean the tutorial will appear further down the list. Positive integers only. +weight: 999 + +# A brief summary of the tutorial. It appears at the top of the tutorial page. Markdown is fine. +summary: | + In this tutorial, you will learn how to work with stack outputs, specifically how to export values from a stack and how to reference those values from another stack. You will do this by creating a simple Kubernetes deployment resource in one stack. You will then create a Kubernetes service resource in a second project/stack that will reference the deployment in the first stack. + +# A list of three to five things the reader will have learned by the end of the tutorial. +youll_learn: + - How to create a stack output + - How to view the stack output + - How to reference the output from a different stack + +# A list of tutorial prerequisites. Markdown is fine. Keep it simple; no need to be exhaustive here. +prereqs: + - The [Pulumi CLI](/docs/install/) + - A [Pulumi Cloud account](https://app.pulumi.com/signup) and [access token](/docs/pulumi-cloud/accounts/#access-tokens) + - A running [Minikube](https://minikube.sigs.k8s.io/docs/start/) cluster + - The Kubernetes command line tool [kubectl](https://kubernetes.io/docs/tasks/tools/) installed + - Your desired [language runtime installed](/docs/iac/get-started/aws/begin/#install-language-runtime) + +# The estimated time, in minutes, for new users to complete the topic. +estimated_time: 15 + +# An optional list of collections this tutorial should be belong to. Collections are defined in data/tutorials/collections.yaml. +collections: + - kubernetes +--- + +## Understanding stack outputs + +Every Pulumi resource has outputs, which are properties of that resource whose values are generated during deployment. You can export these values as stack outputs, and they can be used for important values like resource IDs, computed IP addresses, and DNS names. + +These outputs are shown during an update, can be easily retrieved with the Pulumi CLI, and are displayed in Pulumi Cloud. For the purposes of this tutorial, you will primarily be working from the CLI. + +### Create a new project + +```bash +# Example using Python +$ mkdir pulumi-tutorial-k8s +$ cd pulumi-tutorial-k8s +$ pulumi new kubernetes-python +``` + +Then replace the default code with the following code snippet to scaffold your project with the required imports and overall program structure: + +{{< chooser language "javascript,typescript,python,go,csharp,yaml" / >}} + +{{% choosable language javascript %}} + +```javascript +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="javascript" from="1" to="16" >}} +``` + +{{% /choosable %}} + +{{% choosable language typescript %}} + +```typescript +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="typescript" from="1" to="15" >}} +``` + +{{% /choosable %}} + +{{% choosable language python %}} + +```python +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="python" from="1" to="17" >}} +``` + +{{% /choosable %}} + +{{% choosable language go %}} + +```go +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="go" from="1" to="39" >}} + +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="go" from="63" to="65" >}} +``` + +{{% /choosable %}} + +{{% choosable language csharp %}} + +```csharp +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="csharp" from="1" to="52" >}} + +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="csharp" from="75" to="75" >}} +``` + +{{% /choosable %}} + +{{% choosable language yaml %}} + +```yaml +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="yaml" from="1" to="23" >}} +``` + +{{% /choosable %}} + +This baseline code defines the following on your behalf: + +- a [Kubernetes Deployment](/registry/packages/kubernetes/api-docs/apps/v1/deployment/) + +Then configure the Pulumi CLI to [access your Kubernetes Minikube cluster](tutorials/creating-resources-kubernetes/#configure-kubernetes-access). + +## Export resource values + +As mentioned in the [Creating Resources on Kubernetes tutorial](/tutorials/creating-resources-kubernetes/), every resource has various properties. For any resources that you define in your Pulumi projects, you can [export the values](/docs/iac/concepts/stacks/#outputs) of its properties from your program as outputs. You can view a list of available properties that can be exported by referring to the resource properties section of a particular resource's API documentation (e.g. [Deployment resource properties](/registry/packages/kubernetes/api-docs/apps/v1/deployment/#properties)). The `export` syntax is as follows: + +{{< chooser language "javascript,typescript,python,go,csharp,yaml" / >}} + +{{% choosable language javascript %}} + +```javascript +exports. = ; +``` + +{{% /choosable %}} + +{{% choosable language typescript %}} + +```typescript +export const = ; +``` + +{{% /choosable %}} + +{{% choosable language python %}} + +```python +pulumi.export("", ) +``` + +{{% /choosable %}} + +{{% choosable language go %}} + +```go +ctx.Export("", ) +``` + +{{% /choosable %}} + +{{% choosable language csharp %}} + +```csharp +return await Pulumi.Deployment.RunAsync(() => +{ + + return new Dictionary + { + [""] = + }; + +}); +``` + +{{% /choosable %}} + +{{% choosable language yaml %}} + +```yaml +outputs: + : ${} +``` + +{{% /choosable %}} + +When defining these exports, you'll need to provide two arguments: + +| Argument | Description | +|--------------|-------------| +| Output name | This is the name you will use as the identifier of your output value | +| Output value | This is the actual value of your output | + +To demonstrate how this works, let's export the name of your deployment which can be found in the deployment's metadata. By referring to the documentation, you can see that the metadata of the deployment can be referenced via its `metadata` property, so update your code to reflect that as shown below: + +{{< chooser language "javascript,typescript,python,go,csharp,yaml" / >}} + +{{% choosable language javascript %}} + +```javascript +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="javascript" from="1" to="16" >}} + +exports.deploymentName = deployment.metadata.name; +``` + +{{% /choosable %}} + +{{% choosable language typescript %}} + +```typescript +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="typescript" from="1" to="15" >}} + +exports const deploymentName = deployment.metadata.name; +``` + +{{% /choosable %}} + +{{% choosable language python %}} + +```python +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="python" from="1" to="17" >}} + +pulumi.export("deploymentName", deployment.metadata["name"]) +``` + +{{% /choosable %}} + +{{% choosable language go %}} + +```go +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="go" from="1" to="39" >}} + + ctx.Export("name", deployment.Metadata.Name()) +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="go" from="63" to="65" >}} +``` + +{{% /choosable %}} + +{{% choosable language csharp %}} + +```csharp +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="csharp" from="1" to="52" >}} + + return new Dictionary + { + ["deploymentName"] = deployment.Metadata.Apply(m => m.Name), + + }; +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="csharp" from="75" to="75" >}} +``` + +{{% /choosable %}} + +{{% choosable language yaml %}} + +```yaml +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="yaml" from="1" to="23" >}} + +outputs: + deploymentName: ${deployment.metadata.name} +``` + +{{% /choosable %}} + +## Deploy your resources + +Now save your file and run the `pulumi up` command to preview and deploy the resources you've just defined in your project. + +```bash +$ pulumi up -y +Previewing update (infra) + + Type Name Plan + + pulumi:pulumi:Stack k8s-stackref-dev create + + └─ kubernetes:apps/v1:Deployment nginx create + +Outputs: + name: "nginx-f575adcf" + +Resources: + + 2 to create + +Updating (dev) + +View in Browser (Ctrl+O): https://app.pulumi.com/v-torian-pulumi-corp/k8s-stackref/dev/updates/3 + + Type Name Status + + pulumi:pulumi:Stack k8s-stackref-dev created (5s) + + └─ kubernetes:apps/v1:Deployment nginx created (3s) + +Outputs: + name: "nginx-a3731b33" + +Resources: + + 2 created + +Duration: 7s +``` + +You can see that the output you've created has been provided as a part of the update details. You will learn the different ways you can access this output in the next steps of the tutorial. + +## Access outputs via the CLI + +Now that your resources are deployed, you can access your output values either via the CLI or via your Pulumi program code. To access it via the CLI, you can use the [`pulumi stack output` command](/docs/iac/cli/commands/pulumi_stack_output/). Running this command by itself will list the names and values of all of the exports in your program: + +```bash +$ pulumi stack output + +Current stack outputs (1): + OUTPUT VALUE + deploymentName nginx-a3731b33 +``` + +If you want to retrieve a specific output value, you will need to provide the name of your desired output as shown below: + +```bash +$ pulumi stack output deploymentName + +nginx-a3731b33 +``` + +This can be especially useful if you have any workflow scripts that depend on the outputs of your program. For example, if you wanted to view the details of your deployment using the Kubernetes CLI, you can do so by running the [`kubectl get deployment` command](https://kubernetes.io/docs/reference/kubectl/quick-reference/#viewing-and-finding-resources) and passing the output of `deploymentName` as shown below: + +```bash +$ kubectl get deployment $(pulumi stack output deploymentName) + +NAME READY UP-TO-DATE AVAILABLE AGE +nginx-a3731b33 1/1 1 1 4m52s +``` + +You have seen how you can reference your output values from the CLI. Now let’s take a look at how you can do the same from within another Pulumi program stack. + +## Access outputs via stack reference + +Stack references allow you to access the outputs of one stack from another stack. This enables developers to create resources even when there are inter-stack dependencies. For this section, you are going to create a new Pulumi program that will access stack output values from your existing program. + +### Reference deployment name + +Start by making a new Pulumi project in a new directory. In this new program, you will need to add the code that will reference an output value from your first program. This can be done using Pulumi's [Stack Reference functionality](/docs/concepts/stack/#stackreferences). When defining a stack reference in code, you will need to pass in the fully qualified name of the stack as an argument. This name is comprised of the [organization](/docs/pulumi-cloud/organizations/), [project](/docs/iac/concepts/projects/), and [stack](/docs/iac/concepts/stacks/) names in the format of `//` + +For example, if the name of your organization is `acmecorp`, the name of your first program is `infra`, and the name of your stack is `dev`, then your fully qualified name will be `acmecorp/infra/dev`. + +With that being said, a stack reference will look like the following in your code: + +{{< chooser language "javascript,typescript,python,go,csharp,yaml" / >}} + +{{% choosable language javascript %}} + +```javascript +"use strict"; +const pulumi = require("@pulumi/pulumi"); + +const stackRef = new pulumi.StackReference("acmecorp/infra/dev"); +``` + +{{% /choosable %}} + +{{% choosable language typescript %}} + +```typescript +import * as pulumi from "@pulumi/pulumi"; + +const stackRef = new pulumi.StackReference("acmecorp/infra/dev"); +``` + +{{% /choosable %}} + +{{% choosable language python %}} + +```python +import pulumi + +stack_ref = pulumi.StackReference("acmecorp/infra/dev") +``` + +{{% /choosable %}} + +{{% choosable language go %}} + +```go +package main + +import ( + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + stackRef, err := pulumi.NewStackReference(ctx, "acmecorp/infra/dev", nil) + if err != nil { + return err + } + + return nil + }) +} +``` + +{{% /choosable %}} + +{{% choosable language csharp %}} + +```csharp +using Pulumi; + +return await Pulumi.Deployment.RunAsync(() => +{ + + var stackRef = new StackReference("acmecorp/infra/dev"); + +}); +``` + +{{% /choosable %}} + +{{% choosable language yaml %}} + +```yaml +name: my-second-app-dev +runtime: yaml +description: A program to create a Stack Reference + +resources: + stack-ref: + type: pulumi:pulumi:StackReference + properties: + name: acmecorp/infra/dev +``` + +{{% /choosable %}} + +{{% notes type="info" %}} + +Make sure that the fully qualified name in the example above is populated with the values that are specific to your Pulumi organization, project, and stack. + +{{% /notes %}} + +You will now create an export in your second program that will output the value of the deployment name from your first program. This is to demonstrate how to retrieve output values from another stack for use in your program. + +For the value of your export, you can retrieve it by taking your stack reference variable and using a Stack Reference function called getOutput() against it. + +Update your code with the following: + +{{< chooser language "javascript,typescript,python,go,csharp,yaml" / >}} + +{{% choosable language javascript %}} + +```javascript +"use strict"; +const pulumi = require("@pulumi/pulumi"); + +const stackRef = new pulumi.StackReference("acmecorp/infra/dev"); + +// Retrieve deployment name from the first stack +// using the stack reference above +const deploymentName = stackRef.getOutput("deploymentName"); + +exports.deploymentName = deploymentName; +``` + +{{% /choosable %}} + +{{% choosable language typescript %}} + +```typescript +import * as pulumi from "@pulumi/pulumi"; + +const stackRef = new pulumi.StackReference("acmecorp/infra/dev"); + +// Retrieve deployment name from the first stack +// using the stack reference above +const deploymentName = stackRef.getOutput("deploymentName"); + +export const deploymentName = deploymentName; +``` + +{{% /choosable %}} + +{{% choosable language python %}} + +```python +import pulumi + +stack_ref = pulumi.StackReference("acmecorp/infra/dev") + +# Retrieve deployment name from the first stack +# using the stack reference above +deployment_name = stack_ref.get_output("deploymentName") + +pulumi.export("deploymentName", deployment_nam) +``` + +{{% /choosable %}} + +{{% choosable language go %}} + +```go +package main + +import ( + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + stackRef, err := pulumi.NewStackReference(ctx, "acmecorp/infra/dev", nil) + if err != nil { + return err + } + + // Retrieve deployment name from the first stack + // using the stack reference above + deploymentName := stackRef.GetOutput(pulumi.String("deploymentName")) + + ctx.Export("deploymentName", deploymentName) + return nil + }) +} +``` + +{{% /choosable %}} + +{{% choosable language csharp %}} + +```csharp +using Pulumi; + +return await Pulumi.Deployment.RunAsync(() => +{ + + var stackRef = new StackReference("acmecorp/infra/dev"); + + // Retrieve deployment name from the first stack + // using the stack reference above + var deploymentName = stackRef.GetOutput("deploymentName"); + + return new Dictionary + { + ["deploymentName"] = deploymentName + }; + +}); +``` + +{{% /choosable %}} + +{{% choosable language yaml %}} + +```yaml +name: my-second-app-dev +runtime: yaml +description: A program to create a Stack Reference + +resources: + stack-ref: + type: pulumi:pulumi:StackReference + properties: + name: acmecorp/infra/dev + +variables: + deploymentName: ${stack-ref.outputs["deploymentName"]} + +outputs: + deploymentName: ${deploymentName} +``` + +{{% /choosable %}} + +To verify that your stack reference is working, run `pulumi up`. + +```bash +$ pulumi up -y + +Previewing update (dev): + + Type Name Plan + + pulumi:pulumi:Stack my-second-app-dev create + +Outputs: + deploymentName: output + +Resources: + + 4 to create + +Do you want to perform this update? yes +Updating (dev): + + Type Name Status + + pulumi:pulumi:Stack my-second-app-dev created (2s) + +Outputs: + deploymentName: "nginx-a3731b33" + +Resources: + + 1 created + +Duration: 3s +``` + +You should see the name of your deployment from your first program successfully outputted in the update details of your second program. + +## Use stack reference in resource definition + +In this section, you will use everything you have learned in this tutorial to define a resource that uses a stack reference in the resource definition. In your second program, you will be defining Kubernetes Service resource that will reference the `labels` value in the metadata of the deployment resource that was created in your first program. Use the following steps as a guide for adding the Service resource: + +- Navigate to the [Kubernetes Registry documentation page](/registry/packages/kubernetes/) +- Search for the `kubernetes.core/v1.Service` resource +- Define the Service resource in your second program code, making sure to define the `labels` sub-property of the `metadata` property +- Export required property values in your first program code +- Import required property values in your second program +- Save and deploy your first program code +- Then save and deploy your second program code + +Once you have completed these steps, forward the Nginx service to make it accessible from localhost. First, retrieve the name and port of your service using the following command: + +```bash +$ kubectl get service +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +kubernetes ClusterIP 10.96.0.1 443/TCP 44h +nginx-9e5d5cd4 ClusterIP 10.103.199.118 80/TCP 6m47s +``` + +In the example above, the name of the service is `nginx-9e5d5cd4`. Then run the following command to perform the forwarding, making sure to provide the name and port of your own Nginx service in your own environment: + +```bash +$ kubectl port-forward service/nginx-9e5d5cd4 8080:80 + Forwarding from 127.0.0.1:8080 -> 80 + Forwarding from [::1]:8080 -> 80 +``` + +In a new terminal, verify that Nginx is running and accessible by running curl against the localhost as shown in the below example: + +```bash +curl "http://localhost:8080" + + + + +Welcome to nginx! + + + +

Welcome to nginx!

+

If you see this page, the nginx web server is successfully installed and +working. Further configuration is required.

+ +

For online documentation and support please refer to +nginx.org.
+Commercial support is available at +nginx.com.

+ +

Thank you for using nginx.

+ + +``` + +You should be greated with the HTML code of the Nginx landing page as shown above. + +## View complete solution + +You can view the code for the complete solution below. + +### First program code + +{{< chooser language "javascript,typescript,python,go,csharp,yaml" / >}} + +{{% choosable language javascript %}} + +```javascript +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="javascript" from="1" to="16" >}} + +exports.deploymentLabels = deployment.spec.template.metadata.labels; +``` + +{{% /choosable %}} + +{{% choosable language typescript %}} + +```typescript +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="typescript" from="1" to="16" >}} +exports const deploymentLabels = deployment.spec.template.metadata.labels +``` + +{{% /choosable %}} + +{{% choosable language python %}} + +```python +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="python" from="1" to="17" >}} + +pulumi.export("deploymentLabels", deployment.spec["template"]["metadata"]["labels"]) +``` + +{{% /choosable %}} + +{{% choosable language go %}} + +```go +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="go" from="1" to="39" >}} + + template := deployment.Spec.ApplyT(func(v appsv1.DeploymentSpec) *corev1.PodTemplateSpec { + return &v.Template + }).(corev1.PodTemplateSpecPtrOutput) + + appLabels := template.ApplyT(func(v *corev1.PodTemplateSpec) *metav1.ObjectMeta { return v.Metadata.Labels }).(metav1.ObjectMetaPtrOutput) + + ctx.Export("deploymentLabels", appLabels) +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="go" from="63" to="65" >}} +``` + +{{% /choosable %}} + +{{% choosable language csharp %}} + +```csharp +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="csharp" from="1" to="52" >}} + + var appLabels = deployment.Spec.Apply(spec => spec.Template.Metadata.Labels) + + return new Dictionary + { + ["deploymentLabels"] = appLabels, + + }; +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="csharp" from="75" to="75" >}} +``` + +{{% /choosable %}} + +{{% choosable language yaml %}} + +```yaml +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="yaml" from="1" to="23" >}} + +outputs: + deploymentLabels: ${deployment.spec.template.metadata.labels} +``` + +{{% /choosable %}} + +### Second program code + +{{< chooser language "javascript,typescript,python,go,csharp,yaml" / >}} + +{{% choosable language javascript %}} + +```javascript +"use strict"; +const pulumi = require("@pulumi/pulumi"); +const k8s = require("@pulumi/kubernetes"); + +const stackRef = new pulumi.StackReference("acmecorp/infra/dev"); + +const appLabels = stackRef.getOutput("deploymentLabels"); + +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="javascript" from="18" to="25" >}} +``` + +{{% /choosable %}} + +{{% choosable language typescript %}} + +```typescript +import * as pulumi from "@pulumi/pulumi"; +import * as k8s from "@pulumi/kubernetes"; + +const stackRef = new pulumi.StackReference("acmecorp/infra/dev"); +const appLabels = stackRef.getOutput("deploymentLabels"); + +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="typescript" from="17" to="24" >}} +``` + +{{% /choosable %}} + +{{% choosable language python %}} + +```python +import pulumi +from pulumi_kubernetes.core.v1 import Service + +stack_ref = pulumi.StackReference("acmecorp/infra/dev") +app_labels = stack_ref.get_output("deploymentLabels") + +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="python" from="19" to="28" >}} +``` + +{{% /choosable %}} + +{{% choosable language go %}} + +```go +package main + +import ( + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" + corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/core/v1" + metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/meta/v1" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + stackRef, err := pulumi.NewStackReference(ctx, "acmecorp/infra/dev", nil) + if err != nil { + return err + } + + appLabels := stackRef.GetOutput(pulumi.String("deploymentLabels")) + +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="go" from="53" to="75" >}} +``` + +{{% /choosable %}} + +{{% choosable language csharp %}} + +```csharp +using Pulumi; +using Pulumi.Kubernetes.Core.V1; +using Pulumi.Kubernetes.Types.Inputs.Core.V1; +using Pulumi.Kubernetes.Types.Inputs.Meta.V1; +using System.Collections.Generic; + +return await Pulumi.Deployment.RunAsync(() => +{ + + var stackRef = new StackReference("acmecorp/infra/dev"); + var appLabels = stackRef.GetOutput("deploymentLabels"); + +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="csharp" from="53" to="75" >}} +``` + +{{% /choosable %}} + +{{% choosable language yaml %}} + +```yaml +name: infra +runtime: yaml +description: A program to create a Stack Reference + +variables: + appLabels: ${stack-ref.outputs["deploymentLabels"]} + +resources: + stack-ref: + type: pulumi:pulumi:StackReference + properties: + name: acmecorp/infra/dev + +{{< example-program-snippet path="k8s-deployment-service-for-minikube" language="yaml" from="24" to="35" >}} +``` + +{{% /choosable %}} + +## Clean up + +{{< cleanup >}} + +## Next steps + +In this tutorial, you created a Kubernetes deployment resource and a service resource. You exported resource properties into stack outputs, and referenced those outputs across stacks using stack references. + +To learn more about creating and managing resources in Pulumi, take a look at the following resources: + +- Learn more about creating resources in the [Creating Resources on Kubernetes](/tutorials/creating-resources-kubernetes/). +- Learn more about [stack outputs and references](/docs/concepts/stack/#stackreferences) in the Pulumi documentation. +- Learn more about [Pulumi inputs and outputs](/docs/concepts/inputs-outputs/) in the Pulumi documentation. diff --git a/content/tutorials/stack-outputs-refs-k8s/k8s-stack-ref-meta.png b/content/tutorials/stack-outputs-refs-k8s/k8s-stack-ref-meta.png new file mode 100644 index 000000000000..4692b4442b85 Binary files /dev/null and b/content/tutorials/stack-outputs-refs-k8s/k8s-stack-ref-meta.png differ diff --git a/static/programs/helm-kubernetes-go/go.mod b/static/programs/helm-kubernetes-go/go.mod index 1c4c50dc4fc1..31a31179b061 100644 --- a/static/programs/helm-kubernetes-go/go.mod +++ b/static/programs/helm-kubernetes-go/go.mod @@ -6,88 +6,3 @@ require ( github.com/pulumi/pulumi-kubernetes/sdk/v4 v4.0.3 github.com/pulumi/pulumi/sdk/v3 v3.96.1 ) - -require ( - dario.cat/mergo v1.0.0 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect - github.com/acomagu/bufpipe v1.0.4 // indirect - github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect - github.com/agext/levenshtein v1.2.3 // indirect - github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect - github.com/atotto/clipboard v0.1.4 // indirect - github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect - github.com/blang/semver v3.5.1+incompatible // indirect - github.com/charmbracelet/bubbles v0.16.1 // indirect - github.com/charmbracelet/bubbletea v0.24.2 // indirect - github.com/charmbracelet/lipgloss v0.7.1 // indirect - github.com/cheggaaa/pb v1.0.29 // indirect - github.com/cloudflare/circl v1.3.3 // indirect - github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect - github.com/cyphar/filepath-securejoin v0.2.4 // indirect - github.com/djherbis/times v1.5.0 // indirect - github.com/emirpasic/gods v1.18.1 // indirect - github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.5.0 // indirect - github.com/go-git/go-git/v5 v5.9.0 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/glog v1.1.0 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/hcl/v2 v2.17.0 // indirect - github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect - github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/lucasb-eyer/go-colorful v1.2.0 // indirect - github.com/mattn/go-isatty v0.0.18 // indirect - github.com/mattn/go-localereader v0.0.1 // indirect - github.com/mattn/go-runewidth v0.0.14 // indirect - github.com/mitchellh/go-ps v1.0.0 // indirect - github.com/mitchellh/go-wordwrap v1.0.1 // indirect - github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect - github.com/muesli/cancelreader v0.2.2 // indirect - github.com/muesli/reflow v0.3.0 // indirect - github.com/muesli/termenv v0.15.1 // indirect - github.com/opentracing/basictracer-go v1.1.0 // indirect - github.com/opentracing/opentracing-go v1.2.0 // indirect - github.com/pgavlin/fx v0.1.6 // indirect - github.com/pjbgf/sha1cd v0.3.0 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/pkg/term v1.1.0 // indirect - github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect - github.com/pulumi/esc v0.5.6 // indirect - github.com/rivo/uniseg v0.4.4 // indirect - github.com/rogpeppe/go-internal v1.11.0 // indirect - github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect - github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect - github.com/sergi/go-diff v1.3.1 // indirect - github.com/skeema/knownhosts v1.2.0 // indirect - github.com/spf13/cast v1.4.1 // indirect - github.com/spf13/cobra v1.7.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/texttheater/golang-levenshtein v1.0.1 // indirect - github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect - github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect - github.com/uber/jaeger-lib v2.4.1+incompatible // indirect - github.com/xanzy/ssh-agent v0.3.3 // indirect - github.com/zclconf/go-cty v1.13.2 // indirect - go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.14.0 // indirect - golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect - golang.org/x/mod v0.13.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/sync v0.4.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/term v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect - golang.org/x/tools v0.14.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130 // indirect - google.golang.org/grpc v1.57.1 // indirect - google.golang.org/protobuf v1.31.0 // indirect - gopkg.in/warnings.v0 v0.1.2 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - lukechampine.com/frand v1.4.2 // indirect -) diff --git a/static/programs/helm-kubernetes-part-one-go/go.mod b/static/programs/helm-kubernetes-part-one-go/go.mod index 249e4b10da0c..d2583baf4e73 100644 --- a/static/programs/helm-kubernetes-part-one-go/go.mod +++ b/static/programs/helm-kubernetes-part-one-go/go.mod @@ -6,88 +6,3 @@ require ( github.com/pulumi/pulumi-kubernetes/sdk/v4 v4.0.3 github.com/pulumi/pulumi/sdk/v3 v3.96.1 ) - -require ( - dario.cat/mergo v1.0.0 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect - github.com/acomagu/bufpipe v1.0.4 // indirect - github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect - github.com/agext/levenshtein v1.2.3 // indirect - github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect - github.com/atotto/clipboard v0.1.4 // indirect - github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect - github.com/blang/semver v3.5.1+incompatible // indirect - github.com/charmbracelet/bubbles v0.16.1 // indirect - github.com/charmbracelet/bubbletea v0.24.2 // indirect - github.com/charmbracelet/lipgloss v0.7.1 // indirect - github.com/cheggaaa/pb v1.0.29 // indirect - github.com/cloudflare/circl v1.3.3 // indirect - github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect - github.com/cyphar/filepath-securejoin v0.2.4 // indirect - github.com/djherbis/times v1.5.0 // indirect - github.com/emirpasic/gods v1.18.1 // indirect - github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.5.0 // indirect - github.com/go-git/go-git/v5 v5.9.0 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/glog v1.1.0 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/hcl/v2 v2.17.0 // indirect - github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect - github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/lucasb-eyer/go-colorful v1.2.0 // indirect - github.com/mattn/go-isatty v0.0.18 // indirect - github.com/mattn/go-localereader v0.0.1 // indirect - github.com/mattn/go-runewidth v0.0.14 // indirect - github.com/mitchellh/go-ps v1.0.0 // indirect - github.com/mitchellh/go-wordwrap v1.0.1 // indirect - github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect - github.com/muesli/cancelreader v0.2.2 // indirect - github.com/muesli/reflow v0.3.0 // indirect - github.com/muesli/termenv v0.15.1 // indirect - github.com/opentracing/basictracer-go v1.1.0 // indirect - github.com/opentracing/opentracing-go v1.2.0 // indirect - github.com/pgavlin/fx v0.1.6 // indirect - github.com/pjbgf/sha1cd v0.3.0 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/pkg/term v1.1.0 // indirect - github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect - github.com/pulumi/esc v0.5.6 // indirect - github.com/rivo/uniseg v0.4.4 // indirect - github.com/rogpeppe/go-internal v1.11.0 // indirect - github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect - github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect - github.com/sergi/go-diff v1.3.1 // indirect - github.com/skeema/knownhosts v1.2.0 // indirect - github.com/spf13/cast v1.4.1 // indirect - github.com/spf13/cobra v1.7.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/texttheater/golang-levenshtein v1.0.1 // indirect - github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect - github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect - github.com/uber/jaeger-lib v2.4.1+incompatible // indirect - github.com/xanzy/ssh-agent v0.3.3 // indirect - github.com/zclconf/go-cty v1.13.2 // indirect - go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.14.0 // indirect - golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect - golang.org/x/mod v0.13.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/sync v0.4.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/term v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect - golang.org/x/tools v0.14.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130 // indirect - google.golang.org/grpc v1.57.1 // indirect - google.golang.org/protobuf v1.31.0 // indirect - gopkg.in/warnings.v0 v0.1.2 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - lukechampine.com/frand v1.4.2 // indirect -) diff --git a/static/programs/helm-kubernetes-part-two-go/go.mod b/static/programs/helm-kubernetes-part-two-go/go.mod index 238063874438..ccc7c0eada7c 100644 --- a/static/programs/helm-kubernetes-part-two-go/go.mod +++ b/static/programs/helm-kubernetes-part-two-go/go.mod @@ -9,99 +9,3 @@ require ( github.com/pulumi/pulumi/sdk/v3 v3.117.0 k8s.io/apimachinery v0.32.0 ) - -require ( - dario.cat/mergo v1.0.0 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v1.0.0 // indirect - github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect - github.com/agext/levenshtein v1.2.3 // indirect - github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect - github.com/atotto/clipboard v0.1.4 // indirect - github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect - github.com/blang/semver v3.5.1+incompatible // indirect - github.com/charmbracelet/bubbles v0.16.1 // indirect - github.com/charmbracelet/bubbletea v0.24.2 // indirect - github.com/charmbracelet/lipgloss v0.7.1 // indirect - github.com/cheggaaa/pb v1.0.29 // indirect - github.com/cloudflare/circl v1.3.7 // indirect - github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect - github.com/cyphar/filepath-securejoin v0.2.4 // indirect - github.com/djherbis/times v1.5.0 // indirect - github.com/emirpasic/gods v1.18.1 // indirect - github.com/fxamacker/cbor/v2 v2.7.0 // indirect - github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.5.0 // indirect - github.com/go-git/go-git/v5 v5.12.0 // indirect - github.com/go-logr/logr v1.4.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/glog v1.2.0 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/google/gofuzz v1.2.0 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/hcl/v2 v2.17.0 // indirect - github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/lucasb-eyer/go-colorful v1.2.0 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect - github.com/mattn/go-localereader v0.0.1 // indirect - github.com/mattn/go-runewidth v0.0.15 // indirect - github.com/mitchellh/go-ps v1.0.0 // indirect - github.com/mitchellh/go-wordwrap v1.0.1 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect - github.com/muesli/cancelreader v0.2.2 // indirect - github.com/muesli/reflow v0.3.0 // indirect - github.com/muesli/termenv v0.15.2 // indirect - github.com/opentracing/basictracer-go v1.1.0 // indirect - github.com/opentracing/opentracing-go v1.2.0 // indirect - github.com/pgavlin/fx v0.1.6 // indirect - github.com/pjbgf/sha1cd v0.3.0 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/pkg/term v1.1.0 // indirect - github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect - github.com/pulumi/esc v0.6.2 // indirect - github.com/rivo/uniseg v0.4.4 // indirect - github.com/rogpeppe/go-internal v1.11.0 // indirect - github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect - github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect - github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect - github.com/skeema/knownhosts v1.2.2 // indirect - github.com/spf13/cobra v1.8.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/texttheater/golang-levenshtein v1.0.1 // indirect - github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect - github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect - github.com/uber/jaeger-lib v2.4.1+incompatible // indirect - github.com/x448/float16 v0.8.4 // indirect - github.com/xanzy/ssh-agent v0.3.3 // indirect - github.com/zclconf/go-cty v1.13.2 // indirect - go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.28.0 // indirect - golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect - golang.org/x/mod v0.21.0 // indirect - golang.org/x/net v0.30.0 // indirect - golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/term v0.25.0 // indirect - golang.org/x/text v0.19.0 // indirect - golang.org/x/tools v0.26.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7 // indirect - google.golang.org/grpc v1.63.2 // indirect - google.golang.org/protobuf v1.35.1 // indirect - gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/warnings.v0 v0.1.2 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/klog/v2 v2.130.1 // indirect - k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect - lukechampine.com/frand v1.4.2 // indirect - sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect - sigs.k8s.io/yaml v1.4.0 // indirect -) diff --git a/static/programs/k8s-deployment-service-for-minikube-csharp/Program.cs b/static/programs/k8s-deployment-service-for-minikube-csharp/Program.cs index 33f6f72c3678..b8bc9c8d77e3 100644 --- a/static/programs/k8s-deployment-service-for-minikube-csharp/Program.cs +++ b/static/programs/k8s-deployment-service-for-minikube-csharp/Program.cs @@ -52,11 +52,13 @@ var frontend = new Service(appName, new ServiceArgs { + Selector = new LabelSelectorArgs + { + MatchLabels = appLabels, + }, Metadata = new ObjectMetaArgs { - Labels = deployment.Spec.Apply(spec => - spec.Template.Metadata.Labels - ), + Labels = appLabels, }, Spec = new ServiceSpecArgs { diff --git a/static/programs/k8s-deployment-service-for-minikube-go/go.mod b/static/programs/k8s-deployment-service-for-minikube-go/go.mod index e69d59f87222..370db0ac11f2 100644 --- a/static/programs/k8s-deployment-service-for-minikube-go/go.mod +++ b/static/programs/k8s-deployment-service-for-minikube-go/go.mod @@ -8,86 +8,3 @@ require ( github.com/pulumi/pulumi-kubernetes/sdk/v4 v4.12.0 github.com/pulumi/pulumi/sdk/v3 v3.117.0 ) - -require ( - dario.cat/mergo v1.0.0 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v1.0.0 // indirect - github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect - github.com/agext/levenshtein v1.2.3 // indirect - github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect - github.com/atotto/clipboard v0.1.4 // indirect - github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect - github.com/blang/semver v3.5.1+incompatible // indirect - github.com/charmbracelet/bubbles v0.16.1 // indirect - github.com/charmbracelet/bubbletea v0.24.2 // indirect - github.com/charmbracelet/lipgloss v0.7.1 // indirect - github.com/cheggaaa/pb v1.0.29 // indirect - github.com/cloudflare/circl v1.3.7 // indirect - github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect - github.com/cyphar/filepath-securejoin v0.2.4 // indirect - github.com/djherbis/times v1.5.0 // indirect - github.com/emirpasic/gods v1.18.1 // indirect - github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.5.0 // indirect - github.com/go-git/go-git/v5 v5.12.0 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/glog v1.2.0 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/hcl/v2 v2.17.0 // indirect - github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect - github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/lucasb-eyer/go-colorful v1.2.0 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect - github.com/mattn/go-localereader v0.0.1 // indirect - github.com/mattn/go-runewidth v0.0.15 // indirect - github.com/mitchellh/go-ps v1.0.0 // indirect - github.com/mitchellh/go-wordwrap v1.0.1 // indirect - github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect - github.com/muesli/cancelreader v0.2.2 // indirect - github.com/muesli/reflow v0.3.0 // indirect - github.com/muesli/termenv v0.15.2 // indirect - github.com/opentracing/basictracer-go v1.1.0 // indirect - github.com/opentracing/opentracing-go v1.2.0 // indirect - github.com/pgavlin/fx v0.1.6 // indirect - github.com/pjbgf/sha1cd v0.3.0 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/pkg/term v1.1.0 // indirect - github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect - github.com/pulumi/esc v0.6.2 // indirect - github.com/rivo/uniseg v0.4.4 // indirect - github.com/rogpeppe/go-internal v1.11.0 // indirect - github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect - github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect - github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect - github.com/skeema/knownhosts v1.2.2 // indirect - github.com/spf13/cobra v1.8.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/texttheater/golang-levenshtein v1.0.1 // indirect - github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect - github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect - github.com/uber/jaeger-lib v2.4.1+incompatible // indirect - github.com/xanzy/ssh-agent v0.3.3 // indirect - github.com/zclconf/go-cty v1.13.2 // indirect - go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.23.0 // indirect - golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect - golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.25.0 // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.20.0 // indirect - golang.org/x/term v0.20.0 // indirect - golang.org/x/text v0.15.0 // indirect - golang.org/x/tools v0.17.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7 // indirect - google.golang.org/grpc v1.63.2 // indirect - google.golang.org/protobuf v1.33.0 // indirect - gopkg.in/warnings.v0 v0.1.2 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - lukechampine.com/frand v1.4.2 // indirect -) diff --git a/static/programs/k8s-deployment-service-for-minikube-go/main.go b/static/programs/k8s-deployment-service-for-minikube-go/main.go index 309659368209..1bb84c8d33ac 100644 --- a/static/programs/k8s-deployment-service-for-minikube-go/main.go +++ b/static/programs/k8s-deployment-service-for-minikube-go/main.go @@ -40,14 +40,13 @@ func main() { feType := "ClusterIP" - template := deployment.Spec.ApplyT(func(v appsv1.DeploymentSpec) *corev1.PodTemplateSpec { - return &v.Template - }).(corev1.PodTemplateSpecPtrOutput) - - meta := template.ApplyT(func(v *corev1.PodTemplateSpec) *metav1.ObjectMeta { return v.Metadata }).(metav1.ObjectMetaPtrOutput) - frontend, _ := corev1.NewService(ctx, appName, &corev1.ServiceArgs{ - Metadata: meta, + Selector: &metav1.LabelSelectorArgs{ + MatchLabels: appLabels, + }, + Metadata: &metav1.ObjectMetaArgs{ + Labels: appLabels, + },, Spec: &corev1.ServiceSpecArgs{ Type: pulumi.String(feType), Ports: &corev1.ServicePortArray{ diff --git a/static/programs/k8s-deployment-service-for-minikube-javascript/index.js b/static/programs/k8s-deployment-service-for-minikube-javascript/index.js index f2ee5b2f5056..dc57c28b2069 100644 --- a/static/programs/k8s-deployment-service-for-minikube-javascript/index.js +++ b/static/programs/k8s-deployment-service-for-minikube-javascript/index.js @@ -16,7 +16,7 @@ const deployment = new k8s.apps.v1.Deployment(appName, { }); const frontend = new k8s.core.v1.Service(appName, { - metadata: { labels: deployment.spec.template.metadata.labels }, + metadata: { labels: appLabels }, spec: { type: "ClusterIP", ports: [{ port: 80, targetPort: 80, protocol: "TCP" }], diff --git a/static/programs/k8s-deployment-service-for-minikube-python/__main__.py b/static/programs/k8s-deployment-service-for-minikube-python/__main__.py index e3e228ea48b7..8ab5b59b8f2c 100644 --- a/static/programs/k8s-deployment-service-for-minikube-python/__main__.py +++ b/static/programs/k8s-deployment-service-for-minikube-python/__main__.py @@ -19,7 +19,7 @@ frontend = Service( app_name, metadata={ - "labels": deployment.spec["template"]["metadata"]["labels"], + "labels": app_labels, }, spec={ "type": "ClusterIP", diff --git a/static/programs/k8s-deployment-service-for-minikube-typescript/index.ts b/static/programs/k8s-deployment-service-for-minikube-typescript/index.ts index f2ee5b2f5056..9551a0c4adcf 100644 --- a/static/programs/k8s-deployment-service-for-minikube-typescript/index.ts +++ b/static/programs/k8s-deployment-service-for-minikube-typescript/index.ts @@ -1,6 +1,5 @@ -"use strict"; -const pulumi = require("@pulumi/pulumi"); -const k8s = require("@pulumi/kubernetes"); +import * as pulumi from "@pulumi/pulumi"; +import * as k8s from "@pulumi/kubernetes"; const appName = "nginx"; const appLabels = { app: appName }; @@ -16,7 +15,7 @@ const deployment = new k8s.apps.v1.Deployment(appName, { }); const frontend = new k8s.core.v1.Service(appName, { - metadata: { labels: deployment.spec.template.metadata.labels }, + metadata: { labels: appLabels }, spec: { type: "ClusterIP", ports: [{ port: 80, targetPort: 80, protocol: "TCP" }], diff --git a/static/programs/kubernetes-csi-driver-go/go.mod b/static/programs/kubernetes-csi-driver-go/go.mod index 441d03b6f889..f93b673c23a7 100644 --- a/static/programs/kubernetes-csi-driver-go/go.mod +++ b/static/programs/kubernetes-csi-driver-go/go.mod @@ -8,87 +8,3 @@ require ( github.com/pulumi/pulumi-kubernetes/sdk/v4 v4.12.0 github.com/pulumi/pulumi/sdk/v3 v3.117.0 ) - -require ( - dario.cat/mergo v1.0.0 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v1.0.0 // indirect - github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect - github.com/agext/levenshtein v1.2.3 // indirect - github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect - github.com/atotto/clipboard v0.1.4 // indirect - github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect - github.com/blang/semver v3.5.1+incompatible // indirect - github.com/charmbracelet/bubbles v0.16.1 // indirect - github.com/charmbracelet/bubbletea v0.24.2 // indirect - github.com/charmbracelet/lipgloss v0.7.1 // indirect - github.com/cheggaaa/pb v1.0.29 // indirect - github.com/cloudflare/circl v1.3.7 // indirect - github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect - github.com/cyphar/filepath-securejoin v0.2.4 // indirect - github.com/djherbis/times v1.5.0 // indirect - github.com/emirpasic/gods v1.18.1 // indirect - github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.5.0 // indirect - github.com/go-git/go-git/v5 v5.12.0 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/glog v1.2.0 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/hcl/v2 v2.17.0 // indirect - github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect - github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/lucasb-eyer/go-colorful v1.2.0 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect - github.com/mattn/go-localereader v0.0.1 // indirect - github.com/mattn/go-runewidth v0.0.15 // indirect - github.com/mitchellh/go-ps v1.0.0 // indirect - github.com/mitchellh/go-wordwrap v1.0.1 // indirect - github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect - github.com/muesli/cancelreader v0.2.2 // indirect - github.com/muesli/reflow v0.3.0 // indirect - github.com/muesli/termenv v0.15.2 // indirect - github.com/opentracing/basictracer-go v1.1.0 // indirect - github.com/opentracing/opentracing-go v1.2.0 // indirect - github.com/pgavlin/fx v0.1.6 // indirect - github.com/pjbgf/sha1cd v0.3.0 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/pkg/term v1.1.0 // indirect - github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect - github.com/pulumi/esc v0.6.2 // indirect - github.com/rivo/uniseg v0.4.4 // indirect - github.com/rogpeppe/go-internal v1.11.0 // indirect - github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect - github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect - github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect - github.com/skeema/knownhosts v1.2.2 // indirect - github.com/spf13/cast v1.4.1 // indirect - github.com/spf13/cobra v1.8.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/texttheater/golang-levenshtein v1.0.1 // indirect - github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect - github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect - github.com/uber/jaeger-lib v2.4.1+incompatible // indirect - github.com/xanzy/ssh-agent v0.3.3 // indirect - github.com/zclconf/go-cty v1.13.2 // indirect - go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.23.0 // indirect - golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect - golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.25.0 // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.20.0 // indirect - golang.org/x/term v0.20.0 // indirect - golang.org/x/text v0.15.0 // indirect - golang.org/x/tools v0.17.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7 // indirect - google.golang.org/grpc v1.63.2 // indirect - google.golang.org/protobuf v1.33.0 // indirect - gopkg.in/warnings.v0 v0.1.2 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - lukechampine.com/frand v1.4.2 // indirect -)