From 0248e74d554cdeae45ec7156698b6b9a5889801d Mon Sep 17 00:00:00 2001 From: James Blair Date: Mon, 27 May 2024 02:55:14 +1200 Subject: [PATCH] Begin writing excercise 3. --- data/workshop/exercise2.mdx | 4 +- data/workshop/exercise3.mdx | 113 ++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 data/workshop/exercise3.mdx diff --git a/data/workshop/exercise2.mdx b/data/workshop/exercise2.mdx index 9ce8731..800272b 100644 --- a/data/workshop/exercise2.mdx +++ b/data/workshop/exercise2.mdx @@ -1,5 +1,5 @@ --- -title: Understanding the workshop environment +title: Installing the windows machine config operator exercise: 2 date: '2024-05-26' tags: ['openshift','windows','kubernetes','containers'] @@ -11,7 +11,7 @@ summary: "Preparing our cluster for windows machines." In this first hands on excercise we will prepare our cluster for running Windows nodes by installing an operator and configuring it. -[[https://docs.openshift.com/container-platform/4.15/operators/index.html][Operators]] are among the most important components of OpenShift Container Platform. Operators are the preferred method of packaging, deploying, and managing additional cluster services or application. +[Operatps](https://docs.openshift.com/container-platform/4.15/operators/index.html) are among the most important components of OpenShift Container Platform. Operators are the preferred method of packaging, deploying, and managing additional cluster services or application. To install Operators on OpenShift we use Operator Hub. A simplistic way of thinking about Operator Hub is as the "App Store" for your OpenShift cluster. diff --git a/data/workshop/exercise3.mdx b/data/workshop/exercise3.mdx new file mode 100644 index 0000000..f458e34 --- /dev/null +++ b/data/workshop/exercise3.mdx @@ -0,0 +1,113 @@ +--- +title: Provisioning a windows worker node +exercise: 3 +date: '2024-05-26' +tags: ['openshift','windows','kubernetes','containers'] +draft: false +authors: ['default'] +summary: "Auto scaling nodes with machine sets!" +--- + + +Now that our cluster is ready to support Windows nodes lets provision one through the Machine API. + +The Machine API is a combination of primary resources that are based on the upstream [Cluster API](https://github.com/kubernetes-sigs/cluster-api) project and custom OpenShift Container Platform resources. + +The two primary resources are: + +**1. Machines** + +> A fundamental unit that describes the host for a Node. A machine has a providerSpec, which describes the types of compute nodes that are offered for different cloud platforms. For example, a machine type for a worker node on Amazon Web Services (AWS) might define a specific machine type and required metadata. + +**2. MachineSets** + +> Groups of machines. MachineSets are to machines as ReplicaSets are to Pods. If you need more machines or must scale them down, you change the **replicas** field on the MachineSet to meet your compute need. + + +## 3.1 Create a single replica machineset + +In this excersie we will create a `MachineSet`. Once created this will automatically begin provisoning a Windows machine and adding it to our cluster as a worker node. + +Below is a yaml snippet we will use as base to create our `MachineSet`: + +```yaml +apiVersion: machine.openshift.io/v1beta1 +kind: MachineSet +metadata: + name: windows + namespace: openshift-machine-api +spec: + replicas: 1 + selector: + matchLabels: + machine.openshift.io/cluster-api-cluster: demo + machine.openshift.io/cluster-api-machineset: windows + template: + metadata: + labels: + machine.openshift.io/cluster-api-cluster: demo + machine.openshift.io/cluster-api-machine-role: worker + machine.openshift.io/cluster-api-machine-type: worker + machine.openshift.io/cluster-api-machineset: windows + machine.openshift.io/os-id: Windows + spec: + lifecycleHooks: {} + metadata: + labels: + node-role.kubernetes.io/worker: '' + providerSpec: + value: + userDataSecret: + name: windows-user-data + placement: + availabilityZone: ap-southeast-1c + region: ap-southeast-1 + credentialsSecret: + name: aws-cloud-credentials + instanceType: m5a.4xlarge + metadata: + creationTimestamp: null + blockDevices: + - ebs: + iops: 0 + kmsKey: {} + volumeSize: 120 + volumeType: gp2 + securityGroups: + - filters: + - name: 'tag:Name' + values: + - cluster--worker-sg + kind: AWSMachineProviderConfig + metadataServiceOptions: {} + tags: + - name: kubernetes.io/cluster/cluster- + value: owned + deviceIndex: 0 + ami: + id: ami-0e76083a67107f741 + subnet: + filters: + - name: 'tag:Name' + values: + - cluster--private-ap-southeast-1c + apiVersion: awsproviderconfig.openshift.io/v1beta1 + iamInstanceProfile: + id: cluster--worker-profile + +``` + +There are four references to `` in the sample that we need to replace with the actual cluster id for the cluster we have been allocated for the workshop. + +Run the following command in your bastion host to find your cluster id: + +```bash +name=$(oc get machineset -n openshift-machine-api cluster-nkpgx-zf758-worker-ap-southeast-1c -o jsonpath={.metadata.name}) + +echo ${name:8:11} +``` + +After retrieving your cluster id which will look something like example `nkpgx-zf758` update the sample `MachineSet` using your preferred text editor, then select and copy all of the text to clipboard. + +Within OpenShift you can then click the ➕ button in the top right hand corner, paste in your yaml and click **Create**. +