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

[DOCS] Jenkins docs for signing and verifying using a Jenkins pipeline #303

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

JasonPowr
Copy link
Contributor

Small doc related pr

Copy link
Member

@lance lance left a comment

Choose a reason for hiding this comment

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

Thanks!

@openshift-ci openshift-ci bot added the lgtm label Apr 4, 2024
Copy link

openshift-ci bot commented Apr 4, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JasonPowr, lance

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

### Configuring Jenkins
To ensure the pipeline operates smoothly, the following Jenkins configurations are necessary:

1) Install the Docker Pipeline Plugin: Verify that the Docker Pipeline plugin is installed and enabled.

Choose a reason for hiding this comment

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

Can links to the plugins be added?

-d "grant_type=password" \
-d "scope=openid" \
-d "client_id=${env.OIDC_CLIENT_ID}" \
${env.OIDC_ISSUER_URL}/protocol/openid-connect/token | sed -E 's/.*"access_token":"([^"]*)".*/\\1/' > token.txt

Choose a reason for hiding this comment

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

Suggested change
${env.OIDC_ISSUER_URL}/protocol/openid-connect/token | sed -E 's/.*"access_token":"([^"]*)".*/\\1/' > token.txt
${env.OIDC_ISSUER_URL}/protocol/openid-connect/token | sed -E 's/.*"id_token":"([^"]*)".*/\\1/' > token.txt

-d "client_id=${env.OIDC_CLIENT_ID}" \
${env.OIDC_ISSUER_URL}/protocol/openid-connect/token | sed -E 's/.*"access_token":"([^"]*)".*/\\1/' > token.txt
cosign sign -y --fulcio-url=${env.FULCIO_URL} --rekor-url=${env.REKOR_URL} --oidc-issuer=${env.OIDC_ISSUER_URL} --oidc-client-id=${env.OIDC_CLIENT_ID} --identity-token=token.txt ${env.IMG}:${env.TAG}
cosign verify --rekor-url=${env.REKOR_URL} --certificate-identity-regexp ${env.OIDC_USERNAME} --certificate-oidc-issuer-regexp ${env.OIDC_ISSUER} ${env.IMG}:${env.TAG}

Choose a reason for hiding this comment

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

Lets use the --certificate-identity flag since we know the concrete identity

stage("Sign & Verify Image") {
agent {
docker {
image 'registry.redhat.io/rhtas-tech-preview/cosign-rhel9:0.0.2'

Choose a reason for hiding this comment

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

Suggested change
image 'registry.redhat.io/rhtas-tech-preview/cosign-rhel9:0.0.2'
image 'registry.redhat.io/rhtas/cosign-rhel9:1.0.0'

4) Install the Credentials Plugin: Make sure the Credentials plugin is installed and enabled.

#### Setting Up Credentials
Credentials will need to be set using the credentials plugin, there are three in total that will need to be configured.

Choose a reason for hiding this comment

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

Suggested change
Credentials will need to be set using the credentials plugin, there are three in total that will need to be configured.
Credentials will need to be set using the credentials plugin. There are three credentials in total that will need to be configured.

* Set an ID for these credentials; for ease, you can use `redhat_io_credentials` as the default ID.

* Cosign Credentials
* During the cosign signing process, cosign pushes the signed image to an image registry, because of this it needs credentials, which should be setup in a similar fashion to the above, in the example quay is the registry used and credentials (ID is defaulted to `quay_credentials`) are configured like so:

Choose a reason for hiding this comment

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

Suggested change
* During the cosign signing process, cosign pushes the signed image to an image registry, because of this it needs credentials, which should be setup in a similar fashion to the above, in the example quay is the registry used and credentials (ID is defaulted to `quay_credentials`) are configured like so:
* During the cosign signing process, cosign pushes the signed image to an image registry. As a result, credentials are needed which should be setup in a similar fashion to the above. In this example, quay.io is the registry used and credentials (ID is defaulted to `quay_credentials`) are configured like so:

```

* OIDC Password
* A password, for the OIDC provider will also need to be configured using the credentials plugin (ID is defaulted to `oidc-password`) this should be setup in a similar fashion to the above, but it should be created as a `Secret text` as opposed to a `Username with Password`

Choose a reason for hiding this comment

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

Suggested change
* A password, for the OIDC provider will also need to be configured using the credentials plugin (ID is defaulted to `oidc-password`) this should be setup in a similar fashion to the above, but it should be created as a `Secret text` as opposed to a `Username with Password`
* A password for the OIDC provider will also need to be configured using the credentials plugin (ID is defaulted to `oidc-password`). This should be setup in a similar fashion to the above, but it should be created as a `Secret text` as opposed to a `Username with Password`



#### Setting Up A Pipeline
To Create a pipeline, Dashboard > New item > Pipeline, Pipelines can be created using scm (Source Control Managment) but in this example we use a simple pipeline script, that signs and verify's an image, this example can be found below.

Choose a reason for hiding this comment

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

Suggested change
To Create a pipeline, Dashboard > New item > Pipeline, Pipelines can be created using scm (Source Control Managment) but in this example we use a simple pipeline script, that signs and verify's an image, this example can be found below.
To Create a pipeline, select Dashboard > New item > Pipeline. Pipelines can be created using scm (Source Control Management), but in this example, we use a simple pipeline script that signs and verify's an image. An example can be found below.

@JasonPowr
Copy link
Contributor Author

I've had to update how the pipeline uses cosign credentials, as When deploying this it wasn't working (this time), I believe previously the config for docker within the pipeline was already authenticated with quay, meaning it was skipping the setp each time

@lance
Copy link
Member

lance commented Jul 22, 2024

@JasonPowr what is the status of this PR?

@JasonPowr
Copy link
Contributor Author

@JasonPowr what is the status of this PR?

@lance This pr should be good to go, although there may be better documentation out there by now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants