From 73f7e3a1d29808a7dbc1b86505df37a8c30485fc Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Wed, 8 Nov 2023 23:40:39 +0100 Subject: [PATCH] fix install command --- README.md | 6 +- cmd/install.go | 68 ++++++++++++++++++++--- doc/generate-gateway-api-httproute.md | 4 +- doc/generate-istio-authorizationpolicy.md | 30 ---------- doc/generate-istio-virtualservice.md | 34 ------------ doc/generate-kuadrant-authconfig.md | 29 ---------- doc/install.md | 19 ++----- doc/uninstall.md | 2 +- 8 files changed, 68 insertions(+), 124 deletions(-) delete mode 100644 doc/generate-istio-authorizationpolicy.md delete mode 100644 doc/generate-istio-virtualservice.md delete mode 100644 doc/generate-kuadrant-authconfig.md diff --git a/README.md b/README.md index 40e5c9d..a96fba9 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,7 @@ go install github.com/kuadrant/kuadrantctl@latest ## Commands * [Install Kuadrant](doc/install.md) * [Uninstall Kuadrant](doc/uninstall.md) -* [Generate Istio virtualservice objects](doc/generate-istio-virtualservice.md) -* [Generate Istio authenticationpolicy objects](doc/generate-istio-authorizationpolicy.md) -* [Generate kuadrat authconfig objects](doc/generate-kuadrant-authconfig.md) -* [Generate Gateway API HTTPRoute objects](doc/generate-gateway-api-httproute.md) - +* [Generate Gateway API HTTPRoute objects from OpenAPI 3](doc/generate-gateway-api-httproute.md) ## Contributing The [Development guide](doc/development.md) describes how to build the kuadrantctl CLI and how to test your changes before submitting a patch or opening a PR. diff --git a/cmd/install.go b/cmd/install.go index 31b00ec..9d1741b 100644 --- a/cmd/install.go +++ b/cmd/install.go @@ -36,8 +36,8 @@ const ( func installCommand() *cobra.Command { installCmd := &cobra.Command{ Use: "install", - Short: "Applies a kuadrant manifest bundle, installing or reconfiguring kuadrant on a cluster", - Long: "The install command applies kuadrant manifest bundle and applies it to a cluster.", + Short: "Install Kuadrant", + Long: "The install command installs kuadrant in a OLM powered cluster", PersistentPreRunE: func(cmd *cobra.Command, args []string) error { // Required to have controller-runtim config package read the kubeconfig arg err := flag.CommandLine.Parse([]string{"-kubeconfig", installKubeConfig}) @@ -88,11 +88,6 @@ func installRun(cmd *cobra.Command, args []string) error { return err } - err = waitForDeployments(k8sClient) - if err != nil { - return err - } - return nil } @@ -119,7 +114,7 @@ func waitForDeployments(k8sClient client.Client) error { } func deployKuadrantOperator(k8sClient client.Client) error { - logf.Log.Info("Deploying kuadrant operator", "version", KUADRANT_OPERATOR_VERSION) + logf.Log.Info("Installing kuadrant operator", "version", KUADRANT_OPERATOR_VERSION) //apiVersion: operators.coreos.com/v1alpha1 //kind: Subscription @@ -149,6 +144,61 @@ func deployKuadrantOperator(k8sClient client.Client) error { return err } + var installPlanKey client.ObjectKey + + // Wait for the install process to be completed + logf.Log.Info("Waiting for the kuadrant operator installation") + err = wait.Poll(time.Second*2, time.Second*20, func() (bool, error) { + existingSubs := &operators.Subscription{} + err := k8sClient.Get(context.Background(), client.ObjectKeyFromObject(subs), existingSubs) + if err != nil { + if apierrors.IsNotFound(err) { + logf.Log.Info("Subscription not available", "name", client.ObjectKeyFromObject(subs)) + return false, nil + } + return false, err + } + + if existingSubs.Status.Install == nil || existingSubs.Status.Install.Name == "" { + return false, nil + } + + installPlanKey = client.ObjectKey{ + Name: existingSubs.Status.Install.Name, + Namespace: subs.Namespace, + } + + return true, nil + }) + + if err != nil { + return err + } + + logf.Log.Info("Waiting for the install plan", "name", installPlanKey) + err = wait.Poll(time.Second*5, time.Minute*2, func() (bool, error) { + ip := &operators.InstallPlan{} + err := k8sClient.Get(context.Background(), installPlanKey, ip) + if err != nil { + if apierrors.IsNotFound(err) { + logf.Log.Info("Install plan not available", "name", installPlanKey) + return false, nil + } + return false, err + } + + if ip.Status.Phase != operators.InstallPlanPhaseComplete { + logf.Log.Info("Install plan not ready", "phase", ip.Status.Phase) + return false, nil + } + + return true, nil + }) + + if err != nil { + return err + } + return nil } @@ -164,7 +214,7 @@ func deployKuadrant(k8sClient client.Client) error { return err } - return nil + return waitForDeployments(k8sClient) } func createNamespace(k8sClient client.Client) error { diff --git a/doc/generate-gateway-api-httproute.md b/doc/generate-gateway-api-httproute.md index 95a7ba9..be15a4d 100644 --- a/doc/generate-gateway-api-httproute.md +++ b/doc/generate-gateway-api-httproute.md @@ -1,4 +1,4 @@ -## Generate Gateway API HTTPRoute object +## Generate Gateway API HTTPRoute object from OpenAPI 3 The `kuadrantctl generate gatewayapi httproute` command generates an [Gateway API HTTPRoute](https://gateway-api.sigs.k8s.io/v1alpha2/guides/http-routing/) from your [OpenAPI Specification (OAS) 3.x](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md) and kubernetes service information. @@ -32,4 +32,4 @@ Global Flags: -v, --verbose verbose output ``` -> Under the example folder there are examples of OAS 3 that can be used to generate the resources \ No newline at end of file +> Under the example folder there are examples of OAS 3 that can be used to generate the resources diff --git a/doc/generate-istio-authorizationpolicy.md b/doc/generate-istio-authorizationpolicy.md deleted file mode 100644 index 8fc90ae..0000000 --- a/doc/generate-istio-authorizationpolicy.md +++ /dev/null @@ -1,30 +0,0 @@ -## Generate Istio AuthorizationPolicy objects - -The `kuadrantctl generate istio authorizationpolicy` command generates an [Istio AuthorizationPolicy](https://istio.io/latest/docs/reference/config/security/authorization-policy/) -from your [OpenAPI Specification (OAS) 3.x](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md) and kubernetes service information. - -### OpenAPI specification - -OpenAPI document resource can be provided by one of the following channels: -* Filename in the available path. -* URL format (supported schemes are HTTP and HTTPS). The CLI will try to download from the given address. -* Read from stdin standard input stream. - -### Usage : - -```shell -$ kuadrantctl generate istio authorizationpolicy -h -Generate Istio AuthorizationPolicy - -Usage: - kuadrantctl generate istio authorizationpolicy [flags] - -Flags: - --gateway-label strings Gateway label (required) - -h, --help help for authorizationpolicy - --oas string /path/to/file.[json|yaml|yml] OR http[s]://domain/resource/path.[json|yaml|yml] OR - (required) - --public-host string The address used by a client when attempting to connect to a service (required) - -Global Flags: - -v, --verbose verbose output -``` diff --git a/doc/generate-istio-virtualservice.md b/doc/generate-istio-virtualservice.md deleted file mode 100644 index 5e564bc..0000000 --- a/doc/generate-istio-virtualservice.md +++ /dev/null @@ -1,34 +0,0 @@ -## Generate Istio VirtualService objects - -The `kuadrantctl generate istio virtualservice` command generates an [Istio VirtualService](https://istio.io/latest/docs/reference/config/networking/virtual-service/) -from your [OpenAPI Specification (OAS) 3.x](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md) and kubernetes service information. - -### OpenAPI specification - -OpenAPI document resource can be provided by one of the following channels: -* Filename in the available path. -* URL format (supported schemes are HTTP and HTTPS). The CLI will try to download from the given address. -* Read from stdin standard input stream. - -### Usage : - -```shell -$ kuadrantctl generate istio virtualservice -h -Generate Istio VirtualService from OpenAPI 3.x - -Usage: - kuadrantctl generate istio virtualservice [flags] - -Flags: - --gateway strings Gateways (required) - -h, --help help for virtualservice - --oas string /path/to/file.[json|yaml|yml] OR http[s]://domain/resource/path.[json|yaml|yml] OR - (required) - --path-prefix-match Path match type (defaults to exact match type) - --public-host string The address used by a client when attempting to connect to a service (required) - --service-name string Service name (required) - --service-namespace string Service namespace (required) - -p, --service-port int32 Service port (default 80) - -Global Flags: - -v, --verbose verbose output -``` diff --git a/doc/generate-kuadrant-authconfig.md b/doc/generate-kuadrant-authconfig.md deleted file mode 100644 index 6000cf9..0000000 --- a/doc/generate-kuadrant-authconfig.md +++ /dev/null @@ -1,29 +0,0 @@ -## Generate Kuadrant AuthConfig objects - -The `kuadrantctl generate kuadrant authconfig` command generates an [Authorino AuthConfig](https://github.com/Kuadrant/authorino/blob/v0.7.0/docs/architecture.md#the-authorino-authconfig-custom-resource-definition-crd) -from your [OpenAPI Specification (OAS) 3.x](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md) and kubernetes service information. - -### OpenAPI specification - -OpenAPI document resource can be provided by one of the following channels: -* Filename in the available path. -* URL format (supported schemes are HTTP and HTTPS). The CLI will try to download from the given address. -* Read from stdin standard input stream. - -### Usage : - -```shell -$ kuadrantctl generate kuadrant authconfig -h -Generate kuadrant authconfig from OpenAPI 3.x - -Usage: - kuadrantctl generate kuadrant authconfig [flags] - -Flags: - -h, --help help for authconfig - --oas string /path/to/file.[json|yaml|yml] OR http[s]://domain/resource/path.[json|yaml|yml] OR - (required) - --public-host string The address used by a client when attempting to connect to a service (required) - -Global Flags: - -v, --verbose verbose output -``` diff --git a/doc/install.md b/doc/install.md index a482017..23e57dc 100644 --- a/doc/install.md +++ b/doc/install.md @@ -1,24 +1,15 @@ ## Install Kuadrant -The install command applies kuadrant manifest bundle and applies it to a cluster. +The install command installs kuadrant in a OLM powered cluster. -Components being installed: - -* `kuadrant-system` namespace -* [istio](https://istio.io/) 1.12.1 -* Authentication/Authorization Service - * [Authorino Operator](https://github.com/kuadrant/authorino-operator) v0.1.0 - * [Authorino](https://github.com/Kuadrant/authorino) v0.7.0 -* Rate Limit Service - * [Limitador Operator](https://github.com/kuadrant/limitador-operator) v0.2.0 - * [Limitador](https://github.com/kuadrant/limitador) v0.4.0 -* [kuadrant controller](https://github.com/Kuadrant/kuadrant-controller) v0.2.0 +Using [Kuadrant Operator v0.4.1](https://github.com/Kuadrant/kuadrant-operator/releases/tag/v0.4.1) +as the installation procedure. ### Usage : ```shell $ kuadrantctl install --help -The install command applies kuadrant manifest bundle and applies it to a cluster. +The install command installs kuadrant in a OLM powered cluster Usage: kuadrantctl install [flags] @@ -28,5 +19,5 @@ Flags: --kubeconfig string Kubernetes configuration file Global Flags: - --config string config file (default is $HOME/.kuadrantctl.yaml) + -v, --verbose verbose output ``` diff --git a/doc/uninstall.md b/doc/uninstall.md index 40e3190..3f9a668 100644 --- a/doc/uninstall.md +++ b/doc/uninstall.md @@ -4,7 +4,7 @@ ```shell $ kuadrantctl uninstall -h -The uninstall command removes kuadrant manifest bundle from the cluster. +The uninstall command removes kuadrant from the cluster. Usage: kuadrantctl uninstall [flags]