Create Managed Cluster#
Creation Process#
Step 1: Create Credential#
- Create a
Credential
object with all credentials required per the Credential System.
Step 2: Select the Template#
For details about the templates in Project 2A, see the Templates system.
- Set the
KUBECONFIG
environment variable to the path to the management cluster kubeconfig file. Then select theTemplate
you want to use for the deployment. To list all available templates, run:
kubectl get clustertemplate -n hmc-system
Note
If you want to deploy a hosted control plane template, check additional notes on hosted control planes for each of the clustertemplate sections:
Step 3: Create the ManagedCluster Object YAML Configuration#
-
Create the file with the
ManagedCluster
configuration:apiVersion: hmc.mirantis.com/v1alpha1 kind: ManagedCluster metadata: name: <cluster-name> namespace: <hmc-system-namespace> spec: template: <template-name> credential: <infrastructure-provider-credential-name> dryRun: <"true" or "false": defaults to "false"> config: <cluster-configuration>
Note
Substitute the parameters enclosed in angle brackets with the corresponding
values. Enable the dryRun
flag if required. For details, see
Dry Run.
Following is an interpolated example.
Example
ManagedCluster
for AWS Infrastructure Provider Object Example
apiVersion: hmc.mirantis.com/v1alpha1
kind: ManagedCluster
metadata:
name: my-managed-cluster
namespace: hmc-system
spec:
template: aws-standalone-cp-0-0-3
credential: aws-credential
dryRun: true
config:
region: us-west-2
controlPlane:
instanceType: t3.small
worker:
instanceType: t3.small
Step 4: Apply the ManagedCluster
Configuration to Create it#
-
Apply the
ManagedCluster
object to your Project 2A deployment:kubectl apply -f managedcluster.yaml
Step 5: Check the Status of the ManagedCluster
Object#
-
Check the status of the newly created
ManagedCluster
:kubectl -n <namespace> get managedcluster.hmc <cluster-name> -o=yaml
Info
Reminder: <namespace>
and <cluster-name>
are defined in the .metadata
section of the ManagedCluster
object you created above.
Step 6: Wait for Infrastructure and Cluster to be Provisioned#
-
Wait for infrastructure to be provisioned and the cluster to be deployed:
kubectl -n <namespace> get cluster <cluster-name> -o=yaml
Tip
You may also watch the process with the clusterctl describe
command
(requires the clusterctl
CLI to be installed):
clusterctl describe cluster <cluster-name> -n <namespace> --show-conditions all
Step 7: Retrieve Kubernetes Configuration of Your Managed Cluster#
-
Retrieve the Kubernetes configuration of your managed cluster when it is finished provisioning:
kubectl get secret -n <namespace> <cluster-name>-kubeconfig -o=jsonpath={.data.value} | base64 -d > kubeconfig
Dry Run#
Project 2A ManagedCluster
supports two modes: with and without .spec.dryRun
(defaults to false
).
If no configuration (.spec.config
) is specified, the ManagedCluster
object
will be populated with defaults (default configuration can be found in the
corresponding Template
status) and automatically have .spec.dryRun
set to
true
.
Example
ManagedCluster
with default configuration
apiVersion: hmc.mirantis.com/v1alpha1
kind: ManagedCluster
metadata:
name: my-managed-cluster
namespace: hmc-system
spec:
config:
clusterNetwork:
pods:
cidrBlocks:
- 10.244.0.0/16
services:
cidrBlocks:
- 10.96.0.0/12
controlPlane:
iamInstanceProfile: control-plane.cluster-api-provider-aws.sigs.k8s.io
instanceType: ""
controlPlaneNumber: 3
k0s:
version: v1.27.2+k0s.0
publicIP: false
region: ""
sshKeyName: ""
worker:
amiID: ""
iamInstanceProfile: nodes.cluster-api-provider-aws.sigs.k8s.io
instanceType: ""
workersNumber: 2
template: aws-standalone-cp-0-0-3
credential: aws-credential
dryRun: true
After you adjust your configuration and ensure that it passes validation
(TemplateReady
condition from .status.conditions
), remove the .spec.dryRun
flag to proceed with the deployment.
Here is an example of a ManagedCluster
object that passed the validation:
Example
ManagedCluster
object that passed the validation
apiVersion: hmc.mirantis.com/v1alpha1
kind: ManagedCluster
metadata:
name: my-managed-cluster
namespace: hmc-system
spec:
template: aws-standalone-cp-0-0-3
credential: aws-credential
config:
region: us-east-2
publicIP: true
controlPlaneNumber: 1
workersNumber: 1
controlPlane:
instanceType: t3.small
worker:
instanceType: t3.small
status:
conditions:
- lastTransitionTime: "2024-07-22T09:25:49Z"
message: Template is valid
reason: Succeeded
status: "True"
type: TemplateReady
- lastTransitionTime: "2024-07-22T09:25:49Z"
message: Helm chart is valid
reason: Succeeded
status: "True"
type: HelmChartReady
- lastTransitionTime: "2024-07-22T09:25:49Z"
message: ManagedCluster is ready
reason: Succeeded
status: "True"
type: Ready
observedGeneration: 1
Cleanup#
-
Remove the Management object:
kubectl delete management.hmc hmc
Note
Ensure you have no Project 2A ManagedCluster
objects left in the cluster
prior to Management deletion.
-
Remove the
hmc
Helm release:helm uninstall hmc -n hmc-system
-
Remove the
hmc-system
namespace:kubectl delete ns hmc-system