Questo contenuto non è disponibile nella lingua selezionata.
Chapter 12. Managing machines with the Cluster API
Managing machines with the Cluster API is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.
The Cluster API is an upstream project that is integrated into OpenShift Container Platform as a Technology Preview for Amazon Web Services (AWS) and Google Cloud Platform (GCP) clusters. You can use the Cluster API to create and manage machine sets and machines in your OpenShift Container Platform cluster. This capability is in addition or an alternative to managing machines with the Machine API.
For OpenShift Container Platform 4.11 clusters, you can use the Cluster API to perform node host provisioning management actions after the cluster installation finishes. This system enables an elastic, dynamic provisioning method on top of public or private cloud infrastructure.
With the Cluster API Technology Preview, you can create compute machines and machine sets on OpenShift Container Platform clusters for supported providers. You can also explore the features that are enabled by this implementation that might not be available with the Machine API.
Benefits
By using the Cluster API, OpenShift Container Platform users and developers are able to realize the following advantages:
- The option to use upstream community Cluster API infrastructure providers which might not be supported by the Machine API.
- The opportunity to collaborate with third parties who maintain machine controllers for infrastructure providers.
- The ability to use the same set of Kubernetes tools for infrastructure management in OpenShift Container Platform.
- The ability to create machine sets using the Cluster API that support features that are not available with the Machine API.
Limitations
Using the Cluster API to manage machines is a Technology Preview feature and has the following limitations:
- Only AWS and GCP clusters are supported.
-
To use this feature, you must enable the feature set. Enabling this feature set cannot be undone and prevents minor version updates.
TechPreviewNoUpgrade - You must create the primary resources that the Cluster API requires manually.
- Control plane machines cannot be managed by the Cluster API.
- Migration of existing machine sets created by the Machine API to Cluster API machine sets is not supported.
- Full feature parity with the Machine API is not available.
12.1. Cluster API architecture Copia collegamentoCollegamento copiato negli appunti!
The OpenShift Container Platform integration of the upstream Cluster API is implemented and managed by the Cluster CAPI Operator. The Cluster CAPI Operator and its operands are provisioned in the
openshift-cluster-api
openshift-machine-api
12.1.1. The Cluster CAPI Operator Copia collegamentoCollegamento copiato negli appunti!
The Cluster CAPI Operator is an OpenShift Container Platform Operator that maintains the lifecycle of Cluster API resources. This Operator is responsible for all administrative tasks related to deploying the Cluster API project within an OpenShift Container Platform cluster.
If a cluster is configured correctly to allow the use of the Cluster API, the Cluster CAPI Operator installs the Cluster API Operator on the cluster.
The Cluster CAPI Operator is distinct from the upstream Cluster API Operator.
For more information, see the entry for the Cluster CAPI Operator in the Cluster Operators reference content.
12.1.2. Primary resources Copia collegamentoCollegamento copiato negli appunti!
The Cluster API is comprised of the following primary resources. For the Technology Preview of this feature, you must create these resources manually in the
openshift-cluster-api
- Cluster
- A fundamental unit that represents a cluster that is managed by the Cluster API.
- Infrastructure
- A provider-specific resource that defines properties that are shared by all the machine sets in the cluster, such as the region and subnets.
- Machine template
- A provider-specific template that defines the properties of the machines that a machine set creates.
- Machine set
A group of machines.
Machine sets are to machines as replica sets are to pods. If you need more machines or must scale them down, you change the
field on the machine set to meet your compute needs.replicasWith the Cluster API, a machine set references a
object and a provider-specific machine template.Cluster- Machine
A fundamental unit that describes the host for a node.
The Cluster API creates machines based on the configuration in the machine template.
12.2. Sample YAML files Copia collegamentoCollegamento copiato negli appunti!
For the Cluster API Technology Preview, you must create the primary resources that the Cluster API requires manually. The example YAML files in this section demonstrate how to make these resources work together and configure settings for the machines that they create that are appropriate for your environment.
12.2.1. Sample YAML for a Cluster API cluster resource Copia collegamentoCollegamento copiato negli appunti!
The cluster resource defines the name and infrastructure provider for the cluster and is managed by the Cluster API. This resource has the same structure for all providers.
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: <cluster_name>
namespace: openshift-cluster-api
spec:
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: <infrastructure_kind>
name: <cluster_name>
namespace: openshift-cluster-api
The remaining Cluster API resources are provider-specific. Refer to the example YAML files for your cluster:
12.2.2. Sample YAML files for configuring Amazon Web Services clusters Copia collegamentoCollegamento copiato negli appunti!
Some Cluster API resources are provider-specific. The example YAML files in this section show configurations for an Amazon Web Services (AWS) cluster.
12.2.2.1. Sample YAML for a Cluster API infrastructure resource on Amazon Web Services Copia collegamentoCollegamento copiato negli appunti!
The infrastructure resource is provider-specific and defines properties that are shared by all the machine sets in the cluster, such as the region and subnets. The machine set references this resource when creating machines.
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AWSCluster
metadata:
name: <cluster_name>
namespace: openshift-cluster-api
spec:
region: <region>
12.2.2.2. Sample YAML for a Cluster API machine template resource on Amazon Web Services Copia collegamentoCollegamento copiato negli appunti!
The machine template resource is provider-specific and defines the basic properties of the machines that a machine set creates. The machine set references this template when creating machines.
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha4
kind: AWSMachineTemplate
metadata:
name: <template_name>
namespace: openshift-cluster-api
spec:
template:
spec:
uncompressedUserData: true
iamInstanceProfile: ....
instanceType: m5.large
cloudInit:
insecureSkipSecretsManager: true
ami:
id: ....
subnet:
filters:
- name: tag:Name
values:
- ...
additionalSecurityGroups:
- filters:
- name: tag:Name
values:
- ...
12.2.2.3. Sample YAML for a Cluster API machine set resource on Amazon Web Services Copia collegamentoCollegamento copiato negli appunti!
The machine set resource defines additional properties of the machines that it creates. The machine set also references the infrastructure resource and machine template when creating machines.
apiVersion: cluster.x-k8s.io/v1alpha4
kind: MachineSet
metadata:
name: <machine_set_name>
namespace: openshift-cluster-api
spec:
clusterName: <cluster_name>
replicas: 1
selector:
matchLabels:
test: example
template:
metadata:
labels:
test: example
spec:
bootstrap:
dataSecretName: worker-user-data
clusterName: <cluster_name>
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha4
kind: AWSMachineTemplate
name: <cluster_name>
12.2.3. Sample YAML files for configuring Google Cloud Platform clusters Copia collegamentoCollegamento copiato negli appunti!
Some Cluster API resources are provider-specific. The example YAML files in this section show configurations for a Google Cloud Platform (GCP) cluster.
12.2.3.1. Sample YAML for a Cluster API infrastructure resource on Google Cloud Platform Copia collegamentoCollegamento copiato negli appunti!
The infrastructure resource is provider-specific and defines properties that are shared by all the machine sets in the cluster, such as the region and subnets. The machine set references this resource when creating machines.
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPCluster
metadata:
name: <cluster_name>
spec:
network:
name: <cluster_name>-network
project: <project>
region: <region>
12.2.3.2. Sample YAML for a Cluster API machine template resource on Google Cloud Platform Copia collegamentoCollegamento copiato negli appunti!
The machine template resource is provider-specific and defines the basic properties of the machines that a machine set creates. The machine set references this template when creating machines.
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPMachineTemplate
metadata:
name: <template_name>
namespace: openshift-cluster-api
spec:
template:
spec:
rootDeviceType: pd-ssd
rootDeviceSize: 128
instanceType: n1-standard-4
image: projects/rhcos-cloud/global/images/rhcos-411-85-202203181601-0-gcp-x86-64
subnet: <cluster_name>-worker-subnet
serviceAccounts:
email: <service_account_email_address>
scopes:
- https://www.googleapis.com/auth/cloud-platform
additionalLabels:
kubernetes-io-cluster-<cluster_name>: owned
additionalNetworkTags:
- <cluster_name>-worker
ipForwarding: Disabled
12.2.3.3. Sample YAML for a Cluster API machine set resource on Google Cloud Platform Copia collegamentoCollegamento copiato negli appunti!
The machine set resource defines additional properties of the machines that it creates. The machine set also references the infrastructure resource and machine template when creating machines.
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineSet
metadata:
name: <machine_set_name>
namespace: openshift-cluster-api
spec:
clusterName: <cluster_name>
replicas: 1
selector:
matchLabels:
test: test
template:
metadata:
labels:
test: test
spec:
bootstrap:
dataSecretName: worker-user-data
clusterName: <cluster_name>
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPMachineTemplate
name: <machine_set_name>
failureDomain: <failure_domain>
- 1 6
- Specify a name for the machine set.
- 2 4
- Specify the name of the cluster.
- 3
- For the Cluster API Technology Preview, the Operator can use the worker user data secret from
openshift-machine-apinamespace. - 5
- Specify the machine template kind. This value must match the value for your platform.
- 7
- Specify the failure domain within the GCP region.
12.3. Creating a Cluster API machine set Copia collegamentoCollegamento copiato negli appunti!
You can create machine sets that use the Cluster API to dynamically manage the machine compute resources for specific workloads of your choice.
Prerequisites
- Deploy an OpenShift Container Platform cluster.
- Enable the use of the Cluster API.
-
Install the OpenShift CLI ().
oc -
Log in to as a user with
ocpermission.cluster-admin
Procedure
Create a YAML file that contains the cluster custom resource (CR) and is named
.<cluster_resource_file>.yamlIf you are not sure which value to set for the
parameter, you can check the value for an existing Machine API machine set in your cluster.<cluster_name>To list the Machine API machine sets, run the following command:
$ oc get machinesets -n openshift-machine-api1 - 1
- Specify the
openshift-machine-apinamespace.
Example output
NAME DESIRED CURRENT READY AVAILABLE AGE agl030519-vplxk-worker-us-east-1a 1 1 1 1 55m agl030519-vplxk-worker-us-east-1b 1 1 1 1 55m agl030519-vplxk-worker-us-east-1c 1 1 1 1 55m agl030519-vplxk-worker-us-east-1d 0 0 55m agl030519-vplxk-worker-us-east-1e 0 0 55m agl030519-vplxk-worker-us-east-1f 0 0 55mTo display the contents of a specific machine set CR, run the following command:
$ oc get machineset <machineset_name> \ -n openshift-machine-api \ -o yamlExample output
... template: metadata: labels: machine.openshift.io/cluster-api-cluster: agl030519-vplxk1 machine.openshift.io/cluster-api-machine-role: worker machine.openshift.io/cluster-api-machine-type: worker machine.openshift.io/cluster-api-machineset: agl030519-vplxk-worker-us-east-1a ...- 1
- The cluster ID, which you use for the
<cluster_name>parameter.
Create the cluster CR by running the following command:
$ oc create -f <cluster_resource_file>.yamlVerification
To confirm that the cluster CR is created, run the following command:
$ oc get clusterExample output
NAME PHASE AGE VERSION <cluster_name> Provisioning 4h6m-
Create a YAML file that contains the infrastructure CR and is named .
<infrastructure_resource_file>.yaml Create the infrastructure CR by running the following command:
$ oc create -f <infrastructure_resource_file>.yamlVerification
To confirm that the infrastructure CR is created, run the following command:
$ oc get <infrastructure_kind>where
is the value that corresponds to your platform.<infrastructure_kind>Example output
NAME CLUSTER READY VPC BASTION IP <cluster_name> <cluster_name> true-
Create a YAML file that contains the machine template CR and is named .
<machine_template_resource_file>.yaml Create the machine template CR by running the following command:
$ oc create -f <machine_template_resource_file>.yamlVerification
To confirm that the machine template CR is created, run the following command:
$ oc get <machine_template_kind>where
is the value that corresponds to your platform.<machine_template_kind>Example output
NAME AGE <template_name> 77m-
Create a YAML file that contains the machine set CR and is named .
<machine_set_resource_file>.yaml Create the machine set CR by running the following command:
$ oc create -f <machine_set_resource_file>.yamlVerification
To confirm that the machine set CR is created, run the following command:
$ oc get machineset -n openshift-cluster-api1 - 1
- Specify the
openshift-cluster-apinamespace.
Example output
NAME CLUSTER REPLICAS READY AVAILABLE AGE VERSION <machine_set_name> <cluster_name> 1 1 1 17mWhen the new machine set is available, the
andREPLICASvalues match. If the machine set is not available, wait a few minutes and run the command again.AVAILABLE
Verification
To verify that the machine set is creating machines according to your desired configuration, you can review the lists of machines and nodes in the cluster.
To view the list of Cluster API machines, run the following command:
$ oc get machine -n openshift-cluster-api1 - 1
- Specify the
openshift-cluster-apinamespace.
Example output
NAME CLUSTER NODENAME PROVIDERID PHASE AGE VERSION <machine_set_name>-<string_id> <cluster_name> <ip_address>.<region>.compute.internal <provider_id> Running 8m23sTo view the list of nodes, run the following command:
$ oc get nodeExample output
NAME STATUS ROLES AGE VERSION <ip_address_1>.<region>.compute.internal Ready worker 5h14m v1.24.0+284d62a <ip_address_2>.<region>.compute.internal Ready master 5h19m v1.24.0+284d62a <ip_address_3>.<region>.compute.internal Ready worker 7m v1.24.0+284d62a
12.4. Troubleshooting clusters that use the Cluster API Copia collegamentoCollegamento copiato negli appunti!
Use the information in this section to understand and recover from issues you might encounter. Generally, troubleshooting steps for problems with the Cluster API are similar to those steps for problems with the Machine API.
The Cluster CAPI Operator and its operands are provisioned in the
openshift-cluster-api
openshift-machine-api
oc
12.4.1. CLI commands return Cluster API machines Copia collegamentoCollegamento copiato negli appunti!
For clusters that use the Cluster API,
oc
oc get machine
c
m
To list only Machine API machines, use the fully qualified name
when running themachines.machine.openshift.iocommand:oc get machine$ oc get machines.machine.openshift.ioTo list only Cluster API machines, use the fully qualified name
when running themachines.cluster.x-k8s.iocommand:oc get machine$ oc get machines.cluster.x-k8s.io