From 724527350a085398f7ca0d00a9a79bc8370aac06 Mon Sep 17 00:00:00 2001 From: Swarup Ghosh Date: Wed, 16 Jul 2025 12:42:13 +0530 Subject: [PATCH 1/3] Add hacking.md with local operator development steps Signed-off-by: Swarup Ghosh --- HACKING.md | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 22 +------------ 2 files changed, 93 insertions(+), 21 deletions(-) create mode 100644 HACKING.md diff --git a/HACKING.md b/HACKING.md new file mode 100644 index 000000000..eda16d2f2 --- /dev/null +++ b/HACKING.md @@ -0,0 +1,92 @@ +# Local Development of must-gather-operator + +The operator can be built and run locally provided a `KUBECONFIG` is set in your environment pointing to an OpenShift cluster. It is recommended that development be done using a cluster with `cluster-admin` permissions. + +## Build and Run + +Execute the following pre-requisite steps to setup the must-gather-operator namespace with required manifests. + +```sh +oc apply -f deploy/crds/managed.openshift.io_mustgathers.yaml + +oc new-project must-gather-operator + +oc apply -f deploy/ + +# avoid running pods in the cluster for the operator +oc scale --replicas=0 -n must-gather-operator deploy/must-gather-operator +``` + +Build and run the operator: +```sh +go build . + +export OPERATOR_NAMESPACE=must-gather-operator +export OPERATOR_NAME=must-gather-operator +export WATCH_NAMESPACE=must-gather-operator +export DEFAULT_MUST_GATHER_IMAGE='quay.io/openshift/origin-must-gather:latest' +export NAMESPACE=must-gather-operator + +# the image for the operator is still required, +# it is used by the "upload" container in the Job's pod. +export OPERATOR_IMAGE="quay.io/swghosh/must-gather-operator:latest" + +podman build -t "${OPERATOR_IMAGE}" + +export OSDK_FORCE_RUN_MODE="local" # required to disable leader election +./must-gather-operator +``` + +## Example must-gather + +```sh +oc create -f - << EOF +apiVersion: v1 +kind: Namespace +metadata: + name: sandbox + labels: + name: sandbox +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: sandbox-admin + namespace: sandbox +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: sandbox-admin-cluster-admin-binding +subjects: +- kind: ServiceAccount + name: sandbox-admin + namespace: sandbox +roleRef: + kind: ClusterRole + name: cluster-admin + apiGroup: rbac.authorization.k8s.io +--- +apiVersion: v1 +kind: Secret +metadata: + name: sftp-access-rh-creds + namespace: sandbox +type: Opaque +stringData: + username: some-username + password: a-password +--- +apiVersion: managed.openshift.io/v1alpha1 +kind: MustGather +metadata: + name: example + namespace: sandbox +spec: + caseID: '02527285' + caseManagementAccountSecretRef: + name: sftp-access-rh-creds + serviceAccountRef: + name: sandbox-admin +EOF +``` \ No newline at end of file diff --git a/README.md b/README.md index c03f0e052..20038ac4a 100644 --- a/README.md +++ b/README.md @@ -86,24 +86,4 @@ oc create secret generic case-management-creds --from-literal=username= Date: Mon, 25 Aug 2025 12:37:18 +0530 Subject: [PATCH 2/3] Add steps to deploy must-gather operator on cluster --- HACKING.md | 30 +++++++++++++++++++ .../02_must-gather-operator.ClusterRole.yaml | 1 + 2 files changed, 31 insertions(+) diff --git a/HACKING.md b/HACKING.md index eda16d2f2..345e61267 100644 --- a/HACKING.md +++ b/HACKING.md @@ -89,4 +89,34 @@ spec: serviceAccountRef: name: sandbox-admin EOF +``` + +## Steps to deploy must-gather operator on cluster + +```sh +# Build the image +podman build -f build/Dockerfile -t quay.io/{{user_id}}/mustgather:{{tag}} . + +# Push the image +podman push quay.io/{{user_id}}/mustgather:{{tag}} + +# Then update `container.image` on `line 32` and `OPERATOR_IMAGE` on `line 46` to new built image i.e. `quay.io/{{user_id}}/mustgather:{{tag}}` + +oc apply -f deploy/crds/managed.openshift.io_mustgathers.yaml + +# Create namespace must-gather-operator +oc new-project must-gather-operator + +# Create must-gather-operator service account +oc apply -f examples/other_resources/01_must-gather-operator.ServiceAccount.yaml + +# Create must-gather-admin service account +oc apply -f examples/other_resources/04_must-gather-admin.ServiceAccount.yaml + +# Replace with actual user_name and password for upload to work +oc create secret generic case-management-creds --from-literal=username=test-user --from-literal=password=test-password -n must-gather-operator + +oc apply -f deploy/ + +oc apply -f examples/mustgather_basic.yaml ``` \ No newline at end of file diff --git a/deploy/02_must-gather-operator.ClusterRole.yaml b/deploy/02_must-gather-operator.ClusterRole.yaml index b034c5c7f..bb2286646 100644 --- a/deploy/02_must-gather-operator.ClusterRole.yaml +++ b/deploy/02_must-gather-operator.ClusterRole.yaml @@ -12,6 +12,7 @@ rules: verbs: - list - get + - watch # leader election - apiGroups: - "" From 159bb2d709f628e3effbf9589ac459b2db5a75ff Mon Sep 17 00:00:00 2001 From: Swarup Ghosh Date: Fri, 12 Sep 2025 22:18:06 +0530 Subject: [PATCH 3/3] Update DEFAULT_MUST_GATHER_IMAGE to be multi-arch friendly Signed-off-by: Swarup Ghosh --- HACKING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HACKING.md b/HACKING.md index 345e61267..038d4b8d4 100644 --- a/HACKING.md +++ b/HACKING.md @@ -24,7 +24,7 @@ go build . export OPERATOR_NAMESPACE=must-gather-operator export OPERATOR_NAME=must-gather-operator export WATCH_NAMESPACE=must-gather-operator -export DEFAULT_MUST_GATHER_IMAGE='quay.io/openshift/origin-must-gather:latest' +export DEFAULT_MUST_GATHER_IMAGE='registry.redhat.io/openshift4/ose-must-gather-rhel9:latest' export NAMESPACE=must-gather-operator # the image for the operator is still required,