Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed cluster role binding for secrets to role binding on specific namespaces #527

Merged
merged 12 commits into from
Mar 15, 2024
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
apiVersion: v1
kind: Namespace
metadata:
name: karavi
---
apiVersion: v1
kind: Namespace
metadata:
name: dell-csm
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: connectivity-client-docker-k8s
Expand Down Expand Up @@ -26,7 +36,6 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: connectivity-client-docker-k8s
namespace: <NAMESPACE>
rules:
- apiGroups: [""]
resources: ["pods"]
Expand Down Expand Up @@ -58,9 +67,6 @@ rules:
- apiGroups: ["storage.k8s.io"]
resources: ["csidrivers"]
verbs: ["list", "watch", "get"]
- apiGroups: [""]
resources: ["secrets"]
verbs: ["list","get", "create", "update", "delete"]
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "create", "delete", "update"]
Expand Down Expand Up @@ -91,6 +97,103 @@ roleRef:
name: connectivity-client-docker-k8s
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: connectivity-client-docker-k8s
namespace: <NAMESPACE>
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["list","get", "create", "update", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: connectivity-client-docker-k8s
namespace: <NAMESPACE>
subjects:
- kind: ServiceAccount
name: connectivity-client-docker-k8s
namespace: <NAMESPACE>
roleRef:
kind: Role
name: connectivity-client-docker-k8s
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: connectivity-client-docker-k8s
namespace: default
rules:
- apiGroups: [""]
resources: ["secrets"]
resourceNames: ["iv", "dls-license"]
verbs: ["list","get", "create", "update", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: connectivity-client-docker-k8s
namespace: default
subjects:
- kind: ServiceAccount
name: connectivity-client-docker-k8s
namespace: <NAMESPACE>
roleRef:
kind: Role
name: connectivity-client-docker-k8s
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: connectivity-client-docker-k8s
namespace: "karavi"
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["list","get", "create", "update", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: connectivity-client-docker-k8s
namespace: "karavi"
subjects:
- kind: ServiceAccount
name: connectivity-client-docker-k8s
namespace: <NAMESPACE>
roleRef:
kind: Role
name: connectivity-client-docker-k8s
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: connectivity-client-docker-k8s
namespace: "dell-csm"
jooseppi-luna marked this conversation as resolved.
Show resolved Hide resolved
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["list","get", "create", "update", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: connectivity-client-docker-k8s
namespace: "dell-csm"
subjects:
- kind: ServiceAccount
name: connectivity-client-docker-k8s
namespace: <NAMESPACE>
roleRef:
kind: Role
name: connectivity-client-docker-k8s
apiGroup: rbac.authorization.k8s.io
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
Expand Down
9 changes: 9 additions & 0 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,15 @@ func GetModuleComponentObj(CtrlBuf []byte) ([]crclient.Object, error) {
return ctrlObjects, err
}

ctrlObjects = append(ctrlObjects, &ss)

case "Namespace":

var ss corev1.Namespace
if err := yaml.Unmarshal(raw, &ss); err != nil {
return ctrlObjects, err
}

ctrlObjects = append(ctrlObjects, &ss)
}
}
Expand Down
Loading