In Anthos clusters on bare metal, hybrid clusters perform the dual role of an admin cluster and a user cluster. They run workloads, and at the same time, manage other clusters, and themselves.
Hybrid clusters eliminate the need to run a separate admin cluster in resource-constrained scenarios, and can provide highly available (HA) reliability. In an HA hybrid cluster, if one node fails, then others will take its place.
Hybrid clusters are different from standalone clusters in that they can also manage other clusters. Standalone clusters can't create or manage other clusters.
When you create hybrid clusters, there is some tradeoff between flexibility and security, however. Since hybrid clusters manage themselves, running workloads on the same cluster increases the risk of security exposure to sensitive administrative data, like SSH keys.
You create a hybrid cluster with a high availability (HA) control plane using
bmctl command. The
bmctl command can be run on a separate workstation or on one
of the hybrid cluster nodes.
bmctlis downloaded (
gs://anthos-baremetal-release/bmctl/1.16.1/linux-amd64/bmctl) from Cloud Storage.
- Workstation running
bmctlhas network connectivity to all nodes in the target hybrid cluster.
- Workstation running
bmctlhas network connectivity to the control plane VIP of the target hybrid cluster.
- SSH key used to create the hybrid cluster is available to root, or there is SUDO user access on all nodes in the target hybrid cluster.
- Connect-register service account is configured for use with Connect.
See the Anthos clusters on bare metal quickstart for expanded step-by-step instructions for creating a hybrid cluster.
If you want to enable SELinux to secure your containers, you must make sure that
SELinux is enabled in
Enforced mode on all your host machines. Starting with
Anthos clusters on bare metal release 1.9.0 or later, you can enable or disable SELinux
before or after cluster creation or cluster upgrades. SELinux is enabled by
default on Red Hat Enterprise Linux (RHEL) and CentOS. If SELinux is disabled on
your host machines or you aren't sure, see
Securing your containers using SELinux
for instructions on how to enable it.
Anthos clusters on bare metal supports SELinux in only RHEL and CentOS systems.
Log into gcloud and create a hybrid cluster config file
- Login to gcloud as a user using
gcloud auth application-defaultlogin:
gcloud auth application-default loginYou need to have a Project Owner/Editor role to use the automatic API enablement and Service Account creation features, described below. You can also add the following IAM roles to the user:
- Service Account Admin
- Service Account Key Admin
- Project IAM Admin
- Compute Viewer
- Service Usage Admin
export GOOGLE_APPLICATION_CREDENTIALS=JSON_KEY_FILEJSON_KEY_FILE specifies the path to your service account JSON key file.
export CLOUD_PROJECT_ID=$(gcloud config get-value project)
Create the hybrid cluster with
After you've logged into gcloud and have your project set up, you can create the
cluster config file with the
bmctl command. Note that in this example,
all service accounts are automatically created by the
bmctl create config command:
bmctl create config -c HYBRID_CLUSTER_NAME --enable-apis \ --create-service-accounts --project-id=CLOUD_PROJECT_ID
Here's an example to create a config file for a hybrid cluster
hybrid1 associated with project ID
bmctl create config -c hybrid1 --create-service-accounts --project-id=my-gcp-project
The file is written to
As an alternative to automatically enabling APIs and creating service accounts,
you can also provide your existing service accounts with proper
IAM permissions. Thie means you can skip the automatic service account creation
in the previous step in the
bmctl create config -c hybrid1
Edit the cluster config file
Now that you have a cluster config file, edit it to make the following changes:
Provide the SSH private key to access the hybrid cluster nodes:
# bmctl configuration variables. Because this section is valid YAML but not a valid Kubernetes # resource, this section can only be included when using bmctl to # create the initial admin/hybrid cluster. Afterwards, when creating user clusters by directly # applying the cluster and node pool resources to the existing cluster, you must remove this # section. gcrKeyPath: bmctl-workspace/.sa-keys/my-gcp-project-anthos-baremetal-gcr.json sshPrivateKeyPath: /path/to/your/ssh_private_key gkeConnectAgentServiceAccountKeyPath: bmctl-workspace/.sa-keys/my-gcp-project-anthos-baremetal-connect.json gkeConnectRegisterServiceAccountKeyPath: bmctl-workspace/.sa-keys/my-gcp-project-anthos-baremetal-register.json cloudOperationsServiceAccountKeyPath: bmctl-workspace/.sa-keys/my-gcp-project-anthos-baremetal-cloud-ops.json
Register your clusters to a fleet. The project ID that you specified in the
bmctl create configcommand is automatically added to the
gkeConnect.projectIDfield in the cluster config file. This project is referred to as the fleet host project.
- If you created your config file, using the automatic API enablement and Service Account creation features, you can skip this step.
- If you created the config file without using the automatic API enablement
and Service Account creation features, reference the downloaded service
account JSON keys in the corresponding
gkeConnectRegisterServiceAccountKeyPathfields of the cluster config file.
Change the config to specify a cluster type of
spec: # Cluster type. This can be: # 1) admin: to create an admin cluster. This can later be used to create user clusters. # 2) user: to create a user cluster. Requires an existing admin cluster. # 3) hybrid: to create a hybrid cluster that runs admin cluster components and user workloads. # 4) standalone: to create a cluster that manages itself, runs user workloads, but does not manage other clusters. type: hybrid
Change the config to specify a multi-node, high availability control plane. You want to specify an odd number of nodes to be able to have a majority quorum for HA:
# Control plane configuration controlPlane: nodePoolSpec: nodes: # Control plane node pools. Typically, this is either a single machine # or 3 machines if using a high availability deployment. - address: 10.200.0.4 - address: 10.200.0.5 - address: 10.200.0.6
Specify the pod density of cluster nodes:
.... # NodeConfig specifies the configuration that applies to all nodes in the cluster. nodeConfig: # podDensity specifies the pod density configuration. podDensity: # maxPodsPerNode specifies at most how many pods can be run on a single node. maxPodsPerNode: 250 ....
For hybrid clusters, allowable values for
32-250for HA clusters and
64-250for non-HA clusters. The default value for
maxPodsPerNodeif unspecified is
110. Once the cluster is created, this value cannot be updated.
Pod density is also limited by your cluster's available IP resources. For details, see Pod networking.
Create the hybrid cluster with the cluster config
bmctl command to deploy the cluster:
bmctl create cluster -c CLUSTER_NAME
CLUSTER_NAME specifies cluster name you created in the previous section.
The following shows an example of the command to create a config file for a cluster
bmctl create cluster -c hybrid1
Sample hybrid cluster configurations
For example hybrid cluster configurations, see Hybrid clusters in the Cluster configuration samples.