Hosted Cluster or HCP(Hosted Control Plane) is a concept in OpenShift where an OpenShift cluster is created by hosting control plane components as pods in management cluster in a namespace. It's managed by the project called Hypershift. More about it here.
Where agent is one of the type of hosted cluster deployment where an ISO is used to bringup and attach workers to the hosted cluster. More about it here.
In this blog will try to give discuss on how did we bringup agent based hosted cluster with power worker nodes.
Prerequisite:
- Admin access to an OpenShift cluster (version 4.14+) specified by the
KUBECONFIG environment variable.
- The OpenShift CLI (
oc) or Kubernetes CLI (kubectl).
- A valid pull secret file for the
quay.io/openshift-release-dev repository.
Setup the management cluster:
MCE(Multi Cluster Engine) operator from operator hub would be used to setup the management cluster with required CRDs and operators needed to create the hosted cluster.
Installing MCE:
MCE can be installed via both UI and CLI. Follow below steps to install it via CLI
Create a namespace to install all the resources related to MCE operator
Make that namespace as default namespace
Create operator group
Create multicluster-engine operator subscription, make sure version stable-2.4+ is used.
Ensure subscription installs necessary CRDs and components
Create mce instance to enable and install required components
It may take some time to install all the components. Below command can be used to get status of multiclusterengine created in last step. Wait till it reaches Available status
Creating AgentServiceConfig:
AgentServiceConfig is required to define the set of OS images for assisted service to use and generate the minimal discovery ISO.
-
export STORAGE_CLASS=$(oc get sc | grep default | awk '{print $1}') // If management cluster contains multi zone nodes, need to make sure this storage class’s VOLUMEBINDINGMODE is set to WaitForFirstConsumer. If default storage class does not have this volume binding mode, please create one and use it.
export DB_VOLUME_SIZE="10Gi"
export FS_VOLUME_SIZE="10Gi"
export OCP_VERSION="4.14.0"
export OCP_MAJOR=${OCP_VERSION%.*}
export ARCH="ppc64le"
export OCP_RELEASE_VERSION=$(curl -s https://mirror.openshift.com/pub/openshift-v4/${ARCH}/clients/ocp/${OCP_VERSION}/release.txt | awk '/machine-os / { print $2 }')
export ISO_URL="https://mirror.openshift.com/pub/openshift-v4/${ARCH}/dependencies/rhcos/${OCP_MAJOR}/${OCP_VERSION}/rhcos-${OCP_VERSION}-${ARCH}-live.${ARCH}.iso"
export ROOT_FS_URL="https://mirror.openshift.com/pub/openshift-v4/${ARCH}/dependencies/rhcos/${OCP_MAJOR}/${OCP_VERSION}/rhcos-${OCP_VERSION}-${ARCH}-live-rootfs.${ARCH}.img"
-
envsubst <<"EOF" | oc apply -f -
apiVersion: agent-install.openshift.io/v1beta1
kind: AgentServiceConfig
metadata:
name: agent
spec:
databaseStorage:
storageClassName: ${STORAGE_CLASS}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: ${DB_VOLUME_SIZE}
filesystemStorage:
storageClassName: ${STORAGE_CLASS}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: ${FS_VOLUME_SIZE}
osImages:
- openshiftVersion: "${OCP_VERSION}"
version: "${OCP_RELEASE_VERSION}"
url: "${ISO_URL}"
rootFSUrl: "${ROOT_FS_URL}"
cpuArchitecture: "${ARCH}"
EOF
Create Hosted Control Plane:
Build Hypershift binary:
Create Cluster:
Once cluster-agent.yaml is generated, modify the HostedCluster spec's service field with suitable servicePublishingStrategy for various control plane services. By default it is generated with NodePort, you can change it to Route or LoadBalancer based on your requirement.
Sample services block of a HostedCluster's spec will look like below.
Once you done editing cluster-agent.yaml, you can apply it to deploy the HostedCluster
Wait for the HostedCluster to be available
Create InfraEnv:
Once InfraEnv is created, a minimal iso would be generated by assisted service need to use this iso to bring up the worker nodes. Get the ISO Download URL from below command
Create DNS records:
Create *.api and *.api-int DNS records from the endpoint provided by kube-apiserver service from control plane namespace.
Create *.apps DNS record points to one of the worker's IP or if there is a load balancer on top of the workers, use that to create this DNS record.
Boot the worker:
Boot the ISO generated in previous step on a Power node via PowerVC or IBM Cloud PowerVS VSI. Once it's booted, it will appear as an agent in control plane namespace.
Add agents:
Use below command to list the agents in control plane namespace
Approve the agent using below command
Once agent is approved, scale the node pool according to the approved agent count
Confirm cluster is working fine:
Access the hosted cluster via kubeconfig
Use following commands to validate the agent cluster created
#Containers,Kubernetes,andOpenShift