Skip to content

DRAFT: Hack to allow local kind usage while working towards adding ClusterCatalog management #577

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
33 changes: 33 additions & 0 deletions defaults/05_redhat_operators_clustercatalog.cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: olm.operatorframework.io/v1alpha1
Copy link
Member

Choose a reason for hiding this comment

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

If this is for local testing, you might want to create a staging or dev directory for alternate defaults until the clustercatalog api is available by default in openshift?

kind: ClusterCatalog
metadata:
name: redhat-operators
annotations:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
spec:
priority: -100
source:
type: image
image:
ref: registry.redhat.io/redhat/redhat-operator-index:v4.18
pollInterval: 10m
nodeSelector:
node-role.kubernetes.io/master: ""
kubernetes.io/os: "linux"
priorityClassName: "system-cluster-critical"
tolerations:
- key: "node-role.kubernetes.io/master"
operator: Exists
effect: NoSchedule
- key: "node.kubernetes.io/unreachable"
operator: "Exists"
effect: NoExecute
tolerationSeconds: 120
- key: "node.kubernetes.io/not-ready"
operator: Exists
effect: "NoExecute"
tolerationSeconds: 120
memoryTarget: 30Mi
extractContent:
cacheDir: /tmp/cache
catalogDir: /configs
56 changes: 56 additions & 0 deletions hack/dev_hack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

# Super Hacky Way to Get a Local Kind Cluster Working Enough to Manage OperatorHub and CatalogSource Objects

## Prerequisites
To use the Dockerfiles in this guide, you must log in to `registry.ci`.

### Get Your OpenShift Token
1. Navigate to [OpenShift Console](https://console-openshift-console.apps.ci.l2s4.p1.openshiftapps.com).
2. In the top-right corner, click the menu and select **Copy Login Command**.
3. Copy the login command and use it in the following steps.

## Steps

### 1. Log in to `registry.ci`
Use the `podman` command to log in to the OpenShift registry. Replace the username and password with your own credentials:

```bash
podman login -u=btofel -p=sha256~<blahblahblah> registry.ci.openshift.org
```

> **Note**: Ensure your token is valid before proceeding.

### 2. Build the Marketplace Operator Docker Image
Now, you need to build the marketplace operator for ARM64 architecture:

```bash
podman build --arch arm64 -t localhost/marketplace-operator:latest -f Dockerfile
```

This will create a Docker image tagged as `localhost/marketplace-operator:latest`.

### 3. Save the Docker Image as a TAR File
Export the Docker image to a `.tar` file so it can be loaded into your `kind` cluster:

```bash
podman save -o marketplace-operator.tar localhost/marketplace-operator:latest
```

### 4. Load the Image into the Kind Cluster
Use `kind` to load the Docker image into your cluster named `catalogd`:

```bash
kind load image-archive marketplace-operator.tar --name=catalogd
```

### 5. Apply the Necessary Resources
Finally, apply the resources to the cluster using the following script:

```bash
hack/kind-apply.sh
```

This script will configure your local `kind` cluster enough to manage `OperatorHub` and `CatalogSource` objects.

> **Note**: This is a quick and dirty setup for local testing and development purposes.

35 changes: 35 additions & 0 deletions hack/kind-apply.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# Apply the CRD from GitHub first
kubectl apply -f https://raw.githubusercontent.com/openshift/api/600991d550ac9ee3afbfe994cf0889bf9805a3f5/config/v1/0000_03_marketplace-operator_01_operatorhub.crd.yaml

# Apply the CatalogSource CRD from GitHub
kubectl apply -f https://raw.githubusercontent.com/operator-framework/operator-lifecycle-manager/b31bd89a23d597ca440024458d0099a273642f8c/deploy/upstream/quickstart/crds.yaml

# Apply the first set of manifest files
kubectl apply -f manifests/0000_03_marketplace-operator_02_operatorhub.cr.yaml
kubectl apply -f manifests/01_namespace.yaml
kubectl apply -f manifests/04_service_account.yaml
kubectl apply -f manifests/05_role.yaml
kubectl apply -f manifests/06_role_binding.yaml
kubectl apply -f manifests/07_configmap.yaml
kubectl apply -f manifests/08_service.yaml

# Save the localhost image to a tar file and load it into the kind cluster
#echo "Saving the image as a tarball and loading it into kind cluster..."
#podman save -o marketplace-operator.tar localhost/marketplace-operator:latest
#kind load image-archive marketplace-operator.tar

# Apply the 09_operator.yaml with modifications on the fly (using localhost image)
yq eval '
del(.spec.template.spec.nodeSelector) |
del(.spec.template.spec.tolerations[] | select(.key == "node-role.kubernetes.io/master")) |
del(.spec.template.spec.containers[].volumeMounts[] | select(.name == "marketplace-operator-metrics")) |
del(.spec.template.spec.volumes[] | select(.name == "marketplace-operator-metrics")) |
del(.spec.template.spec.containers[].args[] | select(. == "-tls-cert")) |
del(.spec.template.spec.containers[].args[] | select(. == "/var/run/secrets/serving-cert/tls.crt")) |
del(.spec.template.spec.containers[].args[] | select(. == "-tls-key")) |
del(.spec.template.spec.containers[].args[] | select(. == "/var/run/secrets/serving-cert/tls.key")) |
del(.spec.template.spec.securityContext.runAsNonRoot) |
.spec.template.spec.containers[0].image = "localhost/marketplace-operator:latest"
' manifests/09_operator.yaml | kubectl apply -f -