Created
December 11, 2019 17:47
-
-
Save ncdc/453aa1acdf6e58564a01a2e02856d03a to your computer and use it in GitHub Desktop.
Cluster API Tiltfile WIP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: Python -*- | |
settings = read_json('tilt-settings.json', default={}) | |
allow_k8s_contexts(settings.get('allowed_contexts')) | |
default_registry(settings.get('default_registry')) | |
providers = { | |
'core': { | |
'path': '.', | |
'image': 'gcr.io/k8s-staging-cluster-api/cluster-api-controller' | |
}, | |
'aws': { | |
'path': '../cluster-api-provider-aws', | |
'image': 'gcr.io/k8s-staging-cluster-api-aws/cluster-api-aws-controller', | |
'ignore': ['../cluster-api-provider-aws/config/manager/credentials.yaml'] | |
}, | |
'docker': { | |
'path': './test/infrastructure/docker', | |
'image': 'gcr.io/kubernetes1-226021/manager:dev', | |
'sync_path': '.', | |
'sync_build_path': 'test/infrastructure/docker' | |
} | |
} | |
def enable_provider(name): | |
p = providers.get(name) | |
sync_build_path = p.get('sync_build_path', '.') | |
docker_build( | |
ref=p.get('image'), | |
context=p.get('path'), | |
target='builder', | |
entrypoint='/start.sh /workspace/manager', | |
only=p.get('only'), | |
ignore=p.get('ignore'), | |
live_update=[ | |
sync(p.get('path'), '/workspace'), | |
run("cd " + sync_build_path + ";CGO_ENABLED=0 go build -a -ldflags '-extldflags \"-static\"' -o /workspace/manager ."), | |
run('/restart.sh') | |
] | |
) | |
k8s_yaml(kustomize(p.get('path') + '/config/default')) | |
user_tiltfiles = listdir('tilt.d') | |
for f in user_tiltfiles: | |
include(f) | |
# First, the cert-manager and CRDs | |
cert_manager_images=[ | |
"quay.io/jetstack/cert-manager-controller:v0.11.0", | |
"quay.io/jetstack/cert-manager-cainjector:v0.11.0", | |
"quay.io/jetstack/cert-manager-webhook:v0.11.0" | |
] | |
for image in cert_manager_images: | |
local('docker pull {}'.format(image)) | |
local('kind load docker-image {}'.format(image)) | |
local('kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v0.11.0/cert-manager.yaml') | |
# wait for the service to become available | |
local('kubectl wait --for=condition=Available --timeout=300s apiservice v1beta1.webhook.cert-manager.io') | |
enable_provider('core') | |
for name in settings.get('enable_providers', []): | |
if name == 'aws': | |
b64credentials = local(providers[name]['path'] + "/bin/clusterawsadm alpha bootstrap encode-aws-credentials | tr -d '\n'") | |
command = '''sed -i '' -e 's@credentials: .*@credentials: '"{}"'@' {}/config/manager/credentials.yaml'''.format(b64credentials, providers[name]['path']) | |
local(command) | |
enable_provider(name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment