This article describes how to create a Kubernetes Cluster in the IBM cloud using Platform9 Managed Kubernetes (PMK).
To begin, we will deploy the IBM Cloud CLI and then configure it to work with the IBM Cloud account.
Download and install the IBM Cloud CLI release from one of the official mirrors located at cloud.ibm.com or GitHub.com for your OS version.
To install on Mac or Linux, use the following command to download and install:
xxxxxxxxxx
curl -sL https://raw.githubusercontent.com/IBM-Cloud/ibm-cloud-developer-tools/master/linux-installer/idt-installer | bash
To install on Windows 10, use the following powershell command to download and install:
xxxxxxxxxx
[Net.ServicePointManager]::SecurityProtocol = "Tls12, Tls11, Tls, Ssl3"; iex(New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/IBM-Cloud/ibm-cloud-developer-tools/master/windows-installer/idt-win-installer.ps1')
For DevOps teams requiring automated installations, utilize the installer script directly from this GitHub repo.
The installation results should look similar to the following output.
Once the installation completes, running the ibmcloud command will show the version installed.
xxxxxxxxxx
ibmcloud
ibmcloud version 2.0.3+c7a1126-2021-08-27T19:17:51+00:00
To connect to your IBM Cloud, obtain a temporary password using the “Log in to CLI and API” page and invoke the ibmcloud command.
Login to CLI API image
Temporary password
The login will look similar to the command below.
xxxxxxxxxx
ibmcloud login -a https://cloud.ibm.com -u passcode -p <password>
During the login, you will need to provide which region will be used. In this example, we used us-east. Alternatively, the web-based cloud shell can be used, which has the ibmcloud command installed by default and only requires a login.
Log in to IBM Cloud with your IBMid. If you have multiple accounts, you will be prompted to select which account to use. If you do not specify a region with the -r flag, you will be required to select a region.
xxxxxxxxxx
ibmcloud login
If your credentials are rejected, you might be using a federated ID. To log in with a federated ID, use the |
To access cloud resources, SSH keys should be generated and uploaded to IBM cloud. SSH keys must use RSA and a key size of either 2048 bits or 4096 bits. To create your SSH key via the IBM CLI, execute the command noted below.
xxxxxxxxxx
ssh-keygen -t rsa
Next, upload SSH your public key (the default location will be located in ~/.ssh/id_rsa.pub
) to the UI VPC provisioning page, "SSH keys" section.
The following login command assumed you will use the public SSH key from ~/.ssh/id_rsa.pub
and name the key ibm-my-key
, the command would format like this:
xxxxxxxxxx
ibmcloud is key-create ibm-my-key @~/.ssh/id_rsa.pub
A similar task can be accomplished using the following example CLI commands.
xxxxxxxxxx
ibmcloud is key-create KEY_NAME (KEY | @KEY_FILE)
ibmcloud is key-create ibm-my-key "ssh-rsa <public-ssh-key> hostname"
ibmcloud is key-create my-key @/tmp/my_id_rsa.pub
In this section, we described how to provision IBM Cloud resources for use on a Platform 9 deployment. Initially, we begin by deploying the zone setup, listing the available regions and zones. Here we chose us-east.
xxxxxxxxxx
ibmcloud is regions
ibmcloud is zones us-east
We can also change target zone if required:
xxxxxxxxxx
ibmcloud target -r 'us-west'
Next, we inspect and the provision a private cloud network
ibmcloud is vpcs
ibmcloud is vpc-create platform9 --address-prefix-management auto
Reference: https://cloud.ibm.com/docs/vpc?topic=vpc-infrastructure-cli-plugin-vpc-reference#vpcs
Now we can list the available subnets where we want to deploy the VMs.
xxxxxxxxxx
ibmcloud is subnets
Then, if required, we provision a new subnet.
xxxxxxxxxx
ibmcloud is subnet-create platform9 AAA-XXX-YYY --ipv4-cidr-block 10.10.10.0/24
Reference: https://cloud.ibm.com/docs/vpc?topic=vpc-infrastructure-cli-plugin-vpc-reference#subnets
Next, we will list the available instance profiles to determine which hardware is best suited for our intended purpose.
xxxxxxxxxx
ibmcloud is instance-profiles
To run an instance on Platform9, the minimal requirements are:
In this case, we will use the bx2-4x16
instance profile. To list the available OS images, run the following command.
xxxxxxxxxx
ibmcloud is images
Example output:
xxxxxxxxxx
ID Name OS Arch Created Status Visibility Tags
r010-0b06b73b-6856-4f79-9499-e6c20f15a0de ibm-ubuntu-20-04-2-minimal-amd64-1 available amd64 ubuntu-20-04-amd64 20.04 LTS Focal Fossa Minimal Install 1 public provider none -
In this instance, a Ubuntu image will be utilized for deployment with the ID: r010-0b06b73b-6856-4f79-9499-e6c20f15a0de
. Next, review the available SSH keys and save the key id which will be used during the instance creation.
xxxxxxxxxx
ibmcloud is keys
Now select the placement group where we will deploy the VM.
xxxxxxxxxx
ibmcloud is placement-groups
Using a JSON file, define the persistent volume attachment, IOPs, capacity, and removal behavior for the VM. A 60 GB volume on PMK should be sufficient to prevent storage issues.
xxxxxxxxxx
[
{
"name": "root-attachment",
"delete_volume_on_instance_delete": true,
"volume": {
"name": "root",
"capacity": 60,
"iops": 1000,
"profile": {
"name": "root"
}
}
}
]
Finally, save the definition asstorage.json
file.
References: https://cloud.ibm.com/docs/vpc?topic=vpc-attaching-block-storage&interface=cli#volume_attachment_json
Now, we can provision a VM instance using the following information.
xxxxxxxxxx
ibmcloud is instance-create \
p9k8s1 \
<VPC_ID> \
<ZONE_NAME> \
<PROFILE_ID> \
<SUBNET_ID> \
--image-id <IMAGE_ID> \
--key-ids <KEY_ID> \
--placement-group <PLACEMENT_GROUP_NAME>
The returned result will show the created instance ID of aaaa-bbb-ccc
. The provisioned state can then be reviewed via the CLI
xxxxxxxxxx
ibmcloud is instance aaaa-bbb-ccc
Additionally, a floating IP can be requested for fixed address accessibility.
xxxxxxxxxx
ibmcloud is floating-ip-reserve \
plan9-floatingip \
--nic-id nic-id-from-instance-details
Output:
xxxxxxxxxx
...
Address aaa.bbb.ccc.dddd
Name plan9-floatingip
...
Now the instance can be accessed through aaa.bbb.ccc.dddd
using provided SSH key. More details can be found in the official IBM Cloud documentation.
This section will describe how to deploy Platform9 Kubernetes in an IBM Cloud.
First, obtain your access details from your Platform9 account by going to My infrastructure → Existing Virtual or Physical Infrastructure → Commands for the node setup. This will provide your account URL, username, tenant, and region.
Next, follow the instruction to install the pf9ctl
CLI tool on the VM instance.
xxxxxxxxxx
bash <(curl -sL https://pmkft-assets.s3-us-west-1.amazonaws.com/pf9ctl_setup)
Now, configure Platform 9 on the node by running the following command.
xxxxxxxxxx
pf9ctl config set
Then, enter the Platform 9 details to prepare and configure the node.
xxxxxxxxxx
pf9ctl prep-node
Shortly, a new node will be displayed in the PMK UI. Finally, to finish creating the cluster, click Complete
to deploy it.
If more nodes are required, repeat steps 2, 3, and 4 for all additional nodes required.
References: https://platform9.com/docs/kubernetes/on-premise-kubernetes-pre-requisiteshttps://platform9.com/docs/kubernetes/bareos-create-one-click-cluster
Platform9 can be successfully deployed on IBM Cloud and can cover several use cases including