lwolf / kube-cleanup-operator

Kubernetes Operator to automatically delete completed Jobs and their Pods
MIT License
498 stars 109 forks source link

kube-cleanup-operator does not work on GKE #24

Closed gtseres closed 5 years ago

gtseres commented 5 years ago

I followed the steps in the readme file, but faced an issue when running the binary:

make install_deps
make build
./bin/kube-cleanup-operator --help --> successful
./bin/kube-cleanup-operator --run-outside-cluster --namespace=default -dry-run --> error

The error is the following:

panic: No Auth Provider found for name "gcp"

goroutine 1 [running]:
main.main()
    /Users/george/go/src/github.com/lwolf/kube-cleanup-operator/cmd/main.go:42 +0x8e2

I have managed to overcome this issue by replacing the following line in main.go:

_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"

to

_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"

Am I doing something wrong?

gtseres commented 5 years ago

Maybe adding line _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" can help fix the issue. Can you please verify if the suggested fix is valid so that I can send out a PR? Thanks!

lwolf commented 5 years ago

I guess something changed auth module. I don't have GCP cluster to test. Could you try replacing

_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"

with

_  "k8s.io/client-go/plugin/pkg/client/auth

This should include all possible auth providers and fix the issue.

gtseres commented 5 years ago

Thanks for the feedback. I tried that out and run

make install_deps
make build

but I got the following on make build:

--> Go Version
go version go1.11.2 darwin/amd64
--> Compiling the project
go build -ldflags "-X main.gitsha=v0.1-22-g86418f1-dirty -X main.compiled=1550601150" -o bin/kube-cleanup-operator ./cmd
# github.com/lwolf/kube-cleanup-operator/vendor/k8s.io/client-go/plugin/pkg/client/auth/azure
vendor/k8s.io/client-go/plugin/pkg/client/auth/azure/azure.go:241:4: cannot use expiresIn (type string) as type json.Number in field value
vendor/k8s.io/client-go/plugin/pkg/client/auth/azure/azure.go:242:4: cannot use expiresOn (type string) as type json.Number in field value
vendor/k8s.io/client-go/plugin/pkg/client/auth/azure/azure.go:243:4: cannot use expiresOn (type string) as type json.Number in field value
vendor/k8s.io/client-go/plugin/pkg/client/auth/azure/azure.go:260:23: cannot use token.token.ExpiresIn (type json.Number) as type string in assignment
vendor/k8s.io/client-go/plugin/pkg/client/auth/azure/azure.go:261:23: cannot use token.token.ExpiresOn (type json.Number) as type string in assignment
vendor/k8s.io/client-go/plugin/pkg/client/auth/azure/azure.go:295:3: cannot use spt.Token (type func() adal.Token) as type adal.Token in field value
make: *** [build] Error 2
lwolf commented 5 years ago

that's weird, ok, thanks for trying. let's just have 2 auth modes imported for now, as a workaround. I'll look at it later

_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
gtseres commented 5 years ago

I have sent out this PR, please let me know if any comments: https://github.com/lwolf/kube-cleanup-operator/pull/26

lwolf commented 5 years ago

I cut the release with all your changes. https://github.com/lwolf/kube-cleanup-operator/releases/tag/v0.4.4

Thank you for your contributions.