Skip to content

Commit 0889d0e

Browse files
committed
Wrap the Markdown source at around 100 characters
Signed-off-by: Andrei Kvapil <[email protected]>
1 parent 1123672 commit 0889d0e

File tree

1 file changed

+107
-34
lines changed
  • content/en/blog/_posts/2024-04-05-diy-create-your-own-cloud-with-kubernetes-part-1

1 file changed

+107
-34
lines changed

content/en/blog/_posts/2024-04-05-diy-create-your-own-cloud-with-kubernetes-part-1/index.md

Lines changed: 107 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,78 @@ date: 2024-04-05
1010
At Ænix, we have a deep affection for Kubernetes and dream that all modern technologies will soon
1111
start utilizing its remarkable patterns.
1212

13-
Have you ever thought about building your own cloud? I bet you have. But is it possible to do this using only modern technologies and approaches, without leaving the cozy Kubernetes ecosystem? Our experience in developing Cozystack required us to delve deeply into it.
13+
Have you ever thought about building your own cloud? I bet you have. But is it possible to do this
14+
using only modern technologies and approaches, without leaving the cozy Kubernetes ecosystem?
15+
Our experience in developing Cozystack required us to delve deeply into it.
1416

15-
You might argue that Kubernetes is not intended for this purpose and why not simply use OpenStack for bare metal servers and run Kubernetes inside it as intended. But by doing so, you would simply shift the responsibility from your hands to the hands of OpenStack administrators. This would add at least one more huge and complex system to your ecosystem.
17+
You might argue that Kubernetes is not intended for this purpose and why not simply use OpenStack
18+
for bare metal servers and run Kubernetes inside it as intended. But by doing so, you would simply
19+
shift the responsibility from your hands to the hands of OpenStack administrators.
20+
This would add at least one more huge and complex system to your ecosystem.
1621

17-
Why complicate things? - after all, Kubernetes already has everything needed to run tenant Kubernetes clusters at this point.
22+
Why complicate things? - after all, Kubernetes already has everything needed to run tenant
23+
Kubernetes clusters at this point.
1824

19-
I want to share with you our experience in developing a cloud platform based on Kubernetes, highlighting the open-source projects that we use ourselves and believe deserve your attention.
25+
I want to share with you our experience in developing a cloud platform based on Kubernetes,
26+
highlighting the open-source projects that we use ourselves and believe deserve your attention.
2027

21-
In this series of articles, I will tell you our story about how we prepare managed Kubernetes from bare metal using only open-source technologies. Starting from the basic level of data center preparation, running virtual machines, isolating networks, setting up fault-tolerant storage to provisioning full-featured Kubernetes clusters with dynamic volume provisioning, load balancers, and autoscaling.
28+
In this series of articles, I will tell you our story about how we prepare managed Kubernetes
29+
from bare metal using only open-source technologies. Starting from the basic level of data
30+
center preparation, running virtual machines, isolating networks, setting up fault-tolerant
31+
storage to provisioning full-featured Kubernetes clusters with dynamic volume provisioning,
32+
load balancers, and autoscaling.
2233

2334
With this article, I start a series consisting of several parts:
2435

25-
- **Part 1**: Preparing the groundwork for your cloud. Challenges faced during the preparation and operation of Kubernetes on bare metal and a ready-made recipe for provisioning infrastructure.
26-
- **Part 2**: Networking, storage, and virtualization. How to turn Kubernetes into a tool for launching virtual machines and what is needed for this.
27-
- **Part 3**: Cluster API and how to start provisioning Kubernetes clusters at the push of a button. How autoscaling works, dynamic provisioning of volumes, and load balancers.
36+
- **Part 1**: Preparing the groundwork for your cloud. Challenges faced during the preparation
37+
and operation of Kubernetes on bare metal and a ready-made recipe for provisioning infrastructure.
38+
- **Part 2**: Networking, storage, and virtualization. How to turn Kubernetes into a tool for
39+
launching virtual machines and what is needed for this.
40+
- **Part 3**: Cluster API and how to start provisioning Kubernetes clusters at the push of a
41+
button. How autoscaling works, dynamic provisioning of volumes, and load balancers.
2842

29-
I will try to describe various technologies as independently as possible, but at the same time, I will share our experience and why we came to one solution or another.
43+
I will try to describe various technologies as independently as possible, but at the same time,
44+
I will share our experience and why we came to one solution or another.
3045

31-
To begin with, let's understand the main advantage of Kubernetes and how it has changed the approach to using cloud resources.
46+
To begin with, let's understand the main advantage of Kubernetes and how it has changed the
47+
approach to using cloud resources.
3248

