From d481d484a03bff3a802031da896eac57d213b373 Mon Sep 17 00:00:00 2001 From: Rashmi Gottipati Date: Wed, 1 Nov 2023 11:21:22 -0400 Subject: [PATCH 1/4] Add Ingress overlay to access `Catalog` contents outside of the cluster Signed-off-by: Rashmi Gottipati --- docs/fetching-catalog-contents.md | 111 ++++++++++++++++++ .../overlays/nginx-ingress/kustomization.yaml | 4 + .../resources/nginx_ingress.yaml | 22 ++++ 3 files changed, 137 insertions(+) create mode 100644 manifests/overlays/nginx-ingress/kustomization.yaml create mode 100644 manifests/overlays/nginx-ingress/resources/nginx_ingress.yaml diff --git a/docs/fetching-catalog-contents.md b/docs/fetching-catalog-contents.md index ba19320d..52f5b814 100644 --- a/docs/fetching-catalog-contents.md +++ b/docs/fetching-catalog-contents.md @@ -57,3 +57,114 @@ 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`. + +**Prerequisites** +- [Install kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation) +- 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. + +1. Create a `kind` cluster with `extraPortMappings` and `node-labels` by running the below command: + + ```sh + cat < Date: Thu, 9 Nov 2023 12:36:13 -0500 Subject: [PATCH 2/4] Address review feedback Signed-off-by: Rashmi Gottipati --- config/nginx-ingress/kustomization.yaml | 7 ++ .../resources/nginx_ingress.yaml | 5 - docs/fetching-catalog-contents.md | 117 ++++++------------ .../overlays/nginx-ingress/kustomization.yaml | 4 - 4 files changed, 48 insertions(+), 85 deletions(-) create mode 100644 config/nginx-ingress/kustomization.yaml rename {manifests/overlays => config}/nginx-ingress/resources/nginx_ingress.yaml (70%) delete mode 100644 manifests/overlays/nginx-ingress/kustomization.yaml 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/manifests/overlays/nginx-ingress/resources/nginx_ingress.yaml b/config/nginx-ingress/resources/nginx_ingress.yaml similarity index 70% rename from manifests/overlays/nginx-ingress/resources/nginx_ingress.yaml rename to config/nginx-ingress/resources/nginx_ingress.yaml index e29a559f..2154bc1a 100644 --- a/manifests/overlays/nginx-ingress/resources/nginx_ingress.yaml +++ b/config/nginx-ingress/resources/nginx_ingress.yaml @@ -3,10 +3,6 @@ kind: Ingress metadata: name: catalogd-nginx-ingress namespace: catalogd-system - annotations: - nginx.org/proxy-connect-timeout: "30s" - nginx.org/proxy-read-timeout: "20s" - nginx.org/client-max-body-size: "4m" spec: ingressClassName: nginx rules: @@ -19,4 +15,3 @@ spec: name: catalogd-catalogserver port: number: 80 - diff --git a/docs/fetching-catalog-contents.md b/docs/fetching-catalog-contents.md index 52f5b814..8fd008e1 100644 --- a/docs/fetching-catalog-contents.md +++ b/docs/fetching-catalog-contents.md @@ -63,37 +63,16 @@ curl http://localhost:8080/catalogs/operatorhubio/all.json This section outlines a way of exposing the `Catalogd` Service's endpoints outside the cluster and then accessing the catalog contents using `Ingress`. **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 + ``` -1. Create a `kind` cluster with `extraPortMappings` and `node-labels` by running the below command: - - ```sh - cat </catalogs/operatorhubio/all.json ``` - -1. Wait until `Ingress` is ready by running the below `kubectl wait` command: - - ```sh - $ kubectl wait --namespace ingress-nginx \ - --for=condition=ready pod \ - --selector=app.kubernetes.io/component=controller \ - --timeout=90s - ``` - -1. At this point the `Ingress` controller is ready to process requests. Let's create an `Ingress` object by running the below command: - - ```sh - $ kubectl apply -f https://github.com/operator-framework/catalogd/tree/main/manifests/overlays/nginx-ingress/resources/nginx_ingress.yaml - - Sample `Ingress` Resource: - ```yaml - apiVersion: networking.k8s.io/v1 - kind: Ingress - metadata: - name: catalogd-nginx-ingress - namespace: catalogd-system - annotations: - nginx.org/proxy-connect-timeout: "30s" - nginx.org/proxy-read-timeout: "20s" - nginx.org/client-max-body-size: "4m" - spec: - ingressClassName: nginx - rules: - - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: catalogd-catalogserver - port: - number: 80 - ``` - - -1. Once the `Ingress` object has been successfully created, issue a `curl` request. Below is an example `curl` request to retrieve all of the catalog contents: - + + 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 - $ curl http://localhost/catalogs/operatorhubio/all.json + $ 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. diff --git a/manifests/overlays/nginx-ingress/kustomization.yaml b/manifests/overlays/nginx-ingress/kustomization.yaml deleted file mode 100644 index 570ad9c3..00000000 --- a/manifests/overlays/nginx-ingress/kustomization.yaml +++ /dev/null @@ -1,4 +0,0 @@ -resources: -- ../default -- resources/nginx_ingress.yaml - From 9434287c9f80e582ef17074ad4070c11409da5a0 Mon Sep 17 00:00:00 2001 From: Rashmi Gottipati Date: Thu, 9 Nov 2023 14:13:52 -0500 Subject: [PATCH 3/4] Address review feedback #1 Signed-off-by: Rashmi Gottipati --- config/nginx-ingress/resources/nginx_ingress.yaml | 2 +- docs/fetching-catalog-contents.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/nginx-ingress/resources/nginx_ingress.yaml b/config/nginx-ingress/resources/nginx_ingress.yaml index 2154bc1a..79e1bc0d 100644 --- a/config/nginx-ingress/resources/nginx_ingress.yaml +++ b/config/nginx-ingress/resources/nginx_ingress.yaml @@ -1,7 +1,7 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: catalogd-nginx-ingress + name: catalogd-ingress namespace: catalogd-system spec: ingressClassName: nginx diff --git a/docs/fetching-catalog-contents.md b/docs/fetching-catalog-contents.md index 8fd008e1..62aba18f 100644 --- a/docs/fetching-catalog-contents.md +++ b/docs/fetching-catalog-contents.md @@ -68,9 +68,11 @@ This section outlines a way of exposing the `Catalogd` Service's endpoints outsi - 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 tha 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: @@ -118,7 +120,7 @@ This section outlines a way of exposing the `Catalogd` Service's endpoints outsi Let's verify that the `Ingress` object got created successfully from the sample by running the following command: ```sh - $ kubectl describe ingress/catalogd-nginx-ingress -n catalogd-system + $ kubectl describe ingress/catalogd-ingress -n catalogd-system ``` 1. Run the below example `curl` request to retrieve all of the catalog contents: From 9d68719726fcae9167a324ad190a1f8009e08e3e Mon Sep 17 00:00:00 2001 From: Rashmi Gottipati Date: Thu, 9 Nov 2023 15:26:57 -0500 Subject: [PATCH 4/4] Address feedback #2 Signed-off-by: Rashmi Gottipati --- docs/fetching-catalog-contents.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/fetching-catalog-contents.md b/docs/fetching-catalog-contents.md index 62aba18f..b6e96952 100644 --- a/docs/fetching-catalog-contents.md +++ b/docs/fetching-catalog-contents.md @@ -60,7 +60,7 @@ 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`. +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** @@ -72,7 +72,7 @@ This section outlines a way of exposing the `Catalogd` Service's endpoints outsi ```sh $ kubectl apply -k https://github.com/operator-framework/catalogd/tree/main/config/nginx-ingress ``` - By running tha 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. + 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: