Skip to content

Commit

Permalink
Adding blog : Demonstrating KubeAid (part 0)
Browse files Browse the repository at this point in the history
Signed-off-by: Archisman <[email protected]>
  • Loading branch information
Archisman authored and Klavs Klavsen committed Nov 15, 2024
1 parent 4979745 commit ddeaa44
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 3 deletions.
85 changes: 85 additions & 0 deletions docs/aws/capi/ami.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Demonstrating KubeAid (part 0) - Building a custom ARM64 based Ubuntu 24.04 AMI for ClusterAPI, targetting latest Kubernetes version v1.31.0

When working in AWS, ClusterAPI requires custom AMIs for the VMs that host the Kubernetes cluster. These AMIs must include essential tools like `kubeadm`, `kubelet`, `containerd` etc. pre-installed.

These custom AMIs are built using the the [image-builder](https://github.com/kubernetes-sigs/image-builder) project. While the Kubernetes SIG team provides [pre-built AMIs](https://cluster-api-aws.sigs.k8s.io/topics/images/built-amis), they currently **lack support for ARM CPU architecture and the recent versions of Kubernetes and Ubuntu**.

To address this, we have [forked](https://github.com/Obmondo/image-builder) the image-builder project and added support for the above.

This blog post will guide you through : how to build a custom ARM64 based Ubuntu 24.04 AMI for ClusterAPI, targetting the latest Kubernetes version v1.31.0.

## VPC setup

We need to setup a VPC with a `public subnet`, where the `AMI builder instance` will be spun up.
> You can skip this step, if you already have a similar setup.
We have written up a [Terraform module](https://github.com/Obmondo/kubeaid/tree/master/build/image-builder-vpc-setup), which you can use to create the setup.

First, clone the KubeAid repo and cd into the [image-builder-vpc-setup](https://github.com/Obmondo/kubeaid/tree/master/build/image-builder-vpc-setup) directory :

```sh
git clone https://github.com/Obmondo/KubeAid
cd ./KubeAid/build/image-builder-vpc-setup
```

Specify the Terraform variables by creating a `terraform.tfvars` file.
> You can refer to an example terraform.tfvars file we've added [here](https://github.com/Obmondo/kubeaid/tree/master/build/image-builder-vpc-setup/terraform.tfvars.example).
Next, run these commands :

```sh
terraform init
terraform plan
terraform apply
```

Once done, you'll see the VPC and Subnet ids in the output. Note them down.

## Building the AMI

> Before moving any further, make sure you have your AWS credentials exported as environment variables.
Clone our [image-builder fork](https://github.com/Obmondo/image-builder) locally :

```sh
git clone https://github.com/Obmondo/image-builder
```

To install the prerequisites like Packer and Ansible, run this command :

```sh
make deps-ami
```

Open [image-builder/images/capi/packer/ami/ubuntu-2404-arm64.json](https://github.com/Obmondo/image-builder/blob/main/images/capi/packer/ami/ubuntu-2404-arm64.json) and update the following fields with your specific values :

- `aws_region` : The AWS region where you have the VPC setup.

- `vpc_id` and `subnet_id` : the once that you've copied from the Terraform output in the previous step.

- `ssh_keypair_name` and `ssh_private_key_file`

You can generate an AWS SSH Keypair using this command :
```sh
aws ec2 create-key-pair \
--key-name kubeaid-demo \
--query 'KeyMaterial' --output text --region <aws-region> > ./kubeaid-demo.pem
```

- `ami_regions` - Comma separated AWS regions, where the AMI needs to be available.

- `ami_groups`

By default it's `none`. You can set it to `all`, if you want to the AMI to be public.

> To publicly share the AMI, you must call the DisableImageBlockPublicAccess API.

Then cd into [image-builder/images/capi](https://github.com/Obmondo/image-builder/tree/main/images/capi) and run :

```sh
make build-ami-ubuntu-2404-arm64
```

You can view the AMI ID somewhere in the output.

Now, that the custom AMI is ready, we'll head on to [Bootstrapping and upgrading a self-managed K8s cluster in AWS, effortlessly, using ClusterAPI and KubeAid](https://github.com/Obmondo/kubeaid/blob/master/docs/aws/capi/cluster.md).
9 changes: 6 additions & 3 deletions docs/aws/capi/cluster.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Demonstrating KubeAid (part 1) - Bootstrapping and upgrading a self-managed K8s cluster in AWS, effortlessly, using ClusterAPI
# Demonstrating KubeAid (part 1) - Bootstrapping and upgrading a self-managed K8s cluster in AWS, effortlessly, using ClusterAPI and KubeAid

KubeAid is a comprehensive Kubernetes management suite designed to simplify cluster setup, management and monitoring through GitOps and automation principles. Recently, we’ve introduced support for provisioning and managing the lifecycle of Kubernetes clusters efforlessly using [ClusterAPI](https://cluster-api.sigs.k8s.io).

Expand Down Expand Up @@ -27,6 +27,8 @@ These custom AMIs are built using the the [image-builder](https://github.com/kub

To address this, we have [forked](https://github.com/Obmondo/image-builder) the image-builder project, added support for the above and published ARM based custom AMIs targetting Kubernetes [v1.30.0]() / [v1.31.0]() and Ubuntu 24.04.

> If you wish to build the custom AMI yourself, you can refer to this [blog post](https://github.com/Obmondo/kubeaid/blob/master/docs/aws/capi/ami.md).
## Bootstrapping the cluster using ClusterAPI

First, fork the [KubeAid Config](http://github.com/Obmondo/kubeaid-config) repo.
Expand All @@ -49,8 +51,9 @@ Open the sample YAML configuration file generated at `./outputs/kubeaid-bootstra

If you don't have an existing SSH KeyPair in the corresponding AWS region, you can generate one using this command :
```sh
aws ec2 create-key-pair --key-name kubeaid-demo --query 'KeyMaterial' --output text --region <aws-region> \
> ./outputs/kubeaid-demo.pem
aws ec2 create-key-pair \
--key-name kubeaid-demo \
--query 'KeyMaterial' --output text --region <aws-region> > ./outputs/kubeaid-demo.pem
```

Now to bootstrap the Kubernetes (v1.30.0) cluster with 1 control plane node and worker nodes `autoscaled` between 2 to 5 replicas, you can simply run :
Expand Down

0 comments on commit ddeaa44

Please sign in to comment.