This topic describes how to use the Tanzu Kubernetes Grid CLI to deploy a management cluster to Amazon Elastic Compute Cloud (Amazon EC2).
It is strongly recommended to use the Tanzu Kubernetes Grid installer interface rather than the CLI to deploy your first management cluster to Amazon EC2. When you deploy a management cluster by using the installer interface, it populates the
config.yaml file for the management cluster with the required parameters. You can use the created
config.yaml as a model for future deployments from the CLI.
If this is the first time that you are running Tanzu Kubernetes Grid commands on this machine, and you have not already deployed a management cluster to Amazon EC2 by using the Tanzu Kubernetes Grid installer interface, open a terminal and run the
tkg get management-cluster command.
tkg get management-cluster
tkg command for the first time creates the
$HOME/.tkg folder, that contains the management cluster configuration file
Do not run multiple management cluster deployments on the same bootstrap environment machine at the same time. Do not change context or edit the
kubeconfig file while Tanzu Kubernetes Grid operations are running.
Tanzu Kubernetes Grid does not support IPv6 addresses. This is because upstream Kubernetes only provides alpha support for IPv6. Always provide IPv4 addresses in the procedures in this topic.
.tkg/config.yaml file in a text editor.
If you have already deployed a management cluster to Amazon EC2 from the installer interface, you will see variables that describe your previous deployment.
If you have not already deployed a management cluster to Amazon EC2 from the installer interface, copy and paste the following rows into the configuration file, after the end of the
AWS_REGION: AWS_NODE_AZ: AWS_PUBLIC_NODE_CIDR: AWS_PRIVATE_NODE_CIDR: AWS_VPC_CIDR: CLUSTER_CIDR: AWS_SSH_KEY_NAME: CONTROL_PLANE_MACHINE_TYPE: NODE_MACHINE_TYPE:
The table below describes all of the variables that you must set for deployment to Amazon EC2. Leave a space between the colon (
:) and the variable value. For example:
IMPORTANT: Any environment variables that you have set that have the same key as the variables that you set in
config.yaml will override the values that you set in
config.yaml. You must unset those variables before you deploy the management cluster from the CLI.
||The name of the AWS region in which to deploy the management cluster. If you have already set a different region as an environment variable, for example in Prepare to Deploy the Management Cluster to Amazon EC2, you must unset that environment variable.|
||The name of the AWS availability zone in your chosen region, to use as the availability zone for nodes of this management cluster. Availability zone names are the same as the AWS region name, with a single lower-case letter suffix, such as
||If the recommended range of 10.0.0.0/16 is not available, enter a different IP range in CIDR format for public nodes to use.|
||If the recommended range of 10.0.0.0/24 is not available, enter a different IP range in CIDR format for private nodes to use.|
||If the recommended range of 10.0.0.0/16 is not available, enter a different IP range in CIDR format for the management cluster to use.|
||If the recommended range of 100.96.0.0/11 is not available, enter a different IP range in CIDR format for pods to use.|
||Your SSH key name||Enter the name of the SSH private key that you registered with your Amazon EC2 account in Register an SSH Public Key with Your AWS Account.|
tkg init command.
tkg init for the first time creates the
$HOME/.tkg folder, that contains the template configuration file
config.yaml from which the management cluster is deployed.
tkg init --infrastructure=aws
tkg init --infrastructure=aws --name=management_cluster_name
--plan=devoption. If you do not specify
devplan is used by default.
tkg init --infrastructure=aws --name management_cluster_name --plan=dev
tkg init --infrastructure=aws --name=management_cluster_name --plan=prod
$HOME/.tkgand creates the cluster configuration file,
config.yamlin that folder. To create
config.yamlin a different location or with a different name, specify the
--configoption. If you specify the
--configoption, Tanzu Kubernetes Grid only creates the YAML file in the specified location. Other files are still created in the
tkg init --infrastructure=aws --name=management_cluster_name --config path_to_file/my-config.yaml
Follow the progress of the deployment of the management cluster in the terminal.
Deployment of the management cluster can take several minutes. The first run of
tkg init takes longer than subsequent runs because it has to pull the required Docker images into the image store on your bootstrap environment. Subsequent runs do not require this step, so are faster.
For information about what happened during the deployment of the management cluster, how to connect
kubectl to the management cluster, and how to create namespaces, see Examine the Management Cluster Deployment.