Categories
Tech

Install Tanzu Community Edition with Salt

This blog post is about two open source projects supported by VMware: Salt and Tanzu Community Edition. Salt is event-driven automation, infrastructure management, configuration management, remote execution and much more. Tanzu Community Edition (TCE) is a full-featured, easy-to-manage Kubernetes platform for learners and users, especially those working in small-scale or pre-production environments.

Installing TCE it is well documented here and generally not a complex task, so why automating it? A colleague needs to deploy TCE over and over and I offered my help.

Requirements

Currently my state files install TCE 0.10.0 that can be installed on Linux, Mac or Windows. What I did covers only Ubuntu, my Salt state files are tested against Ubuntu 18.04 (xenial) and Ubuntu 20.04 (focal). So you need the followings:

  • Ubuntu 18.04 or 20.04 x86 desktop (this can be a Virtual Machine)
  • 2 CPUs and 6 GB of RAM
  • Access to internet
  • A user member of sudo group

Note: TCE doesn’t need it, however my automation creates a user named tce. This user has disabled interactive login, it is placed in sudo and docker groups and finally it is allowed for password-less sudo.

Install TCE with Salt

If you are already familiar with Salt you can simply grab my State Files here and apply init.sls against your Ubuntu minion.

If you are not familiar with Salt here is the step-by-step end-to-end guide including installing Salt.

Install and Configure Salt

Here I am providing instrcuctions to install Salt on Ubuntu 20.04, if you have a Ubuntu 18.04 instructions are here. Here we will install both Salt’s Master and Minion on your Ubuntu desktop.

Run the following command to import the Salt repository key.

sudo curl -fsSL -o /usr/share/keyrings/salt-archive-keyring.gpg https://repo.saltproject.io/py3/ubuntu/20.04/amd64/latest/salt-archive-keyring.gpg

Run the following command to create /etc/apt/sources.list.d/salt.list.

echo "deb [signed-by=/usr/share/keyrings/salt-archive-keyring.gpg arch=amd64] https://repo.saltproject.io/py3/ubuntu/20.04/amd64/latest focal main" | sudo tee /etc/apt/sources.list.d/salt.list

Update you repository.

sudo apt-get update

Install salt-master and salt-minion.

sudo apt-get install salt-master
sudo apt-get install salt-minion

Configure Salt Master with the following three commands. The second command set the hostname as the Minion ID.

echo "master: 127:0.0.1" | sudo tee /etc/salt/minion.d/master.conf
hostname | sudo tee /etc/salt/minion_id
echo "timeout: 60" | sudo tee /etc/salt/master.d/timeout.conf

Start the Master and Minion services.

sudo systemctl enable salt-master --now
sudo systemctl enable salt-minion --now

Look for the Minion key to show up. In the screenshot below the command the minion key is named ubuntu-desktop-paolo, you will see a different name according to your hostname.

sudo salt-key -L

Accept your Minion key, be sure to replace ubuntu-desktop-paolo with your actual Minion key name.

sudo salt-key –a ubuntu-dektop-paolo –y

If you list keys again, your Minion ID should appears under the Accepted Key in green.

Download the State files and install TCE

Create a directory to host the State files.

sudo mkdir -p /srv/salt

Clone the repo.

cd /srv/salt
git clone https://github.com/paoloromagnoli/tanzuce.git

Apply the state file.

sudo salt-call state.apply tanzu

Before strarting TCE make sure you switch to tce user.

su - tce

You can follow the TCE documentation here to get started with TCE. Here after I am just reporting a command you can use to check your TCE is working properly:

tanzu management-cluster create --ui

Note: in my case TCE was not able to start the web browser, no big deal you can simply get to TCE UI by accessing http://127.0.0.1:8080 on your favorite browser:

Have fun with your Kubernetes clusters!!!