AWS Fargate環境下にSysdigを導入したい
Fargate環境では何が必要?
AWS Fargate環境ではServerless Agentが必要であることがわかった。
Used for container-based cloud environments such as Fargate
Serverless Agentの構成要素について
Serverless Agentはさらに2つのエージェントを指していることがわかった。
- The Sysdig serverless orchestrator agent
- 各VPCに設置された収集ポイント
- ワークロードエージェントからデータを収集しSysdigに転送
- ランタイムポリシーとルールをSysdigバックエンドからワークロードエージェントへ同期
- The Sysdig serverless workload agent
- 各タスクにインストール
- オーケストレーターエージェントと通信するためのエージェント
※図のLambdaはSysdig Agentのパッチ適用
Serverless Agentの前提条件
ドキュメントは以下の通り
On AWS Side
A custom Terraform/CloudFormation template containing the Fargate task definitions that you want to instrument through the Sysdig Serverless Agent
Two VPC subnets in different availability zones that can connect with the internet via a NAT gateway or an internet gateway
冗長化はマスト
On Sysdig Side
Sysdig Secure up and running
The endpoint of the Sysdig Collector for your region
From the Sysdig Secure UI, retrieve the following:
Access Key to install the agent and push the data to the Sysdig platform
Secure API Token to configure the Sysdig provider.
デプロイ
Sysdig recommends using the Terraform deployment method to instrument your Fargate workloads.
オーケストレーターエージェント
Terraformで設定
provider "aws" {
region = var.region
}
VPCにデプロイ
module "fargate-orchestrator-agent" {
source = "sysdiglabs/fargate-orchestrator-agent/aws"
version = "0.1.1"
vpc_id = var.vpc_id
subnets = [var.subnet_a_id, var.subnet_b_id]
access_key = var.access_key
collector_host = var.collector_host
collector_port = var.collector_port
name = "sysdig-orchestrator"
agent_image = "quay.io/sysdig/orchestrator-agent:latest"
# True if the VPC uses an InternetGateway, false otherwise
assign_public_ip = true
tags = {
description = "Sysdig Serverless Agent Orchestrator"
}
}
module解析中
とりあえずデフォルトVPCに立てることにした
data "aws_vpc" "default" {
filter {
name = "is-default"
values = [ "true" ]
}
}
data "aws_subnet" "default_a" {
vpc_id = data.aws_vpc.default.id
availability_zone = "${data.aws_region.current.name}a"
}
data "aws_subnet" "default_c" {
vpc_id = data.aws_vpc.default.id
availability_zone = "${data.aws_region.current.name}c"
}
module "fargate-orchestrator-agent" {
source = "sysdiglabs/fargate-orchestrator-agent/aws"
version = "0.2.0"
vpc_id = data.aws_vpc.default.id
subnets = [data.aws_subnet.default_a.id, data.aws_subnet.default_c.id]
access_key = var.sysdig_access_key # Sysdig access key
collector_host = "collector.sysdigcloud.com" # Sysdig collector host (default:"collector.sysdigcloud.com")
collector_port = "6443" # Sysdig collector port (default:"6443")
name = "sysdig-orchestrator" # Identifier for module resources
agent_image = "quay.io/sysdig/orchestrator-agent:latest" # Orchestrator agent image
# True if the VPC uses an InternetGateway, false otherwise
assign_public_ip = true # Provisions a public IP for the service. Required when using an Internet Gateway for egress.
tags = {
description = "Sysdig Serverless Agent Orchestrator"
}
}