kubearmor / kubearmor-client

KubeArmor cli tool aka kArmor :robot:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`karmor install --local` does not set `ImagePullPolicy` to `IfNotPresent` for all containers

Vyom-Yadav opened this issue · comments

Description

--local flag does not set ImagePullPolicy to IfNotPresent for many containers across different deployments. For example:

    spec:
      containers:
      - image: kubearmor/kubearmor-relay-server:latest
        imagePullPolicy: Always # This should have been IfNotPresent
        name: kubearmor-relay-server

Work in the scope of this issue

Check all pod controllers (deployments, daemon sets, etc.) deployed by karmor install have ImagePullPolicy set to IfNotPresent for all containers if --local flag is specified.

Hey @kranurag7, as I'm new here, so up to my understanding I think changes had to be made in deployment>>probdeployment.go file.
Do correct me if I'm wrong...
Screenshot from 2023-04-08 18-01-21

Hey @chirag0002 Thanks for looking into the issue.
You need to make the changes here with respect to kubearmor-relay-server. For other resources, where ImagePullPolicy is not set, you can add ImagePullPolicy in the same file.

Hi @kranurag7, I have identified these places in objects.go (1, 2, 3, 4 5, 6, 7, 8, 9 ) where the "ImagePullPolicy" could be modified/created.

Hey @Abhishek-569 Sorry for the delayed response, your implementation works I think for the issue.

@rootxrishabh the changes needs to be done only in the ImagePullPolicy not the Image

Hey @kranurag7,
As you specified in this comment I'll update the ImagePullPolicy where it already exists and add where it doesn't.

Hey @chirag0002 Thanks for looking into the issue. You need to make the changes here with respect to kubearmor-relay-server. For other resources, where ImagePullPolicy is not set, you can add ImagePullPolicy in the same file.

Hey @rootxrishabh, We don't want to update the deployment YAMLs.

As you can see here

if o.Local == true {
daemonset.Spec.Template.Spec.Containers[0].ImagePullPolicy = "IfNotPresent"
daemonset.Spec.Template.Spec.InitContainers[0].ImagePullPolicy = "IfNotPresent"

But this is limited to the Daemonset.
In my opinion the scope of the issue is to implement the same things as part of other deployment and services as well that are installed.

Thanks @kranurag7 will raise a PR soon.

Hey @daemon1024, I appreciate the information. As I understand it, the deployments in the install.go file should be set up with the "IfNotPresent" imagePullPolicy. One specific deployment(one of the many) that needs this configuration is the Policy Manager Deployment. Please correct me if my understanding is incorrect.

As I understand it, the deployments in the install.go file should be set up with the "IfNotPresent" imagePullPolicy.

It should be set to "IfNotPresent" only if the --local flag is used, like how we do in the Daemonset.

One specific deployment(one of the many) that needs this configuration is the Policy Manager Deployment.

That's right