class KubectlProvider (construct)
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.Eks.V2.Alpha.KubectlProvider |
Go | github.com/aws/aws-cdk-go/awscdkeksv2alpha/v2#KubectlProvider |
Java | software.amazon.awscdk.services.eks.v2.alpha.KubectlProvider |
Python | aws_cdk.aws_eks_v2_alpha.KubectlProvider |
TypeScript (source) | @aws-cdk/aws-eks-v2-alpha ยป KubectlProvider |
Implements
IConstruct, IDependable, IKubectl
Implementation of Kubectl Lambda.
Example
const handlerRole = iam.Role.fromRoleArn(this, 'HandlerRole', 'arn:aws:iam::123456789012:role/lambda-role');
// get the serivceToken from the custom resource provider
const functionArn = lambda.Function.fromFunctionName(this, 'ProviderOnEventFunc', 'ProviderframeworkonEvent-XXX').functionArn;
const kubectlProvider = eks.KubectlProvider.fromKubectlProviderAttributes(this, 'KubectlProvider', {
serviceToken: functionArn,
role: handlerRole,
});
const cluster = eks.Cluster.fromClusterAttributes(this, 'Cluster', {
clusterName: 'cluster',
kubectlProvider,
});
Initializer
new KubectlProvider(scope: Construct, id: string, props: KubectlProviderProps)
Parameters
- scope
Construct - id
string - props
KubectlProvider Props
Construct Props
| Name | Type | Description |
|---|---|---|
| cluster | ICluster | The cluster to control. |
| kubectl | ILayer | An AWS Lambda layer that includes kubectl and helm. |
| awscli | ILayer | An AWS Lambda layer that contains the aws CLI. |
| environment? | { [string]: string } | Custom environment variables when running kubectl against this cluster. |
| memory? | Size | The amount of memory allocated to the kubectl provider's lambda function. |
| private | ISubnet[] | Subnets to host the kubectl compute resources. |
| removal | Removal | The removal policy applied to the custom resource that provides kubectl. |
| role? | IRole | An IAM role that can perform kubectl operations against this cluster. |
| security | ISecurity | A security group to use for kubectl execution. |
cluster
Type:
ICluster
The cluster to control.
kubectlLayer
Type:
ILayer
An AWS Lambda layer that includes kubectl and helm.
awscliLayer?
Type:
ILayer
(optional)
An AWS Lambda layer that contains the aws CLI.
If not defined, a default layer will be used containing the AWS CLI 2.x.
environment?
Type:
{ [string]: string }
(optional)
Custom environment variables when running kubectl against this cluster.
memory?
Type:
Size
(optional)
The amount of memory allocated to the kubectl provider's lambda function.
privateSubnets?
Type:
ISubnet[]
(optional)
Subnets to host the kubectl compute resources.
If not specified, the k8s endpoint is expected to be accessible publicly.
removalPolicy?
Type:
Removal
(optional, default: RemovalPolicy.DESTROY)
The removal policy applied to the custom resource that provides kubectl.
The removal policy controls what happens to the resource if it stops being managed by CloudFormation. This can happen in one of three situations:
- The resource is removed from the template, so CloudFormation stops managing it
- A change to the resource is made that requires it to be replaced, so CloudFormation stops managing it
- The stack is deleted, so CloudFormation stops managing all resources in it
role?
Type:
IRole
(optional, default: if not specified, the default role created by a lambda function will
be used.)
An IAM role that can perform kubectl operations against this cluster.
The role should be mapped to the system:masters Kubernetes RBAC role.
This role is directly passed to the lambda handler that sends Kube Ctl commands to the cluster.
securityGroup?
Type:
ISecurity
(optional, default: If not specified, the k8s endpoint is expected to be accessible
publicly.)
A security group to use for kubectl execution.
Properties
| Name | Type | Description |
|---|---|---|
| node | Node | The tree node. |
| service | string | The custom resource provider's service token. |
| role? | IRole | The IAM execution role of the handler. |
node
Type:
Node
The tree node.
serviceToken
Type:
string
The custom resource provider's service token.
role?
Type:
IRole
(optional)
The IAM execution role of the handler.
Methods
| Name | Description |
|---|---|
| to | Returns a string representation of this construct. |
| static from | Import an existing provider. |
| static get | Take existing provider on cluster. |
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromKubectlProviderAttributes(scope, id, attrs)
public static fromKubectlProviderAttributes(scope: Construct, id: string, attrs: KubectlProviderAttributes): IKubectlProvider
Parameters
- scope
Constructโ Construct. - id
stringโ an id of resource. - attrs
Kubectlโ attributes for the provider.Provider Attributes
Returns
Import an existing provider.
static getKubectlProvider(scope, cluster)
public static getKubectlProvider(scope: Construct, cluster: ICluster): IKubectlProvider
Parameters
Returns
Take existing provider on cluster.

.NET
Go
Java
Python
TypeScript (