Skip to content

Commit d5299d9

Browse files
authored
Bug(V4-Upgrade): Fixing the Metadata.Elem().name to Metadata.Name(), … (#2059)
Bug(V4-Upgrade): Fixing the Metadata.Elem().name to Metadata.Name(), fixes #1817 Also swapped out `aws-iam-authenticator` to `aws` cli ``` Previewing update (richard-shade-pulumi/dev) View in Browser (Ctrl+O): https://app.pulumi.com/richard-shade-pulumi/aws-go-eks/dev/previews/514e40b6-ddde-42cc-b2cf-24f044a0f67a Type Name Plan + pulumi:pulumi:Stack aws-go-eks-dev create + ├─ aws:iam:RolePolicyAttachment ngpa-2 create + ├─ aws:eks:Cluster eks-cluster create + ├─ aws:iam:RolePolicyAttachment rpa-0 create + ├─ aws:iam:RolePolicyAttachment rpa-1 create + ├─ aws:iam:RolePolicyAttachment ngpa-0 create + ├─ aws:ec2:SecurityGroup cluster-sg create + ├─ aws:iam:RolePolicyAttachment ngpa-1 create + ├─ aws:eks:NodeGroup node-group-2 create + ├─ aws:iam:Role eks-iam-eksRole create + ├─ aws:iam:Role nodegroup-iam-role create + ├─ pulumi:providers:kubernetes k8sprovider create + ├─ kubernetes:core/v1:Service app-service create + ├─ kubernetes:core/v1:Namespace app-ns create + └─ kubernetes:apps/v1:Deployment app-dep create Outputs: kubeconfig: output<string> url : output<string> Resources: + 15 to create Updating (richard-shade-pulumi/dev) View in Browser (Ctrl+O): https://app.pulumi.com/richard-shade-pulumi/aws-go-eks/dev/updates/16 Type Name Status + pulumi:pulumi:Stack aws-go-eks-dev created (485s) + ├─ aws:ec2:SecurityGroup cluster-sg created (3s) + ├─ aws:iam:Role eks-iam-eksRole created (1s) + ├─ aws:iam:Role nodegroup-iam-role created (1s) + ├─ aws:iam:RolePolicyAttachment rpa-1 created (0.73s) + ├─ aws:iam:RolePolicyAttachment rpa-0 created (1s) + ├─ aws:iam:RolePolicyAttachment ngpa-1 created (0.97s) + ├─ aws:iam:RolePolicyAttachment ngpa-0 created (1s) + ├─ aws:iam:RolePolicyAttachment ngpa-2 created (1s) + ├─ aws:eks:Cluster eks-cluster created (353s) + ├─ aws:eks:NodeGroup node-group-2 created (108s) + ├─ pulumi:providers:kubernetes k8sprovider created (0.36s) + ├─ kubernetes:core/v1:Namespace app-ns created (0.68s) + ├─ kubernetes:core/v1:Service app-service created (10s) + └─ kubernetes:apps/v1:Deployment app-dep created (9s) Outputs: kubeconfig: (yaml) {} url : "a512636840ce747a28f9d81dbe0e31b8-356495054.us-west-2.elb.amazonaws.com" Resources: + 15 created Duration: 8m18s ```
1 parent 9b631ff commit d5299d9

File tree

3 files changed

+29
-31
lines changed

3 files changed

+29
-31
lines changed

aws-go-eks/README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
# AWS Golang EKS Cluster
2+
13
[![Deploy this example with Pulumi](https://www.pulumi.com/images/deploy-with-pulumi/dark.svg)](https://app.pulumi.com/new?template=https://github.com/pulumi/examples/blob/master/aws-go-eks/README.md#gh-light-mode-only)
24
[![Deploy this example with Pulumi](https://get.pulumi.com/new/button-light.svg)](https://app.pulumi.com/new?template=https://github.com/pulumi/examples/blob/master/aws-go-eks/README.md#gh-dark-mode-only)
35

4-
# AWS Golang EKS Cluster
56
This example creates an AWS EKS Cluster and deploys a sample container application to it
67

78
## Deploying the App
@@ -14,7 +15,7 @@ This example creates an AWS EKS Cluster and deploys a sample container applicati
1415
2. [Install Go](https://golang.org/doc/install)
1516
3. [Configure AWS Credentials](https://www.pulumi.com/docs/intro/cloud-providers/aws/setup/)
1617
4. [Install `aws-iam-authenticator`](https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html)
17-
4. [Install `kubectl`](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
18+
5. [Install `kubectl`](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
1819

1920
### Steps
2021

@@ -23,44 +24,43 @@ After cloning this repo, run these commands from the working directory:
2324
1. Create a new stack, which is an isolated deployment target for this example:
2425

2526
```bash
26-
$ pulumi stack init dev
27+
pulumi stack init dev
2728
```
2829

2930
2. Set your desired AWS region:
3031

3132
```bash
32-
$ pulumi config set aws:region us-east-1 # any valid AWS region will work
33+
pulumi config set aws:region us-east-1 # any valid AWS region will work
3334
```
3435

35-
4. Execute the Pulumi program to create our EKS Cluster:
36+
3. Execute the Pulumi program to create our EKS Cluster:
3637

37-
```bash
38-
pulumi up
39-
```
38+
```bash
39+
pulumi up
40+
```
4041

41-
5. After 10-15 minutes, your cluster will be ready, and the kubeconfig JSON you'll use to connect to the cluster will
42+
4. After 10-15 minutes, your cluster will be ready, and the kubeconfig JSON you'll use to connect to the cluster will
4243
be available as an output. You can save this kubeconfig to a file like so:
4344
4445
```bash
45-
$ pulumi stack output kubeconfig --show-secrets >kubeconfig.json
46+
pulumi stack output kubeconfig --show-secrets >kubeconfig.json
4647
```
4748
4849
Once you have this file in hand, you can interact with your new cluster as usual via `kubectl`:
4950
5051
```bash
51-
$ KUBECONFIG=./kubeconfig.json kubectl get nodes
52+
KUBECONFIG=./kubeconfig.json kubectl get nodes
5253
```
5354
54-
6. Ensure that the application is running as expected:
55+
5. Ensure that the application is running as expected:
5556
5657
```bash
57-
$ curl $(pulumi stack output url)
58+
curl $(pulumi stack output url)
5859
```
5960
61+
6. Afterwards, destroy your stack and remove it:
6062
61-
7. Afterwards, destroy your stack and remove it:
62-
63-
```bash
64-
pulumi destroy --yes
65-
pulumi stack rm --yes
66-
```
63+
```bash
64+
pulumi destroy --yes
65+
pulumi stack rm --yes
66+
```

aws-go-eks/go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module aws-go-eks
22

3-
go 1.22
4-
5-
toolchain go1.24.0
3+
go 1.24
64

75
require (
86
github.com/pulumi/pulumi-aws/sdk/v6 v6.69.0

aws-go-eks/main.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,11 @@ func main() {
145145
return err
146146
}
147147

148-
ctx.Export("kubeconfig", generateKubeconfig(eksCluster.Endpoint,
149-
eksCluster.CertificateAuthority.Data().Elem(), eksCluster.Name))
148+
kubeconfig := generateKubeconfig(eksCluster.Endpoint, eksCluster.CertificateAuthority.Data().Elem(), eksCluster.Name)
150149

150+
ctx.Export("kubeconfig", kubeconfig)
151151
k8sProvider, err := kubernetes.NewProvider(ctx, "k8sprovider", &kubernetes.ProviderArgs{
152-
Kubeconfig: generateKubeconfig(eksCluster.Endpoint,
153-
eksCluster.CertificateAuthority.Data().Elem(), eksCluster.Name),
152+
Kubeconfig: kubeconfig,
154153
}, pulumi.DependsOn([]pulumi.Resource{nodeGroup}))
155154
if err != nil {
156155
return err
@@ -170,7 +169,7 @@ func main() {
170169
}
171170
_, err = appsv1.NewDeployment(ctx, "app-dep", &appsv1.DeploymentArgs{
172171
Metadata: &metav1.ObjectMetaArgs{
173-
Namespace: namespace.Metadata.Elem().Name(),
172+
Namespace: namespace.Metadata.Name(),
174173
},
175174
Spec: appsv1.DeploymentSpecArgs{
176175
Selector: &metav1.LabelSelectorArgs{
@@ -198,7 +197,7 @@ func main() {
198197

199198
service, err := corev1.NewService(ctx, "app-service", &corev1.ServiceArgs{
200199
Metadata: &metav1.ObjectMetaArgs{
201-
Namespace: namespace.Metadata.Elem().Name(),
200+
Namespace: namespace.Metadata.Name(),
202201
Labels: appLabels,
203202
},
204203
Spec: &corev1.ServiceSpecArgs{
@@ -253,10 +252,11 @@ func generateKubeconfig(clusterEndpoint pulumi.StringOutput, certData pulumi.Str
253252
"user": {
254253
"exec": {
255254
"apiVersion": "client.authentication.k8s.io/v1beta1",
256-
"command": "aws-iam-authenticator",
255+
"command": "aws",
257256
"args": [
258-
"token",
259-
"-i",
257+
"eks",
258+
"get-token",
259+
"--cluster-name",
260260
"%s",
261261
],
262262
},

0 commit comments

Comments
 (0)