{"id":18787929,"url":"https://github.com/wuhan005/k8s-image-replacer","last_synced_at":"2025-04-13T13:20:19.775Z","repository":{"id":64299687,"uuid":"568356530","full_name":"wuhan005/k8s-image-replacer","owner":"wuhan005","description":"🪤 Replace image when creating pod, aims to speed up image pulling.","archived":false,"fork":false,"pushed_at":"2023-07-25T06:01:33.000Z","size":41,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T04:22:17.547Z","etag":null,"topics":["flamego","go","kubernetes","kubernetes-webhook","mutating-webhook"],"latest_commit_sha":null,"homepage":"","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/wuhan005.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"wuhan005"}},"created_at":"2022-11-20T09:20:30.000Z","updated_at":"2024-07-11T03:33:07.000Z","dependencies_parsed_at":"2024-06-20T03:15:49.733Z","dependency_job_id":"ddcf4b50-af4f-4602-963d-8629a9adc40c","html_url":"https://github.com/wuhan005/k8s-image-replacer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"wuhan005/go-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wuhan005%2Fk8s-image-replacer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wuhan005%2Fk8s-image-replacer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wuhan005%2Fk8s-image-replacer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wuhan005%2Fk8s-image-replacer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wuhan005","download_url":"https://codeload.github.com/wuhan005/k8s-image-replacer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248717931,"owners_count":21150474,"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":["flamego","go","kubernetes","kubernetes-webhook","mutating-webhook"],"created_at":"2024-11-07T20:57:02.462Z","updated_at":"2025-04-13T13:20:19.756Z","avatar_url":"https://github.com/wuhan005.png","language":"Go","funding_links":["https://github.com/sponsors/wuhan005"],"categories":[],"sub_categories":[],"readme":"# 🪤 k8s-image-replacer ![Go](https://github.com/wuhan005/k8s-image-replacer/workflows/Go/badge.svg) [![Go Report Card](https://goreportcard.com/badge/github.com/wuhan005/k8s-image-replacer)](https://goreportcard.com/report/github.com/wuhan005/k8s-image-replacer) [![Sourcegraph](https://img.shields.io/badge/view%20on-Sourcegraph-brightgreen.svg?logo=sourcegraph)](https://sourcegraph.com/github.com/wuhan005/k8s-image-replacer)\n\nReplace image when creating pod, aims to speed up image pulling.\n\n## Getting started\n\n### 1. Generate certificate and key\n\nClone this project. Run `dev/webhook-create-signed-cert.sh` to generate a server certificate/key pair.\n\n```bash\n./dev/webhook-create-signed-cert.sh --service k8s-image-replacer --namespace default --secret k8s-image-replacer-tls\n```\n\n### 2. Deploy `k8s-image-replacer` into your cluster\n\n```bash\nkubectl apply -f dev/k8s-image-replacer.yaml\n```\n\n### 3. Create the mutating webhook configuration for `k8s-image-replacer`\n\nCreate a mutating webhook with the cluster CA bundle.\n\n```bash\n# Replace the ${CA_BUNDLE} placeholder with the actual value.\ncat dev/mutating-webhook-template.yaml | ./dev/webhook-patch-ca-bundle.sh \u003e mutating-webhook.yaml\n\n# Create the mutating webhook.\nkubectl apply -f mutating-webhook.yaml\n```\n\n**The pod with `k8s-image-replacer: enabled` label will be replaced image by default.** If you want to set which pod's\nimage to be replaced, update the `dev/mutating-webhook-template.yaml` and check the Kubernetes\ndocument [here](https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#matching-requests-objectselector)\n.\n\n### (Optional) 4. Build your own image registry proxy.\n\nFollow the [README here](https://github.com/ciiiii/cloudflare-docker-proxy) to build your own image registry proxy with\nCloudflare Workers.\n\n## How it works\n\n1. When a pod is created, the Kubernetes API server will send a request to the\n   `k8s-image-replacer` webhook. For more information, check\n   the [Kubernetes document](https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/).\n2. The webhook service will check if the pod's image is in the replacement map in the\n   configuration file.\n3. If the image is in the replacement map, the webhook will replace the image with the\n   replacement image.\n4. The pod will be created with the replacement image.\n5. The image will be pulled from the image registry proxy.\n\n## Acknowledgements\n\n* [estahn/k8s-image-swapper](https://github.com/estahn/k8s-image-swapper)\n* [ciiiii/cloudflare-docker-proxy](https://github.com/ciiiii/cloudflare-docker-proxy)\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwuhan005%2Fk8s-image-replacer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwuhan005%2Fk8s-image-replacer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwuhan005%2Fk8s-image-replacer/lists"}