diff --git a/README.md b/README.md index 135dd25..fe72ef3 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,9 @@ # Hydra-maester -This project contains a Kubernetes controller that uses Custom Resources to manage Hydra Oauth2 clients. -ORY Hydra Maester watches for instances of `oauth2clients.oathkeeper.ory.sh/v1alpha1` and creates, updates, or deletes corresponding OAuth2 clients by communicating with ORY Hydra API. +This project contains a Kubernetes controller that uses Custom Resources (CR) to manage Hydra Oauth2 clients. ORY Hydra Maester watches for instances of `oauth2clients.oathkeeper.ory.sh/v1alpha1` CR and creates, updates, or deletes corresponding OAuth2 clients by communicating with ORY Hydra's API. + +Visit Hydra-maester's [chart documentation](https://github.com/ory/k8s/blob/master/docs/helm/hydra-maester.md) and view a [sample OAuth2 client resource](./config/samples/hydra_v1alpha1_oauth2client.yaml) to learn more about the `oauth2clients.oathkeeper.ory.sh/v1alpha1` CR. The project is based on [Kubebuilder](https://github.com/kubernetes-sigs/kubebuilder). @@ -39,4 +40,11 @@ Take a look at [Design Readme](./docs/README.md). - `make install` to generate CRD file from go sources and install it on the cluster - `export HYDRA_URL={HYDRA_SERVICE_URL} && make run` to run the controller -To deploy the controller, edit the value of the ```--hydra-url``` argument in the [manager.yaml](config/manager/manager.yaml) file and run ```make deploy```. \ No newline at end of file +To deploy the controller, edit the value of the ```--hydra-url``` argument in the [manager.yaml](config/manager/manager.yaml) file and run ```make deploy```. + +### Command-line flags + +| Name | Required | Description | Default value | Example values | +|-----------------|----------|------------------------------|---------------|------------------------------------------------------| +| **hydra-url** | yes | ORY Hydra's service address | - | ` ory-hydra-admin.ory.svc.cluster.local` | +| **hydra-port** | no | ORY Hydra's service port | `4445` | `4445` | \ No newline at end of file diff --git a/controllers/oauth2client_controller.go b/controllers/oauth2client_controller.go index 74a2d89..310f66d 100644 --- a/controllers/oauth2client_controller.go +++ b/controllers/oauth2client_controller.go @@ -115,14 +115,16 @@ func (r *OAuth2ClientReconciler) registerOAuth2Client(ctx context.Context, clien }, } - err = r.Create(ctx, &clientSecret) - if err != nil { - return err - } - - client.Status.Secret = &clientSecret.Name client.Status.ClientID = created.ClientID client.Status.ObservedGeneration = client.Generation + + err = r.Create(ctx, &clientSecret) + if err != nil { + r.Log.Error(err, fmt.Sprintf("error creating secret for client %s/%s ", client.Name, client.Namespace), "oauth2client", "register") + } else { + client.Status.Secret = &clientSecret.Name + } + return r.Status().Update(ctx, client) }