Skip to content

Commit

Permalink
Add basic eks cluster example and add missing descriptions (#1112)
Browse files Browse the repository at this point in the history
fixes: #1048

Adds a basic example to the eks cluster resource page, since this page
is missing examples. I took this from the pulumi-eks guide:
https://www.pulumi.com/docs/clouds/aws/guides/eks/

I also added in the missing descriptions text for the
[CoreData](https://www.pulumi.com/registry/packages/eks/api-docs/cluster/#coredata)
nested type.

![Screenshot from 2024-04-01
15-03-06](https://github.com/pulumi/pulumi-eks/assets/16751381/304af76b-e2fa-4e02-9d02-719d9eec5ba2)
  • Loading branch information
sean1588 committed Apr 19, 2024
2 parents 13f24b3 + 1c3a916 commit 03aa914
Show file tree
Hide file tree
Showing 13 changed files with 866 additions and 63 deletions.
58 changes: 48 additions & 10 deletions provider/cmd/pulumi-gen-eks/main.go
Expand Up @@ -136,7 +136,8 @@ func generateSchema() schema.PackageSpec {
Outputs: &schema.ObjectTypeSpec{
Properties: map[string]schema.PropertySpec{
"result": {
TypeSpec: schema.TypeSpec{Type: "string"},
TypeSpec: schema.TypeSpec{Type: "string"},
Description: "The kubeconfig for the cluster.",
},
},
Required: []string{"result"},
Expand All @@ -149,9 +150,33 @@ func generateSchema() schema.PackageSpec {
// TODO: method: createNodeGroup(name: string, args: ClusterNodeGroupOptions): NodeGroup
IsComponent: true,
ObjectTypeSpec: schema.ObjectTypeSpec{
Description: "Cluster is a component that wraps the AWS and Kubernetes resources necessary to " +
"run an EKS cluster, its worker nodes, its optional StorageClasses, and an optional " +
"deployment of the Kubernetes Dashboard.",
Description: "Cluster is a component that wraps the AWS and Kubernetes resources necessary to run an EKS cluster, its worker nodes, its optional StorageClasses, and an optional deployment of the Kubernetes Dashboard.\n\n" +
"## Example Usage\n\n### Provisioning a New EKS Cluster\n\n" +
"<!--Start PulumiCodeChooser -->\n" +
// TS example
"```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as eks from \"@pulumi/eks\";\n\n" +
"// Create an EKS cluster with the default configuration.\nconst cluster = new eks.Cluster(\"cluster\", {});\n\n" +
"// Export the cluster's kubeconfig.\nexport const kubeconfig = cluster.kubeconfig;\n ```\n\n" +
// Python example
"```python\n import pulumi\n import pulumi_eks as eks\n \n # Create an EKS cluster with the default configuration.\n cluster = eks.Cluster(\"cluster\")\n\n " +
"# Export the cluster's kubeconfig.\n pulumi.export(\"kubeconfig\", cluster.kubeconfig)\n ```\n\n" +
// Go example
"```go\n package main\n \n import (\n \t\"github.com/pulumi/pulumi-eks/sdk/go/eks\"\n \t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n )\n\n" +
"func main() {\n \tpulumi.Run(func(ctx *pulumi.Context) error {\n \t\t// Create an EKS cluster with the default configuration.\n" +
"\t\tcluster, err := eks.NewCluster(ctx, \"cluster\", nil)\n \t\tif err != nil {\n \t\t\treturn err\n \t\t}\n \t\t// Export the cluster's kubeconfig.\n \t\tctx.Export(\"kubeconfig\", cluster.Kubeconfig)\n" +
"\t\treturn nil\n \t})\n }\n ```\n\n" +
// C# example
"```csharp\n using System.Collections.Generic;\n using Pulumi;\n using Eks = Pulumi.Eks;\n \n return await Deployment.RunAsync(() =>\n {\n \t// Create an EKS cluster with the default configuration.\n" +
"\tvar cluster = new Eks.Cluster(\"cluster\");\n \n \treturn new Dictionary<string, object?>\n \t{\n \t\t// Export the cluster's kubeconfig.\n \t\t[\"kubeconfig\"] = cluster.Kubeconfig,\n \t};\n });\n\n```\n\n" +
// Java example
"```java\nimport com.pulumi.Context;\nimport com.pulumi.Pulumi;\nimport com.pulumi.core.Output;\nimport com.pulumi.eks.Cluster;\nimport java.util.List;\nimport java.util.ArrayList;\nimport java.util.Map;\n" +
"import java.io.File;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\n\npublic class App {\n\tpublic static void main(String[] args) {\n\t\tPulumi.run(App::stack);\n\t}\n\n" +
"\t public static void stack(Context ctx) {\n \t\t// Create an EKS cluster with the default configuration.\n \t\tvar cluster = new Cluster(\"cluster\");\n \n \t\t// Export the cluster's kubeconfig.\n" +
"\t\tctx.export(\"kubeconfig\", cluster.kubeconfig());\n\t}\n }\n```\n\n" +
// YAML example
"```yaml\nresources:\n# Create an EKS cluster with the default configuration.\ncluster:\ntype: eks:Cluster\noutputs:\n# Export the cluster's kubeconfig.\n" +
"kubeconfig: ${cluster.kubeconfig}\n\n```\n" +
"<!--End PulumiCodeChooser -->",
Properties: map[string]schema.PropertySpec{
"kubeconfig": {
TypeSpec: schema.TypeSpec{Ref: "pulumi.json#/Any"},
Expand Down Expand Up @@ -948,16 +973,19 @@ func generateSchema() schema.PackageSpec {
TypeSpec: schema.TypeSpec{Ref: awsRef("#/resources/aws:eks%2Fcluster:Cluster")},
},
"vpcId": {
TypeSpec: schema.TypeSpec{Type: "string"},
TypeSpec: schema.TypeSpec{Type: "string"},
Description: "ID of the cluster's VPC.",
},
"subnetIds": {
TypeSpec: schema.TypeSpec{
Type: "array",
Items: &schema.TypeSpec{Type: "string"},
},
Description: "List of subnet IDs for the EKS cluster.",
},
"endpoint": {
TypeSpec: schema.TypeSpec{Type: "string"},
TypeSpec: schema.TypeSpec{Type: "string"},
Description: "The EKS cluster's Kubernetes API server endpoint.",
},
"clusterSecurityGroup": {
TypeSpec: schema.TypeSpec{Ref: awsRef("#/resources/aws:ec2%2FsecurityGroup:SecurityGroup")},
Expand All @@ -970,9 +998,11 @@ func generateSchema() schema.PackageSpec {
Type: "array",
Items: &schema.TypeSpec{Ref: awsRef("#/resources/aws:iam%2Frole:Role")},
},
Description: "The IAM instance roles for the cluster's nodes.",
},
"nodeGroupOptions": {
TypeSpec: schema.TypeSpec{Ref: "#/types/eks:index:ClusterNodeGroupOptions"},
TypeSpec: schema.TypeSpec{Ref: "#/types/eks:index:ClusterNodeGroupOptions"},
Description: "The cluster's node group options.",
},
"awsProvider": {
TypeSpec: schema.TypeSpec{Ref: awsRef("#/provider")},
Expand All @@ -982,12 +1012,14 @@ func generateSchema() schema.PackageSpec {
Type: "array",
Items: &schema.TypeSpec{Type: "string"},
},
Description: "List of subnet IDs for the public subnets.",
},
"privateSubnetIds": {
TypeSpec: schema.TypeSpec{
Type: "array",
Items: &schema.TypeSpec{Type: "string"},
},
Description: "List of subnet IDs for the private subnets.",
},
"eksNodeAccess": {
TypeSpec: schema.TypeSpec{Ref: k8sRef("#/resources/kubernetes:core%2Fv1:ConfigMap")},
Expand All @@ -997,27 +1029,33 @@ func generateSchema() schema.PackageSpec {
Type: "object",
AdditionalProperties: &schema.TypeSpec{Ref: k8sRef("#/resources/kubernetes:storage.k8s.io%2Fv1:StorageClass")},
},
Description: "The storage class used for persistent storage by the cluster.",
},
"kubeconfig": {
TypeSpec: schema.TypeSpec{Ref: "pulumi.json#/Any"},
TypeSpec: schema.TypeSpec{Ref: "pulumi.json#/Any"},
Description: "The kubeconfig file for the cluster.",
},
"vpcCni": {
TypeSpec: schema.TypeSpec{Ref: "#/resources/eks:index:VpcCni"},
TypeSpec: schema.TypeSpec{Ref: "#/resources/eks:index:VpcCni"},
Description: "The VPC CNI for the cluster.",
},
"tags": {
TypeSpec: schema.TypeSpec{
Type: "object",
AdditionalProperties: &schema.TypeSpec{Type: "string"},
},
Description: "A map of tags assigned to the EKS cluster.",
},
"nodeSecurityGroupTags": {
TypeSpec: schema.TypeSpec{
Type: "object",
AdditionalProperties: &schema.TypeSpec{Type: "string"},
},
Description: "Tags attached to the security groups associated with the cluster's worker nodes.",
},
"fargateProfile": {
TypeSpec: schema.TypeSpec{Ref: awsRef("#/resources/aws:eks%2FfargateProfile:FargateProfile")},
TypeSpec: schema.TypeSpec{Ref: awsRef("#/resources/aws:eks%2FfargateProfile:FargateProfile")},
Description: "The Fargate profile used to manage which pods run on Fargate.",
},
"oidcProvider": {
TypeSpec: schema.TypeSpec{Ref: awsRef("#/resources/aws:iam%2FopenIdConnectProvider:OpenIdConnectProvider")},
Expand Down
44 changes: 29 additions & 15 deletions provider/cmd/pulumi-resource-eks/schema.json
Expand Up @@ -209,28 +209,34 @@
"$ref": "/aws/v6.5.0/schema.json#/types/aws:eks%2FClusterEncryptionConfig:ClusterEncryptionConfig"
},
"endpoint": {
"type": "string"
"type": "string",
"description": "The EKS cluster's Kubernetes API server endpoint."
},
"fargateProfile": {
"$ref": "/aws/v6.5.0/schema.json#/resources/aws:eks%2FfargateProfile:FargateProfile"
"$ref": "/aws/v6.5.0/schema.json#/resources/aws:eks%2FfargateProfile:FargateProfile",
"description": "The Fargate profile used to manage which pods run on Fargate."
},
"instanceRoles": {
"type": "array",
"items": {
"$ref": "/aws/v6.5.0/schema.json#/resources/aws:iam%2Frole:Role"
}
},
"description": "The IAM instance roles for the cluster's nodes."
},
"kubeconfig": {
"$ref": "pulumi.json#/Any"
"$ref": "pulumi.json#/Any",
"description": "The kubeconfig file for the cluster."
},
"nodeGroupOptions": {
"$ref": "#/types/eks:index:ClusterNodeGroupOptions"
"$ref": "#/types/eks:index:ClusterNodeGroupOptions",
"description": "The cluster's node group options."
},
"nodeSecurityGroupTags": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"description": "Tags attached to the security groups associated with the cluster's worker nodes."
},
"oidcProvider": {
"$ref": "/aws/v6.5.0/schema.json#/resources/aws:iam%2FopenIdConnectProvider:OpenIdConnectProvider"
Expand All @@ -239,7 +245,8 @@
"type": "array",
"items": {
"type": "string"
}
},
"description": "List of subnet IDs for the private subnets."
},
"provider": {
"$ref": "/kubernetes/v4.4.0/schema.json#/provider"
Expand All @@ -248,31 +255,37 @@
"type": "array",
"items": {
"type": "string"
}
},
"description": "List of subnet IDs for the public subnets."
},
"storageClasses": {
"type": "object",
"additionalProperties": {
"$ref": "/kubernetes/v4.4.0/schema.json#/resources/kubernetes:storage.k8s.io%2Fv1:StorageClass"
}
},
"description": "The storage class used for persistent storage by the cluster."
},
"subnetIds": {
"type": "array",
"items": {
"type": "string"
}
},
"description": "List of subnet IDs for the EKS cluster."
},
"tags": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"description": "A map of tags assigned to the EKS cluster."
},
"vpcCni": {
"$ref": "#/resources/eks:index:VpcCni"
"$ref": "#/resources/eks:index:VpcCni",
"description": "The VPC CNI for the cluster."
},
"vpcId": {
"type": "string"
"type": "string",
"description": "ID of the cluster's VPC."
}
},
"type": "object",
Expand Down Expand Up @@ -604,7 +617,7 @@
"provider": {},
"resources": {
"eks:index:Cluster": {
"description": "Cluster is a component that wraps the AWS and Kubernetes resources necessary to run an EKS cluster, its worker nodes, its optional StorageClasses, and an optional deployment of the Kubernetes Dashboard.",
"description": "Cluster is a component that wraps the AWS and Kubernetes resources necessary to run an EKS cluster, its worker nodes, its optional StorageClasses, and an optional deployment of the Kubernetes Dashboard.\n\n## Example Usage\n\n### Provisioning a New EKS Cluster\n\n\u003c!--Start PulumiCodeChooser --\u003e\n```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as eks from \"@pulumi/eks\";\n\n// Create an EKS cluster with the default configuration.\nconst cluster = new eks.Cluster(\"cluster\", {});\n\n// Export the cluster's kubeconfig.\nexport const kubeconfig = cluster.kubeconfig;\n ```\n\n```python\n import pulumi\n import pulumi_eks as eks\n \n # Create an EKS cluster with the default configuration.\n cluster = eks.Cluster(\"cluster\")\n\n # Export the cluster's kubeconfig.\n pulumi.export(\"kubeconfig\", cluster.kubeconfig)\n ```\n\n```go\n package main\n \n import (\n \t\"github.com/pulumi/pulumi-eks/sdk/go/eks\"\n \t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n )\n\nfunc main() {\n \tpulumi.Run(func(ctx *pulumi.Context) error {\n \t\t// Create an EKS cluster with the default configuration.\n\t\tcluster, err := eks.NewCluster(ctx, \"cluster\", nil)\n \t\tif err != nil {\n \t\t\treturn err\n \t\t}\n \t\t// Export the cluster's kubeconfig.\n \t\tctx.Export(\"kubeconfig\", cluster.Kubeconfig)\n\t\treturn nil\n \t})\n }\n ```\n\n```csharp\n using System.Collections.Generic;\n using Pulumi;\n using Eks = Pulumi.Eks;\n \n return await Deployment.RunAsync(() =\u003e\n {\n \t// Create an EKS cluster with the default configuration.\n\tvar cluster = new Eks.Cluster(\"cluster\");\n \n \treturn new Dictionary\u003cstring, object?\u003e\n \t{\n \t\t// Export the cluster's kubeconfig.\n \t\t[\"kubeconfig\"] = cluster.Kubeconfig,\n \t};\n });\n\n```\n\n```java\nimport com.pulumi.Context;\nimport com.pulumi.Pulumi;\nimport com.pulumi.core.Output;\nimport com.pulumi.eks.Cluster;\nimport java.util.List;\nimport java.util.ArrayList;\nimport java.util.Map;\nimport java.io.File;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\n\npublic class App {\n\tpublic static void main(String[] args) {\n\t\tPulumi.run(App::stack);\n\t}\n\n\t public static void stack(Context ctx) {\n \t\t// Create an EKS cluster with the default configuration.\n \t\tvar cluster = new Cluster(\"cluster\");\n \n \t\t// Export the cluster's kubeconfig.\n\t\tctx.export(\"kubeconfig\", cluster.kubeconfig());\n\t}\n }\n```\n\n```yaml\nresources:\n# Create an EKS cluster with the default configuration.\ncluster:\ntype: eks:Cluster\noutputs:\n# Export the cluster's kubeconfig.\nkubeconfig: ${cluster.kubeconfig}\n\n```\n\u003c!--End PulumiCodeChooser --\u003e",
"properties": {
"awsProvider": {
"$ref": "/aws/v6.5.0/schema.json#/provider",
Expand Down Expand Up @@ -1607,7 +1620,8 @@
"outputs": {
"properties": {
"result": {
"type": "string"
"type": "string",
"description": "The kubeconfig for the cluster."
}
},
"required": [
Expand Down
29 changes: 29 additions & 0 deletions sdk/dotnet/Cluster.cs
Expand Up @@ -11,6 +11,32 @@ namespace Pulumi.Eks
{
/// <summary>
/// Cluster is a component that wraps the AWS and Kubernetes resources necessary to run an EKS cluster, its worker nodes, its optional StorageClasses, and an optional deployment of the Kubernetes Dashboard.
///
/// ## Example Usage
///
/// ### Provisioning a New EKS Cluster
///
/// &lt;!--Start PulumiCodeChooser --&gt;
///
/// ```csharp
/// using System.Collections.Generic;
/// using Pulumi;
/// using Eks = Pulumi.Eks;
///
/// return await Deployment.RunAsync(() =&gt;
/// {
/// // Create an EKS cluster with the default configuration.
/// var cluster = new Eks.Cluster("cluster");
///
/// return new Dictionary&lt;string, object?&gt;
/// {
/// // Export the cluster's kubeconfig.
/// ["kubeconfig"] = cluster.Kubeconfig,
/// };
/// });
///
/// ```
/// &lt;!--End PulumiCodeChooser --&gt;
/// </summary>
[EksResourceType("eks:index:Cluster")]
public partial class Cluster : global::Pulumi.ComponentResource
Expand Down Expand Up @@ -645,6 +671,9 @@ public ClusterGetKubeconfigArgs()
[OutputType]
internal sealed class ClusterGetKubeconfigResult
{
/// <summary>
/// The kubeconfig for the cluster.
/// </summary>
public readonly string Result;

[OutputConstructor]
Expand Down

0 comments on commit 03aa914

Please sign in to comment.