{"id":20513352,"url":"https://github.com/alex-leonhardt/k8s-mutate-webhook","last_synced_at":"2025-04-13T23:46:54.549Z","repository":{"id":48635099,"uuid":"198102591","full_name":"alex-leonhardt/k8s-mutate-webhook","owner":"alex-leonhardt","description":"A playground to build a very crude k8s mutating webhook in Go","archived":false,"fork":false,"pushed_at":"2023-12-23T20:24:55.000Z","size":1190,"stargazers_count":72,"open_issues_count":3,"forks_count":40,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-27T13:51:23.841Z","etag":null,"topics":["admission-webhook","go","golang","k8s","kubernetes","webhook"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alex-leonhardt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-21T20:33:02.000Z","updated_at":"2025-03-22T08:56:01.000Z","dependencies_parsed_at":"2022-08-27T06:11:42.873Z","dependency_job_id":null,"html_url":"https://github.com/alex-leonhardt/k8s-mutate-webhook","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alex-leonhardt%2Fk8s-mutate-webhook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alex-leonhardt%2Fk8s-mutate-webhook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alex-leonhardt%2Fk8s-mutate-webhook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alex-leonhardt%2Fk8s-mutate-webhook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alex-leonhardt","download_url":"https://codeload.github.com/alex-leonhardt/k8s-mutate-webhook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799697,"owners_count":21163398,"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":["admission-webhook","go","golang","k8s","kubernetes","webhook"],"created_at":"2024-11-15T21:10:25.368Z","updated_at":"2025-04-13T23:46:54.509Z","avatar_url":"https://github.com/alex-leonhardt.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# k8s-mutate-webhook\n\nA playground to try build a crude k8s mutating webhook; the goal is to mutate a Pod CREATE request to _always_ use a debian image and by doing this, learning more about\nthe k8s api, objects, etc. - eventually figure out how scalable this is (could be made) if one had 1000 pods to schedule (concurrently)\n\nThis is a companion to the blog post [Writing a very basic kubernetes mutating admission webhook](https://medium.com/ovni/writing-a-very-basic-kubernetes-mutating-admission-webhook-398dbbcb63ec)  \n\n## build \n\n```\nmake\n```\n\n## test\n\n```\nmake test\n```\n\n## ssl/tls\n\nthe `ssl/` dir contains a script to create a self-signed certificate, not sure this will even work when running in k8s but that's part of figuring this out I guess\n\n_NOTE: the app expects the cert/key to be in `ssl/` dir relative to where the app is running/started and currently is hardcoded to `mutateme.{key,pem}`_\n\n```\ncd ssl/ \nmake \n```\n\n## docker\n\nto create a docker image .. \n\n```\nmake docker\n```\n\nit'll be tagged with the current git commit (short `ref`) and `:latest`\n\ndon't forget to update `IMAGE_PREFIX` in the Makefile or set it when running `make`\n\n### images\n\n[`alexleonhardt/k8s-mutate-webhook`](https://cloud.docker.com/repository/docker/alexleonhardt/k8s-mutate-webhook)\n\n\n## watcher\n\nuseful during devving ... \n\n```\nwatcher -watch github.com/alex-leonhardt/k8s-mutate-webhook -run github.com/alex-leonhardt/k8s-mutate-webhook/cmd/\n```\n\n## Running in docker-for-mac\n\n```bash\ncd ssl \u0026\u0026 make \u0026\u0026 cd -\nmake docker\nsed -i '' 's/imagePullPolicy: Always/imagePullPolicy: Never/' deploy/webhook.yaml # use local image\nsed -i '' \"s/caBundle:.*/caBundle: $(cat ssl/mutateme.pem | base64)/\" deploy/webhook.yaml # use local CA \nkubectl label namespace default mutateme=enabled\nkubectl apply -f deploy/webhook.yaml\n\n# make sure it's running ...\nkubectl get pods\nkubectl logs \u003cPDO\u003e --follow\n\n# create example pod to see it working\nkubectl apply -f pod.yaml\nkubectl get pod c7m -o yaml | grep image: # should be debian\n```\n\n## kudos\n\n- [https://github.com/morvencao/kube-mutating-webhook-tutorial](https://github.com/morvencao/kube-mutating-webhook-tutorial)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falex-leonhardt%2Fk8s-mutate-webhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falex-leonhardt%2Fk8s-mutate-webhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falex-leonhardt%2Fk8s-mutate-webhook/lists"}