Krkn RBAC

RBAC Authorization rules required to run Krkn scenarios.

RBAC Configurations

Krkn supports two types of RBAC configurations:

  1. Non-Privileged RBAC: Provides namespace-scoped permissions for scenarios that only require access to resources within a specific namespace.
  2. Privileged RBAC: Provides cluster-wide permissions for scenarios that require access to cluster-level resources like nodes.

NOTE: The examples below use placeholders such as target-namespace and krkn-namespace which should be replaced with your actual namespaces. The service account name krkn-sa is also a placeholder that you can customize.

RBAC YAML Files

Non-Privileged Role

The non-privileged role provides permissions limited to namespace-scoped resources:

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: krkn-non-privileged-role
  namespace: <target-namespace>
rules:
- apiGroups: [""]
  resources: ["pods", "services"]
  verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: ["apps"]
  resources: ["deployments", "statefulsets"]
  verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: ["batch"]
  resources: ["jobs"]
  verbs: ["get", "list", "watch", "create", "delete"]

Non-Privileged RoleBinding

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: krkn-non-privileged-rolebinding
  namespace: <target-namespace>
subjects:
- kind: ServiceAccount
  name: <krkn-sa>
  namespace: <target-namespace>
roleRef:
  kind: Role
  name: krkn-non-privileged-role
  apiGroup: rbac.authorization.k8s.io

Privileged ClusterRole

The privileged ClusterRole provides permissions for cluster-wide resources:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: krkn-privileged-clusterrole
rules:
- apiGroups: [""]
  resources: ["nodes"]
  verbs: ["get", "list", "watch", "create", "delete", "update", "patch"]
- apiGroups: [""]
  resources: ["pods", "services"]
  verbs: ["get", "list", "watch", "create", "delete", "update", "patch"]
- apiGroups: ["apps"]
  resources: ["deployments", "statefulsets"]
  verbs: ["get", "list", "watch", "create", "delete", "update", "patch"]
- apiGroups: ["batch"]
  resources: ["jobs"]
  verbs: ["get", "list", "watch", "create", "delete", "update", "patch"]

Privileged ClusterRoleBinding

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: krkn-privileged-clusterrolebinding
subjects:
- kind: ServiceAccount
  name: <krkn-sa>
  namespace: <krkn-namespace>
roleRef:
  kind: ClusterRole
  name: krkn-privileged-clusterrole
  apiGroup: rbac.authorization.k8s.io

How to Apply RBAC Configuration

  1. Customize the namespace in the YAML files:

    • Replace target-namespace with the namespace where you want to run Krkn scenarios
    • Replace krkn-namespace with the namespace where Krkn itself is deployed
  2. Create a service account for Krkn:

    kubectl create serviceaccount krkn-sa -n <namespace>
    
  3. Apply the RBAC configuration:

    # For non-privileged access
    kubectl apply -f rbac/non-privileged-role.yaml
    kubectl apply -f rbac/non-privileged-rolebinding.yaml
    
    # For privileged access
    kubectl apply -f rbac/privileged-clusterrole.yaml
    kubectl apply -f rbac/privileged-clusterrolebinding.yaml
    

OpenShift-specific Configuration

For OpenShift clusters, you may need to grant the privileged Security Context Constraint (SCC) to the service account:

oc adm policy add-scc-to-user privileged -z krkn-sa -n <namespace>

Krkn Scenarios and Required RBAC Permissions

The following table lists the available Krkn scenarios and their required RBAC permission levels:

Scenario TypePlugin TypeRequired RBACDescription
pod_disruption_scenariosNamespaceNon-PrivilegedScenarios that disrupt or kill pods
container_scenariosNamespaceNon-PrivilegedScenarios that affect containers
service_disruption_scenariosNamespaceNon-PrivilegedScenarios that disrupt services
application_outages_scenariosNamespaceNon-PrivilegedScenarios that cause application outages
pvc_scenariosNamespaceNon-PrivilegedScenarios that affect persistent volume claims
pod_network_scenariosNamespaceNon-PrivilegedScenarios that affect pod network connectivity
service_hijacking_scenariosNamespaceNon-PrivilegedScenarios that hijack services
node_scenariosClusterPrivilegedScenarios that affect nodes
zone_outages_scenariosClusterPrivilegedScenarios that simulate zone outages
time_scenariosClusterPrivilegedScenarios that manipulate system time
hog_scenariosClusterPrivilegedScenarios that consume resources
cluster_shut_down_scenariosClusterPrivilegedScenarios that shut down the cluster
network_chaos_scenariosClusterPrivilegedScenarios that cause network chaos
network_chaos_ng_scenariosClusterPrivilegedNext-gen network chaos scenarios
syn_flood_scenariosClusterPrivilegedSYN flood attack scenarios

NOTE: Grant the privileged SCC to the user running the pod, to execute all the below krkn testscenarios

oc adm policy add-scc-to-user privileged user1