This is a k8s controller which will watch for Deployment and Daemonset pods and store the image by re-uploading to a bakcup registry from public registry images.
You’ll need a Kubernetes cluster to run against. You can use KIND to get a local cluster for testing, or run against a remote cluster.
Note: Your controller will automatically use the current context in your kubeconfig file (i.e. whatever cluster kubectl cluster-info
shows).
- asciinema demo link link
- Apply docker credential
secret
inconfig/sample/registry-cred.yaml
file. Before applying thesecret
, change thestringData
keyauth
to right<docker-username>
and<password>
inimage-cloner-cred
secret.- If you want to update the docker cred secret name and namespace then need to add the secret name and namespace in
ENV
of the deployment inside./config/manager/manager.yaml
and update theRegistrySecretName
andRegistrySecretNamespace
- If you want to update the docker cred secret name and namespace then need to add the secret name and namespace in
kubectl apply -f config/sample/registry-cred.yaml
- Build and push your image to the location specified by
IMG
:
export REGISTRY=<registry-name>
make docker-push
- Deploy the controller to the cluster with the image specified by
IMG
:
export REGISTRY=<registry-name>
make deploy
or, for deploying in kind
export REGISTRY=<registry-name>
make deploy-to-kind
-
check the pods are up and running:
kubectl get pod -n image-cloner-system
-
apply sample deployment and daemonset
kubectl apply -f config/sample/demo-deployment.yaml
kubectl apply -f config/sample/demo-daemonset.yaml
-
now check in the sample deployment and daemonset images, they will be cloned & pushed to your backup docker registry and use new docker image in the deployment
-
UnDeploy the controller to the cluster:
make undeploy
If you are editing the API definitions, generate the manifests such as CRs or CRDs using:
make manifests
- Added e2e test for deployment and Daemonset controller
- For e2e test follow below steps:
- run the controller and create the
docker cred secret
- run
ginkgo tests/e2e/
- run the controller and create the
make test
Copyright 2022.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.