Merge pull request #337 from TomChv/ci-kind-setup

Setup Kind cluster in CI
This commit is contained in:
Sam Alba 2021-06-03 09:08:49 -07:00 committed by GitHub
commit e328e71e6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 45 additions and 54 deletions

View File

@ -76,6 +76,9 @@ jobs:
with:
go-version: 1.16
- name: Setup Kind Kubernetes Cluster
uses: engineerd/setup-kind@v0.5.0
- name: Install Dependencies
run: |
# SOPS

View File

@ -14,7 +14,7 @@ import (
name: string @dagger(input)
// Helm chart to install from source
chartSource: dagger.#Artifact @dagger(input)
chartSource?: dagger.#Artifact @dagger(input)
// Helm chart to install from repository
chart?: string @dagger(input)
@ -84,11 +84,6 @@ import (
dest: "/entrypoint.sh"
content: #code
},
op.#WriteFile & {
dest: "/kubeconfig"
content: kubeconfig
mode: 0o600
},
if chart != _|_ {
op.#WriteFile & {
dest: "/helm/chart"
@ -126,6 +121,7 @@ import (
if chartSource != _|_ && chart == _|_ {
"/helm/chart": from: chartSource
}
"/kubeconfig": secret: kubeconfig
}
},
]

View File

@ -59,8 +59,7 @@ import (
version: *"v1.19.9" | string @dagger(input)
// Kube config file
// FIXME: should be `dagger.#Secret`
kubeconfig: string @dagger(input)
kubeconfig: dagger.#Secret @dagger(input)
#code: #"""
kubectl create namespace "$KUBE_NAMESPACE" > /dev/null 2>&1 || true
@ -75,11 +74,7 @@ import (
dest: "/entrypoint.sh"
content: #code
},
op.#WriteFile & {
dest: "/kubeconfig"
content: kubeconfig
mode: 0o600
},
if manifest != _|_ {
op.#WriteFile & {
dest: "/source"
@ -103,6 +98,7 @@ import (
if manifest == _|_ {
mount: "/source": from: source
}
mount: "/kubeconfig": secret: kubeconfig
},
]
}

View File

@ -27,7 +27,14 @@ setup() {
@test "stdlib: kubernetes" {
skip_unless_local_kube
"$DAGGER" compute "$TESTDIR"/stdlib/kubernetes --input-dir kubeconfig=~/.kube
"$DAGGER" init
dagger_new_with_plan kubernetes "$TESTDIR"/stdlib/kubernetes/
run "$DAGGER" input -e "kubernetes" secret kubeconfig -f ~/.kube/config
assert_success
run "$DAGGER" up -e "kubernetes"
assert_success
}
@test "stdlib: kustomize" {
@ -37,7 +44,18 @@ setup() {
@test "stdlib: helm" {
skip_unless_local_kube
"$DAGGER" compute "$TESTDIR"/stdlib/kubernetes/helm --input-dir kubeconfig=~/.kube --input-dir TestHelmSimpleChart.deploy.chartSource="$TESTDIR"/stdlib/kubernetes/helm/testdata/mychart
"$DAGGER" init
dagger_new_with_plan helm "$TESTDIR"/stdlib/kubernetes/helm
run "$DAGGER" input -e "helm" secret kubeconfig -f ~/.kube/config
assert_success
cp -R "$TESTDIR"/stdlib/kubernetes/helm/testdata/mychart "$DAGGER_WORKSPACE"/testdata
run "$DAGGER" input -e "helm" dir TestHelmSimpleChart.deploy.chartSource "$DAGGER_WORKSPACE"/testdata
assert_success
run "$DAGGER" up -e "helm"
assert_success
}
@test "stdlib: aws: s3" {

View File

@ -2,28 +2,21 @@ package helm
import (
"dagger.io/dagger"
"dagger.io/file"
"dagger.io/kubernetes/helm"
)
// 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
}
kubeconfig: dagger.#Secret @dagger(input)
// Deploy user local chart
TestHelmSimpleChart: {
// Deploy chart
deploy: helm.#Chart & {
name: "dagger-test-helm-simple-chart-\(random)"
namespace: "dagger-test"
kubeconfig: config.contents
chartSource: dagger.#Artifact
name: "dagger-test-helm-simple-chart-\(random)"
namespace: "dagger-test"
"kubeconfig": kubeconfig
chartSource: dagger.#Artifact
}
// Verify deployment
@ -37,10 +30,10 @@ TestHelmSimpleChart: {
TestHelmRepoChart: {
// Deploy chart
deploy: helm.#Chart & {
name: "dagger-test-helm-repository-\(random)"
namespace: "dagger-test"
kubeconfig: config.contents
chart: "redis"
name: "dagger-test-helm-repository-\(random)"
namespace: "dagger-test"
"kubeconfig": kubeconfig
chart: "redis"
}
// Verify deployment

View File

@ -21,12 +21,6 @@ import (
from: kubernetes.#Kubectl
},
op.#WriteFile & {
dest: "/kubeconfig"
content: config.contents
mode: 0o600
},
op.#WriteFile & {
dest: "/getHelmPods.sh"
content: #getHelmPods
@ -46,6 +40,7 @@ import (
KUBECONFIG: "/kubeconfig"
KUBE_NAMESPACE: namespace
}
mount: "/kubeconfig": secret: kubeconfig
},
]
}

View File

@ -3,19 +3,12 @@ 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
}
kubeconfig: dagger.#Secret @dagger(input)
TestKubeApply: {
// Pod spec
@ -34,9 +27,9 @@ TestKubeApply: {
// Apply deployment
apply: kubernetes.#Apply & {
kubeconfig: config.contents
namespace: "dagger-test"
manifest: yaml.Marshal(kubeSrc)
"kubeconfig": kubeconfig
namespace: "dagger-test"
manifest: yaml.Marshal(kubeSrc)
}
// Verify deployment

View File

@ -27,17 +27,12 @@ import (
from: kubernetes.#Kubectl
},
op.#WriteFile & {
dest: "/kubeconfig"
content: config.contents
mode: 0o600
},
op.#WriteFile & {
dest: "/getPods.sh"
content: #GetPods
},
// Check pods
op.#Exec & {
always: true
args: [
@ -52,6 +47,7 @@ import (
KUBECONFIG: "/kubeconfig"
KUBE_NAMESPACE: namespace
}
mount: "/kubeconfig": secret: kubeconfig
},
op.#WriteFile & {
@ -73,6 +69,7 @@ import (
KUBECONFIG: "/kubeconfig"
KUBE_NAMESPACE: namespace
}
mount: "/kubeconfig": secret: kubeconfig
},
]
}