K8s CRD Error: Unsupported Media type 415

爱⌒轻易说出口 提交于 2020-04-18 12:35:42

问题


So I was following along this tutorial (https://www.youtube.com/watch?v=KBTXBUVNF2I) and after setting up the reconciler, when I execute "make run", I am getting the following error:

/Users/sourav/go/bin/controller-gen object:headerFile=./hack/boilerplate.go.txt paths="./..."
go fmt ./...
go vet ./...
/Users/sourav/go/bin/controller-gen "crd:trivialVersions=true" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
go run ./main.go
2020-03-15T22:13:29.111+0530 INFO controller-runtime.metrics metrics server is starting to listen {"addr": ":8080"}
2020-03-15T22:13:29.112+0530 INFO setup starting manager
2020-03-15T22:13:29.113+0530 INFO controller-runtime.manager starting metrics server {"path": "/metrics"}
2020-03-15T22:13:29.213+0530 INFO controller-runtime.controller Starting EventSource {"controller": "guestbook", "source": "kind source: /, Kind="}
2020-03-15T22:13:29.213+0530 INFO controller-runtime.controller Starting EventSource {"controller": "redis", "source": "kind source: /, Kind="}
2020-03-15T22:13:29.213+0530 INFO controller-runtime.controller Starting EventSource {"controller": "guestbook", "source": "kind source: /, Kind="}
2020-03-15T22:13:29.315+0530 INFO controller-runtime.controller Starting EventSource {"controller": "redis", "source": "kind source: /, Kind="}
2020-03-15T22:13:29.315+0530 INFO controller-runtime.controller Starting EventSource {"controller": "guestbook", "source": "kind source: /, Kind="}
2020-03-15T22:13:29.418+0530 INFO controller-runtime.controller Starting EventSource {"controller": "guestbook", "source": "kind source: /, Kind="}
2020-03-15T22:13:29.418+0530 INFO controller-runtime.controller Starting EventSource {"controller": "redis", "source": "kind source: /, Kind="}
2020-03-15T22:13:29.418+0530 INFO controller-runtime.controller Starting Controller {"controller": "guestbook"}
2020-03-15T22:13:29.418+0530 INFO controller-runtime.controller Starting Controller {"controller": "redis"}
2020-03-15T22:13:29.519+0530 INFO controller-runtime.controller Starting workers {"controller": "redis", "worker count": 1}
2020-03-15T22:13:29.519+0530 INFO controllers.Redis reconciling redis {"redis": "default/redis-sample"}
2020-03-15T22:13:29.523+0530 INFO controller-runtime.controller Starting workers {"controller": "guestbook", "worker count": 1}
2020-03-15T22:13:29.527+0530 ERROR controller-runtime.controller Reconciler error {"controller": "redis", "request": "default/redis-sample", "error": "415: Unsupported Media Type"}
github.com/go-logr/zapr.(*zapLogger).Error
/Users/sourav/go/pkg/mod/github.com/go-logr/zapr@v0.1.0/zapr.go:128
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
/Users/sourav/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.4.0/pkg/internal/controller/controller.go:258
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
/Users/sourav/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.4.0/pkg/internal/controller/controller.go:232
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).worker
/Users/sourav/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.4.0/pkg/internal/controller/controller.go:211
k8s.io/apimachinery/pkg/util/wait.JitterUntil.func1
/Users/sourav/go/pkg/mod/k8s.io/apimachinery@v0.0.0-20190913080033-27d36303b655/pkg/util/wait/wait.go:152
k8s.io/apimachinery/pkg/util/wait.JitterUntil
/Users/sourav/go/pkg/mod/k8s.io/apimachinery@v0.0.0-20190913080033-27d36303b655/pkg/util/wait/wait.go:153
k8s.io/apimachinery/pkg/util/wait.Until
/Users/sourav/go/pkg/mod/k8s.io/apimachinery@v0.0.0-20190913080033-27d36303b655/pkg/util/wait/wait.go:88
2020-03-15T22:13:30.528+0530 INFO controllers.Redis reconciling redis {"redis": "default/redis-sample"}
2020-03-15T22:13:30.548+0530 ERROR controller-runtime.controller Reconciler error {"controller": "redis", "request": "default/redis-sample", "error": "415: Unsupported Media Type"}

The error seems to originate from this line:

https://github.com/DirectXMan12/kubebuilder-workshops/blob/605890232fb368a8ff00ac5e9879c8dfd90f904c/controllers/redis_controller.go#L73

Any Idea what might be causing this error and how to solve it?


回答1:


That is using a relatively new feature, make sure your kubernetes is very up to date and has server side apply enabled.



来源:https://stackoverflow.com/questions/60695673/k8s-crd-error-unsupported-media-type-415

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!