Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load local image in local-deploy #192

Merged
merged 5 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,20 @@ create-kind-cluster: $(KIND) ## Create cluster
delete-kind-cluster: $(KIND) ## Delete cluster
$(KIND) delete cluster

.PHONY: kind-load-image
kind-load-image: ## Load image to kind
ifeq ($(OCI_RUNTIME),$(shell which docker))
# This is an optimization for docker provider. "kind load docker-image" can load an image directly from docker's
# local registry. For other providers (i.e. podman), we must use "kind load image-archive" instead.
$(KIND) load docker-image $(DOCKER_IMG):$(DOCKER_TAG)
else
$(eval tmpfile="/tmp/flp.tar")
-rm $(tmpfile)
$(OCI_RUNTIME) save $(DOCKER_IMG):$(DOCKER_TAG) -o $(tmpfile)
$(KIND) load image-archive $(tmpfile)
-rm $(tmpfile)
endif

##@ metrics

.PHONY: generate-configuration
Expand All @@ -236,7 +250,7 @@ generate-configuration: $(KIND) ## Generate metrics configuration
##@ End2End

.PHONY: local-deployments-deploy
local-deployments-deploy: $(KIND) deploy-prometheus deploy-loki deploy-grafana deploy deploy-netflow-simulator
local-deployments-deploy: $(KIND) deploy-prometheus deploy-loki deploy-grafana build-image kind-load-image deploy deploy-netflow-simulator
kubectl get pods
kubectl rollout status -w deployment/flowlogs-pipeline
kubectl logs -l app=flowlogs-pipeline
Expand Down
2 changes: 1 addition & 1 deletion contrib/kubernetes/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
- containerPort: 6343
- containerPort: 2055
- containerPort: 2056
imagePullPolicy: Always
imagePullPolicy: Never
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be set for Never only for local-deployment.

Copy link
Collaborator

@eranra eranra Apr 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ronensc maybe "IfNotPresent" fits both use-cases ... and actually if the code for OCP like in here https://cookbook.openshift.org/image-registry-and-image-streams/how-do-i-import-an-image-from-an-external-image.html works then you can keep the Never approach and add the code for OCP deployment to also load an image ... I really prefer the second, but it does require a bit of more work to check that this works also for OCP.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried loading the FLP image into an OCP cluster and then started a pod with that image

$ oc import-image quay.io/netobserv/flowlogs-pipeline:latest --confirm
$ oc run  mypod --image=quay.io/netobserv/flowlogs-pipeline:latest --image-pull-policy=Never

But the pod couldn't find the image

$ oc get po
NAME    READY   STATUS              RESTARTS   AGE
mypod   0/1     ErrImageNeverPull   0          4s

Also, AFAIU, image streams are an OpenShift feature and there is no import-image equivalent in kubectl.
Do we want to introduce a new oc command to our Makefile?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ronensc I was looking on https://medium.com/@adilsonbna/importing-an-external-docker-image-into-red-hat-openshift-repository-c25894cd3199

This seems to solve this ... but this is also not trivial and makes things even a bit more complicated

So, what I suggest is a keep things as is and move to IfNotPresent mode ... this should work for both.
Also, small remark in the makefile of OCP that states that this uses the latest version from quay.io

Hope this makes sense to you

We might improve in one of the future PR's

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jotak @mariomac @jpinsonneau @OlivierCazade if any of you guys know how to push an image from local docker into OCP (above links are almost working, but not really :-) ))) we can use that to improve the process of ocp-deploy

volumeMounts:
- name: configuration
mountPath: "/etc/flowlogs-pipeline/"
Expand Down