Skip to content

Commit 058e6f0

Browse files
authored
Fix Tilt Setup/Config and Readme Instructions (#63)
* Initial working example. * Cleanup instructions a bit further. * Remove file and prefer to pull from CAPI. * Move tilt stuff to makefile. * Cleanup. * Slight cleanup. * Initial. * Removed now excess file. * Add dev context to tilt provider. * Minor fixups. * Minor fixups. * Increase timeout for slower fargate containers.
1 parent c8e6011 commit 058e6f0

File tree

18 files changed

+68
-570
lines changed

18 files changed

+68
-570
lines changed

.gitignore

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Binaries for programs and plugins
32
*.exe
43
*.exe~
@@ -7,14 +6,18 @@
76
*.dylib
87
bin
98
testbin/*
9+
10+
# Various build/test artifacts.
1011
.tiltbuild
1112
*log
1213
*flag.mk
13-
1414
out
1515
.build
1616
.DS_Store
1717

18+
# CAPI used with Tilt.
19+
cluster-api
20+
1821
# Ignore output of Makefile sed operations created when generating manifests.
1922
config/default/manager_image_patch_edited.yaml
2023

@@ -24,16 +27,11 @@ config/default/manager_image_patch_edited.yaml
2427
# Output of the go coverage tool, specifically when used with LiteIDE
2528
*.out
2629

27-
# Kubernetes Generated files - skip generated files, except for vendored files
28-
29-
!vendor/**/zz_generated.*
30+
# ACS Credentials file.
3031
cloud-config
3132

32-
# editor and IDE paraphernalia
33+
# Editor and IDE paraphernalia
3334
.idea
3435
*.swp
3536
*.swo
3637
*~
37-
38-
# generated from e2e testing
39-
_artifacts

Makefile

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ help: ## Display this help.
4747
MANIFEST_GEN_INPUTS=$(shell find ./api -type f -name "*test*" -prune -o -name "*zz_generated*" -prune -o -print)
4848
# Using a flag file here as config output is too complicated to be a target.
4949
# The following triggers manifest building if $(IMG) differs from that found in config/default/manager_image_patch.yaml.
50-
$(shell grep -q "$(IMG)" config/default/manager_image_patch_edited.yaml || rm -f config/.flag.mk)
50+
$(shell grep -qs "$(IMG)" config/default/manager_image_patch_edited.yaml || rm -f config/.flag.mk)
5151
.PHONY: manifests
5252
manifests: config/.flag.mk ## Generates crd, webhook, rbac, and other configuration manifests from kubebuilder instructions in go comments.
5353
config/.flag.mk: bin/controller-gen $(MANIFEST_GEN_INPUTS)
@@ -156,6 +156,7 @@ bin/kubectl bin/kube-apiserver bin/etcd &:
156156
clean: ## Clean.
157157
rm -rf $(RELEASE_DIR)
158158
rm -rf bin
159+
rm -rf cluster-api
159160

160161
##@ Testing
161162

@@ -173,3 +174,27 @@ test: lint generate-deepcopy generate-mocks bin/ginkgo bin/kubectl bin/kube-apis
173174
generate-mocks: bin/mockgen $(shell find ./pkg/mocks -type f -name "mock*.go") ## Generate mocks needed for testing. Primarily mocks of the cloud package.
174175
pkg/mocks/mock%.go: $(shell find ./pkg/cloud -type f -name "*test*" -prune -o -print)
175176
go generate ./...
177+
178+
##@ Tilt
179+
180+
.PHONY: tilt-up
181+
tilt-up: cluster-api kind-cluster cluster-api/tilt-settings.json manifests cloud-config # Setup and run tilt for development.
182+
export CLOUDSTACK_B64ENCODED_SECRET=$(base64 -i cloud-config) && cd cluster-api && tilt up
183+
184+
.PHONY: kind-cluster
185+
kind-cluster: cluster-api cluster-api/hack/kind-install-for-capd.sh # Create a kind cluster with a local Docker repository.
186+
-./cluster-api/hack/kind-install-for-capd.sh
187+
188+
cluster-api: # Clone cluster-api repository for tilt use.
189+
git clone --branch v0.3.24 https://github.com/kubernetes-sigs/cluster-api.git
190+
191+
# Need script from CAPI v1.0+
192+
# Can delete this target after upgrading to newer CAPI.
193+
cluster-api/hack/kind-install-for-capd.sh: cluster-api
194+
cd cluster-api && git checkout v1.0.0 -- hack/kind-install-for-capd.sh
195+
196+
# Need script from CAPI v1.0+
197+
# Can delete this target after upgrading to newer CAPI.
198+
cluster-api/tilt-settings.json: hack/tilt-settings.json cluster-api
199+
cp ./hack/tilt-settings.json cluster-api
200+

README.md

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,7 @@ env var KUBEBUILDER_ASSETS should be enough for envtest to work.
3434

3535
Install [tilt prerequisites](https://cluster-api.sigs.k8s.io/developer/tilt.html).
3636

37-
Clone the capi repository at v1.0.0.
38-
39-
`git clone https://github.com/kubernetes-sigs/cluster-api.git`
40-
`cd cluster-api`
41-
`git checkout v1.0.0`
42-
43-
Setup a kind cluster using
44-
[capi repository]/hack/kind-install-for-capd.sh
45-
46-
There is a tiltfile in the hack directory. Edit the relative repository to match the location of the capi repository.
47-
48-
Copy the tiltfile into the capi repo.
49-
50-
Note: Until a more automated tilt setup is built out, tilt will need the secret manually injected into
51-
`config/default/credentials.yaml`. Use `base64 -i cloud-config | tr -d '\n'` to fill in
52-
the `CLOUDSTACK_B64ENCODED_SECRET` that clusterctl would normally fill.
53-
54-
cloud-config: ${CLOUDSTACK_B64ENCODED_SECRET}
55-
56-
Run `tilt up` from the capi repository.
37+
`make tilt-up`
5738

5839
## Running CAPC without Tilt - detailed instructions
5940

@@ -91,7 +72,7 @@ Assuming your running environment is MacOS:
9172
2. Run the following command to save the above cloudstack connection info into an environment variable, to be used by `./config/default/credentials.yaml` and ultimately the generated `infrastructure-components.yaml`, where it gets passed to CAPC:
9273
9374
```
94-
export CLOUDSTACK_B64ENCODED_SECRET=`base64 -i cloud-config`
75+
export CLOUDSTACK_B64ENCODED_SECRET=$(base64 -i cloud-config)
9576
```
9677
6. Set the IMG environment variable so that the Makefile knows where to push docker image (if building your own)
9778
1. `export IMG=localhost:5000/cluster-api-provider-capc`
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: controller-manager
5+
namespace: system
6+
labels:
7+
control-plane: capc-controller-manager
8+
spec:
9+
template:
10+
metadata:
11+
labels:
12+
control-plane: capc-controller-manager
13+
spec:
14+
securityContext:
15+
runAsNonRoot: false

config/dev/config/kustomization.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bases:
2+
- ../../default
3+
patchesStrategicMerge:
4+
- insecure_manager.yaml

controllers/cloudstackcluster_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func getCapiCluster() *clusterv1.Cluster {
6666
}
6767

6868
const (
69-
timeout = time.Second * 30
69+
timeout = time.Second * 60
7070
)
7171

7272
var _ = Describe("CloudStackClusterReconciler", func() {

0 commit comments

Comments
 (0)