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

Use tmpfs for pki entitlements #1207

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
19 changes: 11 additions & 8 deletions task/buildah-oci-ta/0.1/buildah-oci-ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -363,20 +363,23 @@ spec:
[ -n "$COMMIT_SHA" ] && LABELS+=("--label" "vcs-ref=$COMMIT_SHA")
[ -n "$IMAGE_EXPIRES_AFTER" ] && LABELS+=("--label" "quay.expires-after=$IMAGE_EXPIRES_AFTER")

ACTIVATION_KEY_PATH="/activation-key"
ENTITLEMENT_PATH="/entitlement"
if [ -d "$ENTITLEMENT_PATH" ]; then

# do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key.
# when activation keys are used, an empty directory on shared emptydir volume to /etc/pki/entitlement to prevent certificates from being included in the produced container.
Copy link
Contributor

@chmeliik chmeliik Jul 29, 2024

Choose a reason for hiding this comment

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

Do you specifically intend to make the methods mutually exclusive, or just to ensure certificates generated by "subscription-manager register" are not included in the final build.

I think we can achieve that ^ without making them mutually exclusive

Copy link
Contributor

Choose a reason for hiding this comment

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

And if you do intend to make them mutually exclusive, should we prefer certs? IIUC activation keys require extra handling in the Containerfile, while the certs "just work"

Copy link
Contributor Author

@brianwcook brianwcook Jul 29, 2024

Choose a reason for hiding this comment

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

I think they should be made mutually exclusive and that is what I did here intentionally. I'd like to document that the etc-pki-entitlement method of storing certs is discouraged and prone to random certificate revocation. Including activation keys now intentionally causes the certs generated by that method to be preferred.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated the PR with more info about my intentions here.

Copy link
Member

Choose a reason for hiding this comment

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

Since the intended direction is activation keys, I think it is fine for that to be the overriding path even if it is more work than certs. The workaround is to remove the configuration for the unused method which should be a best practice anyway.


if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
mkdir /shared/rhsm-tmp
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key -v /shared/rhsm-tmp:/etc/pki/entitlement:Z"
echo "Adding activation key to the build"
elif [ -d "$ENTITLEMENT_PATH" ]; then
cp -r --preserve=mode "$ENTITLEMENT_PATH" /tmp/entitlement
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/entitlement:/etc/pki/entitlement"
echo "Adding the entitlement to the build"
fi

ACTIVATION_KEY_PATH="/activation-key"
if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key"
echo "Adding activation key to the build"
fi

ADDITIONAL_SECRET_PATH="/additional-secret"
ADDITIONAL_SECRET_TMP="/tmp/additional-secret"
if [ -d "$ADDITIONAL_SECRET_PATH" ]; then
Expand Down
19 changes: 11 additions & 8 deletions task/buildah-oci-ta/0.2/buildah-oci-ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -363,20 +363,23 @@ spec:
[ -n "$COMMIT_SHA" ] && LABELS+=("--label" "vcs-ref=$COMMIT_SHA")
[ -n "$IMAGE_EXPIRES_AFTER" ] && LABELS+=("--label" "quay.expires-after=$IMAGE_EXPIRES_AFTER")

ACTIVATION_KEY_PATH="/activation-key"
ENTITLEMENT_PATH="/entitlement"
if [ -d "$ENTITLEMENT_PATH" ]; then

# do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key.
# when activation keys are used, an empty directory on shared emptydir volume to /etc/pki/entitlement to prevent certificates from being included in the produced container.

if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
mkdir /shared/rhsm-tmp
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key -v /shared/rhsm-tmp:/etc/pki/entitlement:Z"
echo "Adding activation key to the build"
elif [ -d "$ENTITLEMENT_PATH" ]; then
cp -r --preserve=mode "$ENTITLEMENT_PATH" /tmp/entitlement
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/entitlement:/etc/pki/entitlement"
echo "Adding the entitlement to the build"
fi

ACTIVATION_KEY_PATH="/activation-key"
if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key"
echo "Adding activation key to the build"
fi

ADDITIONAL_SECRET_PATH="/additional-secret"
ADDITIONAL_SECRET_TMP="/tmp/additional-secret"
if [ -d "$ADDITIONAL_SECRET_PATH" ]; then
Expand Down
19 changes: 11 additions & 8 deletions task/buildah-remote-oci-ta/0.1/buildah-remote-oci-ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -375,20 +375,23 @@ spec:
[ -n "$COMMIT_SHA" ] && LABELS+=("--label" "vcs-ref=$COMMIT_SHA")
[ -n "$IMAGE_EXPIRES_AFTER" ] && LABELS+=("--label" "quay.expires-after=$IMAGE_EXPIRES_AFTER")

