CreateFargateProfile - Amazon Elastic Kubernetes Service

CreateFargateProfile

Creates an AWS Fargate profile for your Amazon EKS cluster. You must have at least one Fargate profile in a cluster to be able to run pods on Fargate.

The Fargate profile allows an administrator to declare which pods run on Fargate and specify which pods run on which Fargate profile. This declaration is done through the profile’s selectors. Each profile can have up to five selectors that contain a namespace and labels. A namespace is required for every selector. The label field consists of multiple optional key-value pairs. Pods that match the selectors are scheduled on Fargate. If a to-be-scheduled pod matches any of the selectors in the Fargate profile, then that pod is run on Fargate.

When you create a Fargate profile, you must specify a pod execution role to use with the pods that are scheduled with the profile. This role is added to the cluster's Kubernetes Role Based Access Control (RBAC) for authorization so that the kubelet that is running on the Fargate infrastructure can register with your Amazon EKS cluster so that it can appear in your cluster as a node. The pod execution role also provides IAM permissions to the Fargate infrastructure to allow read access to Amazon ECR image repositories. For more information, see Pod Execution Role in the Amazon EKS User Guide.

Fargate profiles are immutable. However, you can create a new updated profile to replace an existing profile and then delete the original after the updated profile has finished creating.

If any Fargate profiles in a cluster are in the DELETING status, you must wait for that Fargate profile to finish deleting before you can create any other profiles in that cluster.

For more information, see AWS Fargate Profile in the Amazon EKS User Guide.

Request Syntax

POST /clusters/name/fargate-profiles HTTP/1.1 Content-type: application/json { "clientRequestToken": "string", "fargateProfileName": "string", "podExecutionRoleArn": "string", "selectors": [ { "labels": { "string" : "string" }, "namespace": "string" } ], "subnets": [ "string" ], "tags": { "string" : "string" } }

URI Request Parameters

The request requires the following URI parameters.

name

The name of the Amazon EKS cluster to apply the Fargate profile to.

Request Body

The request accepts the following data in JSON format.

clientRequestToken

Unique, case-sensitive identifier that you provide to ensure the idempotency of the request.

Type: String

Required: No

fargateProfileName

The name of the Fargate profile.

Type: String

Required: Yes

podExecutionRoleArn

The Amazon Resource Name (ARN) of the pod execution role to use for pods that match the selectors in the Fargate profile. The pod execution role allows Fargate infrastructure to register with your cluster as a node, and it provides read access to Amazon ECR image repositories. For more information, see Pod Execution Role in the Amazon EKS User Guide.

Type: String

Required: Yes

selectors

The selectors to match for pods to use this Fargate profile. Each selector must have an associated namespace. Optionally, you can also specify labels for a namespace. You may specify up to five selectors in a Fargate profile.

Type: Array of FargateProfileSelector objects

Required: No

subnets

The IDs of subnets to launch your pods into. At this time, pods running on Fargate are not assigned public IP addresses, so only private subnets (with no direct route to an Internet Gateway) are accepted for this parameter.

Type: Array of strings

Required: No

tags

The metadata to apply to the Fargate profile to assist with categorization and organization. Each tag consists of a key and an optional value, both of which you define. Fargate profile tags do not propagate to any other resources associated with the Fargate profile, such as the pods that are scheduled with it.

Type: String to string map

Key Length Constraints: Minimum length of 1. Maximum length of 128.

Value Length Constraints: Maximum length of 256.

Required: No

Response Syntax

HTTP/1.1 200 Content-type: application/json { "fargateProfile": { "clusterName": "string", "createdAt": number, "fargateProfileArn": "string", "fargateProfileName": "string", "podExecutionRoleArn": "string", "selectors": [ { "labels": { "string" : "string" }, "namespace": "string" } ], "status": "string", "subnets": [ "string" ], "tags": { "string" : "string" } } }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

fargateProfile

The full description of your new Fargate profile.

Type: FargateProfile object

Errors

For information about the errors that are common to all actions, see Common Errors.

ClientException

These errors are usually caused by a client action. Actions can include using an action or resource on behalf of a user that doesn't have permissions to use the action or resource or specifying an identifier that is not valid.

HTTP Status Code: 400

InvalidParameterException

The specified parameter is invalid. Review the available parameters for the API request.

HTTP Status Code: 400

InvalidRequestException

The request is invalid given the state of the cluster. Check the state of the cluster and the associated operations.

HTTP Status Code: 400

ResourceLimitExceededException

You have encountered a service limit on the specified resource.

HTTP Status Code: 400

ServerException

These errors are usually caused by a server-side issue.

HTTP Status Code: 500

UnsupportedAvailabilityZoneException

At least one of your specified cluster subnets is in an Availability Zone that does not support Amazon EKS. The exception output specifies the supported Availability Zones for your account, from which you can choose subnets for your cluster.

HTTP Status Code: 400

Example

In the following example or examples, the Authorization header contents (AUTHPARAMS) must be replaced with an AWS Signature Version 4 signature. For more information about creating these signatures, see Signature Version 4 Signing Process in the AWS General Reference.

You need to learn how to sign HTTP requests only if you intend to manually create them. When you use the AWS Command Line Interface (AWS CLI) or one of the AWS SDKs to make requests to AWS, these tools automatically sign the requests for you with the access key that you specify when you configure the tools. When you use these tools, you don't need to learn how to sign requests yourself.

Example

The following example creates a Fargate profile called default-with-infrastructure-label in the fargate cluster. Pods that are launched in the default namespace with the Kubernetes label "infrastructure": "fargate" will be run on Fargate.

Sample Request

POST /clusters/fargate/fargate-profiles HTTP/1.1 Host: eks.us-west-2.amazonaws.com Accept-Encoding: identity User-Agent: aws-cli/1.16.284 Python/3.7.5 Darwin/18.7.0 botocore/1.13.20 X-Amz-Date: 20191120T202529Z Authorization: AUTHPARAMS Content-Length: 355 { "fargateProfileName": "default-with-infrastructure-label", "podExecutionRoleArn": "arn:aws:iam::012345678910:role/AmazonEKSPodExecutionRole", "subnets": [ "subnet-0420a37ee456daf3f", "subnet-09a8afb8db4f02d21" ], "selectors": [ { "namespace": "default", "labels": { "infrastructure": "fargate" } } ], "clientRequestToken": "e188d61d-73b7-493c-9cd8-e39f242957eb" }

Sample Response

HTTP/1.1 200 OK Date: Wed, 20 Nov 2019 20:37:30 GMT Content-Type: application/json Content-Length: 610 x-amzn-RequestId: 16c4ddc8-21cf-4811-817d-cf0afbf5e83b x-amz-apigw-id: DeaRjFWPvHcFcXw= X-Amzn-Trace-Id: Root=1-5dd5a409-0bba535e4d90de6e19517d8c Connection: keep-alive { "fargateProfile": { "fargateProfileName": "compute-label", "fargateProfileArn": "arn:aws:eks:us-west-2:012345678910:fargateprofile/fargate/compute-label/78b74305-1f1e-54b7-f7f0-f03f2a3d3481", "clusterName": "fargate", "createdAt": 1574206849.791, "podExecutionRoleArn": "arn:aws:iam::012345678910:role/AmazonEKSPodExecutionRole", "subnets": [ "subnet-0420a37ee456daf3f", "subnet-09a8afb8db4f02d21" ], "selectors": [ { "namespace": "kube-system", "labels": { "compute": "fargate" } } ], "status": "DELETING", "tags": {} } }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: