Skip to content

Install jq in gcb-docker-gcloud image #34963

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ArkaSaha30
Copy link
Member

@ArkaSaha30 ArkaSaha30 commented Jun 11, 2025

This commit will install jq in gcb-docker-gcloud image so that the utility is available for all cloudbuild.yaml

Fixes: kubernetes/kubernetes#131257
Ref Discussion: kubernetes/kubernetes#131258 (comment)

Built and locally tested:

arkas1@arkas1-ubuntu-vm:~/test-infra/images/gcb-docker-gcloud$ docker run -it --rm gcb-docker-gcloud:latest 
1ebeb22425f4:/workspace# jq
jq - commandline JSON processor [version 1.8.0]

Usage:	jq [options] <jq filter> [file...]
	jq [options] --args <jq filter> [strings...]
	jq [options] --jsonargs <jq filter> [JSON_TEXTS...]

jq is a tool for processing JSON inputs, applying the given filter to
its JSON text inputs and producing the filter's results as JSON on
standard output.

The simplest filter is ., which copies jq's input to its output
unmodified except for formatting. For more advanced filters see
the jq(1) manpage ("man jq") and/or https://jqlang.org/.

Example:

	$ echo '{"foo": 0}' | jq .
	{
	  "foo": 0
	}

For listing the command options, use jq --help.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 11, 2025
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 11, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ArkaSaha30
Once this PR has been reviewed and has the lgtm label, please assign cjwagner for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@k8s-ci-robot k8s-ci-robot added area/images sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Jun 11, 2025
This commit will install `jq` in gcb-docker-gcloud image
so that the utility is available for all cloudbuild.yaml

Signed-off-by: ArkaSaha30 <arkasaha30@gmail.com>
@ArkaSaha30 ArkaSaha30 force-pushed the jq-for-gcb-docker-gcloud branch from 5c8115d to fc86490 Compare June 11, 2025 07:05
Copy link
Member

@BenTheElder BenTheElder left a comment

Choose a reason for hiding this comment

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

I'm not sure if this is the right approach.

We want to be able to build locally too, and this image is minimal containing docker-cli (so you can docker run) and gcloud (so you can upload results to the staging locations).

I don't think we should extend this image.

We could probably docker run jq in the build? (we should also obtain this via digest)

@@ -32,6 +32,10 @@ WORKDIR /workspace
RUN echo http://dl-cdn.alpinelinux.org/alpine/latest-stable/community >> /etc/apk/repositories && \
apk --no-cache add curl python3 py-crcmod bash libc6-compat openssh-client git gnupg docker-cli make

# Install jq
RUN curl -o /usr/bin/jq -fsSLO https://github.com/jqlang/jq/releases/download/jq-1.8.0/jq-linux-amd64
Copy link
Member

Choose a reason for hiding this comment

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

If we do do this, we should at the very least be doing an integrity check (we should be for the others already here but that's not related to this PR), if not pinning the hash outright

@ArkaSaha30
Copy link
Member Author

We could probably docker run jq in the build? (we should also obtain this via digest)

Are you suggesting something like this for all uses of jq in Makefile?

BASE.windows := mcr.microsoft.com/oss/kubernetes/windows-pause-image-base:v0.4.1@sha256:37cc10768383b55611d724a05eb18564cb5184c89b0c2faa7d4eff63475092df

JQ_IMAGE := ghcr.io/jqlang/jq@sha256:a186dcd84a1e28bb48cdf3d7768b890d08621a87bb651fadb7db6815a6bf5ad5

ALL_OSVERSIONS.windows := $(shell docker manifest inspect ${BASE.windows} | docker run --rm -i ${JQ_IMAGE} '.manifests' | jq -c '.[]' | jq '.platform."os.version"' | tr -d '"')

@BenTheElder
Copy link
Member

Yeah that could work, right? Also means we control the jq version inline for any compat issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/images cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pause image 3.10.1 not available in staging, production
3 participants