@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,718 @@
|
|
|
1
|
+
#!/usr/bin/env nu
|
|
2
|
+
|
|
3
|
+
# Installs and configures Crossplane with optional cloud provider setup
|
|
4
|
+
#
|
|
5
|
+
# Examples:
|
|
6
|
+
# > main apply crossplane --provider aws
|
|
7
|
+
# > main apply crossplane --provider google --app
|
|
8
|
+
# > main apply crossplane --provider azure --db-config --github-config --github-user user --github-token token
|
|
9
|
+
def --env "main apply crossplane" [
|
|
10
|
+
--provider = none, # Which provider to use. Available options are `none`, `google`, `aws`, and `azure`
|
|
11
|
+
--app-config = false, # Whether to apply DOT App Configuration
|
|
12
|
+
--db-config = false, # Whether to apply DOT SQL Configuration
|
|
13
|
+
--github-config = false, # Whether to apply DOT GitHub Configuration
|
|
14
|
+
--github-user: string, # GitHub user required for the DOT GitHub Configuration and optinal for the DOT App Configuration
|
|
15
|
+
--github-token: string, # GitHub token required for the DOT GitHub Configuration and optinal for the DOT App Configuration
|
|
16
|
+
--policies = false, # Whether to create Validating Admission Policies
|
|
17
|
+
--skip-login = false, # Whether to skip the login (only for Azure)
|
|
18
|
+
--db-provider = false, # Whether to apply database provider (not needed if --db-config is `true`)
|
|
19
|
+
--aws-access-key-id: string, # AWS Access Key ID (optional, falls back to AWS_ACCESS_KEY_ID env var)
|
|
20
|
+
--aws-secret-access-key: string, # AWS Secret Access Key (optional, falls back to AWS_SECRET_ACCESS_KEY env var)
|
|
21
|
+
--azure-tenant: string, # Azure Tenant ID (optional, falls back to AZURE_TENANT env var)
|
|
22
|
+
--upcloud-username: string, # UpCloud username (optional, falls back to UPCLOUD_USERNAME env var)
|
|
23
|
+
--upcloud-password: string # UpCloud password (optional, falls back to UPCLOUD_PASSWORD env var)
|
|
24
|
+
] {
|
|
25
|
+
|
|
26
|
+
print $"\nInstalling (ansi green_bold)Crossplane(ansi reset)...\n"
|
|
27
|
+
|
|
28
|
+
helm repo add crossplane https://charts.crossplane.io/stable
|
|
29
|
+
|
|
30
|
+
helm repo update
|
|
31
|
+
|
|
32
|
+
(
|
|
33
|
+
helm upgrade --install crossplane "crossplane/crossplane"
|
|
34
|
+
--namespace crossplane-system --create-namespace
|
|
35
|
+
--set provider.defaultActivations={"*.m.upbound.io", "*.m.crossplane.io"}
|
|
36
|
+
--wait
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
mut provider_data = {}
|
|
40
|
+
if $provider == "google" {
|
|
41
|
+
$provider_data = setup google
|
|
42
|
+
} else if $provider == "aws" {
|
|
43
|
+
setup aws --aws-access-key-id $aws_access_key_id --aws-secret-access-key $aws_secret_access_key
|
|
44
|
+
} else if $provider == "azure" {
|
|
45
|
+
setup azure --skip-login $skip_login --azure-tenant $azure_tenant
|
|
46
|
+
} else if $provider == "upcloud" {
|
|
47
|
+
setup upcloud --upcloud-username $upcloud_username --upcloud-password $upcloud_password
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if $app_config {
|
|
51
|
+
|
|
52
|
+
print $"\n(ansi green_bold)Applying `dot-application` Configuration...(ansi reset)\n"
|
|
53
|
+
|
|
54
|
+
let version = "v3.0.31"
|
|
55
|
+
{
|
|
56
|
+
apiVersion: "pkg.crossplane.io/v1"
|
|
57
|
+
kind: "Configuration"
|
|
58
|
+
metadata: { name: "crossplane-app" }
|
|
59
|
+
spec: { package: $"xpkg.upbound.io/devops-toolkit/dot-application:($version)" }
|
|
60
|
+
} | to yaml | kubectl apply --filename -
|
|
61
|
+
|
|
62
|
+
if $policies {
|
|
63
|
+
|
|
64
|
+
{
|
|
65
|
+
apiVersion: "admissionregistration.k8s.io/v1"
|
|
66
|
+
kind: "ValidatingAdmissionPolicy"
|
|
67
|
+
metadata: { name: "dot-app" }
|
|
68
|
+
spec: {
|
|
69
|
+
failurePolicy: "Fail"
|
|
70
|
+
matchConstraints: {
|
|
71
|
+
resourceRules: [{
|
|
72
|
+
apiGroups: ["devopstoolkit.live"]
|
|
73
|
+
apiVersions: ["*"]
|
|
74
|
+
operations: ["CREATE", "UPDATE"]
|
|
75
|
+
resources: ["appclaims"]
|
|
76
|
+
}]
|
|
77
|
+
}
|
|
78
|
+
validations: [
|
|
79
|
+
{
|
|
80
|
+
expression: "has(object.spec.parameters.scaling) && has(object.spec.parameters.scaling.enabled) && object.spec.parameters.scaling.enabled"
|
|
81
|
+
message: "`spec.parameters.scaling.enabled` must be set to `true`."
|
|
82
|
+
}, {
|
|
83
|
+
expression: "has(object.spec.parameters.scaling) && object.spec.parameters.scaling.min > 1"
|
|
84
|
+
message: "`spec.parameters.scaling.min` must be greater than `1`."
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
} | to yaml | kubectl apply --filename -
|
|
89
|
+
|
|
90
|
+
{
|
|
91
|
+
apiVersion: "admissionregistration.k8s.io/v1"
|
|
92
|
+
kind: "ValidatingAdmissionPolicyBinding"
|
|
93
|
+
metadata: { name: "dot-app" }
|
|
94
|
+
spec: {
|
|
95
|
+
policyName: "dot-app"
|
|
96
|
+
validationActions: ["Deny"]
|
|
97
|
+
}
|
|
98
|
+
} | to yaml | kubectl apply --filename -
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if ($db_config or $db_provider) and $provider == "google" {
|
|
105
|
+
|
|
106
|
+
start $"https://console.cloud.google.com/marketplace/product/google/sqladmin.googleapis.com?project=($provider_data.project_id)"
|
|
107
|
+
|
|
108
|
+
print $"\n(ansi yellow_bold)ENABLE(ansi reset) the API.\nPress the (ansi yellow_bold)enter key(ansi reset) to continue.\n"
|
|
109
|
+
input
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if $db_config {
|
|
114
|
+
|
|
115
|
+
print $"\n(ansi green_bold)Applying `dot-sql` Configuration...(ansi reset)\n"
|
|
116
|
+
|
|
117
|
+
let version = "v2.1.68"
|
|
118
|
+
{
|
|
119
|
+
apiVersion: "pkg.crossplane.io/v1"
|
|
120
|
+
kind: "Configuration"
|
|
121
|
+
metadata: { name: "crossplane-sql" }
|
|
122
|
+
spec: { package: $"xpkg.upbound.io/devops-toolkit/dot-sql:($version)" }
|
|
123
|
+
} | to yaml | kubectl apply --filename -
|
|
124
|
+
|
|
125
|
+
} else if $db_provider {
|
|
126
|
+
|
|
127
|
+
apply db-provider $provider
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if $github_config {
|
|
132
|
+
|
|
133
|
+
print $"\n(ansi green_bold)Applying `dot-github` Configuration...(ansi reset)\n"
|
|
134
|
+
|
|
135
|
+
{
|
|
136
|
+
apiVersion: "pkg.crossplane.io/v1"
|
|
137
|
+
kind: "Configuration"
|
|
138
|
+
metadata: { name: "devops-toolkit-dot-github" }
|
|
139
|
+
spec: { package: "xpkg.upbound.io/devops-toolkit/dot-github:v0.0.57" }
|
|
140
|
+
} | to yaml | kubectl apply --filename -
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if $db_config or $github_config or $app_config {
|
|
145
|
+
|
|
146
|
+
print $"\n(ansi green_bold)Applying Kubernetes and Helm providers...(ansi reset)\n"
|
|
147
|
+
|
|
148
|
+
{
|
|
149
|
+
apiVersion: "rbac.authorization.k8s.io/v1"
|
|
150
|
+
kind: "ClusterRole"
|
|
151
|
+
metadata: {
|
|
152
|
+
name: "crossplane-all"
|
|
153
|
+
labels: {
|
|
154
|
+
"rbac.crossplane.io/aggregate-to-crossplane": "true"
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
rules: [{
|
|
158
|
+
apiGroups: ["*"]
|
|
159
|
+
resources: ["*"]
|
|
160
|
+
verbs: ["*"]
|
|
161
|
+
}]
|
|
162
|
+
} | to yaml | kubectl apply --filename -
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
{
|
|
166
|
+
apiVersion: "v1"
|
|
167
|
+
kind: "ServiceAccount"
|
|
168
|
+
metadata: {
|
|
169
|
+
name: "crossplane-provider-helm"
|
|
170
|
+
namespace: "crossplane-system"
|
|
171
|
+
}
|
|
172
|
+
} | to yaml | kubectl apply --filename -
|
|
173
|
+
|
|
174
|
+
{
|
|
175
|
+
apiVersion: "rbac.authorization.k8s.io/v1"
|
|
176
|
+
kind: "ClusterRoleBinding"
|
|
177
|
+
metadata: { name: crossplane-provider-helm }
|
|
178
|
+
subjects: [{
|
|
179
|
+
kind: "ServiceAccount"
|
|
180
|
+
name: "crossplane-provider-helm"
|
|
181
|
+
namespace: "crossplane-system"
|
|
182
|
+
}]
|
|
183
|
+
roleRef: {
|
|
184
|
+
kind: "ClusterRole"
|
|
185
|
+
name: "cluster-admin"
|
|
186
|
+
apiGroup: "rbac.authorization.k8s.io"
|
|
187
|
+
}
|
|
188
|
+
} | to yaml | kubectl apply --filename -
|
|
189
|
+
|
|
190
|
+
{
|
|
191
|
+
apiVersion: "pkg.crossplane.io/v1beta1"
|
|
192
|
+
kind: "DeploymentRuntimeConfig"
|
|
193
|
+
metadata: { name: "crossplane-provider-helm" }
|
|
194
|
+
spec: { deploymentTemplate: { spec: {
|
|
195
|
+
selector: {}
|
|
196
|
+
template: { spec: {
|
|
197
|
+
containers: [{ name: "package-runtime" }]
|
|
198
|
+
serviceAccountName: "crossplane-provider-helm"
|
|
199
|
+
} }
|
|
200
|
+
} } }
|
|
201
|
+
} | to yaml | kubectl apply --filename -
|
|
202
|
+
|
|
203
|
+
{
|
|
204
|
+
apiVersion: "pkg.crossplane.io/v1"
|
|
205
|
+
kind: "Provider"
|
|
206
|
+
metadata: { name: "crossplane-provider-helm" }
|
|
207
|
+
spec: {
|
|
208
|
+
package: "xpkg.upbound.io/crossplane-contrib/provider-helm:v1.0.0"
|
|
209
|
+
runtimeConfigRef: { name: "crossplane-provider-helm" }
|
|
210
|
+
}
|
|
211
|
+
} | to yaml | kubectl apply --filename -
|
|
212
|
+
|
|
213
|
+
{
|
|
214
|
+
apiVersion: "v1"
|
|
215
|
+
kind: "ServiceAccount"
|
|
216
|
+
metadata: {
|
|
217
|
+
name: "crossplane-provider-kubernetes"
|
|
218
|
+
namespace: "crossplane-system"
|
|
219
|
+
}
|
|
220
|
+
} | to yaml | kubectl apply --filename -
|
|
221
|
+
|
|
222
|
+
{
|
|
223
|
+
apiVersion: "rbac.authorization.k8s.io/v1"
|
|
224
|
+
kind: "ClusterRoleBinding"
|
|
225
|
+
metadata: { name: "crossplane-provider-kubernetes" }
|
|
226
|
+
subjects: [{
|
|
227
|
+
kind: "ServiceAccount"
|
|
228
|
+
name: "crossplane-provider-kubernetes"
|
|
229
|
+
namespace: "crossplane-system"
|
|
230
|
+
}]
|
|
231
|
+
roleRef: {
|
|
232
|
+
kind: "ClusterRole"
|
|
233
|
+
name: "cluster-admin"
|
|
234
|
+
apiGroup: "rbac.authorization.k8s.io"
|
|
235
|
+
}
|
|
236
|
+
} | to yaml | kubectl apply --filename -
|
|
237
|
+
|
|
238
|
+
{
|
|
239
|
+
apiVersion: "pkg.crossplane.io/v1beta1"
|
|
240
|
+
kind: "DeploymentRuntimeConfig"
|
|
241
|
+
metadata: { name: "crossplane-provider-kubernetes" }
|
|
242
|
+
spec: { deploymentTemplate: { spec: {
|
|
243
|
+
selector: {}
|
|
244
|
+
template: { spec: {
|
|
245
|
+
containers: [{ name: "package-runtime" }]
|
|
246
|
+
serviceAccountName: "crossplane-provider-kubernetes"
|
|
247
|
+
} }
|
|
248
|
+
} } }
|
|
249
|
+
} | to yaml | kubectl apply --filename -
|
|
250
|
+
|
|
251
|
+
{
|
|
252
|
+
apiVersion: "pkg.crossplane.io/v1"
|
|
253
|
+
kind: "Provider"
|
|
254
|
+
metadata: { name: "crossplane-provider-kubernetes" }
|
|
255
|
+
spec: {
|
|
256
|
+
package: "xpkg.upbound.io/crossplane-contrib/provider-kubernetes:v1.0.0"
|
|
257
|
+
runtimeConfigRef: { name: "crossplane-provider-kubernetes" }
|
|
258
|
+
}
|
|
259
|
+
} | to yaml | kubectl apply --filename -
|
|
260
|
+
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if $db_config or $app_config or $github_config or $db_provider {
|
|
264
|
+
wait crossplane
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if ($db_config and $provider != "none") or $db_provider {
|
|
268
|
+
|
|
269
|
+
if $provider == "google" {
|
|
270
|
+
(
|
|
271
|
+
apply providerconfig $provider
|
|
272
|
+
--google-project-id $provider_data.project_id
|
|
273
|
+
)
|
|
274
|
+
} else {
|
|
275
|
+
apply providerconfig $provider
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if ($github_user | is-not-empty) and ($github_token | is-not-empty) {
|
|
282
|
+
|
|
283
|
+
{
|
|
284
|
+
apiVersion: v1,
|
|
285
|
+
kind: Secret,
|
|
286
|
+
metadata: {
|
|
287
|
+
name: github,
|
|
288
|
+
namespace: crossplane-system
|
|
289
|
+
},
|
|
290
|
+
type: Opaque,
|
|
291
|
+
stringData: {
|
|
292
|
+
credentials: $"{\"token\":\"($github_token)\",\"owner\":\"($github_user)\"}"
|
|
293
|
+
}
|
|
294
|
+
} | to yaml | kubectl apply --filename -
|
|
295
|
+
|
|
296
|
+
if $app_config or $github_config {
|
|
297
|
+
|
|
298
|
+
{
|
|
299
|
+
apiVersion: "github.upbound.io/v1beta1",
|
|
300
|
+
kind: ProviderConfig,
|
|
301
|
+
metadata: {
|
|
302
|
+
name: default
|
|
303
|
+
},
|
|
304
|
+
spec: {
|
|
305
|
+
credentials: {
|
|
306
|
+
secretRef: {
|
|
307
|
+
key: credentials,
|
|
308
|
+
name: github,
|
|
309
|
+
namespace: crossplane-system,
|
|
310
|
+
},
|
|
311
|
+
source: Secret
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
} | to yaml | kubectl apply --filename -
|
|
315
|
+
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
# Deletes Crossplane resources and waits for managed resources to be cleaned up
|
|
323
|
+
#
|
|
324
|
+
# Examples:
|
|
325
|
+
# > main delete crossplane
|
|
326
|
+
# > main delete crossplane --kind AppClaim --name myapp --namespace default
|
|
327
|
+
def "main delete crossplane" [
|
|
328
|
+
--kind: string,
|
|
329
|
+
--name: string,
|
|
330
|
+
--namespace: string
|
|
331
|
+
] {
|
|
332
|
+
|
|
333
|
+
if ($kind | is-not-empty) and ($name | is-not-empty) and ($namespace | is-not-empty) {
|
|
334
|
+
kubectl --namespace $namespace delete $kind $name
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
print $"\nWaiting for (ansi green_bold)Crossplane managed resources(ansi reset) to be deleted...\n"
|
|
338
|
+
|
|
339
|
+
mut command = { kubectl get managed --output name }
|
|
340
|
+
if ($name | is-not-empty) {
|
|
341
|
+
$command = {
|
|
342
|
+
(
|
|
343
|
+
kubectl get managed --output name
|
|
344
|
+
--selector $"crossplane.io/claim-name=($name)"
|
|
345
|
+
)
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
mut resources = (do $command)
|
|
350
|
+
mut counter = ($resources | wc -l | into int)
|
|
351
|
+
|
|
352
|
+
while $counter > 0 {
|
|
353
|
+
print $"($resources)\nWaiting for remaining (ansi green_bold)($counter)(ansi reset) managed resources to be (ansi green_bold)removed(ansi reset)...\n"
|
|
354
|
+
sleep 10sec
|
|
355
|
+
$resources = (do $command)
|
|
356
|
+
$counter = ($resources | wc -l | into int)
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
def "main publish crossplane" [
|
|
362
|
+
package: string
|
|
363
|
+
--sources = ["compositions"]
|
|
364
|
+
--version = ""
|
|
365
|
+
] {
|
|
366
|
+
|
|
367
|
+
mut version = $version
|
|
368
|
+
if $version == "" {
|
|
369
|
+
$version = $env.VERSION
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
package generate --sources $sources
|
|
373
|
+
|
|
374
|
+
up login --token $env.UP_TOKEN
|
|
375
|
+
|
|
376
|
+
up xpkg build --package-root package --output $"($package).xpkg"
|
|
377
|
+
|
|
378
|
+
(
|
|
379
|
+
up xpkg push
|
|
380
|
+
$"xpkg.upbound.io/($env.UP_ACCOUNT)/dot-($package):($version)"
|
|
381
|
+
)
|
|
382
|
+
|
|
383
|
+
rm --force $"package/($package).xpkg"
|
|
384
|
+
|
|
385
|
+
open config.yaml
|
|
386
|
+
| upsert spec.package $"xpkg.upbound.io/devops-toolkit/dot-($package):($version)"
|
|
387
|
+
| save config.yaml --force
|
|
388
|
+
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
def "package generate" [
|
|
392
|
+
--sources = ["compositions"]
|
|
393
|
+
] {
|
|
394
|
+
|
|
395
|
+
for source in $sources {
|
|
396
|
+
kcl run $"kcl/($source).k" |
|
|
397
|
+
save $"package/($source).yaml" --force
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
def "apply providerconfig" [
|
|
403
|
+
provider: string,
|
|
404
|
+
--google-project-id: string,
|
|
405
|
+
] {
|
|
406
|
+
|
|
407
|
+
if $provider == "google" {
|
|
408
|
+
|
|
409
|
+
{
|
|
410
|
+
apiVersion: "gcp.upbound.io/v1beta1"
|
|
411
|
+
kind: "ProviderConfig"
|
|
412
|
+
metadata: { name: "default" }
|
|
413
|
+
spec: {
|
|
414
|
+
projectID: $google_project_id
|
|
415
|
+
credentials: {
|
|
416
|
+
source: "Secret"
|
|
417
|
+
secretRef: {
|
|
418
|
+
namespace: "crossplane-system"
|
|
419
|
+
name: "gcp-creds"
|
|
420
|
+
key: "creds"
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
} | to yaml | kubectl apply --filename -
|
|
425
|
+
|
|
426
|
+
} else if $provider == "aws" {
|
|
427
|
+
|
|
428
|
+
{
|
|
429
|
+
apiVersion: "aws.upbound.io/v1beta1"
|
|
430
|
+
kind: "ProviderConfig"
|
|
431
|
+
metadata: { name: default }
|
|
432
|
+
spec: {
|
|
433
|
+
credentials: {
|
|
434
|
+
source: Secret
|
|
435
|
+
secretRef: {
|
|
436
|
+
namespace: crossplane-system
|
|
437
|
+
name: aws-creds
|
|
438
|
+
key: creds
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
} | to yaml | kubectl apply --filename -
|
|
443
|
+
|
|
444
|
+
} else if $provider == "azure" {
|
|
445
|
+
|
|
446
|
+
{
|
|
447
|
+
apiVersion: "azure.upbound.io/v1beta1"
|
|
448
|
+
kind: "ProviderConfig"
|
|
449
|
+
metadata: { name: default }
|
|
450
|
+
spec: {
|
|
451
|
+
credentials: {
|
|
452
|
+
source: "Secret"
|
|
453
|
+
secretRef: {
|
|
454
|
+
namespace: "crossplane-system"
|
|
455
|
+
name: "azure-creds"
|
|
456
|
+
key: "creds"
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
} | to yaml | kubectl apply --filename -
|
|
461
|
+
|
|
462
|
+
} else if $provider == "upcloud" {
|
|
463
|
+
|
|
464
|
+
{
|
|
465
|
+
apiVersion: "provider.upcloud.com/v1beta1"
|
|
466
|
+
kind: "ProviderConfig"
|
|
467
|
+
metadata: { name: default }
|
|
468
|
+
spec: {
|
|
469
|
+
credentials: {
|
|
470
|
+
source: "Secret"
|
|
471
|
+
secretRef: {
|
|
472
|
+
namespace: "crossplane-system"
|
|
473
|
+
name: "upcloud-creds"
|
|
474
|
+
key: "creds"
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
} | to yaml | kubectl apply --filename -
|
|
479
|
+
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
def "apply db-provider" [
|
|
485
|
+
provider: string
|
|
486
|
+
] {
|
|
487
|
+
|
|
488
|
+
if $provider == "google" {
|
|
489
|
+
|
|
490
|
+
{
|
|
491
|
+
apiVersion: "pkg.crossplane.io/v1"
|
|
492
|
+
kind: "Provider"
|
|
493
|
+
metadata: { name: "provider-gcp-sql" }
|
|
494
|
+
spec: { package: "xpkg.crossplane.io/crossplane-contrib/provider-gcp-sql:v1.14.0" }
|
|
495
|
+
} | to yaml | kubectl apply --filename -
|
|
496
|
+
|
|
497
|
+
} else if $provider == "aws" {
|
|
498
|
+
|
|
499
|
+
{
|
|
500
|
+
apiVersion: "pkg.crossplane.io/v1"
|
|
501
|
+
kind: "Provider"
|
|
502
|
+
metadata: { name: "provider-aws-rds" }
|
|
503
|
+
spec: { package: "xpkg.crossplane.io/crossplane-contrib/provider-aws-rds:v1.23.0" }
|
|
504
|
+
} | to yaml | kubectl apply --filename -
|
|
505
|
+
|
|
506
|
+
{
|
|
507
|
+
apiVersion: "pkg.crossplane.io/v1"
|
|
508
|
+
kind: "Provider"
|
|
509
|
+
metadata: { name: "provider-aws-ec2" }
|
|
510
|
+
spec: { package: "xpkg.crossplane.io/crossplane-contrib/provider-aws-ec2:v1.23.0" }
|
|
511
|
+
} | to yaml | kubectl apply --filename -
|
|
512
|
+
|
|
513
|
+
} else if $provider == "azure" {
|
|
514
|
+
|
|
515
|
+
{
|
|
516
|
+
apiVersion: "pkg.crossplane.io/v1"
|
|
517
|
+
kind: "Provider"
|
|
518
|
+
metadata: { name: "provider-azure-dbforpostgresql" }
|
|
519
|
+
spec: { package: "xpkg.crossplane.io/crossplane-contrib/provider-azure-dbforpostgresql:v1.13.0" }
|
|
520
|
+
} | to yaml | kubectl apply --filename -
|
|
521
|
+
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
# Waits for all Crossplane providers to be deployed and healthy
|
|
527
|
+
def "wait crossplane" [] {
|
|
528
|
+
|
|
529
|
+
print $"\n(ansi green_bold)Waiting for Crossplane providers to be deployed...(ansi reset)\n"
|
|
530
|
+
|
|
531
|
+
sleep 60sec
|
|
532
|
+
|
|
533
|
+
(
|
|
534
|
+
kubectl wait
|
|
535
|
+
--for=condition=healthy provider.pkg.crossplane.io
|
|
536
|
+
--all --timeout 30m
|
|
537
|
+
)
|
|
538
|
+
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
def "setup google" [] {
|
|
542
|
+
|
|
543
|
+
mut project_id = ""
|
|
544
|
+
|
|
545
|
+
print $"\nInstalling (ansi green_bold)Crossplane Google Cloud Provider(ansi reset)...\n"
|
|
546
|
+
|
|
547
|
+
if PROJECT_ID in $env {
|
|
548
|
+
$project_id = $env.PROJECT_ID
|
|
549
|
+
} else {
|
|
550
|
+
|
|
551
|
+
gcloud auth login
|
|
552
|
+
|
|
553
|
+
$project_id = $"dot-(date now | format date "%Y%m%d%H%M%S")"
|
|
554
|
+
$env.PROJECT_ID = $project_id
|
|
555
|
+
$"export PROJECT_ID=($project_id)\n" | save --append .env
|
|
556
|
+
|
|
557
|
+
gcloud projects create $project_id
|
|
558
|
+
|
|
559
|
+
start $"https://console.cloud.google.com/billing/enable?project=($project_id)"
|
|
560
|
+
|
|
561
|
+
print $"
|
|
562
|
+
Select the (ansi yellow_bold)Billing account(ansi reset) and press the (ansi yellow_bold)SET ACCOUNT(ansi reset) button.
|
|
563
|
+
Press the (ansi yellow_bold)enter key(ansi reset) to continue.
|
|
564
|
+
"
|
|
565
|
+
input
|
|
566
|
+
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
let sa_name = "devops-toolkit"
|
|
570
|
+
|
|
571
|
+
let sa = $"($sa_name)@($project_id).iam.gserviceaccount.com"
|
|
572
|
+
|
|
573
|
+
let project = $project_id
|
|
574
|
+
|
|
575
|
+
do --ignore-errors {(
|
|
576
|
+
gcloud iam service-accounts create $sa_name
|
|
577
|
+
--project $project
|
|
578
|
+
)}
|
|
579
|
+
|
|
580
|
+
sleep 5sec
|
|
581
|
+
|
|
582
|
+
(
|
|
583
|
+
gcloud projects add-iam-policy-binding
|
|
584
|
+
--role roles/admin $project
|
|
585
|
+
--member $"serviceAccount:($sa)"
|
|
586
|
+
)
|
|
587
|
+
|
|
588
|
+
(
|
|
589
|
+
gcloud iam service-accounts keys
|
|
590
|
+
create gcp-creds.json --project $project
|
|
591
|
+
--iam-account $sa
|
|
592
|
+
)
|
|
593
|
+
|
|
594
|
+
(
|
|
595
|
+
kubectl --namespace crossplane-system
|
|
596
|
+
create secret generic gcp-creds
|
|
597
|
+
--from-file creds=./gcp-creds.json
|
|
598
|
+
)
|
|
599
|
+
|
|
600
|
+
{ project_id: $project }
|
|
601
|
+
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
def "setup aws" [
|
|
605
|
+
--aws-access-key-id: string,
|
|
606
|
+
--aws-secret-access-key: string
|
|
607
|
+
] {
|
|
608
|
+
|
|
609
|
+
print $"\nInstalling (ansi green_bold)Crossplane AWS Provider(ansi reset)...\n"
|
|
610
|
+
|
|
611
|
+
mut access_key = $aws_access_key_id
|
|
612
|
+
if ($access_key | is-empty) and ("AWS_ACCESS_KEY_ID" in $env) {
|
|
613
|
+
$access_key = $env.AWS_ACCESS_KEY_ID
|
|
614
|
+
} else if ($access_key | is-empty) {
|
|
615
|
+
error make { msg: "AWS Access Key ID required via --aws-access-key-id parameter or AWS_ACCESS_KEY_ID environment variable" }
|
|
616
|
+
}
|
|
617
|
+
$env.AWS_ACCESS_KEY_ID = $access_key
|
|
618
|
+
$"export AWS_ACCESS_KEY_ID=($env.AWS_ACCESS_KEY_ID)\n"
|
|
619
|
+
| save --append .env
|
|
620
|
+
|
|
621
|
+
mut secret_key = $aws_secret_access_key
|
|
622
|
+
if ($secret_key | is-empty) and ("AWS_SECRET_ACCESS_KEY" in $env) {
|
|
623
|
+
$secret_key = $env.AWS_SECRET_ACCESS_KEY
|
|
624
|
+
} else if ($secret_key | is-empty) {
|
|
625
|
+
error make { msg: "AWS Secret Access Key required via --aws-secret-access-key parameter or AWS_SECRET_ACCESS_KEY environment variable" }
|
|
626
|
+
}
|
|
627
|
+
$env.AWS_SECRET_ACCESS_KEY = $secret_key
|
|
628
|
+
$"export AWS_SECRET_ACCESS_KEY=($env.AWS_SECRET_ACCESS_KEY)\n"
|
|
629
|
+
| save --append .env
|
|
630
|
+
|
|
631
|
+
$"[default]
|
|
632
|
+
aws_access_key_id = ($env.AWS_ACCESS_KEY_ID)
|
|
633
|
+
aws_secret_access_key = ($env.AWS_SECRET_ACCESS_KEY)
|
|
634
|
+
" | save aws-creds.conf --force
|
|
635
|
+
|
|
636
|
+
(
|
|
637
|
+
kubectl --namespace crossplane-system
|
|
638
|
+
create secret generic aws-creds
|
|
639
|
+
--from-file creds=./aws-creds.conf
|
|
640
|
+
--from-literal $"accessKeyID=($env.AWS_ACCESS_KEY_ID)"
|
|
641
|
+
--from-literal $"secretAccessKey=($env.AWS_SECRET_ACCESS_KEY)"
|
|
642
|
+
)
|
|
643
|
+
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
def "setup azure" [
|
|
647
|
+
--skip-login = false,
|
|
648
|
+
--azure-tenant: string
|
|
649
|
+
] {
|
|
650
|
+
|
|
651
|
+
print $"\nInstalling (ansi green_bold)Crossplane Azure Provider(ansi reset)...\n"
|
|
652
|
+
|
|
653
|
+
mut tenant = $azure_tenant
|
|
654
|
+
if ($tenant | is-empty) and ("AZURE_TENANT" in $env) {
|
|
655
|
+
$tenant = $env.AZURE_TENANT
|
|
656
|
+
} else if ($tenant | is-empty) {
|
|
657
|
+
error make { msg: "Azure Tenant ID required via --azure-tenant parameter or AZURE_TENANT environment variable" }
|
|
658
|
+
}
|
|
659
|
+
$"export AZURE_TENANT=($tenant)\n" | save --append .env
|
|
660
|
+
|
|
661
|
+
if $skip_login == false { az login --tenant $tenant }
|
|
662
|
+
|
|
663
|
+
let subscription_id = (az account show --query id -o tsv)
|
|
664
|
+
|
|
665
|
+
(
|
|
666
|
+
az ad sp create-for-rbac --sdk-auth --role Owner
|
|
667
|
+
--scopes $"/subscriptions/($subscription_id)"
|
|
668
|
+
| save azure-creds.json --force
|
|
669
|
+
)
|
|
670
|
+
|
|
671
|
+
(
|
|
672
|
+
kubectl --namespace crossplane-system
|
|
673
|
+
create secret generic azure-creds
|
|
674
|
+
--from-file creds=./azure-creds.json
|
|
675
|
+
)
|
|
676
|
+
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
def "setup upcloud" [
|
|
680
|
+
--upcloud-username: string,
|
|
681
|
+
--upcloud-password: string
|
|
682
|
+
] {
|
|
683
|
+
|
|
684
|
+
print $"\nInstalling (ansi green_bold)Crossplane UpCloud Provider(ansi reset)...\n"
|
|
685
|
+
|
|
686
|
+
mut username = $upcloud_username
|
|
687
|
+
if ($username | is-empty) and ("UPCLOUD_USERNAME" in $env) {
|
|
688
|
+
$username = $env.UPCLOUD_USERNAME
|
|
689
|
+
} else if ($username | is-empty) {
|
|
690
|
+
error make { msg: "UpCloud username required via --upcloud-username parameter or UPCLOUD_USERNAME environment variable" }
|
|
691
|
+
}
|
|
692
|
+
$env.UPCLOUD_USERNAME = $username
|
|
693
|
+
$"export UPCLOUD_USERNAME=($env.UPCLOUD_USERNAME)\n"
|
|
694
|
+
| save --append .env
|
|
695
|
+
|
|
696
|
+
mut password = $upcloud_password
|
|
697
|
+
if ($password | is-empty) and ("UPCLOUD_PASSWORD" in $env) {
|
|
698
|
+
$password = $env.UPCLOUD_PASSWORD
|
|
699
|
+
} else if ($password | is-empty) {
|
|
700
|
+
error make { msg: "UpCloud password required via --upcloud-password parameter or UPCLOUD_PASSWORD environment variable" }
|
|
701
|
+
}
|
|
702
|
+
$env.UPCLOUD_PASSWORD = $password
|
|
703
|
+
$"export UPCLOUD_PASSWORD=($env.UPCLOUD_PASSWORD)\n"
|
|
704
|
+
| save --append .env
|
|
705
|
+
|
|
706
|
+
{
|
|
707
|
+
apiVersion: "v1"
|
|
708
|
+
kind: "Secret"
|
|
709
|
+
metadata: {
|
|
710
|
+
name: "upcloud-creds"
|
|
711
|
+
}
|
|
712
|
+
type: "Opaque"
|
|
713
|
+
stringData: {
|
|
714
|
+
creds: $"{\"username\": \"($env.UPCLOUD_USERNAME)\", \"password\": \"($env.UPCLOUD_PASSWORD)\"}"
|
|
715
|
+
}
|
|
716
|
+
} | to yaml | kubectl --namespace crossplane-system apply --filename -
|
|
717
|
+
|
|
718
|
+
}
|