3349
It is important to understand that the use of Kubernetes in the cloud and on bare metal differs.
3450

3551
## Kubernetes in the cloud
3652

37-
When you operate Kubernetes in the cloud, you don't worry about persistent volumes, cloud load balancers, or the process of provisioning nodes. All of this is handled by your cloud provider, who accepts your requests in the form of Kubernetes objects. In other words, the server side is completely hidden from you, and you don't really want to know how exactly the cloud provider implements as it's not in your area of responsibility.
53+
When you operate Kubernetes in the cloud, you don't worry about persistent volumes,
54+
cloud load balancers, or the process of provisioning nodes. All of this is handled by your cloud
55+
provider, who accepts your requests in the form of Kubernetes objects. In other words, the server
56+
side is completely hidden from you, and you don't really want to know how exactly the cloud
57+
provider implements as it's not in your area of responsibility.
3858

3959
{{< figure src="cloud.svg" alt="A diagram showing cloud Kubernetes, with load balancing and storage done outside the cluster" caption="A diagram showing cloud Kubernetes, with load balancing and storage done outside the cluster" >}}
4060

41-
Kubernetes offers convenient abstractions that work the same everywhere, allowing you to deploy your application on any Kubernetes in any cloud.
61+
Kubernetes offers convenient abstractions that work the same everywhere, allowing you to deploy
62+
your application on any Kubernetes in any cloud.
4263

43-
In the cloud, you very commonly have several separate entities: the Kubernetes control plane, virtual machines, persistent volumes, and load balancers as distinct entities. Using these entities, you can create highly dynamic environments.
64+
In the cloud, you very commonly have several separate entities: the Kubernetes control plane,
65+
virtual machines, persistent volumes, and load balancers as distinct entities. Using these entities, you can create highly dynamic environments.
4466

45-
Thanks to Kubernetes, virtual machines are now only seen as a utility entity for utilizing cloud resources. You no longer store data inside virtual machines. You can delete all your virtual machines at any moment and recreate them without breaking your application. The Kubernetes control plane will continue to hold information about what should run in your cluster. The load balancer will keep sending traffic to your workload, simply changing the endpoint to send traffic to a new node. And your data will be safely stored in external persistent volumes provided by cloud.
67+
Thanks to Kubernetes, virtual machines are now only seen as a utility entity for utilizing
68+
cloud resources. You no longer store data inside virtual machines. You can delete all your virtual
69+
machines at any moment and recreate them without breaking your application. The Kubernetes control
70+
plane will continue to hold information about what should run in your cluster. The load balancer
71+
will keep sending traffic to your workload, simply changing the endpoint to send traffic to a new
72+
node. And your data will be safely stored in external persistent volumes provided by cloud.
4673

47-
This approach is fundamental when using Kubernetes in clouds. The reason for it is quite obvious: the simpler the system, the more stable it is, and for this simplicity you go buying Kubernetes in the cloud.
74+
This approach is fundamental when using Kubernetes in clouds. The reason for it is quite obvious:
75+
the simpler the system, the more stable it is, and for this simplicity you go buying Kubernetes
76+
in the cloud.
4877

4978
## Kubernetes on bare metal
5079

51-
Using Kubernetes in the clouds is really simple and convenient, which cannot be said about bare metal installations. In the bare metal world, Kubernetes, on the contrary, becomes unbearably complex. Firstly, because the entire network, backend storage, cloud balancers, etc. are usually run not outside, but inside your cluster. As result such a system is much more difficult to update and maintain.
80+
Using Kubernetes in the clouds is really simple and convenient, which cannot be said about bare
81+
metal installations. In the bare metal world, Kubernetes, on the contrary, becomes unbearably
82+
complex. Firstly, because the entire network, backend storage, cloud balancers, etc. are usually
83+
run not outside, but inside your cluster. As result such a system is much more difficult to
84+
update and maintain.
5285

5386
{{< figure src="baremetal.svg" alt="A diagram showing bare metal Kubernetes, with load balancing and storage done inside the cluster" caption="A diagram showing bare metal Kubernetes, with load balancing and storage done inside the cluster" >}}
5487

@@ -62,18 +95,35 @@ cheaper spot instances. However, when you have a physical server, you can't just
6295
recreate it, firstly because it often runs some cluster services, stores data, and its update process
6396
is significantly more complicated.
6497

