ebe26a90ca
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
48 lines
889 B
CUE
48 lines
889 B
CUE
package kubernetes
|
|
|
|
import (
|
|
"encoding/yaml"
|
|
"dagger.io/dagger"
|
|
"dagger.io/file"
|
|
"dagger.io/kubernetes"
|
|
)
|
|
|
|
// We assume that a kinD cluster is running locally
|
|
// To deploy a local KinD cluster, follow this link : https://kind.sigs.k8s.io/docs/user/quick-start/
|
|
kubeconfig: dagger.#Artifact
|
|
|
|
// Retrive kubeconfig
|
|
config: file.#Read & {
|
|
filename: "config"
|
|
from: kubeconfig
|
|
}
|
|
|
|
TestKubeApply: {
|
|
// Pod spec
|
|
kubeSrc: {
|
|
apiVersion: "v1"
|
|
kind: "Pod"
|
|
metadata: name: "kube-test-\(random)"
|
|
spec: {
|
|
restartPolicy: "Never"
|
|
containers: [{
|
|
name: "test"
|
|
image: "hello-world"
|
|
}]
|
|
}
|
|
}
|
|
|
|
// Apply deployment
|
|
apply: kubernetes.#Apply & {
|
|
kubeconfig: config.contents
|
|
namespace: "dagger-test"
|
|
sourceInline: yaml.Marshal(kubeSrc)
|
|
}
|
|
|
|
// Verify deployment
|
|
verify: #VerifyApply & {
|
|
podname: kubeSrc.metadata.name
|
|
namespace: apply.namespace
|
|
}
|
|
}
|