Skip to content

Commit

Permalink
Add Dispatchfile (#430)
Browse files Browse the repository at this point in the history
Co-authored-by: Shane Utt <[email protected]>
  • Loading branch information
cprovencher and shaneutt committed Feb 19, 2020
1 parent 4c6ce44 commit 576d61b
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 1 deletion.
71 changes: 71 additions & 0 deletions Dispatchfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!starlark
# vi:syntax=python
#

git = "src-git"

def secretVar(name, key):
return k8s.corev1.EnvVarSource(secretKeyRef=k8s.corev1.SecretKeySelector(localObjectReference=k8s.corev1.LocalObjectReference(name=name), key=key))

gitResource(git,
url="$(context.git.url)",
revision="$(context.git.commit)")

dindTask("publish", inputs=[git], steps=[
v1.Container(
name = "publish-charts",
workingDir = "/workspace/src-git",
args = [
"/bin/bash", "-c",
"""
apt-get update
apt-get install -qq git build-essential
git fetch origin master --unshallow
export GIT_REMOTE_URL=https://mesosphere:${GITHUB_USER_TOKEN}@github.com/mesosphere/charts.git
make publish
"""
],
env=[k8s.corev1.EnvVar(name="GITHUB_USER_TOKEN", valueFrom=secretVar("scmtoken", "password"))]
)
])

dindTask("lint", inputs=[git], steps=[
v1.Container(
name = "lint-charts",
workingDir = "/workspace/src-git",
args = [
"/bin/bash", "-c",
"""
apt-get update
apt-get install -qq git build-essential
git fetch origin master --unshallow
make lint
"""
]
)
])

dindTask("test", inputs=[git], deps=["lint"], steps=[
v1.Container(
name = "test-charts",
workingDir = "/workspace/src-git",
args = [
"/bin/bash", "-c",
"""
apt-get update
apt-get install -qq git build-essential
git fetch origin master --unshallow
make test
"""
],
resources = k8s.corev1.ResourceRequirements(
limits = {
"cpu": k8s.resource_quantity("1000m"),
"memory": k8s.resource_quantity("6Gi")
}
)
)
])

action(tasks=["test"], on=pullRequest(branches=["*"]))
action(tasks=["publish"], on=push(branches=["master"]))
13 changes: 12 additions & 1 deletion test/e2e-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -o errexit
set -o nounset
set -o pipefail
set -x

readonly KIND_VERSION=v0.6.1
readonly CLUSTER_NAME=chart-testing
Expand Down Expand Up @@ -45,8 +46,18 @@ create_kind_cluster() {
"https://github.com/kubernetes-sigs/kind/releases/download/$KIND_VERSION/kind-$(uname)-amd64"
chmod +x "${tmp}/kind"

curl -sSLo "${tmp}/entrypoint.sh" "https://raw.githubusercontent.com/mesosphere/dispatch/f74d477930e8cf05b84eb8a0f98c3866b66e1125/docker/kind/entrypoint.sh?token=ACIQJHWXERD34NEOUHGOWIS6KWQO6"
chmod +x "${tmp}/entrypoint.sh"

cat << EOF > tmp_dockerfile
FROM kindest/node:$K8S_VERSION
ADD ./entrypoint.sh /usr/local/bin/entrypoint
EOF

docker build -t tmp-dispatch-kind:latest -f tmp_dockerfile "${tmp}"

"${tmp}/kind" create cluster --name "$CLUSTER_NAME" \
--config test/kind-config.yaml --image "kindest/node:$K8S_VERSION" \
--config test/kind-config.yaml --image "tmp-dispatch-kind:latest" \
--wait 60s

docker_exec mkdir -p /root/.kube
Expand Down
19 changes: 19 additions & 0 deletions test/kind-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,22 @@ apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
# These kubeadm config patches are required for running Kind inside a docker container.
# We started running Kind in a kubernetes pod as part of the CI transition to Dispatch.
kubeadmConfigPatches:
- |
apiVersion: kubeadm.k8s.io/v1beta2
kind: JoinConfiguration
metadata:
name: config
nodeRegistration:
kubeletExtraArgs:
cgroup-root: "/kubelet"
- |
apiVersion: kubeadm.k8s.io/v1beta2
kind: InitConfiguration
metadata:
name: config
nodeRegistration:
kubeletExtraArgs:
cgroup-root: "/kubelet"

0 comments on commit 576d61b

Please sign in to comment.