Comments (5)
go client to create one crd
Do you mean how you can create a CRD programatically using a Go client?
You can use the apiextensions client - https://github.com/kubernetes/apiextensions-apiserver/blob/master/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/customresourcedefinition.go.
Here is an example on how to use it: https://github.com/kubernetes/kube-deploy/blob/6fd78203fdd2fde0069b8e0f63788f8e7fd63c52/cluster-api/api/cluster/v1alpha1/crd.go#L25-L73.
However, in general, we do not suggest creating a CRD in this way (also the reason why sample-controller doesn't do this). Creating CRDs is not a permission you regularly want to grant to a controller. Instead, it's better for the admin to do it at the time of deploy so you don’t have to grant more privileges to the controller executable than it actually needs.
from sample-controller.
Hi nikhita, I mean after crd is registered in k8s (e.g. kubectl create -f artifacts/examples/crd.yaml), how to run a crd instance in go instead of kubectl create -f artifacts/examples/example-foo.yaml
. It seems possible to use a k8s dynamic client and Unstructured type?
from sample-controller.
@nikhita why is this not recommended to do creation using the client ? We are internally using the extensions client to do this in an automated way . Also How do you block this ?
from sample-controller.
how to run a crd instance in go instead of kubectl create -f artifacts/examples/example-foo.yaml. It seems possible to use a k8s dynamic client and Unstructured type?
@hochuenw You can use a typed client i.e. client generated from code-generator and use the Create()
method - https://github.com/kubernetes/sample-controller/blob/master/pkg/client/clientset/versioned/typed/samplecontroller/v1alpha1/foo.go#L99.
Also, the sample-controller uses the Update
method (https://github.com/kubernetes/sample-controller/blob/master/controller.go#L334) so you can probably use that as a reference.
from sample-controller.
@nikhita why is this not recommended to do creation using the client ?
@krmayankk Creating a CRD is a privileged operation. If you are creating the CRD using the controller, it means your controller has privileged permissions - which isn't really necessary and can be avoided.
Also How do you block this ?
Sorry, I am not sure I follow the question. How to block what?
from sample-controller.
Related Issues (20)
- fooLister not achive FooLister interface HOT 1
- errors after copying over source code and attempting build HOT 1
- Got SECURITY ERROR when downloading k8s.io/client-go HOT 6
- Move CRD from `v1beta1` to `v1` HOT 3
- README is wrong on generating code when using Go modules HOT 5
- Please give a more detail readme, there are too many pitfall HOT 8
- `./hack/update-codegen.sh` fails on pristine checkout HOT 4
- go build with error sf.IsExported undefined HOT 8
- [enhancement] Move the code generator logic to a dockerfile HOT 2
- Generate the code with update-codegen.sh in a wrong path HOT 5
- Documentation error: example CRD already exists while trying to apply manually HOT 5
- How is the Deep Copy files are generated ? HOT 5
- Why has not the NewController use a leader election like leaderelection? HOT 4
- 无法执行生成 HOT 8
- How are the files crd.yaml and crd-status-subresource. yaml generated HOT 4
- State of the docs? HOT 4
- Why does fooInformer not register a delete event handling handler?
- code is not generated to correct dir HOT 4
- code generator errors HOT 6
- Some optimization suggestions for code generators HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sample-controller.