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

feat: reduce number of containers #243

Merged
merged 1 commit into from
May 2, 2023

Conversation

ksimon1
Copy link
Member

@ksimon1 ksimon1 commented Apr 24, 2023

What this PR does / why we need it:
feat: reduce number of containers
feat: reduce number of dockerfiles

this commit reduces number of builded containers to just 2. One container for disk-virt tasks and second for everything else. The disk-virt containers requires separate container, because they need different base image (kubevirt libguestfs which is distroless and we can't install there anything). Other tasks share the same container, because they don't need anything special.
This change will help to decrease maintenance effort, because we will not have to take care about 9 containers, but only about two. This commit also reduce number of dockerfiles to just two (one for disk-virt tasks, second for everything else). This will help to reduce time needed to e.g. bump golang version, or bump base images versions. It will also reduce complexity of build scripts and it will reduce build time.

New containers will have names:
kubevirt/tekton-tasks
kubevirt/tekton-tasks-disk-virt

kubevirt/tekton-tasks container contains :copy-template, create-vm, execute-in-vm, generate-ssh-keys, modify-data-object, modify-vm-template and wait-for-vmi-status tasks.
kubevirt/tekton-tasks-disk-virt container contains: disk-virt-customize and disk-virt-sysprep

Release note:

kubevirt/tekton-tasks container contains :copy-template, create-vm, execute-in-vm, generate-ssh-keys, modify-data-object, modify-vm-template and wait-for-vmi-status tasks.
kubevirt/tekton-tasks-disk-virt container contains: disk-virt-customize and disk-virt-sysprep

@kubevirt-bot kubevirt-bot added dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/XXL labels Apr 24, 2023
@openshift-ci openshift-ci bot requested review from 0xFelix and akrejcir April 24, 2023 07:42
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 24, 2023
build/Dockerfile Outdated Show resolved Hide resolved
build/Dockerfile Outdated Show resolved Hide resolved
build/Dockerfile Outdated Show resolved Hide resolved
build/Dockerfile Outdated Show resolved Hide resolved
build/Dockerfile.DiskVirt Outdated Show resolved Hide resolved
build/Dockerfile.DiskVirt Outdated Show resolved Hide resolved
USER_NAME=${TASK_NAME} \
HOME=/home/${TASK_NAME}

USER 0
Copy link
Member

Choose a reason for hiding this comment

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

This is overriden in L34?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the libguestfs does not allow to do user modifications without switching to root. Then on line 34 it is switched back to regular user

CGO_ENABLED=0 GOOS=linux go build -o /out/${TASK_NAME} cmd/${TASK_NAME}/main.go; \
done

FROM quay.io/kubevirt/libguestfs-tools:v0.59.0
Copy link
Member

Choose a reason for hiding this comment

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

Make the kubevirt version a variable?

scripts/build-release-images.sh Outdated Show resolved Hide resolved
scripts/build-release-images.sh Outdated Show resolved Hide resolved
ksimon1 added a commit to ksimon1/release that referenced this pull request Apr 24, 2023
project

kubevirt tekton tasks project will use only 2 containers -
kubevirt/kubevirt-tekton-tasks#243.
This commit adjusts settings for openshift ci
Signed-off-by: Karel Šimon <ksimon@redhat.com>
openshift-ci bot pushed a commit to openshift/release that referenced this pull request Apr 24, 2023
…38645)

project

kubevirt tekton tasks project will use only 2 containers -
kubevirt/kubevirt-tekton-tasks#243.
This commit adjusts settings for openshift ci
Signed-off-by: Karel Šimon <ksimon@redhat.com>
@ksimon1
Copy link
Member Author

ksimon1 commented Apr 24, 2023

/retest

1 similar comment
@ksimon1
Copy link
Member Author

ksimon1 commented Apr 24, 2023

/retest

@ksimon1 ksimon1 force-pushed the reduce-containers branch 5 times, most recently from 43bcf85 to cb8f09e Compare April 25, 2023 08:35
@ksimon1
Copy link
Member Author

ksimon1 commented Apr 25, 2023

/hold WIP

@kubevirt-bot kubevirt-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 25, 2023
@ksimon1 ksimon1 force-pushed the reduce-containers branch 3 times, most recently from a9d8974 to aa31216 Compare April 27, 2023 09:57
@ksimon1
Copy link
Member Author

ksimon1 commented Apr 27, 2023

/hold cancel

@kubevirt-bot kubevirt-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 27, 2023
Copy link
Member

@0xFelix 0xFelix left a comment

Choose a reason for hiding this comment

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

It's really nitpicky but I'd like if both Containerfiles were kept as similar as possible.

build/Containerfile Outdated Show resolved Hide resolved
build/Containerfile.DiskVirt Show resolved Hide resolved
build/Containerfile.DiskVirt Outdated Show resolved Hide resolved
build/Containerfile.DiskVirt Show resolved Hide resolved
@@ -191,7 +193,7 @@ spec:
description: The namespace of a VM that was created.
steps:
- name: createvm
image: "quay.io/kubevirt/tekton-task-create-vm:v0.14.0"
image: "quay.io/kubevirt/tekton-tasks:v0.14.0"
command:
- create-vm
Copy link
Member

Choose a reason for hiding this comment

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

Not using entrypoint?

Copy link
Member Author

@ksimon1 ksimon1 Apr 28, 2023

Choose a reason for hiding this comment

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

Some tasks do not need a user modifications.
Another problem is, that the entrypoint is doing some nasty things with quotation marks of parameters and e.g. modify-template task has problem with it.

command:
- entrypoint
args:
- '--verbose'
- $(params.verbose)
env:
- name: COMMAND
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need the COMMAND env or could the command to be executed be the first arg in a step?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've tried both approaches, but I like this one better because I don't know if the arguments are guaranteed in the order. Through the env variable, it is always certain that the command will be there.

scripts/onboard-new-task-with-ci-stub.sh Outdated Show resolved Hide resolved
feat: reduce number of dockerfiles

this commit reduces number of builded containers to just 2.
One container for disk-virt tasks and second for everything else.
The disk-virt containers requires separate container, because they need
different base image (kubevirt libguestfs which is distroless and we
can't install there anything). Other tasks share the same container,
because they don't need anything special.
This change will help to decrease maintenance effort, because we will
not have to take care about 9 containers, but only about two.
This commit also reduce number of dockerfiles to just two (one for disk-virt tasks,
second for everything else). This will help to reduce time needed to
e.g. bump golang version, or bump base images versions. It will also reduce
complexity of build scripts and it will reduce build time.

New containers will have names:
kubevirt/tekton-tasks
kubevirt/tekton-tasks-disk-virt

kubevirt/tekton-tasks container contains :copy-template, create-vm,
execute-in-vm, generate-ssh-keys, modify-data-object, modify-vm-template
and wait-for-vmi-status tasks.
kubevirt/tekton-tasks-disk-virt container contains: disk-virt-customize
and disk-virt-sysprep

Signed-off-by: Karel Šimon <ksimon@redhat.com>
Copy link
Member

@0xFelix 0xFelix left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 2, 2023
@openshift-ci
Copy link

openshift-ci bot commented May 2, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 0xFelix, ksimon1

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ksimon1 ksimon1 merged commit b7a8612 into kubevirt:main May 2, 2023
1 check passed
ascerra pushed a commit to ascerra/release that referenced this pull request May 8, 2023
…penshift#38645)

project

kubevirt tekton tasks project will use only 2 containers -
kubevirt/kubevirt-tekton-tasks#243.
This commit adjusts settings for openshift ci
Signed-off-by: Karel Šimon <ksimon@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants