📜 ⬆️ ⬇️

We deployed our own in the cloud. Install CoreOS

I have always been interested in cloud technologies. Including the most trending of them - this is decentralization, clustering, optimization and distribution of everything: computing resources, data, donuts and power . Therefore, I could not pass by CoreOS, about which there is a lot of talk in the IT community now, and which became for me the starting point for experiments.

To combine business with pleasure, I began to look for a suitable application on which, on the one hand, it would be interesting to apply cloud technologies, and on the other, it could be useful in the future. Therefore, I decided to deploy an installation of OwnCloud based on CoreOS.
Now I will tell you what this has led to, and in the course of the action I will provide links so that the person interested can deepen their knowledge in the subject field. But if you have questions - feel free to ask them in the comments.

So, I set myself tasks:
  1. Install CoreOS on bare-metal server
  2. Configure Distributed Data Warehouse
  3. Write your Dockerfile and run the application in a cluster
  4. Configure automatic update and registration of containers
  5. Consider unused technologies and come up with an application for them (*)

In this article I will talk about installing CoreOS. About setting up and further experiments - in the future.

Install CoreOS on bare-metal server


To install OwnCloud on the server, you need to get a server.
Installation on virtual servers "for money" or the same virtual servers on a local machine is not as interesting as installing on "live" hardware. But with the current dollar rate, renting a server is expensive. Therefore, a raid was made on Google to find a provider offering a cheap and “metallic” solution.
')
Google offered me two companies, both French: Kimsufi and Online .
Kimsufi is a daughter of OVH, one of the largest hosting providers.
Online is a subsidiary of iliad, one of the largest telecommunications companies.

Both companies offer cheap and powerful solutions. Although according to reviews from online.net the network is better, my choice fell on Kimsufi for two subjective reasons: 1) the server on the VIA Nano U2250 is too slow, and for the next one in the line, they are asking for 16 euros - the toad is choking; 2) availability of a verified account with OVH / Kimsufi.

check in


About registration, confirmation and removal of VAT from the provider Kimsufi had a lot to say ( Habr ). The only thing worth warning about is the waiting time. It seems that the support for Kimsufi works on the residual principle - the problems of customers are solved only when there are no tasks from the “big brother” (OVH). It is worth bearing in mind if you want to place production there.

We buy servers


I ordered three servers. Why three? Because only three servers can guarantee fault tolerance and the absence of a split-brain.
Brief explanation
In the products tested further, the formula for the calculation of fault tolerance is (n-1) / 2, from which it can be seen that the minimum value of the number n is three. In our case, proofs can be found in the dock, etcd and Percona XtraDB Cluster , to discuss - in the comments.

