https://github.com/ishankhare07/image-cloner
A k8s controller which watches the applications and caches the images by re-uploading to our own registry and re-configures the applications to use these copies. It currently applies to only Deployments and Daemonsets
https://github.com/ishankhare07/image-cloner
kubernetes kubernetes-container-images kubernetes-controller
Last synced: 3 months ago
JSON representation
A k8s controller which watches the applications and caches the images by re-uploading to our own registry and re-configures the applications to use these copies. It currently applies to only Deployments and Daemonsets
- Host: GitHub
- URL: https://github.com/ishankhare07/image-cloner
- Owner: ishankhare07
- Created: 2021-03-19T12:15:15.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-23T11:16:47.000Z (over 5 years ago)
- Last Synced: 2025-06-25T07:50:40.449Z (about 1 year ago)
- Topics: kubernetes, kubernetes-container-images, kubernetes-controller
- Language: Go
- Homepage:
- Size: 82 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# image-cloner
A k8s controller which watches the applications and caches the images by re-uploading to our own registry and re-configures the applications to use these copies.
[](https://asciinema.org/a/401567)
### Prerequisits
1. A cluster is required, it can be a managed cluster like GKE etc. or a local `kind` or `minikube` cluster.
The makefile contains the way to create the `kind` cluster with the following command.
If you don't have `kind` installed:
```shell
$ make install-kind
```
```shell
$ make cluster
```
2. The operator need a secret which holds the registry creds to the private docker registry where all the image will be cached.
This has to be created upfront before deploying the operator to your cluster. Below are the steps
```yaml
apiVersion: v1
kind: Secret
metadata:
name: private-registry-creds
namespace: system
type: Opaque
stringData:
DOCKER_REGISTRY_URI: # example "index.docker.io/ishankhare07"
DOCKER_REGISTRY_USERNAME:
DOCKER_REGISTRY_PASSWORD:
```
And then create this secret in the cluster:
```shell
$ kubectl apply -f secret.yaml
```
### Use your registry to host operator
The controller image is currently available as a public image on dockerhub at `ishankhare07/image-cloner`, in case you want to host your own image
build and push to your registry in the following way:
```shell
$ docker login
...
...
...
$ IMG="" make build
$ IMG="" make push
$ IMG="" make deploy
```
### Use existing registry image
If you are okay with using the current image on the public dockerhub, just go ahead and deploy:
```shell
$ make deploy
```
This will apply the following to your cluster:
1. Create namespace `system`
2. Create `clusterrole` for the controllers
3. Create `clusterrolebindings`
4. Create `deployment` which will actually run the controller.
### Running locally
When running locally, create a file called `config/config.env` which contains the private registry cred as follows:
```
DOCKER_REGISTRY_URI=""
DOCKER_REGISTRY_USERNAME=""
DOCKER_REGISTRY_PASSWORD=""
```
This allows easily testing the whole flow, next just run:
```shell
$ make cluster
$ make run
```