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

Add must-gather container #1034

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions .chloggen/add-must-gather.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: new_component

# The name of the component, or a single word describing the area of concern, (e.g. tempostack, tempomonolithic, github action)
component: must-gather

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add must-gather to collect information about the components deployed by the operator in a cluster.

# One or more tracking issues related to the change
issues: [1033]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
6 changes: 6 additions & 0 deletions .github/workflows/reusable-publish-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,9 @@ jobs:
run: make bundle bundle-build bundle-push catalog-build catalog-push
env:
IMG_PREFIX: ghcr.io/${{ github.repository }}

- name: Publish must-gather image
if: ${{ inputs.publish_bundle }}
run: make container-must-gather container-must-gather-push
env:
IMG_PREFIX: ghcr.io/${{ github.repository }}
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ JAEGER_QUERY_IMAGE ?= docker.io/jaegertracing/jaeger-query:$(JAEGER_QUERY_VERSIO
TEMPO_QUERY_IMAGE ?= docker.io/grafana/tempo-query:$(TEMPO_QUERY_VERSION)
TEMPO_GATEWAY_IMAGE ?= quay.io/observatorium/api:$(TEMPO_GATEWAY_VERSION)
TEMPO_GATEWAY_OPA_IMAGE ?= quay.io/observatorium/opa-openshift:$(TEMPO_GATEWAY_OPA_VERSION)
MUSTGATHER_IMAGE ?= ${IMG_PREFIX}/must-gather:$(OPERATOR_VERSION)
OAUTH_PROXY_IMAGE ?= quay.io/openshift/origin-oauth-proxy:$(OAUTH_PROXY_VERSION)

VERSION_PKG ?= github.com/grafana/tempo-operator/internal/version
Expand Down Expand Up @@ -146,6 +147,10 @@ test: manifests generate fmt setup-envtest ## Run tests.
build: generate fmt ## Build manager binary.
CGO_ENABLED=0 go build -o bin/manager -ldflags ${LD_FLAGS} main.go

.PHONY: must-gather
must-gather:
CGO_ENABLED=0 go build -o bin/must-gather ./cmd/gather/main.go

.PHONY: run
run: manifests generate ## Run a controller from your host.
@echo -e "\033[33mRemoving tempo-operator from the cluster. Webhooks are disabled, use the normal deployment method to enable full operator functionality.\033[0m"
Expand All @@ -161,6 +166,14 @@ run: manifests generate ## Run a controller from your host.
RELATED_IMAGE_OAUTH_PROXY=$(OAUTH_PROXY_IMAGE) \
go run -ldflags ${LD_FLAGS} ./main.go --zap-log-level=info start

.PHONY: container-must-gather
container-must-gather:
docker build -f cmd/gather/Dockerfile --load -t ${MUSTGATHER_IMAGE} .

.PHONY: container-must-gather-push
container-must-gather-push:
docker push ${MUSTGATHER_IMAGE}

.PHONY: docker-build
docker-build: ## Build docker image with the manager.
docker buildx build --load --platform linux/${ARCH} --build-arg OPERATOR_VERSION --build-arg TEMPO_VERSION -t ${IMG} .
Expand Down
34 changes: 34 additions & 0 deletions cmd/gather/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Build the manager binary
FROM golang:1.22 as builder

WORKDIR /workspace
# Cache tool dependencies
COPY Makefile Makefile
RUN make controller-gen kustomize
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY . .

RUN make must-gather


FROM registry.access.redhat.com/ubi9-minimal:9.2

RUN INSTALL_PKGS=" \
rsync \
tar \
" && \
microdnf install -y $INSTALL_PKGS && \
microdnf clean all

COPY --from=builder /workspace/bin/must-gather /usr/bin/must-gather

USER 65532:65532

ENTRYPOINT ["/usr/bin/must-gather"]
36 changes: 36 additions & 0 deletions cmd/gather/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Tempo Operator Must-Gather

The Tempo Operator `must-gather` tool is designed to collect comprehensive information about Tempo components within an OpenShift cluster. This utility extends the functionality of [OpenShift must-gather](https://github.com/openshift/must-gather) by specifically targeting and retrieving data related to the Tempo Operator, helping in diagnostics and troubleshooting.

Note that you can use this utility too to gather information about the objects deployed by the Tempo Operator if you don't use OpenShift.

## What is a Must-Gather?

The `must-gather` tool is a utility that collects logs, cluster information, and resource configurations related to a specific operator or application in an OpenShift cluster. It helps cluster administrators and developers diagnose issues by providing a snapshot of the cluster's state related to the targeted component. More information [in the official documentation](https://docs.openshift.com/container-platform/4.16/support/gathering-cluster-data.html).

## Usage

First, you will need to build and push the image:
```sh
make container-must-gather container-must-gather-push
```

To run the must-gather tool for the Tempo Operator, use one of the following commands, depending on how you want to source the image and the namespace where the operator is deployed.

### Using the image from the Operator deployment

If you want to use the image in a running cluster, you need to run the following command:

```sh
oc adm must-gather --image=<must-gather-image> -- /usr/bin/must-gather --operator-namespace tempo-operator-system
```

### Using it as a CLI

You only need to build and run:
```sh
make must-gather
./bin/must-gather --help
```

This is the recommended way to do it if you are not using OpenShift.
Loading