ACTIVATION_KEY_PATH="/activation-key"
ENTITLEMENT_PATH="/entitlement"
if [ -d "$ENTITLEMENT_PATH" ]; then

# do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key.
# when activation keys are used, an empty directory on shared emptydir volume to /etc/pki/entitlement to prevent certificates from being included in the produced container.

if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
mkdir /shared/rhsm-tmp
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key -v /shared/rhsm-tmp:/etc/pki/entitlement:Z"
echo "Adding activation key to the build"
elif [ -d "$ENTITLEMENT_PATH" ]; then
cp -r --preserve=mode "$ENTITLEMENT_PATH" /tmp/entitlement
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/entitlement:/etc/pki/entitlement"
echo "Adding the entitlement to the build"
fi

ACTIVATION_KEY_PATH="/activation-key"
if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key"
echo "Adding activation key to the build"
fi

ADDITIONAL_SECRET_PATH="/additional-secret"
ADDITIONAL_SECRET_TMP="/tmp/additional-secret"
if [ -d "$ADDITIONAL_SECRET_PATH" ]; then
Expand Down
19 changes: 11 additions & 8 deletions task/buildah-remote-oci-ta/0.2/buildah-remote-oci-ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -375,20 +375,23 @@ spec:
[ -n "$COMMIT_SHA" ] && LABELS+=("--label" "vcs-ref=$COMMIT_SHA")
[ -n "$IMAGE_EXPIRES_AFTER" ] && LABELS+=("--label" "quay.expires-after=$IMAGE_EXPIRES_AFTER")

ACTIVATION_KEY_PATH="/activation-key"
ENTITLEMENT_PATH="/entitlement"
if [ -d "$ENTITLEMENT_PATH" ]; then

# do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key.
# when activation keys are used, an empty directory on shared emptydir volume to /etc/pki/entitlement to prevent certificates from being included in the produced container.

if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
mkdir /shared/rhsm-tmp
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key -v /shared/rhsm-tmp:/etc/pki/entitlement:Z"
echo "Adding activation key to the build"
elif [ -d "$ENTITLEMENT_PATH" ]; then
cp -r --preserve=mode "$ENTITLEMENT_PATH" /tmp/entitlement
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/entitlement:/etc/pki/entitlement"
echo "Adding the entitlement to the build"
fi

ACTIVATION_KEY_PATH="/activation-key"
if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key"
echo "Adding activation key to the build"
fi

ADDITIONAL_SECRET_PATH="/additional-secret"
ADDITIONAL_SECRET_TMP="/tmp/additional-secret"
if [ -d "$ADDITIONAL_SECRET_PATH" ]; then
Expand Down
19 changes: 11 additions & 8 deletions task/buildah-remote/0.1/buildah-remote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -367,20 +367,23 @@ spec:
[ -n "$COMMIT_SHA" ] && LABELS+=("--label" "vcs-ref=$COMMIT_SHA")
[ -n "$IMAGE_EXPIRES_AFTER" ] && LABELS+=("--label" "quay.expires-after=$IMAGE_EXPIRES_AFTER")

ACTIVATION_KEY_PATH="/activation-key"
ENTITLEMENT_PATH="/entitlement"
if [ -d "$ENTITLEMENT_PATH" ]; then

# do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key.
# when activation keys are used, an empty directory on shared emptydir volume to /etc/pki/entitlement to prevent certificates from being included in the produced container.

if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
mkdir /shared/rhsm-tmp
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key -v /shared/rhsm-tmp:/etc/pki/entitlement:Z"
echo "Adding activation key to the build"
elif [ -d "$ENTITLEMENT_PATH" ]; then
cp -r --preserve=mode "$ENTITLEMENT_PATH" /tmp/entitlement
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/entitlement:/etc/pki/entitlement"
echo "Adding the entitlement to the build"
fi

ACTIVATION_KEY_PATH="/activation-key"
if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key"
echo "Adding activation key to the build"
fi

ADDITIONAL_SECRET_PATH="/additional-secret"
ADDITIONAL_SECRET_TMP="/tmp/additional-secret"
if [ -d "$ADDITIONAL_SECRET_PATH" ]; then
Expand Down
19 changes: 11 additions & 8 deletions task/buildah-remote/0.2/buildah-remote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -357,20 +357,23 @@ spec:
[ -n "$COMMIT_SHA" ] && LABELS+=("--label" "vcs-ref=$COMMIT_SHA")
[ -n "$IMAGE_EXPIRES_AFTER" ] && LABELS+=("--label" "quay.expires-after=$IMAGE_EXPIRES_AFTER")

