diff --git a/config/nginx-ingress/kustomization.yaml b/config/nginx-ingress/kustomization.yaml new file mode 100644 index 00000000..7bdced5d --- /dev/null +++ b/config/nginx-ingress/kustomization.yaml @@ -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 diff --git a/config/nginx-ingress/resources/nginx_ingress.yaml b/config/nginx-ingress/resources/nginx_ingress.yaml new file mode 100644 index 00000000..79e1bc0d --- /dev/null +++ b/config/nginx-ingress/resources/nginx_ingress.yaml @@ -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 diff --git a/docs/fetching-catalog-contents.md b/docs/fetching-catalog-contents.md index ba19320d..b6e96952 100644 --- a/docs/fetching-catalog-contents.md +++ b/docs/fetching-catalog-contents.md @@ -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://
/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.