{"id":21888691,"url":"https://github.com/swisscom/korp","last_synced_at":"2025-04-15T10:20:13.712Z","repository":{"id":44140329,"uuid":"195994510","full_name":"swisscom/korp","owner":"swisscom","description":"A command line tool for pushing docker images into a corporate registry based on Kubernetes yaml files","archived":false,"fork":false,"pushed_at":"2024-10-16T15:18:10.000Z","size":130,"stargazers_count":16,"open_issues_count":6,"forks_count":2,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-15T10:19:58.149Z","etag":null,"topics":[],"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/swisscom.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":"2019-07-09T11:23:32.000Z","updated_at":"2025-04-09T10:14:27.000Z","dependencies_parsed_at":"2022-07-21T14:02:38.274Z","dependency_job_id":null,"html_url":"https://github.com/swisscom/korp","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swisscom%2Fkorp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swisscom%2Fkorp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swisscom%2Fkorp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swisscom%2Fkorp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swisscom","download_url":"https://codeload.github.com/swisscom/korp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249048753,"owners_count":21204307,"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-11-28T11:16:40.774Z","updated_at":"2025-04-15T10:20:13.675Z","avatar_url":"https://github.com/swisscom.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# korp\n\nA command line tool for pushing docker images referenced in Kubernetes yaml files into a custom Docker registry. The name `korp` derives from combining the customary shorthand for \"corporation\" with a k for Kubernetes. The name was chosen because corporate Docker registries are the main use case for the tool.\n\n## Versioning\n\nCurrent version: `1.0.2`\n\n## Installation\n\n1. Download the [latest release](https://github.com/swisscom/korp/releases) and unpack it\n2. Add the `korp` binary to your PATH\n\n## Usage\n\n`korp` has three commands for 1. scanning yaml files, 2. pulling the referenced images and 3. pushing them to the new registry. Patching the yaml files for deployment is delegated to `kustomize` and `kubectl apply -k` since this is a well-established tool set for last-mile customization of Kubernetes yaml files.\n\n### Scan\n\nThe `scan` command recursively scans a directory, collects all references to Docker images and creates a `kustomization.yml` file consisting of an `images` section.\n\n#### Example\n\nThe following command will scan the `templates` directory (and its sub-directories) and create an `images` entry in `kustomization.yml` for each image reference found where the `newName` field is the normalized image name prefixed with `my-registry.example.org`.\n\n```\nkorp scan -f ./templates -r my-registry.example.org\n```\n\n### Pull\n\nThe `pull` command will read the `kustomization.yml` file generated by the `scan` command and pull all original images to the local Docker daemon i.e. the Docker daemon which is running on the machine where `korp` is executed.\n\n#### Example\n\nThe following command pulls all images referenced by the `name` attribute of the elements of the `images` list in the `kustomization.yml` file in the current directory.\n\n```\nkorp pull\n```\n\n### Push\n\nThe `push` command will read the `kustomization.yml` file generated by the `scan` command, tag all referenced images with their new name (including the new registry) and push them. The command assumes that `scan` and `pull` have already been executed.\n\n#### Example\n\nThe following command tags each image according to the `newName` attribute in the corresponding entry of the `images` list and pushes all images.\n\n```\nkorp push\n```\n\n### Patching your YAML files\n\n`korp` delegates the actual patching of the image references in the YAML files to `kustomize`. You can use the following steps to apply the `kustomization.yaml` generated by `korp` to your YAML files.\n\n1. Add the required resources to the `kustomization.yaml`. The set of resources depends on your use case. If you want to add all `yaml` files which were scanned by `korp` (excluding the `kustomization.yaml` itself) you can use the following glob pattern.\n\n   ```\n   kustomize edit add resource **/!(kustomization).yaml;\n   ```\n\n1. Apply your YAML files with `kubectl`.\n\n   ```\n   kubectl apply -k .\n   ```\n\n## A Complete Example\n\nLet's look at how to use `korp` on a real world example. Let's assume you want to deploy [Istio](https://github.com/istio/istio) in a corporate environment which has its own Docker registry. These are the steps which you would need to execute.\n\n### Render the Istio Helm Charts\n\nAt the time of writing Istio is deployed using two Helm charts `istio-init` and `istio`. Since `korp` works with yaml files, you need to first render these two charts against your `values.yml` files using the command `helm template`.\n\n1. Clone the Istio repo\n\n```\ngit clone https://github.com/istio/istio.git\ncd istio\n```\n\n2. Make the desired changes to `install/kubernetes/helm/istio-init/values.yaml` and `install/kubernetes/helm/istio/values.yaml`. You can ignore the fact that the `hub` attributes in these files point to public registries. This will be patched with the help of `korp` after the yaml files are rendered.\n\n3. Render the Helm charts to two directories.\n\n```\nmkdir $HOME/tmp/istio-init\nmkdir $HOME/tmp/istio\nhelm template install/kubernetes/helm/istio-init --name istio-init --namespace istio-system --output-dir $HOME/tmp/istio-init\nhelm template install/kubernetes/helm/istio --name istio --namespace istio-system --output-dir $HOME/tmp/istio\n```\n\n### Scan the rendered yaml files for image references\n\n4. Scan the `istio-init` yaml files. You will see a `kustomization.yml` file being created with one `images` entry.\n\n```\ncd $HOME/tmp/istio-init/istio-init\nkorp scan . -r your-registry.example.org\n```\n\n5. Scan the `istio` yaml files. You will see a `kustomization.yml` file being created with various `images` entries.\n\n```\ncd $HOME/tmp/istio/istio\nkorp scan . -r your-registry.example.org\n```\n\n### Pull the referenced images\n\n6. Pull the `istio-init` images.\n\n```\ncd $HOME/tmp/istio-init/istio-init\nkorp pull\n```\n\n7. Pull the `istio` images.\n\n```\ncd $HOME/tmp/istio/istio\nkorp pull\n```\n\n### Push the referenced images to your registry\n\n8. Push the `istio-init` images. Depending on your network and proxy setup, you might need to change your network connection.\n\n```\ncd $HOME/tmp/istio-init/istio-init\nkorp push\n```\n\n9. Push the `istio` images.\n\n```\ncd $HOME/tmp/istio/istio\nkorp push\n```\n\n### Apply the patches to your yaml files and deploy the components\n\n10. Apply the yaml files for `istio-init` using `kustomize`\n\n```\ncd $HOME/tmp/istio-init/istio-init\nkubectl create ns istio-system\nkustomize edit add resource **/!(kustomization).yaml\nkubectl apply -k .\n```\n\n11. Apply the yaml files for `istio` using `kustomize`\n\n```\ncd $HOME/tmp/istio/istio\nkustomize edit add resource **/!(kustomization).yaml\nkubectl apply -k .\n```\n\n## Autocompletion\n\nSource the `autocomplete-scripts/*_autocomplete` file in your `.bashrc | .zshrc` file while setting the `PROG` variable to the name of your program.\n\n### Method 1\n\n```\ngo build .\nsource \u003c(./korp autocompletion zsh)\n./korp\n# now play with tab\n```\n\n### Method 2\n\n```\ngo build .\nPROG=korp source autocomplete-scripts/zsh_autocomplete\n./korp\n# now play with tab\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswisscom%2Fkorp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswisscom%2Fkorp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswisscom%2Fkorp/lists"}