projectcapsule / capsule

Multi-tenancy and policy-based framework for Kubernetes.
https://capsule.clastix.io
Apache License 2.0
1.59k stars 155 forks source link

Dev env setup issues #429

Closed brightzheng100 closed 3 years ago

brightzheng100 commented 3 years ago

Bug description

While setting up the dev env for Capsule, I encountered some issues by following the doc here: https://github.com/clastix/capsule/blob/master/docs/operator/contributing.md

How to reproduce

I followed the abovementioned doc but the step in Run Capsule is wrong.

If I issued make run, I'd hit the first error:

$ make run
...
go run ./main.go
# command-line-arguments
./main.go:61:55: undefined: GitTag
./main.go:61:63: undefined: GitCommit
./main.go:61:74: undefined: GitDirty
./main.go:62:46: undefined: GitRepo
./main.go:63:46: undefined: BuildTime

This is because the GitTag is defined in version.go file, so the fix is very straightforward:

run: generate manifests
    go run ./main.go ./version.go

The I tried it again, I'd hit second error:

$ make run
...
{"level":"error","ts":"2021-09-23T16:36:00.297+0800","logger":"setup","msg":"unable to start manager","error":"unable to determinate the Namespace Capsule is running on","stacktrace":"main.main\n\t/Users/brightzheng/development/go/k8s-ecosystem/capsule/main.go:100\nruntime.main\n\t/usr/local/Cellar/go/1.17.1/libexec/src/runtime/proc.go:255"}

This is also obvious, the main.go is expecting a system env:

    if namespace = os.Getenv("NAMESPACE"); len(namespace) == 0 {
        setupLog.Error(fmt.Errorf("unable to determinate the Namespace Capsule is running on"), "unable to start manager")
        os.Exit(1)
    }

So the fix is also very obvious:

$ export NAMESPACE=capsule-system
$ make run

PS: I'm using k3d-powered k3s cluster as this is lighter way than kind.

Expected behavior

The doc should work expected to easily setup the dev env.

Additional context

prometherion commented 3 years ago

Thanks for reporting this, @brightzheng100!

This run target has been inherited upon OperatorSDK scaffolding and I never used and totally forgot to keep aligned with the requested changes.

Would be great to fix the missing pieces and document documentation, too: contributions are warmly welcomed! 🤗

brightzheng100 commented 3 years ago

Sure, I can enhance it with not only Kind but also K3d(+K3s), more options for devs:)