Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dispatchfile #430

Merged
merged 2 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
shaneutt marked this conversation as resolved.
Show resolved Hide resolved
- |
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"