Skip to content

Commit

Permalink
Update with minor fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Ravi Hari <[email protected]>
  • Loading branch information
RaviHari committed Dec 22, 2020
1 parent 3650927 commit 699fe8e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ With the Cluster/Namespace level, healthchecks can be run in any namespace provi
The `level` in the `HealthCheck` spec defines at which level it runs; it can be either `Namespace` or `Cluster`.
When `level` is set to `Namespace`, Active-Monitor will create a `ServiceAccount` in the namespace as defined in the workflow spec, it will also create the `Role` and `RoleBinding` with namespace level permissions so that the `HealthChecks` in a namespace can be performed.

When the `level` is set to be cluster the Active-Monitor will create a serviceaccount in the namespace as defined in the workflow spec, it will also create the clusterrole and clusterrolebinding with cluster level permissions so that the healthchecks in a cluster scope can be performed.
When the `level` is set to be `Cluster` the Active-Monitor will create a serviceaccount in the namespace as defined in the workflow spec, it will also create the clusterrole and clusterrolebinding with cluster level permissions so that the healthchecks in a cluster scope can be performed.

## Dependencies
* Kubernetes command line tool (kubectl)
Expand Down
12 changes: 6 additions & 6 deletions controllers/healthcheck_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ func (r *HealthCheckReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)
if err != nil {
log.Error(err, "Error creating NamespaceRole for the workflow")
}
log.Info("Successfully Created", "ClusterRole", nsrole)
log.Info("Successfully Created", "NamespaceRole", nsrole)

nsrb, err := r.CreateClusterRoleBinding(r.kubeclient, amnsrolebinding, nsrole, sa, wfNamespace)
nsrb, err := r.CreateNameSpaceRoleBinding(r.kubeclient, amnsrolebinding, nsrole, sa, wfNamespace)
if err != nil {
log.Error(err, "Error creating NamespaceRoleBinding for the workflow")
}
Expand Down Expand Up @@ -374,7 +374,7 @@ func (r *HealthCheckReconciler) CreateServiceAccount(clientset kubernetes.Interf
// create a ClusterRole account
func (r *HealthCheckReconciler) createClusterRole(clientset kubernetes.Interface, clusterrole string) (string, error) {
clusrole, err := clientset.RbacV1().ClusterRoles().Get(clusterrole, metav1.GetOptions{})
// If a clusrole already exists just re-use it
// If a Cluster Role already exists just re-use it
if err == nil {
return clusrole.Name, nil
}
Expand Down Expand Up @@ -402,7 +402,7 @@ func (r *HealthCheckReconciler) createClusterRole(clientset kubernetes.Interface
// Create NamespaceRole
func (r *HealthCheckReconciler) CreateNameSpaceRole(clientset kubernetes.Interface, nsrole string, namespace string) (string, error) {
nsrole1, err := clientset.RbacV1().Roles(namespace).Get(nsrole, metav1.GetOptions{})
// If a clusrole already exists just re-use it
// If a Namespace Role already exists just re-use it
if err == nil {
return nsrole1.Name, nil
}
Expand All @@ -427,7 +427,7 @@ func (r *HealthCheckReconciler) CreateNameSpaceRole(clientset kubernetes.Interfa
}

// Create a NamespaceRoleBinding
func (r *HealthCheckReconciler) CreateNameSpaceRoleBinding(clientset kubernetes.Interface, rolebinding string, namespace string, serviceaccount string, nsrole string) (string, error) {
func (r *HealthCheckReconciler) CreateNameSpaceRoleBinding(clientset kubernetes.Interface, rolebinding string, nsrole string, serviceaccount string, namespace string) (string, error) {
nsrb, err := clientset.RbacV1().RoleBindings(namespace).Get(rolebinding, metav1.GetOptions{})
// If a Namespace RoleBinding already exists just re-use it
if err == nil {
Expand Down Expand Up @@ -460,7 +460,7 @@ func (r *HealthCheckReconciler) CreateNameSpaceRoleBinding(clientset kubernetes.
// Create a ClusterRoleBinding
func (r *HealthCheckReconciler) CreateClusterRoleBinding(clientset kubernetes.Interface, clusterrolebinding string, clusterrole string, serviceaccount string, namespace string) (string, error) {
crb, err := clientset.RbacV1().ClusterRoleBindings().Get(clusterrolebinding, metav1.GetOptions{})
// If a Namespace RoleBinding already exists just re-use it
// If a Cluster RoleBinding already exists just re-use it
if err == nil {
return crb.Name, nil
}
Expand Down

0 comments on commit 699fe8e

Please sign in to comment.