@vfarcic/dot-ai 0.102.0 → 0.104.0
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.
- package/README.md +14 -0
- package/dist/core/nushell-runtime.d.ts +39 -0
- package/dist/core/nushell-runtime.d.ts.map +1 -0
- package/dist/core/nushell-runtime.js +103 -0
- package/dist/core/platform-operations.d.ts +76 -0
- package/dist/core/platform-operations.d.ts.map +1 -0
- package/dist/core/platform-operations.js +317 -0
- package/dist/interfaces/mcp.d.ts.map +1 -1
- package/dist/interfaces/mcp.js +9 -1
- package/dist/tools/build-platform.d.ts +25 -0
- package/dist/tools/build-platform.d.ts.map +1 -0
- package/dist/tools/build-platform.js +277 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +6 -1
- package/dist/tools/version.d.ts +7 -0
- package/dist/tools/version.d.ts.map +1 -1
- package/dist/tools/version.js +34 -5
- package/package.json +3 -2
- package/prompts/map-intent-to-operation.md +104 -0
- package/prompts/parse-script-operations.md +72 -0
- package/scripts/ack.nu +195 -0
- package/scripts/anthropic.nu +24 -0
- package/scripts/argo-workflows.nu +47 -0
- package/scripts/argocd.nu +85 -0
- package/scripts/aso.nu +74 -0
- package/scripts/atlas.nu +15 -0
- package/scripts/backstage.nu +349 -0
- package/scripts/cert-manager.nu +13 -0
- package/scripts/cnpg.nu +14 -0
- package/scripts/common.nu +116 -0
- package/scripts/crossplane.nu +718 -0
- package/scripts/dot.nu +32 -0
- package/scripts/external-secrets.nu +110 -0
- package/scripts/gatekeeper.nu +19 -0
- package/scripts/github.nu +42 -0
- package/scripts/image.nu +67 -0
- package/scripts/ingress.nu +149 -0
- package/scripts/kro.nu +11 -0
- package/scripts/kubernetes.nu +609 -0
- package/scripts/kubevela.nu +22 -0
- package/scripts/kyverno.nu +16 -0
- package/scripts/mcp.nu +139 -0
- package/scripts/port.nu +71 -0
- package/scripts/prometheus.nu +21 -0
- package/scripts/registry.nu +55 -0
- package/scripts/storage.nu +210 -0
- package/scripts/tests.nu +12 -0
- package/scripts/toolhive.nu +21 -0
- package/scripts/velero.nu +45 -0
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
#!/usr/bin/env nu
|
|
2
|
+
|
|
3
|
+
# Creates a Kubernetes cluster with the specified provider
|
|
4
|
+
#
|
|
5
|
+
# Examples:
|
|
6
|
+
# > main create kubernetes aws --name my-cluster --min_nodes 3 --max_nodes 5
|
|
7
|
+
# > main create kubernetes kind --name test-cluster
|
|
8
|
+
def --env "main create kubernetes" [
|
|
9
|
+
provider: string # The Kubernetes provider to use (aws, azure, google, upcloud, kind)
|
|
10
|
+
--name = "dot" # Name of the Kubernetes cluster
|
|
11
|
+
--min-nodes = 2 # Minimum number of nodes in the cluster
|
|
12
|
+
--max-nodes = 4 # Maximum number of nodes in the cluster
|
|
13
|
+
--node-size = "small" # Supported values: small, medium, large
|
|
14
|
+
--auth = true # Whether to perform authentication with the cloud provider
|
|
15
|
+
--enable-ingress = true # Whether to enable ingress for the kind provider
|
|
16
|
+
--aws-access-key-id: string, # AWS Access Key ID (optional, falls back to AWS_ACCESS_KEY_ID env var)
|
|
17
|
+
--aws-secret-access-key: string, # AWS Secret Access Key (optional, falls back to AWS_SECRET_ACCESS_KEY env var)
|
|
18
|
+
--azure-tenant: string, # Azure Tenant ID (optional, falls back to AZURE_TENANT env var)
|
|
19
|
+
--upcloud-username: string, # UpCloud username (optional, falls back to UPCLOUD_USERNAME env var)
|
|
20
|
+
--upcloud-password: string # UpCloud password (optional, falls back to UPCLOUD_PASSWORD env var)
|
|
21
|
+
] {
|
|
22
|
+
|
|
23
|
+
$env.KUBECONFIG = $"($env.PWD)/kubeconfig-($name).yaml"
|
|
24
|
+
$"export KUBECONFIG=($env.KUBECONFIG)\n" | save --append .env
|
|
25
|
+
$"export KUBECONFIG_($name | str upcase)=($env.KUBECONFIG)\n" | save --append .env
|
|
26
|
+
|
|
27
|
+
if $provider == "google" {
|
|
28
|
+
|
|
29
|
+
(
|
|
30
|
+
create gke --name $name --node_size $node_size
|
|
31
|
+
--min_nodes $min_nodes --max_nodes $max_nodes
|
|
32
|
+
--auth $auth
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
} else if $provider == "aws" {
|
|
36
|
+
|
|
37
|
+
(
|
|
38
|
+
create eks --name $name --node_size $node_size
|
|
39
|
+
--min_nodes $min_nodes --max_nodes $max_nodes
|
|
40
|
+
--aws-access-key-id $aws_access_key_id
|
|
41
|
+
--aws-secret-access-key $aws_secret_access_key
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
} else if $provider == "azure" {
|
|
45
|
+
|
|
46
|
+
(
|
|
47
|
+
create aks --name $name --node_size $node_size
|
|
48
|
+
--min_nodes $min_nodes --max_nodes $max_nodes
|
|
49
|
+
--azure-tenant $azure_tenant
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
} else if $provider == "upcloud" {
|
|
53
|
+
|
|
54
|
+
(
|
|
55
|
+
create upcloud --name $name --node_size $node_size
|
|
56
|
+
--min_nodes $min_nodes --max_nodes $max_nodes
|
|
57
|
+
--upcloud-username $upcloud_username
|
|
58
|
+
--upcloud-password $upcloud_password
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
} else if $provider == "kind" {
|
|
62
|
+
|
|
63
|
+
mut config = {
|
|
64
|
+
kind: "Cluster"
|
|
65
|
+
apiVersion: "kind.x-k8s.io/v1alpha4"
|
|
66
|
+
name: $name
|
|
67
|
+
nodes: [{
|
|
68
|
+
role: "control-plane"
|
|
69
|
+
}]
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if $enable_ingress {
|
|
73
|
+
$config = $config | merge {
|
|
74
|
+
nodes: [{
|
|
75
|
+
role: "control-plane"
|
|
76
|
+
kubeadmConfigPatches: ['kind: InitConfiguration
|
|
77
|
+
nodeRegistration:
|
|
78
|
+
kubeletExtraArgs:
|
|
79
|
+
node-labels: "ingress-ready=true"'
|
|
80
|
+
]
|
|
81
|
+
extraPortMappings: [{
|
|
82
|
+
containerPort: 80
|
|
83
|
+
hostPort: 80
|
|
84
|
+
protocol: "TCP"
|
|
85
|
+
}, {
|
|
86
|
+
containerPort: 443
|
|
87
|
+
hostPort: 443
|
|
88
|
+
protocol: "TCP"
|
|
89
|
+
}]
|
|
90
|
+
}]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
$config | to yaml | save $"kind.yaml" --force
|
|
95
|
+
|
|
96
|
+
kind create cluster --config kind.yaml
|
|
97
|
+
|
|
98
|
+
} else {
|
|
99
|
+
|
|
100
|
+
print $"(ansi red_bold)($provider)(ansi reset) is not a supported."
|
|
101
|
+
exit 1
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
$env.KUBECONFIG
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
# Lists the required packages for Kubernetes functionality
|
|
110
|
+
#
|
|
111
|
+
# Examples:
|
|
112
|
+
# > main packages kubernetes
|
|
113
|
+
def "main packages kubernetes" [] {
|
|
114
|
+
|
|
115
|
+
print $"(ansi yellow_bold)Following Nix packages are required(ansi reset):
|
|
116
|
+
* kind
|
|
117
|
+
* kubectl
|
|
118
|
+
* awscli2
|
|
119
|
+
* eksctl
|
|
120
|
+
* google-cloud-sdk
|
|
121
|
+
* azure-cli
|
|
122
|
+
"
|
|
123
|
+
|
|
124
|
+
print $"(ansi yellow_bold)Following tools not available as Nix packages are required(ansi reset):
|
|
125
|
+
* upctl
|
|
126
|
+
"
|
|
127
|
+
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
# Destroys a Kubernetes cluster created with the specified provider
|
|
131
|
+
#
|
|
132
|
+
# Examples:
|
|
133
|
+
# > main destroy kubernetes aws --name my-cluster
|
|
134
|
+
# > main destroy kubernetes google --name test-cluster --delete_project false
|
|
135
|
+
def "main destroy kubernetes" [
|
|
136
|
+
provider: string # The Kubernetes provider to delete (aws, azure, google, upcloud, kind)
|
|
137
|
+
--name = "dot" # Name of the Kubernetes cluster to destroy
|
|
138
|
+
--delete_project = true # Whether to delete the associated cloud project
|
|
139
|
+
] {
|
|
140
|
+
|
|
141
|
+
if $provider == "google" {
|
|
142
|
+
|
|
143
|
+
rm --force $env.KUBECONFIG
|
|
144
|
+
|
|
145
|
+
(
|
|
146
|
+
gcloud container clusters delete $name
|
|
147
|
+
--project $env.PROJECT_ID --zone us-east1-b --quiet
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
if $delete_project {
|
|
151
|
+
gcloud projects delete $env.PROJECT_ID --quiet
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
} else if $provider == "aws" {
|
|
155
|
+
|
|
156
|
+
let region = "us-east-1"
|
|
157
|
+
|
|
158
|
+
(
|
|
159
|
+
eksctl delete addon --name aws-ebs-csi-driver
|
|
160
|
+
--cluster $name --region $region
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
(
|
|
164
|
+
eksctl delete nodegroup --name primary
|
|
165
|
+
--cluster $name --drain=false
|
|
166
|
+
--region $region --parallel 10 --wait
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
(
|
|
170
|
+
eksctl delete cluster
|
|
171
|
+
--config-file $"eksctl-config-($name).yaml"
|
|
172
|
+
--wait
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
} else if $provider == "azure" {
|
|
176
|
+
|
|
177
|
+
(
|
|
178
|
+
az aks delete --resource-group $env.RESOURCE_GROUP
|
|
179
|
+
--name $name --yes
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
if $delete_project {
|
|
183
|
+
|
|
184
|
+
az group delete --name $env.RESOURCE_GROUP --yes
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
} else if $provider == "upcloud" {
|
|
189
|
+
|
|
190
|
+
print $"Deleting (ansi yellow_bold)Kubernetes(ansi reset)..."
|
|
191
|
+
|
|
192
|
+
upctl kubernetes delete $name
|
|
193
|
+
|
|
194
|
+
print $"Waiting for (ansi yellow_bold)10 minutes(ansi reset) to fully clean up the cluster..."
|
|
195
|
+
|
|
196
|
+
sleep 600sec
|
|
197
|
+
|
|
198
|
+
print $"Deleting (ansi yellow_bold)network(ansi reset)..."
|
|
199
|
+
|
|
200
|
+
upctl network delete $name
|
|
201
|
+
|
|
202
|
+
} else if $provider == "kind" {
|
|
203
|
+
|
|
204
|
+
kind delete cluster --name $name
|
|
205
|
+
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if "KUBECONFIG" in $env {
|
|
209
|
+
rm --force $env.KUBECONFIG
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
# Creates Kubernetes credentials in a kubeconfig file
|
|
215
|
+
#
|
|
216
|
+
# Examples:
|
|
217
|
+
# > main create kubernetes_creds --source_kuberconfig kubeconfig.yaml --destination_kuberconfig new-kubeconfig.yaml
|
|
218
|
+
def "main create kubernetes_creds" [
|
|
219
|
+
--source_kuberconfig = "kubeconfig.yaml" # Path to the source kubeconfig file
|
|
220
|
+
--destination_kuberconfig = "kubeconfig_new.yaml" # Path to the destination kubeconfig file
|
|
221
|
+
] {
|
|
222
|
+
|
|
223
|
+
{
|
|
224
|
+
apiVersion: "v1"
|
|
225
|
+
kind: "ServiceAccount"
|
|
226
|
+
metadata: {
|
|
227
|
+
name: "creds"
|
|
228
|
+
namespace: "kube-system"
|
|
229
|
+
}
|
|
230
|
+
} | to yaml | kubectl --kubeconfig $source_kuberconfig apply --filename -
|
|
231
|
+
|
|
232
|
+
{
|
|
233
|
+
apiVersion: "v1"
|
|
234
|
+
kind: "Secret"
|
|
235
|
+
metadata: {
|
|
236
|
+
name: "creds"
|
|
237
|
+
namespace: "kube-system"
|
|
238
|
+
annotations: {
|
|
239
|
+
"kubernetes.io/service-account.name": "creds"
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
type: "kubernetes.io/service-account-token"
|
|
243
|
+
} | to yaml | kubectl --kubeconfig $source_kuberconfig apply --filename -
|
|
244
|
+
|
|
245
|
+
{
|
|
246
|
+
apiVersion: "rbac.authorization.k8s.io/v1"
|
|
247
|
+
kind: "ClusterRoleBinding"
|
|
248
|
+
metadata: {
|
|
249
|
+
name: "creds"
|
|
250
|
+
}
|
|
251
|
+
subjects: [{
|
|
252
|
+
kind: "ServiceAccount"
|
|
253
|
+
name: "creds"
|
|
254
|
+
namespace: "kube-system"
|
|
255
|
+
}]
|
|
256
|
+
roleRef: {
|
|
257
|
+
kind: "ClusterRole"
|
|
258
|
+
name: "cluster-admin"
|
|
259
|
+
apiGroup: "rbac.authorization.k8s.io"
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
| to yaml
|
|
263
|
+
| kubectl --kubeconfig $source_kuberconfig apply --filename -
|
|
264
|
+
|
|
265
|
+
let kube_ca_data = open $source_kuberconfig
|
|
266
|
+
| get clusters.0.cluster.certificate-authority-data
|
|
267
|
+
|
|
268
|
+
let kube_url = open $source_kuberconfig
|
|
269
|
+
| get clusters.0.cluster.server
|
|
270
|
+
|
|
271
|
+
let token_encoded = (
|
|
272
|
+
kubectl
|
|
273
|
+
--kubeconfig $source_kuberconfig
|
|
274
|
+
--namespace kube-system
|
|
275
|
+
get secret creds --output yaml
|
|
276
|
+
)
|
|
277
|
+
| from yaml
|
|
278
|
+
| get data.token
|
|
279
|
+
|
|
280
|
+
let token = ($token_encoded | decode base64 | decode)
|
|
281
|
+
|
|
282
|
+
{
|
|
283
|
+
apiVersion: "v1"
|
|
284
|
+
kind: "Config"
|
|
285
|
+
clusters: [{
|
|
286
|
+
name: "default-cluster"
|
|
287
|
+
cluster: {
|
|
288
|
+
certificate-authority-data: $kube_ca_data
|
|
289
|
+
server: $"($kube_url):443"
|
|
290
|
+
}
|
|
291
|
+
}]
|
|
292
|
+
contexts: [{
|
|
293
|
+
name: "default-context"
|
|
294
|
+
context: {
|
|
295
|
+
cluster: "default-cluster"
|
|
296
|
+
namespace: "default"
|
|
297
|
+
user: "default-user"
|
|
298
|
+
}
|
|
299
|
+
}]
|
|
300
|
+
current-context: "default-context"
|
|
301
|
+
users: [{
|
|
302
|
+
name: "default-user"
|
|
303
|
+
user: {
|
|
304
|
+
token: $token
|
|
305
|
+
}
|
|
306
|
+
}]
|
|
307
|
+
} | to yaml | save $source_kuberconfig --force
|
|
308
|
+
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
# Creates a UpCloud Kubernetes cluster
|
|
312
|
+
#
|
|
313
|
+
# Examples:
|
|
314
|
+
# > create upcloud --name my-cluster --node_size medium --min_nodes 3 --max_nodes 5
|
|
315
|
+
def --env "create upcloud" [
|
|
316
|
+
--name = "dot" # Name of the Kubernetes cluster
|
|
317
|
+
--node_size = "small" # Supported values: small, medium, large
|
|
318
|
+
--min_nodes = 2 # Minimum number of nodes in the cluster
|
|
319
|
+
--max_nodes = 4 # Maximum number of nodes in the cluster
|
|
320
|
+
--upcloud-username: string, # UpCloud username (optional, falls back to UPCLOUD_USERNAME env var)
|
|
321
|
+
--upcloud-password: string # UpCloud password (optional, falls back to UPCLOUD_PASSWORD env var)
|
|
322
|
+
] {
|
|
323
|
+
|
|
324
|
+
print $"
|
|
325
|
+
Visit https://signup.upcloud.com/?promo=devops50 to (ansi yellow_bold)sign up(ansi reset) and get $50+ credits.
|
|
326
|
+
Make sure that (ansi yellow_bold)Allow API connections from all networks(ansi reset) is checked inside the https://hub.upcloud.com/account/overview page.
|
|
327
|
+
Install `(ansi yellow_bold)upctl(ansi reset)` from https://upcloudltd.github.io/upcloud-cli if you do not have it already.
|
|
328
|
+
Press the (ansi yellow_bold)enter key(ansi reset) to continue.
|
|
329
|
+
"
|
|
330
|
+
input
|
|
331
|
+
|
|
332
|
+
mut username = $upcloud_username
|
|
333
|
+
if ($username | is-empty) and ("UPCLOUD_USERNAME" in $env) {
|
|
334
|
+
$username = $env.UPCLOUD_USERNAME
|
|
335
|
+
} else if ($username | is-empty) {
|
|
336
|
+
error make { msg: "UpCloud username required via --upcloud-username parameter or UPCLOUD_USERNAME environment variable" }
|
|
337
|
+
}
|
|
338
|
+
$env.UPCLOUD_USERNAME = $username
|
|
339
|
+
$"export UPCLOUD_USERNAME=($username)\n"
|
|
340
|
+
| save --append .env
|
|
341
|
+
|
|
342
|
+
mut password = $upcloud_password
|
|
343
|
+
if ($password | is-empty) and ("UPCLOUD_PASSWORD" in $env) {
|
|
344
|
+
$password = $env.UPCLOUD_PASSWORD
|
|
345
|
+
} else if ($password | is-empty) {
|
|
346
|
+
error make { msg: "UpCloud password required via --upcloud-password parameter or UPCLOUD_PASSWORD environment variable" }
|
|
347
|
+
}
|
|
348
|
+
$env.UPCLOUD_PASSWORD = $password
|
|
349
|
+
$"export UPCLOUD_PASSWORD=($password)\n"
|
|
350
|
+
| save --append .env
|
|
351
|
+
print ""
|
|
352
|
+
|
|
353
|
+
mut vm_size = "2xCPU-4GB"
|
|
354
|
+
if $node_size == "medium" {
|
|
355
|
+
$vm_size = "4xCPU-8GB"
|
|
356
|
+
} else if $node_size == "large" {
|
|
357
|
+
$vm_size = "8xCPU-32GB"
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
print $"Creating (ansi yellow_bold)network(ansi reset)..."
|
|
361
|
+
|
|
362
|
+
do --ignore-errors {(
|
|
363
|
+
upctl network create --name $name --zone us-nyc1
|
|
364
|
+
--ip-network address="10.0.1.0/24,dhcp=true"
|
|
365
|
+
)}
|
|
366
|
+
|
|
367
|
+
print $"Creating (ansi yellow_bold)Kubernetes(ansi reset) cluster..."
|
|
368
|
+
|
|
369
|
+
(
|
|
370
|
+
upctl kubernetes create --name $name --zone us-nyc1
|
|
371
|
+
--node-group $"count=($min_nodes),name=dot,plan=($vm_size)"
|
|
372
|
+
--plan dev-md --network $name --version "1.30"
|
|
373
|
+
--kubernetes-api-allow-ip "0.0.0.0/0" --wait
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
print $"Getting (ansi yellow_bold)kubeconfig(ansi reset)..."
|
|
377
|
+
|
|
378
|
+
(
|
|
379
|
+
upctl kubernetes config $name --output yaml
|
|
380
|
+
--write $env.KUBECONFIG
|
|
381
|
+
)
|
|
382
|
+
|
|
383
|
+
print $"Waiting for (ansi yellow_bold)5 minutes(ansi reset) to fully set up the cluster..."
|
|
384
|
+
|
|
385
|
+
sleep 300sec
|
|
386
|
+
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
# Creates an Azure Kubernetes Service (AKS) cluster
|
|
390
|
+
#
|
|
391
|
+
# Examples:
|
|
392
|
+
# > create aks --name my-cluster --node_size medium --min_nodes 3 --max_nodes 5
|
|
393
|
+
def --env "create aks" [
|
|
394
|
+
--name = "dot", # Name of the Kubernetes cluster
|
|
395
|
+
--min_nodes = 2, # Minimum number of nodes in the cluster
|
|
396
|
+
--max_nodes = 4, # Maximum number of nodes in the cluster
|
|
397
|
+
--node_size = "small", # Supported values: small, medium, large
|
|
398
|
+
--auth = true, # Whether to perform authentication with Azure
|
|
399
|
+
--azure-tenant: string # Azure Tenant ID (optional, falls back to AZURE_TENANT env var)
|
|
400
|
+
] {
|
|
401
|
+
|
|
402
|
+
let location = "eastus"
|
|
403
|
+
|
|
404
|
+
mut tenant = $azure_tenant
|
|
405
|
+
if ($tenant | is-empty) and ("AZURE_TENANT" in $env) {
|
|
406
|
+
$tenant = $env.AZURE_TENANT
|
|
407
|
+
} else if ($tenant | is-empty) {
|
|
408
|
+
error make { msg: "Azure Tenant ID required via --azure-tenant parameter or AZURE_TENANT environment variable" }
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
if $auth {
|
|
412
|
+
az login --tenant $tenant
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
mut resource_group = ""
|
|
416
|
+
if RESOURCE_GROUP in $env {
|
|
417
|
+
$resource_group = $env.RESOURCE_GROUP
|
|
418
|
+
} else {
|
|
419
|
+
$resource_group = $"dot-(date now | format date "%Y%m%d%H%M%S")"
|
|
420
|
+
$env.RESOURCE_GROUP = $resource_group
|
|
421
|
+
$"export RESOURCE_GROUP=($resource_group)\n" | save --append .env
|
|
422
|
+
az group create --name $resource_group --location $location
|
|
423
|
+
}
|
|
424
|
+
mut vm_size = "Standard_B2s"
|
|
425
|
+
if $node_size == "medium" {
|
|
426
|
+
$vm_size = "Standard_B4ms"
|
|
427
|
+
} else if $node_size == "large" {
|
|
428
|
+
$vm_size = "Standard_B8ms"
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
(
|
|
432
|
+
az aks create --resource-group $resource_group --name $name
|
|
433
|
+
--node-count $min_nodes --min-count $min_nodes
|
|
434
|
+
--max-count $max_nodes
|
|
435
|
+
--node-vm-size $vm_size
|
|
436
|
+
--enable-managed-identity --generate-ssh-keys
|
|
437
|
+
--enable-cluster-autoscaler --yes
|
|
438
|
+
)
|
|
439
|
+
|
|
440
|
+
(
|
|
441
|
+
az aks get-credentials --resource-group $resource_group
|
|
442
|
+
--name $name --file $env.KUBECONFIG
|
|
443
|
+
)
|
|
444
|
+
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
# Creates a Google Kubernetes Engine (GKE) cluster
|
|
448
|
+
#
|
|
449
|
+
# Examples:
|
|
450
|
+
# > create gke --name my-cluster --node_size medium --min_nodes 3 --max_nodes 5 --auth true
|
|
451
|
+
def --env "create gke" [
|
|
452
|
+
--name = "dot", # Name of the Kubernetes cluster
|
|
453
|
+
--min_nodes = 2, # Minimum number of nodes in the cluster
|
|
454
|
+
--max_nodes = 4, # Maximum number of nodes in the cluster
|
|
455
|
+
--node_size = "small" # Supported values: small, medium, large
|
|
456
|
+
--auth = true # Whether to perform authentication with Google Cloud
|
|
457
|
+
] {
|
|
458
|
+
|
|
459
|
+
if $auth {
|
|
460
|
+
gcloud auth login
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
mut project_id = ""
|
|
464
|
+
if PROJECT_ID in $env and not $auth {
|
|
465
|
+
$project_id = $env.PROJECT_ID
|
|
466
|
+
} else {
|
|
467
|
+
$project_id = $"dot-(date now | format date "%Y%m%d%H%M%S")"
|
|
468
|
+
$env.PROJECT_ID = $project_id
|
|
469
|
+
$"export PROJECT_ID=($project_id)\n" | save --append .env
|
|
470
|
+
|
|
471
|
+
gcloud projects create $project_id
|
|
472
|
+
|
|
473
|
+
start $"https://console.cloud.google.com/marketplace/product/google/container.googleapis.com?project=($project_id)"
|
|
474
|
+
|
|
475
|
+
print $"
|
|
476
|
+
(ansi yellow_bold)ENABLE(ansi reset) the API.
|
|
477
|
+
Press the (ansi yellow_bold)enter key(ansi reset) to continue.
|
|
478
|
+
"
|
|
479
|
+
input
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
mut vm_size = "e2-standard-2"
|
|
483
|
+
if $node_size == "medium" {
|
|
484
|
+
$vm_size = "e2-standard-4"
|
|
485
|
+
} else if $node_size == "large" {
|
|
486
|
+
$vm_size = "e2-standard-8"
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
(
|
|
490
|
+
gcloud container clusters create $name --project $project_id
|
|
491
|
+
--zone us-east1-b --machine-type $vm_size
|
|
492
|
+
--enable-autoscaling --num-nodes $min_nodes
|
|
493
|
+
--min-nodes $min_nodes --max-nodes $max_nodes
|
|
494
|
+
--enable-network-policy --no-enable-autoupgrade
|
|
495
|
+
)
|
|
496
|
+
|
|
497
|
+
(
|
|
498
|
+
gcloud container clusters get-credentials $name
|
|
499
|
+
--project $project_id --zone us-east1-b
|
|
500
|
+
)
|
|
501
|
+
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
# Creates an Amazon Elastic Kubernetes Service (EKS) cluster
|
|
505
|
+
#
|
|
506
|
+
# Examples:
|
|
507
|
+
# > create eks --name my-cluster --node_size medium --min_nodes 3 --max_nodes 5
|
|
508
|
+
def --env "create eks" [
|
|
509
|
+
--name = "dot", # Name of the Kubernetes cluster
|
|
510
|
+
--min_nodes = 2, # Minimum number of nodes in the cluster
|
|
511
|
+
--max_nodes = 4, # Maximum number of nodes in the cluster
|
|
512
|
+
--node_size = "small", # Supported values: small, medium, large
|
|
513
|
+
--aws-access-key-id: string, # AWS Access Key ID (optional, falls back to AWS_ACCESS_KEY_ID env var)
|
|
514
|
+
--aws-secret-access-key: string # AWS Secret Access Key (optional, falls back to AWS_SECRET_ACCESS_KEY env var)
|
|
515
|
+
] {
|
|
516
|
+
|
|
517
|
+
let region = "us-east-1"
|
|
518
|
+
|
|
519
|
+
mut access_key = $aws_access_key_id
|
|
520
|
+
if ($access_key | is-empty) and ("AWS_ACCESS_KEY_ID" in $env) {
|
|
521
|
+
$access_key = $env.AWS_ACCESS_KEY_ID
|
|
522
|
+
} else if ($access_key | is-empty) {
|
|
523
|
+
error make { msg: "AWS Access Key ID required via --aws-access-key-id parameter or AWS_ACCESS_KEY_ID environment variable" }
|
|
524
|
+
}
|
|
525
|
+
$"export AWS_ACCESS_KEY_ID=($access_key)\n"
|
|
526
|
+
| save --append .env
|
|
527
|
+
|
|
528
|
+
mut secret_key = $aws_secret_access_key
|
|
529
|
+
if ($secret_key | is-empty) and ("AWS_SECRET_ACCESS_KEY" in $env) {
|
|
530
|
+
$secret_key = $env.AWS_SECRET_ACCESS_KEY
|
|
531
|
+
} else if ($secret_key | is-empty) {
|
|
532
|
+
error make { msg: "AWS Secret Access Key required via --aws-secret-access-key parameter or AWS_SECRET_ACCESS_KEY environment variable" }
|
|
533
|
+
}
|
|
534
|
+
$"export AWS_SECRET_ACCESS_KEY=($secret_key)\n"
|
|
535
|
+
| save --append .env
|
|
536
|
+
|
|
537
|
+
let aws_account_id = (
|
|
538
|
+
aws sts get-caller-identity --query "Account"
|
|
539
|
+
--output text
|
|
540
|
+
)
|
|
541
|
+
$"export AWS_ACCOUNT_ID=($aws_account_id)\n"
|
|
542
|
+
| save --append .env
|
|
543
|
+
|
|
544
|
+
$"[default]
|
|
545
|
+
aws_access_key_id = ($access_key)
|
|
546
|
+
aws_secret_access_key = ($secret_key)
|
|
547
|
+
" | save aws-creds.conf --force
|
|
548
|
+
|
|
549
|
+
mut vm_size = "t3.medium"
|
|
550
|
+
if $node_size == "medium" {
|
|
551
|
+
$vm_size = "t3.xlarge"
|
|
552
|
+
} else if $node_size == "large" {
|
|
553
|
+
$vm_size = "t3.2xlarge"
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
{
|
|
557
|
+
apiVersion: "eksctl.io/v1alpha5"
|
|
558
|
+
kind: "ClusterConfig"
|
|
559
|
+
metadata: {
|
|
560
|
+
name: $name
|
|
561
|
+
region: $region
|
|
562
|
+
version: "1.31"
|
|
563
|
+
}
|
|
564
|
+
managedNodeGroups: [{
|
|
565
|
+
name: "primary"
|
|
566
|
+
instanceType: $vm_size
|
|
567
|
+
minSize: $min_nodes
|
|
568
|
+
maxSize: $max_nodes
|
|
569
|
+
iam: {
|
|
570
|
+
withAddonPolicies: {
|
|
571
|
+
autoScaler: true
|
|
572
|
+
ebs: true
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}]
|
|
576
|
+
} | to yaml | save $"eksctl-config-($name).yaml" --force
|
|
577
|
+
|
|
578
|
+
(
|
|
579
|
+
eksctl create cluster
|
|
580
|
+
--config-file $"eksctl-config-($name).yaml"
|
|
581
|
+
--kubeconfig $env.KUBECONFIG
|
|
582
|
+
)
|
|
583
|
+
|
|
584
|
+
(
|
|
585
|
+
eksctl create addon --name aws-ebs-csi-driver
|
|
586
|
+
--cluster $name
|
|
587
|
+
--service-account-role-arn $"arn:aws:iam::($aws_account_id):role/AmazonEKS_EBS_CSI_DriverRole"
|
|
588
|
+
--region $region --force
|
|
589
|
+
)
|
|
590
|
+
|
|
591
|
+
(
|
|
592
|
+
kubectl patch storageclass gp2
|
|
593
|
+
--patch '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
|
|
594
|
+
)
|
|
595
|
+
|
|
596
|
+
(
|
|
597
|
+
eksctl utils associate-iam-oidc-provider --cluster $name
|
|
598
|
+
--region $region --approve
|
|
599
|
+
)
|
|
600
|
+
|
|
601
|
+
let oidc_provider = (
|
|
602
|
+
aws eks describe-cluster --name $name --region $region
|
|
603
|
+
--query "cluster.identity.oidc.issuer"
|
|
604
|
+
--output text | str replace "https://" ""
|
|
605
|
+
)
|
|
606
|
+
$"export OIDC_PROVIDER=($oidc_provider)\n"
|
|
607
|
+
| save --append .env
|
|
608
|
+
|
|
609
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env nu
|
|
2
|
+
|
|
3
|
+
# Installs KubeVela platform
|
|
4
|
+
#
|
|
5
|
+
# Examples:
|
|
6
|
+
# > main apply kubevela example.com --ingress_class nginx
|
|
7
|
+
def "main apply kubevela" [
|
|
8
|
+
host: string
|
|
9
|
+
--ingress_class = "nginx"
|
|
10
|
+
] {
|
|
11
|
+
|
|
12
|
+
vela install
|
|
13
|
+
|
|
14
|
+
# (
|
|
15
|
+
# vela addon enable velaux
|
|
16
|
+
# $"domain=vela.($host)"
|
|
17
|
+
# $"gatewayDriver=($ingress_class)"
|
|
18
|
+
# )
|
|
19
|
+
|
|
20
|
+
# start $"http://($host)"
|
|
21
|
+
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env nu
|
|
2
|
+
|
|
3
|
+
# Installs Kyverno policy engine for Kubernetes
|
|
4
|
+
def "main apply kyverno" [] {
|
|
5
|
+
|
|
6
|
+
helm repo add kyverno https://kyverno.github.io/kyverno
|
|
7
|
+
|
|
8
|
+
helm repo update
|
|
9
|
+
|
|
10
|
+
(
|
|
11
|
+
helm upgrade --install kyverno kyverno/kyverno
|
|
12
|
+
--namespace kyverno --create-namespace
|
|
13
|
+
--wait
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
}
|