Skip to content

Commit

Permalink
adding create configmap permission in subscriber manifest and few ref…
Browse files Browse the repository at this point in the history
…actors in subscriber (#2248)

* adding create configmap permission and few refactors in subscriber

Signed-off-by: Raj Babu Das <[email protected]>

* adding create configmap permission and few refactors in subscriber

Signed-off-by: Raj Babu Das <[email protected]>
  • Loading branch information
imrajdas authored Oct 13, 2020
1 parent a5e989f commit 183ff31
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions litmus-portal/cluster-agents/subscriber/pkg/k8s/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
)

// IsClusterConfirmed checks if the config map with "is_cluster_confirmed" is true or not.
func IsClusterConfirmed(clusterData map[string]string) (bool, string, error) {
func IsClusterConfirmed() (bool, string, error) {
clientset, err := GetGenericK8sClient()
if err != nil {
return false, "", err
Expand Down Expand Up @@ -75,7 +75,7 @@ func ClusterRegister(clusterData map[string]string) (bool, error) {

_, err = clientset.CoreV1().ConfigMaps(AgentNamespace).Create(&newConfigMap)
if err != nil {
return false, nil
return false, err
}

log.Println("Configmap created")
Expand Down
10 changes: 6 additions & 4 deletions litmus-portal/cluster-agents/subscriber/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ func init() {
k8s.KubeConfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
flag.Parse()

var isConfirmed bool
isConfirmed, newKey, err = k8s.IsClusterConfirmed(clusterData)
isConfirmed, newKey, err := k8s.IsClusterConfirmed()
if err != nil {
log.Fatal(err)
}
Expand All @@ -51,9 +50,12 @@ func init() {
}

if responseInterface.Data.ClusterConfirm.IsClusterConfirmed == true {
log.Println("cluster confirmed")
clusterData["KEY"] = responseInterface.Data.ClusterConfirm.NewClusterKey
k8s.ClusterRegister(clusterData)
_, err = k8s.ClusterRegister(clusterData)
if err != nil {
log.Fatal(err)
}
log.Println("cluster confirmed")
} else {
log.Fatal("Cluster not confirmed")
}
Expand Down
2 changes: 2 additions & 0 deletions litmus-portal/graphql-server/manifests/cluster-subscriber.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,7 @@ metadata:
name: argo-chaos
namespace: #{AGENT-NAMESPACE}
---
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
Expand Down Expand Up @@ -1084,6 +1085,7 @@ rules:
- configmaps
verbs:
- get
- create
- apiGroups:
- litmuschaos.io
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ rules:
- configmaps
verbs:
- get
- create
- apiGroups:
- litmuschaos.io
resources:
Expand Down

0 comments on commit 183ff31

Please sign in to comment.