Since there are a lot of people who want to buy servers for such a price, it is quite difficult to become the happy owner of your piece of iron in an “honest” way. Personally, I used this script to catch them.
Difference of KS-2 line servers
KS-2a - percent N2800, 2TB HDD disk (or I'm lucky ^ _ ^)
KS-2b - percent D425, 1TB HDD disk
KS-2c - percent N2800, 40GB SSD disk


Install CoreOS


Once the servers have been paid for and have been pre-tested, you will receive a server certificate by mail. Immediately after this server will be available through the web admin area.
How to get rid of the annoying popup in the admin panel and the nuances of the refund policy
After the appearance of the server in the Kimsufi admin area, we will be offered to install the OS until we install at least something through the web interface. After that, you can not get your money back for the server.

DC owners can appreciate some features
Many different ( undocumented ) interesting.

First we need to get into the recovery, and then the installation follows the official installation instructions on the disk .
To boot into Rescue, in the web interface, click on Netboot -> Rescue. After that, the server must be restarted, the easiest way to do this is to click on the Restart button. Password to enter will come in the mail.
Once logged in to the server via SSH, download the installation script
wget https://raw.github.com/coreos/init/master/bin/coreos-install chmod +x coreos-install ./coreos-install --help 

We write our cloud-init file and the installation process via coreos-install -C stable -c / path / to / cloud-init -d / dev / sda.

After the installation is complete, you can make changes manually: add an ssh-key or edit cloud-init. To do this, mount the ROOT partition - it is number nine. For example:
 mount /dev/sda9 /mnt echo 'ssh-rsa AAAAB... user@domain' > /mnt/home/core/.ssh/authorized_keys 

Or you can put the key through cloud-init:
cloud-init number one
 #cloud-config hostname: core1 coreos: write_files: - path: /home/core/.ssh/authorized_keys permissions: 0600 owner: core content: | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+jxun+xn31x4tP7NdM6nMFI5b00bbk+VK4JM5mdyS+30/lIhhArMWnhla7NTw0BINdvutErZRFzhIqf5yaR/+O7/Oqc9J53dWJiEnz0si9hutbVSYA/Peo0Z9nFBm6Aep3816AzJYNzKIZg17JwqTKpEnV/ArXOmbCek9hi50R7yuZvtehWmJMNqTxKhqb5aD1joARd2iTMfS39pFsLsrxn8b2mGfcQH9v0+HwmNEiCGpq+HCMFTpt9Z1SOukeTpKOWOiBEzQPqaeaIeqXTDHHj2zWHv0/elIuRBFpxgC00DvoshlAzmB6CwCttBkigGQP2Mlcnovuo0RyuJRAlw1 user@domain 


cloud-init number two
 #cloud-config hostname: core1 coreos: write_files: - path: /etc/ssh/sshd_config owner: root content: | # Use most defaults for sshd configuration. UsePrivilegeSeparation sandbox Subsystem sftp internal-sftp ClientAliveInterval 180 UseDNS no AuthorizedKeysFile %h/.ssh/authorized_keys.d/coreos-cloudinit ssh_authorized_keys: - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+jxun+xn31x4tP7NdM6nMFI5b00bbk+VK4JM5mdyS+30/lIhhArMWnhla7NTw0BINdvutErZRFzhIqf5yaR/+O7/Oqc9J53dWJiEnz0si9hutbVSYA/Peo0Z9nFBm6Aep3816AzJYNzKIZg17JwqTKpEnV/ArXOmbCek9hi50R7yuZvtehWmJMNqTxKhqb5aD1joARd2iTMfS39pFsLsrxn8b2mGfcQH9v0+HwmNEiCGpq+HCMFTpt9Z1SOukeTpKOWOiBEzQPqaeaIeqXTDHHj2zWHv0/elIuRBFpxgC00DvoshlAzmB6CwCttBkigGQP2Mlcnovuo0RyuJRAlw1 user@domain 



During the first boot of the system, scripts are run that do some magic (repair GPT, resize the root filesystem (/ dev / sda9), etc.).
Note
Learn more about CoreOS partitioning at the dock , mail list, or on the githaba.

To boot into a freshly installed OS, you need to change the boot order through the web interface -> Netboot to boot from the hard disk and send the server to reboot (using the reboot command in the terminal, or using the Restart button in the web admin panel).
If you have not forgotten to put an ssh-key or have specified your user in the cloud-init, then you should be let into the system. If I can, congratulations! If not, something went wrong.

Repartition disk


Once the system is installed, you can begin to study it. And a lot of interesting things: etcd, fleet, systemd and related technologies: kubernetes, confd and more!
But before going further, I decided to create two additional partitions: for storing user data (distributed) and for storing containers and system applications (btrfs).
Why was btrfs chosen if it is experimental? Because the goal of my experiment is to experiment with new technologies. And despite the fact that btrfs has been working on desktops / laptops for a couple of years now, I haven’t used it in production.
History reference
Initially, the btrfs partition was created at the root of CoreOS. Recently, ext4 with AUFS / OverlayFS has been used for root. The reason for leaving btrfs is related to two unpleasant bugs that should have been fixed from the kernel version 3.18, in which the developers swear. Nevertheless, btrfs still may have some problems when working with a large number (several thousand) of layers (snapshots), but a discussion of this is beyond the scope of this article. Write comments!

In order to select something, you need to free at the beginning! To do this, go back to Rescue.
If you can not boot into Rescue
I ran into a problem: after a fresh installation of CoreOS, the machine did not want to boot over PXE, including in rescue. If you have a misfortune, you can use a one-time hack: use iptables to block all ICMP traffic (systemctl show iptables-restore.service) and do Restart via the web interface. The automation will consider that the server has not booted, and the engineer will manually load it into Rescue. Correct this can only be done by changing the motherboard and killing the MAC address on the switch by the engineer.

I reduced the size of the file system, then reduced the size of the partition and afterwards created new ones.
The root is on the ninth partition: / dev / sda9. Let's start:
 e2fsck -yf /dev/sda9 #      resize2fs /dev/sda9 100G #      100 gdisk /dev/sda #    resize2fs /dev/sda9 100G #  ,    

In gdisk, you need to delete the partition and create a new resized one.
If my memory serves me, the keyboard shortcuts will be done: d -> 9 -> n -> 9 -> -> + 100G -> -> c -> 9 -> ROOT -> w -> Y ->
If you’ve done everything right, you can safely boot from the hard disk and see that / dev / sda9 is 100GB or 93GB.
 core3 ~ # df -h /dev/sda9 Filesystem Size Used Avail Use% Mounted on /dev/sda9 97G 128M 93G 1% / 

Despite the fact that I install CoreOS on Kimsufi servers, the instruction is suitable for other providers. If you are faced with nuances when installing - write, discuss.

This completes the story about installing CoreOS on bare-metal Kimsufi server.

Who's next?


In the next article I will tell you how to create partitions from the free space, how to configure RTM ( Real Time Monitoring - monitoring script to draw beautiful graphs in the OVH web admin), etcd, fleet and how to deploy a distributed file system.

Source: https://habr.com/ru/post/256107/


All Articles