Kuadrant / kuadrantctl

Kuadrant configuration command line utility
Apache License 2.0
6 stars 13 forks source link

kuadrantctl api apply command #23

Closed eguzki closed 2 years ago

eguzki commented 2 years ago

This PR removes existing api generate and api create commands and replaces them with a single api apply comamnd.

Removed commands were using and old version of the API CRD 0.0.1.pre and this API CRD was totally re-designed in this PR New API CRD.

Briefly, the API CRD v0.0.1pre contained data structures to define partially the OpenAPI spec, like operations, hosts and security scheme. The new API CRD includes upstream service refernce and either OpenAPI raw doc or HTTP path matching rules. An example to illustrate:

apiVersion: networking.kuadrant.io/v1beta1
kind: API 
metadata:
  name: myapi.mytag 
spec:
  mappings: 
    HTTPPathMatch: 
      type: Prefix
      value: /
  destination:
    schema: "http"
    serviceReference:
      name: dogs
      port: 80

The new kuadrantctl api apply command allows easily to create new and update (reconciliate) existing API v0.1.1 custom resources from a service reference and OpenAPI or HTTP match options.

The proposed usage:

$ kuadrantctl api apply -h
The apply command allows easily to create and update existing *kuadrant API* custom resources

Usage:
  kuadrantctl api apply [flags]

Flags:
      --api-name string          If not set, the name of the API can be matched with the service name
  -h, --help                     help for apply
      --kubeconfig string        Kubernetes configuration file
      --match-path string        Define a single specific path, prefix or regex (default "/")
      --match-path-type string   Specifies how to match against the matchpath value. Accepted values are Exact, Prefix and RegularExpression. Defaults to Prefix (default "Prefix")
  -n, --namespace string         Service namespace (required)
      --oas string               /path/to/file.[json|yaml|yml] OR http[s]://domain/resource/path.[json|yaml|yml] OR -
      --port string              Only required if there are multiple ports in the service. Either the Name of the port or the Number
      --scheme string            Either HTTP or HTTPS specifies how the kuadrant gateway will connect to this API (default "http")
      --service-name string      Service name (required)
      --tag string               A special tag used to distinguish this deployment between several instances of the API
      --to-stdout                Serialize the kuadrant API object in stdout instead of applying to the cluster

Global Flags:
      --config string   config file (default is $HOME/.kuadrantctl.yaml)
  -v, --verbose         verbose output