{"id":17370109,"url":"https://github.com/gianarb/todo-crd","last_synced_at":"2025-03-27T18:45:21.241Z","repository":{"id":57511382,"uuid":"186422622","full_name":"gianarb/todo-crd","owner":"gianarb","description":null,"archived":false,"fork":false,"pushed_at":"2019-05-13T13:40:32.000Z","size":35,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T21:43:41.870Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gianarb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-13T13:13:47.000Z","updated_at":"2020-08-06T12:56:06.000Z","dependencies_parsed_at":"2022-08-29T05:20:26.913Z","dependency_job_id":null,"html_url":"https://github.com/gianarb/todo-crd","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gianarb%2Ftodo-crd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gianarb%2Ftodo-crd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gianarb%2Ftodo-crd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gianarb%2Ftodo-crd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gianarb","download_url":"https://codeload.github.com/gianarb/todo-crd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245905249,"owners_count":20691753,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-16T00:23:34.496Z","updated_at":"2025-03-27T18:45:21.221Z","avatar_url":"https://github.com/gianarb.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"This is an example about how to extend Kubernetes with a Custom Resource\nDefinition.\n\nI have used [code-generator](https://github.com/kubernetes/code-generator) to\ngenerate types, clients and informers for this CRD. The `cmd/main.go` starts a\nshared informer to extend capabilities with your business code.\n\n## Run on kubernetes\n\n1. Start minikube\n2. Deploy CRD, apps\n```\nkubectl apply -f artifacts/crd.yaml\nkubectl apply -f artifacts/app.yaml\n```\n3. Tail the logs from the pod to see what the application does\n4. Create your first item: `kubectl apply -f artifacts/todo.yaml`\n\n## Dependency Management\nThe project uses `go mod` but it is requited by `code-generator` for the project\nto be in the `GOPATH`. You should export `GO111MODULE=on` to be sure that the\nproject uses `go mod` even if it is inside the `GOPATH`.\n\n## Generate code\nCheckout the project in your GOPATH because `code-generator` still uses\n`GOPATH`. And this is the command I used to generate the code inside\n`pkg/client`.\n\n```\n~/go/src/k8s.io/code-generator/generate-groups.sh all \\\n    github.com/gianarb/todo-crd/pkg/client \\\n    github.com/gianarb/todo-crd/pkg/apis todoexample:v1\n```\n\n## Run locally \nYou can start minkube, register the crd with `kubectl apply -f\nartifacts/crd.yaml` and run `go run ./cmd/main.go` to start the shared informer\napp:\n\n```\ngo run cmd/main.go\n{\"level\":\"info\",\"msg\":\"The todo operator started.\"}\n```\n\nThis the expected log. As you can see in `./cmd/main.go` I have just initialized\nthe Shared Informer without implementing any method. When you create a new todo\nitem from `./artifacts/todo.yaml` you should see logs from the application:\n\n```\n$ go run cmd/main.go\n{\"level\":\"info\",\"msg\":\"The todo operator started.\"}\n{\"level\":\"info\",\"msg\":\"new key received\",\"message_key\":\"default/buy-book\"}\n{\"level\":\"info\",\"msg\":\"new key received\",\"message_key\":\"default/buy-book\"}\n```\n\n## Credits\nSome of the project and articles I read to make this to work:\n\n* https://github.com/kubernetes/sample-controller\n* https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/\n* https://github.com/kubernetes/client-go/blob/master/INSTALL.md#go-modules\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgianarb%2Ftodo-crd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgianarb%2Ftodo-crd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgianarb%2Ftodo-crd/lists"}