Skip to content

Commit

Permalink
Refactor tiltfile
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentBaer authored and Vincent Baer committed Sep 14, 2022
1 parent 6358b33 commit 4eae2ee
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ force-delete-capo: ## Force delete Cluster api Outscale cluster (Remove finalize
logs-capi: ## Get logs capi
kubectl logs -l control-plane=controller-manager -n ${CAPI_NAMESPACE} --tail=${LOG_TAIL}

.PHONY: create-capm
create-capm: kustomize controller-gen manifests generate capm

.PHONY: capm
capm: envsubst ## Deploy controller to the K8s cluster specified in ~/.kube/config.
ifndef KUSTOMIZE
Expand Down
44 changes: 40 additions & 4 deletions Tiltfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
settings = {
"trigger_mode": "manual",
"capi_version": "v1.2.1",
}

trigger_mode(TRIGGER_MODE_MANUAL)
settings.update(read_json(
"tilt-settings.json",
default = {},
))
envsubst_cmd = "./bin/envsubst"
update_settings(k8s_upsert_timeout_secs=60)
if settings.get("trigger_mode") == "manual":
trigger_mode(TRIGGER_MODE_MANUAL)

docker_build(os.getenv('CONTROLLER_IMAGE', ''), '.')
if "allowed_contexts" in settings:
allow_k8s_contexts(settings.get("allowed_contexts"))
else:
allow_k8s_contexts(os.getenv('K8S_CONTEXT', 'phandalin'))

if "controller_image" in settings:
docker_build(settings.get("controller_image"), '.')
capo_cmd = "img=" + settings.get("controller_image") + ":latest make create-capm"
else:
docker_build(os.getenv('CONTROLLER_IMAGE', ''), '.')
capo_cmd = "IMG=" + os.getenv('CONTROLLER_IMAGE','') + ":latest make create-capm"

allow_k8s_contexts(os.getenv('K8S_CONTEXT', 'phandalin'))

def deploy_capi():
version = settings.get("capi_version")
capi = local('kubectl get deployment -n capi-system capi-controller-manager --ignore-not-found')
if not capi:
capi_cmd = "MINIMUM_CLUSTERCTL_VERSION=${version} make deploy-clusterapi"
local(capi_cmd)

def create_capm():
capo_secret = local('kubectl get secret -n cluster-api-provider-outscale-system cluster-api-provider-outscale --ignore-not-found')
if not capo_secret:
if os.getenv('OSC_ACCESS_KEY', "none") == "none":
print("No AK/SK secret for capo")
fail("Need to have OSC_SECRET_KEY and OSC_ACCESS_KEY environement variable")
else:
cred_cmd = "make credential"
local(cred_cmd)
local(capo_cmd)
deploy_capi()
create_capm()
k8s_yaml('capm.yaml')
3 changes: 3 additions & 0 deletions tilt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "outscale",
}

0 comments on commit 4eae2ee

Please sign in to comment.