You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.
Class: Aws::EKS::Client
- Inherits:
-
Seahorse::Client::Base
- Object
- Seahorse::Client::Base
- Aws::EKS::Client
- Defined in:
- (unknown)
Overview
An API client for Amazon Elastic Kubernetes Service. To construct a client, you need to configure a :region
and :credentials
.
eks = Aws::EKS::Client.new(
region: region_name,
credentials: credentials,
# ...
)
See #initialize for a full list of supported configuration options.
Region
You can configure a default region in the following locations:
ENV['AWS_REGION']
Aws.config[:region]
Go here for a list of supported regions.
Credentials
Default credentials are loaded automatically from the following locations:
ENV['AWS_ACCESS_KEY_ID']
andENV['AWS_SECRET_ACCESS_KEY']
Aws.config[:credentials]
- The shared credentials ini file at
~/.aws/credentials
(more information) - From an instance profile when running on EC2
You can also construct a credentials object from one of the following classes:
Alternatively, you configure credentials with :access_key_id
and
:secret_access_key
:
# load credentials from disk
creds = YAML.load(File.read('/path/to/secrets'))
Aws::EKS::Client.new(
access_key_id: creds['access_key_id'],
secret_access_key: creds['secret_access_key']
)
Always load your credentials from outside your application. Avoid configuring credentials statically and never commit them to source control.
Instance Attribute Summary
Attributes inherited from Seahorse::Client::Base
Constructor collapse
-
#initialize(options = {}) ⇒ Aws::EKS::Client
constructor
Constructs an API client.
API Operations collapse
-
#create_cluster(options = {}) ⇒ Types::CreateClusterResponse
Creates an Amazon EKS control plane.
-
#create_fargate_profile(options = {}) ⇒ Types::CreateFargateProfileResponse
Creates an AWS Fargate profile for your Amazon EKS cluster.
-
#create_nodegroup(options = {}) ⇒ Types::CreateNodegroupResponse
Creates a managed worker node group for an Amazon EKS cluster.
-
#delete_cluster(options = {}) ⇒ Types::DeleteClusterResponse
Deletes the Amazon EKS cluster control plane.
If you have active services in your cluster that are associated with a load balancer, you must delete those services before deleting the cluster so that the load balancers are deleted properly.
-
#delete_fargate_profile(options = {}) ⇒ Types::DeleteFargateProfileResponse
Deletes an AWS Fargate profile.
When you delete a Fargate profile, any pods running on Fargate that were created with the profile are deleted.
-
#delete_nodegroup(options = {}) ⇒ Types::DeleteNodegroupResponse
Deletes an Amazon EKS node group for a cluster.
.
-
#describe_cluster(options = {}) ⇒ Types::DescribeClusterResponse
Returns descriptive information about an Amazon EKS cluster.
The API server endpoint and certificate authority data returned by this operation are required for
kubelet
andkubectl
to communicate with your Kubernetes API server. -
#describe_fargate_profile(options = {}) ⇒ Types::DescribeFargateProfileResponse
Returns descriptive information about an AWS Fargate profile.
.
-
#describe_nodegroup(options = {}) ⇒ Types::DescribeNodegroupResponse
Returns descriptive information about an Amazon EKS node group.
.
-
#describe_update(options = {}) ⇒ Types::DescribeUpdateResponse
Returns descriptive information about an update against your Amazon EKS cluster or associated managed node group.
When the status of the update is
Succeeded
, the update is complete. -
#list_clusters(options = {}) ⇒ Types::ListClustersResponse
Lists the Amazon EKS clusters in your AWS account in the specified Region.
.
-
#list_fargate_profiles(options = {}) ⇒ Types::ListFargateProfilesResponse
Lists the AWS Fargate profiles associated with the specified cluster in your AWS account in the specified Region.
.
-
#list_nodegroups(options = {}) ⇒ Types::ListNodegroupsResponse
Lists the Amazon EKS managed node groups associated with the specified cluster in your AWS account in the specified Region.
-
#list_tags_for_resource(options = {}) ⇒ Types::ListTagsForResourceResponse
List the tags for an Amazon EKS resource.
.
-
#list_updates(options = {}) ⇒ Types::ListUpdatesResponse
Lists the updates associated with an Amazon EKS cluster or managed node group in your AWS account, in the specified Region.
.
-
#tag_resource(options = {}) ⇒ Struct
Associates the specified tags to a resource with the specified
resourceArn
. -
#untag_resource(options = {}) ⇒ Struct
Deletes specified tags from a resource.
.
-
#update_cluster_config(options = {}) ⇒ Types::UpdateClusterConfigResponse
Updates an Amazon EKS cluster configuration.
-
#update_cluster_version(options = {}) ⇒ Types::UpdateClusterVersionResponse
Updates an Amazon EKS cluster to the specified Kubernetes version.
-
#update_nodegroup_config(options = {}) ⇒ Types::UpdateNodegroupConfigResponse
Updates an Amazon EKS managed node group configuration.
-
#update_nodegroup_version(options = {}) ⇒ Types::UpdateNodegroupVersionResponse
Updates the Kubernetes version or AMI version of an Amazon EKS managed node group.
You can update a node group using a launch template only if the node group was originally deployed with a launch template.
Instance Method Summary collapse
-
#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ Boolean
Waiters polls an API operation until a resource enters a desired state.
-
#waiter_names ⇒ Array<Symbol>
Returns the list of supported waiters.
Methods inherited from Seahorse::Client::Base
add_plugin, api, #build_request, clear_plugins, define, new, #operation, #operation_names, plugins, remove_plugin, set_api, set_plugins
Methods included from Seahorse::Client::HandlerBuilder
#handle, #handle_request, #handle_response
Constructor Details
#initialize(options = {}) ⇒ Aws::EKS::Client
Constructs an API client.
Instance Method Details
#create_cluster(options = {}) ⇒ Types::CreateClusterResponse
Creates an Amazon EKS control plane.
The Amazon EKS control plane consists of control plane instances that run the Kubernetes software, such as etcd
and the API server. The control plane runs in an account managed by AWS, and the Kubernetes API is exposed via the Amazon EKS API server endpoint. Each Amazon EKS cluster control plane is single-tenant and unique and runs on its own set of Amazon EC2 instances.
The cluster control plane is provisioned across multiple Availability Zones and fronted by an Elastic Load Balancing Network Load Balancer. Amazon EKS also provisions elastic network interfaces in your VPC subnets to provide connectivity from the control plane instances to the worker nodes (for example, to support kubectl exec
, logs
, and proxy
data flows).
Amazon EKS worker nodes run in your AWS account and connect to your cluster's control plane via the Kubernetes API server endpoint and a certificate file that is created for your cluster.
You can use the endpointPublicAccess
and endpointPrivateAccess
parameters to enable or disable public and private access to your cluster's Kubernetes API server endpoint. By default, public access is enabled, and private access is disabled. For more information, see Amazon EKS Cluster Endpoint Access Control in the Amazon EKS User Guide .
You can use the logging
parameter to enable or disable exporting the Kubernetes control plane logs for your cluster to CloudWatch Logs. By default, cluster control plane logs aren't exported to CloudWatch Logs. For more information, see Amazon EKS Cluster Control Plane Logs in the Amazon EKS User Guide .
CloudWatch Logs ingestion, archive storage, and data scanning rates apply to exported control plane logs. For more information, see Amazon CloudWatch Pricing.
Cluster creation typically takes between 10 and 15 minutes. After you create an Amazon EKS cluster, you must configure your Kubernetes tooling to communicate with the API server and launch worker nodes into your cluster. For more information, see Managing Cluster Authentication and Launching Amazon EKS Worker Nodes in the Amazon EKS User Guide.
#create_fargate_profile(options = {}) ⇒ Types::CreateFargateProfileResponse
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.
#create_nodegroup(options = {}) ⇒ Types::CreateNodegroupResponse
Creates a managed worker node group for an Amazon EKS cluster. You can only create a node group for your cluster that is equal to the current Kubernetes version for the cluster. All node groups are created with the latest AMI release version for the respective minor Kubernetes version of the cluster, unless you deploy a custom AMI using a launch template. For more information about using launch templates, see Launch template support.
An Amazon EKS managed node group is an Amazon EC2 Auto Scaling group and associated Amazon EC2 instances that are managed by AWS for an Amazon EKS cluster. Each node group uses a version of the Amazon EKS-optimized Amazon Linux 2 AMI. For more information, see Managed Node Groups in the Amazon EKS User Guide.
#delete_cluster(options = {}) ⇒ Types::DeleteClusterResponse
Deletes the Amazon EKS cluster control plane.
If you have active services in your cluster that are associated with a load balancer, you must delete those services before deleting the cluster so that the load balancers are deleted properly. Otherwise, you can have orphaned resources in your VPC that prevent you from being able to delete the VPC. For more information, see Deleting a Cluster in the Amazon EKS User Guide.
If you have managed node groups or Fargate profiles attached to the cluster, you must delete them first. For more information, see DeleteNodegroup and DeleteFargateProfile.
#delete_fargate_profile(options = {}) ⇒ Types::DeleteFargateProfileResponse
Deletes an AWS Fargate profile.
When you delete a Fargate profile, any pods running on Fargate that were created with the profile are deleted. If those pods match another Fargate profile, then they are scheduled on Fargate with that profile. If they no longer match any Fargate profiles, then they are not scheduled on Fargate and they may remain in a pending state.
Only one Fargate profile in a cluster can be in the DELETING
status at a time. You must wait for a Fargate profile to finish deleting before you can delete any other profiles in that cluster.
#delete_nodegroup(options = {}) ⇒ Types::DeleteNodegroupResponse
Deletes an Amazon EKS node group for a cluster.
#describe_cluster(options = {}) ⇒ Types::DescribeClusterResponse
Returns descriptive information about an Amazon EKS cluster.
The API server endpoint and certificate authority data returned by this operation are required for kubelet
and kubectl
to communicate with your Kubernetes API server. For more information, see Create a kubeconfig for Amazon EKS.
The API server endpoint and certificate authority data aren't available until the cluster reaches the ACTIVE
state.
#describe_fargate_profile(options = {}) ⇒ Types::DescribeFargateProfileResponse
Returns descriptive information about an AWS Fargate profile.
#describe_nodegroup(options = {}) ⇒ Types::DescribeNodegroupResponse
Returns descriptive information about an Amazon EKS node group.
#describe_update(options = {}) ⇒ Types::DescribeUpdateResponse
Returns descriptive information about an update against your Amazon EKS cluster or associated managed node group.
When the status of the update is Succeeded
, the update is complete. If an update fails, the status is Failed
, and an error detail explains the reason for the failure.
#list_clusters(options = {}) ⇒ Types::ListClustersResponse
Lists the Amazon EKS clusters in your AWS account in the specified Region.
#list_fargate_profiles(options = {}) ⇒ Types::ListFargateProfilesResponse
Lists the AWS Fargate profiles associated with the specified cluster in your AWS account in the specified Region.
#list_nodegroups(options = {}) ⇒ Types::ListNodegroupsResponse
Lists the Amazon EKS managed node groups associated with the specified cluster in your AWS account in the specified Region. Self-managed node groups are not listed.
#list_tags_for_resource(options = {}) ⇒ Types::ListTagsForResourceResponse
List the tags for an Amazon EKS resource.
#list_updates(options = {}) ⇒ Types::ListUpdatesResponse
Lists the updates associated with an Amazon EKS cluster or managed node group in your AWS account, in the specified Region.
#tag_resource(options = {}) ⇒ Struct
Associates the specified tags to a resource with the specified resourceArn
. If existing tags on a resource are not specified in the request parameters, they are not changed. When a resource is deleted, the tags associated with that resource are deleted as well. Tags that you create for Amazon EKS resources do not propagate to any other resources associated with the cluster. For example, if you tag a cluster with this operation, that tag does not automatically propagate to the subnets and worker nodes associated with the cluster.
#untag_resource(options = {}) ⇒ Struct
Deletes specified tags from a resource.
#update_cluster_config(options = {}) ⇒ Types::UpdateClusterConfigResponse
Updates an Amazon EKS cluster configuration. Your cluster continues to function during the update. The response output includes an update ID that you can use to track the status of your cluster update with the DescribeUpdate API operation.
You can use this API operation to enable or disable exporting the Kubernetes control plane logs for your cluster to CloudWatch Logs. By default, cluster control plane logs aren't exported to CloudWatch Logs. For more information, see Amazon EKS Cluster Control Plane Logs in the Amazon EKS User Guide .
CloudWatch Logs ingestion, archive storage, and data scanning rates apply to exported control plane logs. For more information, see Amazon CloudWatch Pricing.
You can also use this API operation to enable or disable public and private access to your cluster's Kubernetes API server endpoint. By default, public access is enabled, and private access is disabled. For more information, see Amazon EKS Cluster Endpoint Access Control in the Amazon EKS User Guide .
At this time, you can not update the subnets or security group IDs for an existing cluster.
Cluster updates are asynchronous, and they should finish within a few minutes. During an update, the cluster status moves to UPDATING
(this status transition is eventually consistent). When the update is complete (either Failed
or Successful
), the cluster status moves to Active
.
#update_cluster_version(options = {}) ⇒ Types::UpdateClusterVersionResponse
Updates an Amazon EKS cluster to the specified Kubernetes version. Your cluster continues to function during the update. The response output includes an update ID that you can use to track the status of your cluster update with the DescribeUpdate API operation.
Cluster updates are asynchronous, and they should finish within a few minutes. During an update, the cluster status moves to UPDATING
(this status transition is eventually consistent). When the update is complete (either Failed
or Successful
), the cluster status moves to Active
.
If your cluster has managed node groups attached to it, all of your node groups’ Kubernetes versions must match the cluster’s Kubernetes version in order to update the cluster to a new Kubernetes version.
#update_nodegroup_config(options = {}) ⇒ Types::UpdateNodegroupConfigResponse
Updates an Amazon EKS managed node group configuration. Your node group continues to function during the update. The response output includes an update ID that you can use to track the status of your node group update with the DescribeUpdate API operation. Currently you can update the Kubernetes labels for a node group or the scaling configuration.
#update_nodegroup_version(options = {}) ⇒ Types::UpdateNodegroupVersionResponse
Updates the Kubernetes version or AMI version of an Amazon EKS managed node group.
You can update a node group using a launch template only if the node group was originally deployed with a launch template. If you need to update a custom AMI in a node group that was deployed with a launch template, then update your custom AMI, specify the new ID in a new version of the launch template, and then update the node group to the new version of the launch template.
If you update without a launch template, then you can update to the latest available AMI version of a node group's current Kubernetes version by not specifying a Kubernetes version in the request. You can update to the latest AMI version of your cluster's current Kubernetes version by specifying your cluster's Kubernetes version in the request. For more information, see Amazon EKS-Optimized Linux AMI Versions in the Amazon EKS User Guide.
You cannot roll back a node group to an earlier Kubernetes version or AMI version.
When a node in a managed node group is terminated due to a scaling action or update, the pods in that node are drained first. Amazon EKS attempts to drain the nodes gracefully and will fail if it is unable to do so. You can force
the update if Amazon EKS is unable to drain the nodes as a result of a pod disruption budget issue.
#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ Boolean
Waiters polls an API operation until a resource enters a desired state.
Basic Usage
Waiters will poll until they are succesful, they fail by entering a terminal state, or until a maximum number of attempts are made.
# polls in a loop, sleeping between attempts client.waiter_until(waiter_name, params)
Configuration
You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. You configure waiters by passing a block to #wait_until:
# poll for ~25 seconds
client.wait_until(...) do |w|
w.max_attempts = 5
w.delay = 5
end
Callbacks
You can be notified before each polling attempt and before each
delay. If you throw :success
or :failure
from these callbacks,
it will terminate the waiter.
started_at = Time.now
client.wait_until(...) do |w|
# disable max attempts
w.max_attempts = nil
# poll for 1 hour, instead of a number of attempts
w.before_wait do |attempts, response|
throw :failure if Time.now - started_at > 3600
end
end
Handling Errors
When a waiter is successful, it returns true
. When a waiter
fails, it raises an error. All errors raised extend from
Waiters::Errors::WaiterFailed.
begin
client.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
# resource did not enter the desired state in time
end
#waiter_names ⇒ Array<Symbol>
Returns the list of supported waiters. The following table lists the supported waiters and the client method they call:
Waiter Name | Client Method | Default Delay: | Default Max Attempts: |
---|---|---|---|
:cluster_active | #describe_cluster | 30 | 40 |
:cluster_deleted | #describe_cluster | 30 | 40 |
:nodegroup_active | #describe_nodegroup | 30 | 80 |
:nodegroup_deleted | #describe_nodegroup | 30 | 40 |