65-
There are different approaches to solving this problem, ranging from in-place updates, as done by kubeadm, kubespray, and k3s, to full automation of provisioning physical nodes through Cluster API and Metal3.
98+
There are different approaches to solving this problem, ranging from in-place updates, as done by
99+
kubeadm, kubespray, and k3s, to full automation of provisioning physical nodes through Cluster API
100+
and Metal3.
66101

67-
I like the hybrid approach offered by Talos Linux, where your entire system is described in a single configuration file. Most parameters of this file can be applied without rebooting or recreating the node, including the version of Kubernetes control-plane components. However, it still keeps the maximum declarative nature of Kubernetes.
68-
This approach minimizes unnecessary impact on cluster services when updating bare metal nodes. In most cases, you won't need to migrate your virtual machines and rebuild the cluster filesystem on minor updates.
102+
I like the hybrid approach offered by Talos Linux, where your entire system is described in a
103+
single configuration file. Most parameters of this file can be applied without rebooting or
104+
recreating the node, including the version of Kubernetes control-plane components. However, it
105+
still keeps the maximum declarative nature of Kubernetes.
106+
This approach minimizes unnecessary impact on cluster services when updating bare metal nodes.
107+
In most cases, you won't need to migrate your virtual machines and rebuild the cluster filesystem
108+
on minor updates.
69109

70110
## Preparing a base for your future cloud
71111

72-
So, suppose you've decided to build your own cloud. To start somewhere, you need a base layer. You need to think not only about how you will install Kubernetes on your servers but also about how you will update and maintain it. Consider the fact that you will have to think about things like updating the kernel, installing necessary modules, as well packages and security patches. Now you have to think much more that you don't have to worry about when using a ready-made Kubernetes in the cloud.
112+
So, suppose you've decided to build your own cloud. To start somewhere, you need a base layer.
113+
You need to think not only about how you will install Kubernetes on your servers but also about how
114+
you will update and maintain it. Consider the fact that you will have to think about things like
115+
updating the kernel, installing necessary modules, as well packages and security patches.
116+
Now you have to think much more that you don't have to worry about when using a ready-made
117+
Kubernetes in the cloud.
73118

74-
Of course you can use standard distributions like Ubuntu or Debian, or you can consider specialized ones like Flatcar Container Linux, Fedora Core, and Talos Linux. Each has its advantages and disadvantages.
119+
Of course you can use standard distributions like Ubuntu or Debian, or you can consider specialized
120+
ones like Flatcar Container Linux, Fedora Core, and Talos Linux. Each has its advantages and
121+
disadvantages.
75122

76-
What about us? At Ænix, we use quite a few specific kernel modules like ZFS, DRBD, and OpenvSwitch, so we decided to go the route of forming a system image with all the necessary modules in advance. In this case, Talos Linux turned out to be the most convenient for us. For example, such a config is enough to build a system image with all the necessary kernel modules:
123+
What about us? At Ænix, we use quite a few specific kernel modules like ZFS, DRBD, and OpenvSwitch,
124+
so we decided to go the route of forming a system image with all the necessary modules in advance.
125+
In this case, Talos Linux turned out to be the most convenient for us.
126+
For example, such a config is enough to build a system image with all the necessary kernel modules:
77127

