{"id":18293050,"url":"https://github.com/kubesphere/volume-initializer","last_synced_at":"2025-04-09T08:13:54.896Z","repository":{"id":254980457,"uuid":"848138593","full_name":"kubesphere/volume-initializer","owner":"kubesphere","description":"A webhook to initialize the pvc volumes of pod","archived":false,"fork":false,"pushed_at":"2024-12-02T09:49:45.000Z","size":121,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T19:15:48.509Z","etag":null,"topics":["initcontainer","pvc","volume","webhook"],"latest_commit_sha":null,"homepage":"https://github.com/kubesphere/volume-initializer","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kubesphere.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-27T07:48:28.000Z","updated_at":"2024-12-02T08:58:32.000Z","dependencies_parsed_at":"2024-08-27T10:03:24.270Z","dependency_job_id":"ce030ca4-b191-4f48-8322-03d4b5d8bab3","html_url":"https://github.com/kubesphere/volume-initializer","commit_stats":{"total_commits":15,"total_committers":1,"mean_commits":15.0,"dds":0.0,"last_synced_commit":"36adde25678c8e39a7407858c045b084cfde5916"},"previous_names":["kubesphere/volume-initializer"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubesphere%2Fvolume-initializer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubesphere%2Fvolume-initializer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubesphere%2Fvolume-initializer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubesphere%2Fvolume-initializer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kubesphere","download_url":"https://codeload.github.com/kubesphere/volume-initializer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247827525,"owners_count":21002901,"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":["initcontainer","pvc","volume","webhook"],"created_at":"2024-11-05T14:21:28.473Z","updated_at":"2025-04-09T08:13:54.878Z","avatar_url":"https://github.com/kubesphere.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Volume Initializer\n\n# Introduction\nThis project delivers a [mutating admission webhook](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#mutatingadmissionwebhook) that can be used to initialize the pvc volumes of pod by injecting init containers into the pod.\n\nThe pvc volumes will be mounted to the injected init containers, you can do anything you want to the volumes, such as changing the ownership/permissions/contents of the volumes, just before your original container starts.\n\nOne typical usecase is using it to change the ownership/permissions of the volumes because your original containers are not running as root and unable to write data into the volumes.\n\n# Installation \n\n## Deploy CRD\n```sh\nkubectl apply -f config/crd/bases\n```\n\n## Deploy CR\nCreate a volume initializer yaml and apply it.\n\nTake [this](config/samples/storage.kubesphere.io_v1alpha1_initializer.yaml) for example.\n\n## Deploy Webhook\n\n```sh\ndeploy/prepare.sh \u0026\u0026 kubectl apply -f deploy/webhook-deployment.yaml\n```\n\n## Test \nCreate pod with pvc volumes to test.\n\nTake [this](config/samples/mongo-test.yaml) for example. This example requires you have storage class named `local-path` and `local-path2` on your cluster. You can install the [local-path-provisioner](https://github.com/rancher/local-path-provisioner) for quick testing.\n\n# Environment Variables\nThe following environment variables will be present in the injected init container.\n\n| Environment Variable | Explanation                                                                                                                                     | Present When      | Example Values    |\n|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|\n| PVC_1_MOUNT_PATH     | pvc volume's mount path in the init container                                                                                                   | Always            | `/data`           |\n| PVC_1_UID            | value from pod's label `volume.storage.kubesphere.io/uid` or `${volume-name}.volume.storage.kubesphere.io/uid`, can be used to chown the volume | When label exists | `mongodb`, `1001` |\n| PVC_1_GID            | value from pod's label `volume.storage.kubesphere.io/gid` or `${volume-name}.volume.storage.kubesphere.io/gid`, can be used to chown the volume | When label exists | `0`, `mongodb`    |\n\n\n# FAQ\n1. Why not use pod's annotations instead of labels to pass the volume's UID/GID to init container?\n- The webhook listens the pod CREATE events, such pods are likely generated from replicaset(from deployment/statefulset/daemonset), and normally don't have annotations present at the admission stage (i.e. when this webhook processes the requests). Therefore, we need to use the labels.\n\n\n# Limitations\n- If the pvc matches multiple pvcMatchers and init containers, only the first init container will be injected.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkubesphere%2Fvolume-initializer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkubesphere%2Fvolume-initializer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkubesphere%2Fvolume-initializer/lists"}