-
Notifications
You must be signed in to change notification settings - Fork 111
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
bentito
wants to merge
1
commit into
operator-framework:master
Choose a base branch
from
bentito:hacking_to_clustercatalogs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
apiVersion: olm.operatorframework.io/v1alpha1 | ||
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 - |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?