Skip to content

Commit

Permalink
Merge pull request #1 from Theog75/v0.1.0
Browse files Browse the repository at this point in the history
readme
  • Loading branch information
Theog75 authored Dec 15, 2020
2 parents faf06eb + 7c5afe2 commit 8c72ef6
Show file tree
Hide file tree
Showing 4 changed files with 11,141 additions and 5 deletions.
30 changes: 30 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# Chaoskube Operator

The Chaoskube operator allows developers to consume a chaoskube object into their environment on top of Kubernetes. the operator will deploy a chaoskube instance in the relevant namespace along with the requested configuration as listed in the Chaoskube object request (CR) yaml. for example:

```
apiVersion: cache.redhat.com/v1alpha1
kind: Chaoskube
metadata:
name: chaoskube-nightly
spec:
# Add fields here
size: 1
args:
- --interval=1m
- --namespaces=sosivio-test
- --minimum-age=5m
- --no-dry-run
```

The above example will instantiate a chaoskube instance in the chaoskube-nightly namespace which will terminate a random pod every 1 minute with a minimum pod age of 5 minutes.

[All Chaoskube configurations](https://github.com/linki/chaoskube) can be applied as args in the CR above to configure chaoskube for each namespace (or possibly several of them running in a namespace) individually.

## deploying the Operator

1. clone this git repo
3. run the build.sh script as cluster-admin



## initialize the sdk:
```
operator-sdk init --domain=redhat.com --repo=chaosoperator
Expand Down
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ kind: Kustomization
images:
- name: controller
newName: docker.rct.co.il/chaoskube
newTag: v0.2.7
newTag: v0.2.13
13 changes: 9 additions & 4 deletions controllers/chaoskube_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ package controllers

import (
"context"
"fmt"
"reflect"
"strings"

"github.com/go-logr/logr"

// v1 "k8s.io/api/apps/v1"

rbacv1 "k8s.io/api/rbac/v1"
"k8s.io/api/rbac/v1beta1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -72,10 +75,11 @@ func (r *ChaoskubeReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
return ctrl.Result{}, err
}

foundrb := &v1beta1.ClusterRoleBinding{}
errrb := r.Get(ctx, types.NamespacedName{Name: chaoskube.Name + "-" + chaoskube.Namespace + "-chaos", Namespace: chaoskube.Namespace}, foundrb)
foundrb := &rbacv1.ClusterRoleBinding{}
errrb := r.Get(ctx, types.NamespacedName{Name: chaoskube.Name + "-" + chaoskube.Namespace + "-chaos", Namespace: ""}, foundrb)
// errrb := r.Get(ctx, types.NamespacedName{Name: chaoskube.Name, Namespace: chaoskube.Namespace}, foundrb)
if errrb != nil && errors.IsNotFound(errrb) {
fmt.Println(errrb.Error(), "----------------")
//rolebindingForChaoskube m.Name + "-" + m.Namespace + "-chaos"
rol := r.rolebindingForChaoskube(chaoskube)
log.Info("Creating a new ClusterRoleBinding", "ClusterRoleBinding.Namespace", rol.Namespace, "ClusterRoleBinding.Name", rol.Name)
Expand All @@ -84,8 +88,9 @@ func (r *ChaoskubeReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
log.Error(err, "Failed to create new ClusterRoleBinding", "ClusterRoleBinding.Namespace", rol.Namespace, "ClusterRoleBinding.Name", rol.Name)
return ctrl.Result{}, err
}
} else {
log.Info("Error creating CluesterRoleBinding ", errrb)
// } else {
// log.Info("Failed to get ClusterRoleBinding")
// return ctrl.Result{}, errrb
}

// Check if the deployment already exists, if not create a new one
Expand Down
Loading

0 comments on commit 8c72ef6

Please sign in to comment.