@intentius/chant-lexicon-aws 0.0.12 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,175 @@
1
+ ---
2
+ skill: chant-eks
3
+ description: End-to-end EKS workflow bridging AWS infrastructure and Kubernetes workloads
4
+ user-invocable: true
5
+ ---
6
+
7
+ # EKS End-to-End Workflow
8
+
9
+ ## Overview
10
+
11
+ This skill bridges two lexicons:
12
+ - **`@intentius/chant-lexicon-aws`** — EKS cluster, node groups, IAM roles, OIDC provider (CloudFormation)
13
+ - **`@intentius/chant-lexicon-k8s`** — Kubernetes workloads, IRSA, ALB Ingress, storage, observability (K8s YAML)
14
+
15
+ ## Architecture
16
+
17
+ ```
18
+ AWS Lexicon (CloudFormation) K8s Lexicon (kubectl apply)
19
+ ┌────────────────────────┐ ┌────────────────────────────┐
20
+ │ VPC + Subnets │ │ NamespaceEnv (quotas) │
21
+ │ EKS Cluster │ │ AutoscaledService (app) │
22
+ │ Managed Node Group │──ARNs──→ │ IrsaServiceAccount (IRSA) │
23
+ │ OIDC Provider │ │ AlbIngress (ALB) │
24
+ │ IAM Roles (IRSA) │ │ EbsStorageClass (gp3) │
25
+ │ EKS Add-ons │ │ FluentBitAgent (logs) │
26
+ └────────────────────────┘ │ ExternalDnsAgent (DNS) │
27
+ └────────────────────────────┘
28
+ ```
29
+
30
+ ## Step 1: Provision AWS Infrastructure
31
+
32
+ ```bash
33
+ # Build CloudFormation template
34
+ chant build src/infra/ --output infra.json
35
+
36
+ # Deploy
37
+ aws cloudformation deploy \
38
+ --template-file infra.json \
39
+ --stack-name my-eks-cluster \
40
+ --capabilities CAPABILITY_NAMED_IAM
41
+ ```
42
+
43
+ Key AWS resources:
44
+ - **EKS Cluster** — control plane
45
+ - **Managed Node Group** — EC2 worker nodes
46
+ - **OIDC Provider** — enables IRSA (IAM Roles for Service Accounts)
47
+ - **IAM Roles** — node role, app IRSA roles, ALB controller role
48
+
49
+ ## Step 2: Configure kubectl
50
+
51
+ ```bash
52
+ aws eks update-kubeconfig --name my-cluster --region us-east-1
53
+ kubectl get nodes # verify connectivity
54
+ ```
55
+
56
+ ## Step 3: Deploy K8s Workloads
57
+
58
+ ```bash
59
+ # Build K8s manifests
60
+ chant build src/k8s/ --output manifests.yaml
61
+
62
+ # Apply
63
+ kubectl apply -f manifests.yaml
64
+ ```
65
+
66
+ ### Key K8s composites for EKS
67
+
68
+ ```typescript
69
+ import {
70
+ NamespaceEnv,
71
+ AutoscaledService,
72
+ IrsaServiceAccount,
73
+ AlbIngress,
74
+ EbsStorageClass,
75
+ FluentBitAgent,
76
+ ExternalDnsAgent,
77
+ } from "@intentius/chant-lexicon-k8s";
78
+
79
+ // 1. Namespace with quotas and network isolation
80
+ const ns = NamespaceEnv({
81
+ name: "prod",
82
+ cpuQuota: "16",
83
+ memoryQuota: "32Gi",
84
+ defaultCpuRequest: "100m",
85
+ defaultMemoryRequest: "128Mi",
86
+ defaultDenyIngress: true,
87
+ });
88
+
89
+ // 2. IRSA ServiceAccount (use IAM Role ARN from CloudFormation outputs)
90
+ const irsa = IrsaServiceAccount({
91
+ name: "app-sa",
92
+ iamRoleArn: "arn:aws:iam::123456789012:role/app-role", // from CF output
93
+ namespace: "prod",
94
+ });
95
+
96
+ // 3. Application with autoscaling
97
+ const app = AutoscaledService({
98
+ name: "api",
99
+ image: "api:1.0",
100
+ port: 8080,
101
+ maxReplicas: 10,
102
+ cpuRequest: "200m",
103
+ memoryRequest: "256Mi",
104
+ namespace: "prod",
105
+ });
106
+
107
+ // 4. ALB Ingress (use ACM cert ARN from CloudFormation outputs)
108
+ const ingress = AlbIngress({
109
+ name: "api-ingress",
110
+ hosts: [{ hostname: "api.example.com", paths: [{ path: "/", serviceName: "api", servicePort: 80 }] }],
111
+ certificateArn: "arn:aws:acm:us-east-1:123456789012:certificate/abc", // from CF output
112
+ namespace: "prod",
113
+ });
114
+
115
+ // 5. Storage
116
+ const storage = EbsStorageClass({ name: "gp3-encrypted", type: "gp3", encrypted: true });
117
+
118
+ // 6. Observability
119
+ const logging = FluentBitAgent({
120
+ logGroup: "/aws/eks/my-cluster/containers",
121
+ region: "us-east-1",
122
+ clusterName: "my-cluster",
123
+ });
124
+
125
+ // 7. DNS
126
+ const dns = ExternalDnsAgent({
127
+ iamRoleArn: "arn:aws:iam::123456789012:role/external-dns-role",
128
+ domainFilters: ["example.com"],
129
+ });
130
+ ```
131
+
132
+ ## Step 4: Verify
133
+
134
+ ```bash
135
+ kubectl get pods -n prod
136
+ kubectl get ingress -n prod
137
+ kubectl logs -n amazon-cloudwatch -l app.kubernetes.io/name=fluent-bit
138
+ ```
139
+
140
+ ## Cleanup
141
+
142
+ ```bash
143
+ # Delete K8s workloads first
144
+ kubectl delete -f manifests.yaml
145
+
146
+ # Then delete AWS infrastructure
147
+ aws cloudformation delete-stack --stack-name my-eks-cluster
148
+ aws cloudformation wait stack-delete-complete --stack-name my-eks-cluster
149
+ ```
150
+
151
+ ## Cross-Lexicon Value Flow
152
+
153
+ CloudFormation outputs flow into K8s composite props:
154
+
155
+ | CloudFormation Output | K8s Composite Prop |
156
+ |----------------------|-------------------|
157
+ | App IAM Role ARN | `IrsaServiceAccount.iamRoleArn` |
158
+ | ALB Controller Role ARN | `IrsaServiceAccount.iamRoleArn` (for ALB controller SA) |
159
+ | ACM Certificate ARN | `AlbIngress.certificateArn` |
160
+ | ExternalDNS Role ARN | `ExternalDnsAgent.iamRoleArn` |
161
+ | EKS Cluster Name | `FluentBitAgent.clusterName`, `AdotCollector.clusterName` |
162
+ | EFS Filesystem ID | `EfsStorageClass.fileSystemId` |
163
+
164
+ ## EKS Init Template
165
+
166
+ Scaffold a dual-lexicon EKS project:
167
+
168
+ ```bash
169
+ chant init --lexicon aws --template eks
170
+ ```
171
+
172
+ This creates:
173
+ - `src/infra/` — EKS cluster, node group, IAM (AWS lexicon)
174
+ - `src/k8s/` — namespace, app, ingress, storage (K8s lexicon)
175
+ - `package.json` with both `@intentius/chant-lexicon-aws` and `@intentius/chant-lexicon-k8s`