|
1 | 1 | # Creating a cluster
|
| 2 | + |
| 3 | +### Provision local boostrap management cluster: |
| 4 | + |
| 5 | +1. Create simple, local bootstrap cluster with a control-plane and worker node |
| 6 | + |
| 7 | + Using [kind](https://kind.sigs.k8s.io/docs/user/quick-start/): |
| 8 | + |
| 9 | + ```console |
| 10 | + ~ kind create cluster --name my-bootstrap --config bootstrap.yaml |
| 11 | + ``` |
| 12 | + |
| 13 | + Example bootstrap.yaml: |
| 14 | + ```yaml |
| 15 | + kind: Cluster |
| 16 | + apiVersion: kind.x-k8s.io/v1alpha4 |
| 17 | + nodes: |
| 18 | + - role: control-plane |
| 19 | + - role: worker |
| 20 | + ``` |
| 21 | + |
| 22 | + Make sure the nodes are in `Ready` state before moving on. |
| 23 | + |
| 24 | + ```console |
| 25 | + ~ kubectl get nodes |
| 26 | + NAME STATUS ROLES AGE VERSION |
| 27 | + my-bootstrap-control-plane Ready control-plane,master 46h v1.20.2 |
| 28 | + my-bootstrap-worker Ready <none> 46h v1.20.2 |
| 29 | + ``` |
| 30 | + |
| 31 | +2. Set workload cluster environment variables |
| 32 | + |
| 33 | + Make sure these value reflects your API Key for PowerVS environment in IBM Cloud. |
| 34 | + |
| 35 | + ```console |
| 36 | + export IBMCLOUD_API_KEY=<YOUR_API_KEY> |
| 37 | + ``` |
| 38 | + |
| 39 | +3. Initialize local bootstrap cluter as a management cluster |
| 40 | + |
| 41 | + This cluster will be used to provision a workload cluster in IBM Cloud. |
| 42 | + |
| 43 | + ```console |
| 44 | + ~ clusterctl init --infrastructure ibmcloud:<TAG> |
| 45 | + ``` |
| 46 | + |
| 47 | + Output: |
| 48 | + ```console |
| 49 | + Fetching providers |
| 50 | + Installing cert-manager Version="v1.5.3" |
| 51 | + Waiting for cert-manager to be available... |
| 52 | + Installing Provider="cluster-api" Version="v0.4.4" TargetNamespace="capi-system" |
| 53 | + Installing Provider="bootstrap-kubeadm" Version="v0.4.4" TargetNamespace="capi-kubeadm-bootstrap-system" |
| 54 | + Installing Provider="control-plane-kubeadm" Version="v0.4.4" TargetNamespace="capi-kubeadm-control-plane-system" |
| 55 | + Installing Provider="infrastructure-ibmcloud" Version="v0.1.0-alpha.2" TargetNamespace="capi-ibmcloud-system" |
| 56 | + |
| 57 | + Your management cluster has been initialized successfully! |
| 58 | + |
| 59 | + You can now create your first workload cluster by running the following: |
| 60 | + |
| 61 | + clusterctl generate cluster [name] --kubernetes-version [version] | kubectl apply -f - |
| 62 | + ``` |
| 63 | + |
| 64 | +4. Create PowerVS network port |
| 65 | + |
| 66 | + ```console |
| 67 | + ~ pvsadm create port --description "capi-port" --network <NETWORK_NAME> --instance-id <SERVICE_INSTANCE_ID> |
| 68 | + ``` |
| 69 | + |
| 70 | + Output: |
| 71 | + ```console |
| 72 | + I1125 15:24:20.581757 1548881 port.go:89] Successfully created a port, id: ac18ef17-8517-40e3-889d-4f246e9bd17e |
| 73 | + +---------------------+------------+------+-----------------+-------------------+--------------------------------------+-------------+--------+ |
| 74 | + | DESCRIPTION | EXTERNALIP | HREF | IPADDRESS | MACADDRESS | PORTID | PVMINSTANCE | STATUS | |
| 75 | + +---------------------+------------+------+-----------------+-------------------+--------------------------------------+-------------+--------+ |
| 76 | + | capi-port | | | 192.168.151.125 | fa:16:3e:34:2c:ef | 7eff02b5-040c-4934-957a-18209e65eca4 | | DOWN | |
| 77 | + +---------------------+------------+------+-----------------+-------------------+--------------------------------------+-------------+--------+ |
| 78 | + ``` |
| 79 | + |
| 80 | + ```console |
| 81 | + ~ pvsadm get ports --instance-id <SERVICE_INSTANCE_ID> --network <NETWORK_NAME> |
| 82 | + ``` |
| 83 | + |
| 84 | + Output: |
| 85 | + ```console |
| 86 | + +-------------------+-----------------+-----------------+-------------------+--------------------------------------+--------+ |
| 87 | + | DESCRIPTION | EXTERNALIP | IPADDRESS | MACADDRESS | PORTID | STATUS | |
| 88 | + +-------------------+-----------------+-----------------+-------------------+--------------------------------------+--------+ |
| 89 | + | capi-port | 158.175.162.125 | 192.168.151.125 | fa:16:3e:34:2c:ef | 7eff02b5-040c-4934-957a-18209e65eca4 | DOWN | |
| 90 | + +-------------------+-----------------+-----------------+-------------------+--------------------------------------+--------+ |
| 91 | + ``` |
| 92 | + |
| 93 | +4. Provision workload cluster in IBM Cloud PowerVS |
| 94 | + |
| 95 | + You can use clusterctl to render the yaml through templates. |
| 96 | + |
| 97 | + **Note:** the `IBMPOWERVS_IMAGE_ID` value below should reflect the ID of the custom qcow2 image, the `kubernetes-version` value below should reflect the kubernetes version of the custom qcow2 image. |
| 98 | + |
| 99 | + ```console |
| 100 | + IBMPOWERVS_SSHKEY_NAME="my-pub-key" \ |
| 101 | + IBMPOWERVS_VIP="192.168.151.22" \ |
| 102 | + IBMPOWERVS_VIP_EXTERNAL="158.175.162.22" \ |
| 103 | + IBMPOWERVS_VIP_CIDR="29" \ |
| 104 | + IBMPOWERVS_IMAGE_ID="505f57d8-1143-4a99-b67f-7e82d73342bf" \ |
| 105 | + IBMPOWERVS_SERVICE_INSTANCE_ID="7845d372-d4e1-46b8-91fc-41051c984601" \ |
| 106 | + IBMPOWERVS_NETWORK_ID="0ad342f5-f461-414a-a870-e2f2a2b7fa0c" \ |
| 107 | + clusterctl generate cluster ibm-powervs-1 --kubernetes-version v1.22.4 \ |
| 108 | + --target-namespace default \ |
| 109 | + --control-plane-machine-count=3 \ |
| 110 | + --worker-machine-count=1 \ |
| 111 | + --from ./cluster-template-powervs.yaml | kubectl apply -f - |
| 112 | + ``` |
| 113 | + |
| 114 | + Output: |
| 115 | + ```console |
| 116 | + cluster.cluster.x-k8s.io/ibm-powervs-1 created |
| 117 | + ibmpowervscluster.infrastructure.cluster.x-k8s.io/ibm-powervs-1 created |
| 118 | + kubeadmcontrolplane.controlplane.cluster.x-k8s.io/ibm-powervs-1-control-plane created |
| 119 | + ibmpowervsmachinetemplate.infrastructure.cluster.x-k8s.io/ibm-powervs-1-control-plane created |
| 120 | + machinedeployment.cluster.x-k8s.io/ibm-powervs-1-md-0 created |
| 121 | + ibmpowervsmachinetemplate.infrastructure.cluster.x-k8s.io/ibm-powervs-1-md-0 created |
| 122 | + kubeadmconfigtemplate.bootstrap.cluster.x-k8s.io/ibm-powervs-1-md-0 created |
| 123 | + ``` |
| 124 | + |
| 125 | +5. Deploy Container Network Interface (CNI) |
| 126 | + |
| 127 | + Example: calico |
| 128 | + ```console |
| 129 | + kubectl apply -f https://docs.projectcalico.org/v3.15/manifests/calico.yaml |
| 130 | + ``` |
| 131 | + |
| 132 | + |
| 133 | +6. Check the state of the provisioned cluster and machine objects within the local management cluster |
| 134 | + |
| 135 | + Clusters |
| 136 | + ```console |
| 137 | + ~ kubectl get clusters |
| 138 | + NAME PHASE |
| 139 | + ibm-powervs-1 Provisioned |
| 140 | + ``` |
| 141 | + |
| 142 | + Kubeadm Control Plane |
| 143 | + ```console |
| 144 | + ~ kubectl get kubeadmcontrolplane |
| 145 | + NAME INITIALIZED API SERVER AVAILABLE VERSION REPLICAS READY UPDATED UNAVAILABLE |
| 146 | + ibm-powervs-1-control-plane true true v1.22.4 1 1 1 |
| 147 | + ``` |
| 148 | + |
| 149 | + Machines |
| 150 | + ```console |
| 151 | + ~ kubectl get machines |
| 152 | + ibm-powervs-1-control-plane-vzz47 ibmpowervs://ibm-powervs-1/ibm-powervs-1-control-plane-rg6xv Running v1.22.4 |
| 153 | + ibm-powervs-1-md-0-5444cfcbcd-6gg5z ibmpowervs://ibm-powervs-1/ibm-powervs-1-md-0-dbxb7 Running v1.22.4 |
| 154 | + ibm-powervs-1-md-0-5444cfcbcd-7kr9x ibmpowervs://ibm-powervs-1/ibm-powervs-1-md-0-k7blr Running v1.22.4 |
| 155 | + ``` |
| 156 | + |
| 157 | +7. Check the state of the newly provisioned cluster within IBM Cloud |
| 158 | + |
| 159 | + ```console |
| 160 | + ~ clusterctl get kubeconfig ibm-powervs-1 > ~/.kube/ibm-powervs-1 |
| 161 | + ~ export KUBECONFIG=~/.kube/ibm-powervs-1 |
| 162 | + ~ kubectl get nodes |
| 163 | + NAME STATUS ROLES AGE VERSION |
| 164 | + ibm-powervs-1-control-plane-rg6xv Ready master 41h v1.22.4 |
| 165 | + ibm-powervs-1-md-0-4dc5c Ready <none> 41h v1.22.4 |
| 166 | + ibm-powervs-1-md-0-dbxb7 Ready <none> 20h v1.22.4 |
| 167 | + ``` |
0 commit comments