78128
```yaml
79129
arch: amd64
@@ -108,9 +158,9 @@ Then we use the `docker` command line tool to build an OS image:
108158
cat config.yaml | docker run --rm -i -v /dev:/dev --privileged "ghcr.io/siderolabs/imager:v1.6.4" -
109159
```
110160
111-
And as a result, we get a Docker container image with everything we need, which we can use to install
112-
Talos Linux on our servers. You can do the same; this image will contain all the necessary firmware
113-
and kernel modules.
161+
And as a result, we get a Docker container image with everything we need, which we can use to
162+
install Talos Linux on our servers. You can do the same; this image will contain all the necessary
163+
firmware and kernel modules.
114164
115165
But the question arises, how do you deliver the freshly formed image to your nodes?
116166
@@ -127,21 +177,38 @@ image, and you can use a simple Debian-flavored script to help you bootstrap you
127177
128178
[![asciicast](asciicast.svg)](https://asciinema.org/a/627123)
129179
130-
The [source](https://github.com/aenix-io/talos-bootstrap/) for that `talos-bootstrap` script is available on GitHub.
180+
The [source](https://github.com/aenix-io/talos-bootstrap/) for that `talos-bootstrap` script is
181+
available on GitHub.
131182
132-
This script allows you to deploy Kubernetes on bare metal in five minutes and obtain a kubeconfig for accessing it. However, many unresolved issues still lie ahead.
183+
This script allows you to deploy Kubernetes on bare metal in five minutes and obtain a kubeconfig
184+
for accessing it. However, many unresolved issues still lie ahead.
133185
134186
## Delivering system components
135187
136-
At this stage, you already have a Kubernetes cluster capable of running various workloads. However, it is not fully functional yet. In other words, you need to set up networking and storage, as well as install necessary cluster extensions, like KubeVirt to run virtual machines, as well the monitoring stack and other system-wide components.
188+
At this stage, you already have a Kubernetes cluster capable of running various workloads. However,
189+
it is not fully functional yet. In other words, you need to set up networking and storage, as well
190+
as install necessary cluster extensions, like KubeVirt to run virtual machines, as well the
191+
monitoring stack and other system-wide components.
137192
138-
Traditionally, this is solved by installing **Helm charts** into your cluster. You can do this by running `helm install` commands locally, but this approach becomes inconvenient when you want to track updates, and if you have multiple clusters and you want to keep them uniform. In fact, there are plenty of ways to do this declaratively. To solve this, I recommend using best GitOps practices. I mean tools like ArgoCD and FluxCD.
193+
Traditionally, this is solved by installing **Helm charts** into your cluster. You can do this by
194+
running `helm install` commands locally, but this approach becomes inconvenient when you want to
195+
track updates, and if you have multiple clusters and you want to keep them uniform. In fact, there
196+
are plenty of ways to do this declaratively. To solve this, I recommend using best GitOps practices.
197+
I mean tools like ArgoCD and FluxCD.
139198
140-
While ArgoCD is more convenient for dev purposes with its graphical interface and a central control plane, FluxCD, on the other hand, is better suited for creating Kubernetes distributions. With FluxCD, you can specify which charts with what parameters should be launched and describe dependencies. Then, FluxCD will take care of everything for you.
199+
While ArgoCD is more convenient for dev purposes with its graphical interface and a central control
200+
plane, FluxCD, on the other hand, is better suited for creating Kubernetes distributions. With FluxCD,
201+
you can specify which charts with what parameters should be launched and describe dependencies. Then,
202+
FluxCD will take care of everything for you.
141203
142-
It is suggested to perform a one-time installation of FluxCD in your newly created cluster and provide it with the configuration. This will install everything necessary, bringing the cluster to the expected state.
204+
It is suggested to perform a one-time installation of FluxCD in your newly created cluster and
205+
provide it with the configuration. This will install everything necessary, bringing the cluster
206+
to the expected state.
143207
144-
By carrying out a single installation of FluxCD in your newly minted cluster and configuring it accordingly, you enable it to automatically deploy all the essentials. This will allow your cluster to upgrade itself into the desired state. For example, after installing our platform you'll see the next pre-configured Helm charts with system components:
208+
By carrying out a single installation of FluxCD in your newly minted cluster and configuring it
209+
accordingly, you enable it to automatically deploy all the essentials. This will allow your cluster
210+
to upgrade itself into the desired state. For example, after installing our platform you'll see the
211+
next pre-configured Helm charts with system components:
145212
146213
```
147214
NAMESPACE NAME AGE READY STATUS
@@ -173,6 +240,12 @@ cozy-victoria-metrics-operator victoria-metrics-operator 4m1s True Rele
173240
174241
## Conclusion
175242
176-
As a result, you achieve a highly repeatable environment that you can provide to anyone, knowing that it operates exactly as intended. This is actually what the [Cozystack](https://github.com/aenix-io/cozystack) project does, which you can try out for yourself absolutely free.
243+
As a result, you achieve a highly repeatable environment that you can provide to anyone, knowing
244+
that it operates exactly as intended.
245+
This is actually what the [Cozystack](https://github.com/aenix-io/cozystack) project does, which
246+
you can try out for yourself absolutely free.
177247
178-
In the following articles, I will discuss [how to prepare Kubernetes for running virtual machines](/blog/2024/04/05/diy-create-your-own-cloud-with-kubernetes-part-2/) and [how to run Kubernetes clusters with the click of a button](/blog/2024/04/05/diy-create-your-own-cloud-with-kubernetes-part-3/). Stay tuned, it'll be fun!
248+
In the following articles, I will discuss
249+
[how to prepare Kubernetes for running virtual machines](/blog/2024/04/05/diy-create-your-own-cloud-with-kubernetes-part-2/)
250+
and [how to run Kubernetes clusters with the click of a button](/blog/2024/04/05/diy-create-your-own-cloud-with-kubernetes-part-3/).
251+
Stay tuned, it'll be fun!

0 commit comments

Comments
 (0)