Add test for kube-gcp basic step
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
parent
f24af776db
commit
2a15682386
@ -191,25 +191,7 @@ The below `config.cue` defines:
|
|||||||
- `gkeConfig`: transform a `gcpConfig` to a readable format for `kubernetes.#Resources.kubeconfig`
|
- `gkeConfig`: transform a `gcpConfig` to a readable format for `kubernetes.#Resources.kubeconfig`
|
||||||
using `alpha.dagger.io/gcp/gke`
|
using `alpha.dagger.io/gcp/gke`
|
||||||
|
|
||||||
```cue title="todoapp/kube/config.cue"
|
```cue file=tests/kube-gcp/basic/config.cue title="todoapp/kube/config.cue"
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"alpha.dagger.io/gcp"
|
|
||||||
"alpha.dagger.io/gcp/gke"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Value created for generic reference of `kubeconfig` in `todoapp.cue`
|
|
||||||
kubeconfig: gkeConfig.kubeconfig
|
|
||||||
|
|
||||||
// gcpConfig used for Google connection
|
|
||||||
gcpConfig: gcp.#Config
|
|
||||||
|
|
||||||
// gkeConfig used for deployment
|
|
||||||
gkeConfig: gke.#KubeConfig & {
|
|
||||||
// config field references `gkeConfig` value to set in once
|
|
||||||
config: gcpConfig
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
2
docs/learn/tests/.dagger/env/kube-gcp-basic/.gitignore
vendored
Normal file
2
docs/learn/tests/.dagger/env/kube-gcp-basic/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# dagger state
|
||||||
|
state/**
|
32
docs/learn/tests/.dagger/env/kube-gcp-basic/values.yaml
vendored
Normal file
32
docs/learn/tests/.dagger/env/kube-gcp-basic/values.yaml
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
plan:
|
||||||
|
package: ./kube-gcp/basic/test
|
||||||
|
name: kube-gcp-basic
|
||||||
|
inputs:
|
||||||
|
gcpConfig.project:
|
||||||
|
text: dagger-ci
|
||||||
|
gcpConfig.region:
|
||||||
|
text: us-west2-a
|
||||||
|
gcpConfig.serviceKey:
|
||||||
|
secret: ENC[AES256_GCM,data:kwplJvCrAGhmGckG0ZBVXb+C2T9LFN+Nxd7EbFJIEOUtkslxTC5CungmJBSM57lQ7ATQZOzSwxt3tHffqinCPMoOsZEfqeOptp3K9bgBuOm5VW89U/dpIES3CEueGOZemlgj30QrDBcOwdRGFU5BySs4KLNK5jT+CTgY5T26jbX3amPTQvxye/YLKXND8PrdFCzAuMRygR4E5vqsE2Xs6efwyivT6GAulA6Ny6BfhZQlPplOsPP5f53B8yLU8CfuE6TLhafyY+jyatL3a8qGrRPuv6WGbQO0flP4KtYvnzbY09by4ysK7+9Ndy2jF+6J4MggHK/reYcCM2Pq70b03Z9RaludBeclpROBqv9qv7I+mO8CH9YBwFSdpB2p+Li5FpOzbBM/RFJG6H9KmkB0XWOu3jDIbbHQ35jk5O9hjFIf5Tq+MGDUlOOe5KB8dJtjHd93uvWA9/6T0WyWklOTLXVbNX/DnUVVDofZeG5vTIvKZ4faPE3/1QWqJmNn2V3cm5gES7NDUQHn3fFFSyaHMjFsI3PJhpIyzXkHf8Fzqw0P1dRNPIfxMESFT9yRqhGKuL95GgIwa8VzmcvSyFjKNoUpEwMt2sPV2YNVIAx2qiI8sshAa/oN9+vFgBFarEOX/CPSDliz9gMWq3fSz9g3cSO9tuMH+Uz6bJ0hxqrLtOs9kt5Z8Tpg3A0gQ5eln0lncKtd0h5K/OgE96vq7yOLUHUVDlwyvwXbhJO2yjtqi32LuwrktesEZSJLGgk3q6qQvzvWFePI4HLTLpa/6srwYKEWW1F2ovX1yFHv3GeVqmZDJmHFe3Wl+pfXdp1JE2geUxUCxV7TMSvsiByXKhGXMpADr5yVO8VTjCIaiZHH70hF9bfWh9f8gOYNVpyt93z2q8CJ57xt+339I/2twGfukGZjQM8suGmzIzIfilDsL2fxpepjNI75j+eFzR10CEUfzir5If7lbNHUHl9sU+sKYZ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x+hbPzn8aowSL4o3WpHDLw==,type:str]
|
||||||
|
gkeConfig.clusterName:
|
||||||
|
text: test-cluster
|
||||||
|
sops:
|
||||||
|
kms: []
|
||||||
|
gcp_kms: []
|
||||||
|
azure_kv: []
|
||||||
|
hc_vault: []
|
||||||
|
age:
|
||||||
|
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
|
||||||
|
enc: |
|
||||||
|
-----BEGIN AGE ENCRYPTED FILE-----
|
||||||
|
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBlbzlrT3FBd0dmNjJROHE4
|
||||||
|
cGFtdzdmWm00Z2d3N3RpOXp3dloyU014M1FFCml6dU1BclFxU2ZhSmdUZ0lBNEUx
|
||||||
|
TlA2UjR3dmpxZXAySTNDdmozVldxSXMKLS0tIGZNclEvQlhuL0VuL0x0SEZqMDZR
|
||||||
|
cTFrdThhbHUxSG53c0hwT2VvRE1qL1UKD4aR1Cb9+wQthHtPpj/aFh+tLsW1xWNH
|
||||||
|
ijbpYjLg6PpFwJmuuWrDylP6Mfv9Zyg35utzR5ECE0W1M9oLU3aLjg==
|
||||||
|
-----END AGE ENCRYPTED FILE-----
|
||||||
|
lastmodified: "2021-08-16T21:50:36Z"
|
||||||
|
mac: ENC[AES256_GCM,data:k0tYmkhSiMYKg9NZSTHoDx0bOtwAa4FS3vpg6/5O2oQ35xs//iCEIgvPrwdO0E+dwT8t4dyorC6WEBxNuhrs0HdIEPF6i5qqLgPOXQmZYuss8ueroEggEFbtakyLuZ8bNFLF5ym2Sr0pBJiWfJkexMS/d96m1ouV2c8Wq2sNkig=,iv:SCUwU5rR4/C5oZJg/rkkyx+2/tmWbjDZ/SsbalPxjbU=,tag:nXNnByQBXhPZXlqpfjjzFQ==,type:str]
|
||||||
|
pgp: []
|
||||||
|
encrypted_suffix: secret
|
||||||
|
version: 3.7.1
|
@ -153,6 +153,15 @@ setup() {
|
|||||||
dagger -w "$DAGGER_SANDBOX" -e kube-aws-cue-manifest up
|
dagger -w "$DAGGER_SANDBOX" -e kube-aws-cue-manifest up
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "doc-1007-kube-gcp" {
|
||||||
|
#################### BASIC ####################
|
||||||
|
# Copy deployment to sandbox
|
||||||
|
copy_to_sandbox kube-gcp-basic kube-gcp
|
||||||
|
|
||||||
|
# Up deployment
|
||||||
|
dagger -w "$DAGGER_SANDBOX" -e kube-gcp-basic up
|
||||||
|
}
|
||||||
|
|
||||||
@test "doc-1008-aws-cloudformation" {
|
@test "doc-1008-aws-cloudformation" {
|
||||||
setup_example_sandbox "doc"
|
setup_example_sandbox "doc"
|
||||||
|
|
||||||
|
18
docs/learn/tests/kube-gcp/basic/config.cue
Normal file
18
docs/learn/tests/kube-gcp/basic/config.cue
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"alpha.dagger.io/gcp"
|
||||||
|
"alpha.dagger.io/gcp/gke"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Value created for generic reference of `kubeconfig` in `todoapp.cue`
|
||||||
|
kubeconfig: gkeConfig.kubeconfig
|
||||||
|
|
||||||
|
// gcpConfig used for Google connection
|
||||||
|
gcpConfig: gcp.#Config
|
||||||
|
|
||||||
|
// gkeConfig used for deployment
|
||||||
|
gkeConfig: gke.#KubeConfig & {
|
||||||
|
// config field references `gkeConfig` value to set in once
|
||||||
|
config: gcpConfig
|
||||||
|
}
|
11
docs/learn/tests/kube-gcp/basic/input.cue
Normal file
11
docs/learn/tests/kube-gcp/basic/input.cue
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"alpha.dagger.io/git"
|
||||||
|
)
|
||||||
|
|
||||||
|
manifest: git.#Repository & {
|
||||||
|
remote: "https://github.com/dagger/examples.git"
|
||||||
|
ref: "main"
|
||||||
|
subdir: "todoapp/k8s"
|
||||||
|
}
|
66
docs/learn/tests/kube-gcp/basic/test/test.cue
Normal file
66
docs/learn/tests/kube-gcp/basic/test/test.cue
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"alpha.dagger.io/dagger/op"
|
||||||
|
"alpha.dagger.io/kubernetes"
|
||||||
|
)
|
||||||
|
|
||||||
|
TestEks: {
|
||||||
|
#_GetDeployment: """
|
||||||
|
kubectl describe deployment todoapp | grep 'True'
|
||||||
|
"""
|
||||||
|
|
||||||
|
#_DeleteDeployment: """
|
||||||
|
kubectl delete deployment todoapp
|
||||||
|
kubectl delete service todoapp-service
|
||||||
|
"""
|
||||||
|
|
||||||
|
#up: [
|
||||||
|
op.#Load & {
|
||||||
|
from: kubernetes.#Kubectl
|
||||||
|
},
|
||||||
|
|
||||||
|
op.#WriteFile & {
|
||||||
|
dest: "/kubeconfig"
|
||||||
|
content: todoApp.kubeconfig
|
||||||
|
},
|
||||||
|
|
||||||
|
op.#WriteFile & {
|
||||||
|
dest: "/getPods.sh"
|
||||||
|
content: #_GetDeployment
|
||||||
|
},
|
||||||
|
|
||||||
|
op.#WriteFile & {
|
||||||
|
dest: "/deletePods.sh"
|
||||||
|
content: #_DeleteDeployment
|
||||||
|
},
|
||||||
|
|
||||||
|
// Get pods
|
||||||
|
op.#Exec & {
|
||||||
|
always: true
|
||||||
|
args: [
|
||||||
|
"/bin/bash",
|
||||||
|
"--noprofile",
|
||||||
|
"--norc",
|
||||||
|
"-eo",
|
||||||
|
"pipefail",
|
||||||
|
"/getPods.sh",
|
||||||
|
]
|
||||||
|
env: KUBECONFIG: "/kubeconfig"
|
||||||
|
},
|
||||||
|
|
||||||
|
// Delete pods
|
||||||
|
op.#Exec & {
|
||||||
|
always: true
|
||||||
|
args: [
|
||||||
|
"/bin/bash",
|
||||||
|
"--noprofile",
|
||||||
|
"--norc",
|
||||||
|
"-eo",
|
||||||
|
"pipefail",
|
||||||
|
"/deletePods.sh",
|
||||||
|
]
|
||||||
|
env: KUBECONFIG: "/kubeconfig"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
16
docs/learn/tests/kube-gcp/basic/todoapp.cue
Normal file
16
docs/learn/tests/kube-gcp/basic/todoapp.cue
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"alpha.dagger.io/dagger"
|
||||||
|
"alpha.dagger.io/kubernetes"
|
||||||
|
)
|
||||||
|
|
||||||
|
// input: kubernetes objects directory to deploy to
|
||||||
|
// set with `dagger input dir manifest ./k8s -e kube`
|
||||||
|
manifest: dagger.#Artifact & dagger.#Input
|
||||||
|
|
||||||
|
// Deploy the manifest to a kubernetes cluster
|
||||||
|
todoApp: kubernetes.#Resources & {
|
||||||
|
"kubeconfig": kubeconfig
|
||||||
|
source: manifest
|
||||||
|
}
|
Reference in New Issue
Block a user