Skip to content

Commit

Permalink
✨ Add Ingress overlay to access Catalog contents outside of the clu…
Browse files Browse the repository at this point in the history
…ster (#209)

* Add Ingress overlay to access `Catalog` contents outside of the cluster

Signed-off-by: Rashmi Gottipati <chowdary.grashmi@gmail.com>

* Address review feedback

Signed-off-by: Rashmi Gottipati <chowdary.grashmi@gmail.com>

* Address review feedback #1

Signed-off-by: Rashmi Gottipati <chowdary.grashmi@gmail.com>

* Address feedback #2

Signed-off-by: Rashmi Gottipati <chowdary.grashmi@gmail.com>

---------

Signed-off-by: Rashmi Gottipati <chowdary.grashmi@gmail.com>
  • Loading branch information
rashmigottipati committed Nov 10, 2023
1 parent ca0bc34 commit 3dc8131
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
7 changes: 7 additions & 0 deletions config/nginx-ingress/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../default
- resources/nginx_ingress.yaml
- https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
17 changes: 17 additions & 0 deletions config/nginx-ingress/resources/nginx_ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: catalogd-ingress
namespace: catalogd-system
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: catalogd-catalogserver
port:
number: 80
78 changes: 78 additions & 0 deletions docs/fetching-catalog-contents.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,81 @@ An example `curl` request that assumes the port-forwarding is mapped to port 808
```sh
curl http://localhost:8080/catalogs/operatorhubio/all.json
```

# Fetching `Catalog` contents from the `Catalogd` Service outside of the cluster

This section outlines a way of exposing the `Catalogd` Service's endpoints outside the cluster and then accessing the catalog contents using `Ingress`. We will be using `Ingress NGINX` Controller for the sake of this example but you are welcome to use the `Ingress` Controller of your choice.

**Prerequisites**

- [Install kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)
- Assuming `kind` is installed, create a `kind` cluster with `extraPortMappings` and `node-labels` as shown in the [kind documentation](https://kind.sigs.k8s.io/docs/user/ingress/)
- Install latest version of `Catalogd` by navigating to the [releases page](https://github.com/operator-framework/catalogd/releases) and following the install instructions included in the release you want to install.
- Install the `Ingress NGINX` Controller by running the below command:

```sh
$ kubectl apply -k https://github.com/operator-framework/catalogd/tree/main/config/nginx-ingress
```
By running that above command, the `Ingress` Controller is installed. Along with it, the `Ingress` Resource will be applied automatically as well, thereby creating an `Ingress` Object on the cluster.

1. Once the prerequisites are satisfied, create a `Catalog` object that points to the OperatorHub Community catalog by running the following command:

```sh
$ kubectl apply -f - << EOF
apiVersion: catalogd.operatorframework.io/v1alpha1
kind: Catalog
metadata:
name: operatorhubio
spec:
source:
type: image
image:
ref: quay.io/operatorhubio/catalog:latest
EOF
```
1. Before proceeding further, let's verify that the `Catalog` object was created successfully by running the below command:
```sh
$ kubectl describe catalog/operatorhubio
```
1. At this point the `Catalog` object exists and `Ingress` controller is ready to process requests. The sample `Ingress` Resource that was created during Step 4 of Prerequisites is shown as below:
```yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: catalogd-nginx-ingress
namespace: catalogd-system
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: catalogd-catalogserver
port:
number: 80
```
Let's verify that the `Ingress` object got created successfully from the sample by running the following command:
```sh
$ kubectl describe ingress/catalogd-ingress -n catalogd-system
```
1. Run the below example `curl` request to retrieve all of the catalog contents:
```sh
$ curl http://<address>/catalogs/operatorhubio/all.json
```
To obtain `address` of the ingress object, you can run the below command and look for the value in the `ADDRESS` field from output:
```sh
$ kubectl -n catalogd-system get ingress
```
You can further use the `curl` commands outlined in the [Catalogd README](https://github.com/operator-framework/catalogd/blob/main/README.md) to filter out the JSON content by list of bundles, channels & packages.

0 comments on commit 3dc8131

Please sign in to comment.