a5e9ac8a0f
Code convention: use nouns instead of verbs whenever possible. Reasoning: One can apply just about anything to Kubernetes via this: deployment, load balancer, RBAC policy, a custom CRD resource, etc. Upstream those are called resources: You give `kubectl apply` one or more manifests and it will create the corresponding resources. Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
41 lines
793 B
CUE
41 lines
793 B
CUE
package kubernetes
|
|
|
|
import (
|
|
"encoding/yaml"
|
|
"dagger.io/dagger"
|
|
"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.#Secret @dagger(input)
|
|
|
|
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.#Resources & {
|
|
"kubeconfig": kubeconfig
|
|
namespace: "dagger-test"
|
|
manifest: yaml.Marshal(kubeSrc)
|
|
}
|
|
|
|
// Verify deployment
|
|
verify: #VerifyApply & {
|
|
podname: kubeSrc.metadata.name
|
|
namespace: apply.namespace
|
|
}
|
|
}
|