ACTIVATION_KEY_PATH="/activation-key"
ENTITLEMENT_PATH="/entitlement"
if [ -d "$ENTITLEMENT_PATH" ]; then

# do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key.
# when activation keys are used, an empty directory on shared emptydir volume to /etc/pki/entitlement to prevent certificates from being included in the produced container.

if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
mkdir /shared/rhsm-tmp
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key -v /shared/rhsm-tmp:/etc/pki/entitlement:Z"
echo "Adding activation key to the build"
elif [ -d "$ENTITLEMENT_PATH" ]; then
cp -r --preserve=mode "$ENTITLEMENT_PATH" /tmp/entitlement
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/entitlement:/etc/pki/entitlement"
echo "Adding the entitlement to the build"
fi

ACTIVATION_KEY_PATH="/activation-key"
if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key"
echo "Adding activation key to the build"
fi

ADDITIONAL_SECRET_PATH="/additional-secret"
ADDITIONAL_SECRET_TMP="/tmp/additional-secret"
if [ -d "$ADDITIONAL_SECRET_PATH" ]; then
Expand Down
20 changes: 11 additions & 9 deletions task/buildah/0.1/buildah.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -310,20 +310,23 @@ spec:
[ -n "$COMMIT_SHA" ] && LABELS+=("--label" "vcs-ref=$COMMIT_SHA")
[ -n "$IMAGE_EXPIRES_AFTER" ] && LABELS+=("--label" "quay.expires-after=$IMAGE_EXPIRES_AFTER")

ACTIVATION_KEY_PATH="/activation-key"
ENTITLEMENT_PATH="/entitlement"
if [ -d "$ENTITLEMENT_PATH" ]; then

# do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key.
# when activation keys are used, an empty directory on shared emptydir volume to /etc/pki/entitlement to prevent certificates from being included in the produced container.

if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
mkdir /shared/rhsm-tmp
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key -v /shared/rhsm-tmp:/etc/pki/entitlement:Z"
echo "Adding activation key to the build"
elif [ -d "$ENTITLEMENT_PATH" ]; then
cp -r --preserve=mode "$ENTITLEMENT_PATH" /tmp/entitlement
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/entitlement:/etc/pki/entitlement"
echo "Adding the entitlement to the build"
fi

ACTIVATION_KEY_PATH="/activation-key"
if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key"
echo "Adding activation key to the build"
fi

ADDITIONAL_SECRET_PATH="/additional-secret"
ADDITIONAL_SECRET_TMP="/tmp/additional-secret"
if [ -d "$ADDITIONAL_SECRET_PATH" ]; then
Expand Down Expand Up @@ -553,7 +556,6 @@ spec:
- cyclonedx
- $(params.IMAGE)
workingDir: $(workspaces.source.path)

volumes:
- name: varlibcontainers
emptyDir: {}
Expand Down
19 changes: 11 additions & 8 deletions task/buildah/0.2/buildah.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -299,20 +299,23 @@ spec:
[ -n "$COMMIT_SHA" ] && LABELS+=("--label" "vcs-ref=$COMMIT_SHA")
[ -n "$IMAGE_EXPIRES_AFTER" ] && LABELS+=("--label" "quay.expires-after=$IMAGE_EXPIRES_AFTER")

ACTIVATION_KEY_PATH="/activation-key"
ENTITLEMENT_PATH="/entitlement"
if [ -d "$ENTITLEMENT_PATH" ]; then

# do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key.
# when activation keys are used, an empty directory on shared emptydir volume to /etc/pki/entitlement to prevent certificates from being included in the produced container.

if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
mkdir /shared/rhsm-tmp
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key -v /shared/rhsm-tmp:/etc/pki/entitlement:Z"
echo "Adding activation key to the build"
elif [ -d "$ENTITLEMENT_PATH" ]; then
cp -r --preserve=mode "$ENTITLEMENT_PATH" /tmp/entitlement
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/entitlement:/etc/pki/entitlement"
echo "Adding the entitlement to the build"
fi

ACTIVATION_KEY_PATH="/activation-key"
if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key"
echo "Adding activation key to the build"
fi

ADDITIONAL_SECRET_PATH="/additional-secret"
ADDITIONAL_SECRET_TMP="/tmp/additional-secret"
if [ -d "$ADDITIONAL_SECRET_PATH" ]; then
Expand Down
Loading