{"title": "Amazon Elastic Kubernetes Service (EKS) setup for Workbench", "url": "https://support.expel.io/hc/en-us/articles/11742327047827-Amazon-Elastic-Kubernetes-Service-EKS-setup-for-Workbench", "date": "2022-12-01T15:04:57Z", "contents": "The Expel Amazon Elastic Kubernetes Service (EKS) consumes audit logs from the\nAWS platform through Kinesis. This visibility allows Workbench to identify\nactivity of interest in EKS, investigate, and notify organizations if action\nis recommended.\n\n![Kub_Amazon_1_Overview.png](https://support.expel.io/hc/article_attachments/11742313846547/uuid-63054dbd-f784-8502-1004-aed43158f216.png)\n\nComplete the steps below for each EKS cluster in each AWS account to be\nmonitored by Workbench.\n\n#### In this article\n\n * Before you start\n\n * Enable control plane logging for each EKS cluster\n\n * Send EKS logs to a Kinesis stream\n\n * Step 1: Create a new Kinesis data stream\n\n * Step 2: Create an IAM role for CloudWatch log delivery\n\n * Step 3: Route logs from CloudWatch to Kinesis stream\n\n * Create IAM Role for Workbench\n\n * Grant Workbench IAM Role required permissions\n\n * Grant Workbench read-only cluster permissions\n\n * Step 4: Connecting to Workbench\n\n * Put these IP addresses in your allow list\n\n## Before you start\n\nTo complete this procedure you need:\n\n * Administrative access to Amazon Web Services (AWS).\n\n * User privileges to create a Kinesis stream, CloudWatch log subscription, IAM role, and IAM policy.\n\n## Enable control plane logging for each EKS cluster\n\nAt a minimum, Workbench requires logging of the **audit** events for each\ncluster. This provides visibility into activity affecting resources in the\ncluster (the “who, what, and when” we need to detect and respond to).\n\nUpdate logging configuration with the AWS CLI like this:\n\n \n \n aws eks update-cluster-config \\\n _--region_ **_< your-cluster-region>_** \\\n _--name_ **_< your-cluster-name>_** _\\_ \n _--logging '{\"clusterLogging\":[{\"types\":[\"audit\"],\"enabled\":true}]}'_\n \n\nFor more information on configuring control plane logging, see the Amazon\nreference guide.\n\n## Send EKS logs to a Kinesis stream\n\nAfter control plane logging is enabled, EKS begins sending logs to CloudWatch.\nNext, the logs must be routed from CloudWatch to a Kinesis data stream so that\nWorkbench can consume the logs in real time. Complete the steps below to route\nEKS logs to a Kinesis data stream.\n\n## Step 1: Create a new Kinesis data stream\n\nCreate a stream with the AWS CLI like this:\n\n \n \n _aws kinesis create-stream \\_\n _--region_ **_< your-cluster-region>_** _\\_\n _--stream-name_ **_< your-stream-name>_** _\\_\n _--stream-mode-details '{\"StreamMode\": \"ON_DEMAND\"}'_\n\nWe recommend creating an `“ON_DEMAND”` stream to allow the stream to adjust\ncapacity based on demand.\n\n## Step 2: Create an IAM role for CloudWatch log delivery\n\nAn IAM role is required to allow CloudWatch to deliver logs to your Kinesis\nstream.\n\nTo start, create a trust policy document that allows the CloudWatch service to\nassume the role:\n\n \n \n _{_\n \n \n _\"Statement\": {_\n \n \n _\"Effect\": \"Allow\",_\n \n _\"Principal\": { \"Service\": \"logs._ **_< your-region>_** _.amazonaws.com\" },_\n \n _\"Action\": \"sts:AssumeRole\",_\n \n \n _\"Condition\": {_\n \n _\"StringLike\": { \"aws:SourceArn\": \"arn:aws:logs:_ **_< your-region>_** _:_ **_< your-account-id>_** _:*\" }_\n \n _}_\n \n \n _}_\n \n \n _}_\n \n \n\nThen, create the IAM role supplying this trust document:\n\n \n \n \n _aws iam create-role \\_\n \n _--role-name_ **_< your-cloudwatch-role-name>_**\n _--assume-role-policy-document file://_ **_< your-trust-document-file-path>_**\n \n\nNext, create an IAM policy document that grants this role permissions to put\nrecords into your Kinesis stream:\n\n \n \n \n _{_\n \n \n _\"Statement\": [_\n \n \n _{_\n \n \n _\"Effect\": \"Allow\",_\n \n \n _\"Action\": \"kinesis:PutRecord\",_\n \n _\"Resource\": \"_ **_< your-kinesis-arn>_** _\"_\n \n _}_\n \n \n _]_\n \n \n _}_\n \n \n\nFinally, apply this IAM policy to the CloudWatch role:\n\n \n \n aws iam put-role-policy \\\n --role-name **< your-cloudwatch-role-name>** \\\n --policy-name “ **< your-policy-name>**” \\\n --policy-document file:// **< your-policy-document-path>**\n\n## Step 3: Route logs from CloudWatch to Kinesis stream\n\nLogs can be routed to Kinesis with a CloudWatch log group subscription filter.\nCreate this filter with the AWS CLI like this:\n\n \n \n aws logs put-subscription-filter \\\n _--region_ **_< your-cluster-region>_** _\\_\n _–log-group-name_ **_< your-cluster-log-group-name>_** _\\_\n –filter-name “AllEKSLogs” \\\n –filter-pattern “”\n _–destination-arn_ **_< your-kinesis-stream-arn>_**\n _--role-arn_ **_< your-cloudwatch-role>_**\n\n### Create IAM Role for Workbench\n\nTo authenticate to your AWS account and retrieve logs, Workbench requires an\nIAM role. If you already have an Workbench IAM role for another Workbench\nintegration (like CloudWatch or AWS GuardDuty), this existing role can be\nreused and you can go to: **Grant Expel IAM Role required permissions**.\n\nTo start, create a trust policy document that allows Workbench to assume the\nrole:\n\n \n \n \n _{_\n \n \n _\"Statement\":_\n \n \n _[_\n \n \n _{_\n \n \n _\"Effect\": \"Allow\",_\n \n \n _\"Principal\":_\n \n \n _{_\n \n \n _\"AWS\": \"arn:aws:iam::012205512454:user/ExpelCloudService\"_\n \n \n _},_\n \n \n _\"Action\": \"sts:AssumeRole\",_\n \n \n _\"Condition\":_\n \n \n _{_\n \n \n _\"StringEquals\":_\n \n \n _{_\n \n _\"sts:ExternalId\": \"_ **_< your-customer-guid>_** _\"_\n \n _}_\n \n \n _}_\n \n \n _}_\n \n \n _]_\n \n \n _}_\n \n \n\nThen, create the IAM role supplying this trust document:\n\n \n \n _aws iam create-role \\_\n \n _--role-name_ **_< your-expel-role-name>_**\n _--assume-role-policy-document file://_ **_< your-trust-document-file-path>_**\n\n### Grant Workbench IAM Role required permissions\n\nWorkbench requires IAM permissions to retrieve logs from Kinesis, as well as\ninvestigate activity of interest affecting your EKS clusters.\n\nFirst, create an IAM policy document granting Workbench required permissions\nfor Kinesis and EKS:\n\n \n \n \n _{_\n \n \n _\"Version\": \"2012-10-17\",_\n \n \n _\"Statement\": [_\n \n _{_\n \n _\"Effect\": \"Allow\",_\n \n \n _\"Action\": [_\n \n \n _\"kinesis:DescribeLimits\",_\n \n \n _\"kinesis:DescribeStream\",_\n \n \n _\"kinesis:DescribeStreamSummary\",_\n \n \n _\"kinesis:GetRecords\",_\n \n \n _\"kinesis:GetShardIterator\",_\n \n \n _\"kinesis:ListShards\"_\n \n \n _],_\n \n _\"Resource\": \"_ **_< your kinesis stream arn>_** _\"_\n \n _},_\n \n \n _{_\n \n \n _\"Effect\": \"Allow\",_\n \n \n _\"Action\": [_\n \n \n _\"eks:AccessKubernetesApi\",_\n \n \n _\"eks:DescribeCluster\",_\n \n \n _\"eks:DescribeNodegroup\",_\n \n \n _\"eks:ListClusters\",_\n \n \n _\"eks:ListNodegroups\",_\n \n \n _\"eks:ListUpdates\",_\n \n \n _\"sts:GetCallerIdentity\",_\n \n \n _\"ec2:DescribeRegions\",_\n \n \n _\"autoscaling:DescribeAutoScalingGroups\"_\n \n ],\n \n \n _\"Resource\": \"*\"_\n \n \n _}_\n \n \n _]_\n \n \n _}_\n \n \n\nThen, apply this policy to the Expel IAM role:\n\n \n \n aws iam put-role-policy \\\n --role-name **< your-expel-role-name>** \\ \n --policy-name “ **< your-policy-name>**” \\\n --policy-document file:// **< your-policy-document-path>**\n \n\n### Grant Workbench read-only cluster permissions\n\nExpel suggests providing limited read-only access to your EKS clusters to\nenable deep investigation of interesting activity. These permissions can be\nfine-tuned based on your needs. Workbench can deliver service without this\naccess, but it significantly limits our ability to thoroughly investigate\nactivity in your clusters.\n\nFirst, create an Expel ClusterRole manifest to grant limited, read-only\npermissions:\n\n \n \n \n _apiVersion: rbac.authorization.k8s.io/v1_\n \n \n _kind: ClusterRole_\n \n \n _metadata:_\n \n \n _name: expel-reader-clusterrole_\n \n _rules:_\n \n \n _- apiGroups:_\n \n \n _- \"\"_\n \n \n _- admissionregistration.k8s.io_\n \n \n _- apps_\n \n \n _- networking.k8s.io_\n \n \n _- rbac.authorization.k8s.io_\n \n \n _resources:_\n \n \n _- apiservices_\n \n \n _- clusterrolebindings_\n \n \n _- clusterroles_\n \n \n _- cronjobs_\n \n \n _- daemonsets_\n \n \n _- deployments_\n \n \n _- events_\n \n \n _- flowschemas_\n \n \n _- horizontalpodautoscalers_\n \n \n _- ingressclasses_\n \n \n _- ingresses_\n \n \n _- jobs_\n \n \n _- localsubjectaccessreviews_\n \n \n _- mutatingwebhookconfigurations_\n \n \n _- namespaces_\n \n \n _- networkpolicies_\n \n \n _- nodes_\n \n \n _- persistentvolumes_\n \n \n _- poddisruptionbudgets_\n \n \n _- pods_\n \n \n _- podsecuritypolicies_\n \n \n _- podtemplates_\n \n \n _- replicasets_\n \n \n _- rolebindings_\n \n \n _- roles_\n \n \n _- selfsubjectaccessreviews_\n \n \n _- selfsubjectrulesreviews_\n \n \n _- serviceaccounts_\n \n \n _- services_\n \n \n _- statefulsets_\n \n \n _- subjectaccessreviews_\n \n \n _- tokenreviews_\n \n \n _- validatingwebhookconfigurations_\n \n \n _- volumeattachments_\n \n \n _verbs:_\n \n \n _- get_\n \n \n _- list_\n \n\nUse kubectl to apply this role:\n\n \n \n = _kubectl apply -f_ **_< your-expel-role-manifest>_** \n\nNext, bind this role to a Workbench user with a ClusterRoleBinding. Create a\nClusterRoleBinding manifest:\n\n \n \n \n _kind: ClusterRoleBinding_\n \n \n _apiVersion: rbac.authorization.k8s.io/v1_\n \n \n _metadata:_\n \n \n _name: expel-reader-clusterrolebinding_\n \n \n _subjects:_\n \n \n _- kind: User_\n \n \n _name: expel-user_\n \n \n _roleRef:_\n \n \n _kind: ClusterRole_\n \n \n _name: expel-reader-clusterrole_\n \n \n _apiGroup: rbac.authorization.k8s.io_\n \n\nUse kubectl to apply this role:\n\n \n \n _kubectl apply -f_ **_< your-expel-role-binding-manifest>_**\n\nFinally, map the Workbench IAM role to the in-cluster user “expel-user”. This\nrequires editing the “aws-auth” configMap with **EKS ctl**.\n\n \n \n \n _eksctl create iamidentitymapping \\_\n \n _--cluster_ **_< your-cluster-name>_** _\\_\n _--region_ **_< your-region>_** _\\_\n _--arn_ **_< your-expel-role-arn>_** _\\_\n \n _--username expel-user_\n \n \n\nYou can confirm the mapping is created by running:\n\n \n \n _eksctl get iamidentitymapping --cluster_ **_< your-cluster-name>_** _--region_ **_< your-region>_**\n\n## Step 4: Connecting to Workbench\n\nThe steps below outline how to finish connecting to Workbench.\n\n 1. Log in to Workbench at https://workbench.expel.io.\n\n 2. Navigate to Settings > Security devices.\n\n 3. Click +Add security device.\n\n 4. Select Amazon Elastic Kubernetes Service (EKS).\n\n![Kub_Amazon_2_AddSecDev.png](https://support.expel.io/hc/article_attachments/11742327407123/uuid-84d48493-7573-0adb-802a-3aa552fe62ae.png)\n\n 5. Name the device, provide a description, and fill in the Role ARN, Role Session Name, Region, External ID, and Kinesis Stream Name.\n\n 6. Click Save.\n\n## Put these IP addresses in your allow list\n\n * 34.75.13.114\n\n * 34.75.152.7\n\n * 35.243.190.98\n\n * 104.196.158.205\n\n * 34.75.81.28\n\n * 34.75.210.18\n\n### Tip\n\nThis article was accurate at the time of writing, but changes happen. If you\nfind the instructions are outdated, leave a description in the comment field\nbelow and let us know!\n\n"}