preloader
Virtual Elephant
Articles

Tanzu Kubernetes Grid
Bootstrap Server

VMware’s flagship Kubernetes offering, Tanzu Kubernetes Grid, allows for an organization to quickly build and deploy an enterprise-grade Kubernetes service offering. The first step to building TKG within any VMware SDDC, AWS or Azure environment is configuring the TKG Bootstrap Server. The official documentation covers the process step-by-step, however the Virtual Elephant site has automated the process through Ansible.

Official Documentation

https://docs.vmware.com/en/VMware-Tanzu-Kubernetes-Grid/1.6/vmware-tanzu-kubernetes-grid-16/GUID-install-cli.html

GitHub Repo

The Virtual Elephant GitHub site has published the Ansible playbooks necessary to automate the configuration of the TKG bootstrap server and can be cloned from: https://github.com/virtualelephant/tanzu-bootstrap

Bootstrap VM Configuration

VM Specifications

vCPU: 4
Memory: 8Gb
Disk: 60Gb
OS: Ubuntu 22.04 Desktop

Pre-requisite Packages

 

Ansible Playbooks

The Ansible playbooks for building the TKG Bootstrap Server are broken into two pieces. The first playbook, prereqs.yaml, installs several OS packages via apt along with Docker. It also sets up the Ansible and AWS packages through pip3 that are needed for the second playbook. The second playbook, tanzu_pkgs.yaml, downloads the binaries from an AWS S3 bucket and then installs them locally.

The critical factor to remember when leveraging these Ansible playbooks, is that they are designed to be run locally on the Bootstrap server itself and not remotely. The playbooks are detailed below:

---
- hosts: localhost
become: yes
gather_facts: false
vars_files:
- globals.yaml

tasks:
# Docker installation bits
- name: Install system packages
apt:
name: ['pip', 'unzip', 'net-tools']
force_apt_get: yes
state: present

- name: Install Ansible and AWS modules through pip3
command: "{{ item }}"
with_items:
- pip3 install --upgrade pip
- pip3 install ansible
- pip3 install boto boto3
- pip3 install ansible[aws]

- name: Get Docker GPG key
shell: "curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg"

- name: Add Docker repo
lineinfile:
dest: /etc/apt/sources.list.d/docker.list
line: "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu jammy stable"
create: yes

- name: Update repo list for Docker
apt:
update_cache: yes
force_apt_get: yes

- name: Install Docker
apt:
name: ['docker-ce', 'docker-ce-cli', 'docker-compose-plugin', 'docker-scan-plugin', 'docker-ce-rootless-extras']
force_apt_get: yes
state: present

- name: Add user to Docker group
user:
name: deploy
groups: docker
append: yes

- name: Enable and start Docker service
systemd:
name: docker
enabled: yes
state: restarted
---
- hosts: localhost
become: yes
gather_facts: false
vars_files:
- globals.yaml

tasks:
- name: Download Tanzu bundle from S3
aws_s3:
aws_access_key: "{{ lookup('env', 'AWS_ACCESS_KEY_ID') }}"
aws_secret_key: "{{ lookup('env', 'AWS_SECRET_ACCESS_KEY') }}"
bucket: "tanzu-downloads"
object: "tanzu-cli-bundle-linux-amd64.tar.gz"
dest: "/tmp/tanzu-cli-bundle-linux-amd64.tar.gz"
mode: get

- name: Download Tanzu kubectl from S3"
aws_s3:
aws_access_key: "{{ lookup('env', 'AWS_ACCESS_KEY_ID') }}"
aws_secret_key: "{{ lookup('env', 'AWS_SECRET_ACCESS_KEY') }}"
bucket: "tanzu-downloads"
object: "kubectl-linux-v1.23.8+vmware.2.gz"
dest: "/tmp/kubectl-linux-v1.23.8+vmware.2.gz"
mode: get

- name: Unpack kubectl command from gzip file
command: gzip -d /tmp/kubectl-linux-v1.23.8+vmware.2.gz
register: gzip_kubectl

- name: Install kubectl command on host
command: install /tmp/kubectl-linux-v1.23.8+vmware.2 /usr/local/bin/kubectl
register: kubectl_install

- name: Unzip Tanzu bundle
command: gzip -d /tmp/tanzu-cli-bundle-linux-amd64.tar.gz
register: gzip_tanzu

- name: Unpack Tanzu bundle from .tar file
command: tar xvf /tmp/tanzu-cli-bundle-linux-amd64.tar -C /tmp/

- name: Install Tanzu CLI
command: install /tmp/cli/core/{{ version }}/tanzu-core-linux_amd64 /usr/local/bin/tanzu
register: tanzu_install

- name: Sync Tanzu Plugins
command: tanzu plugin sync
register: tanzu_plugin_sync

- name: Initialize Tanzu
command: tanzu init
register: tanzu_init

- name: Install supporting packages from Tanzu tarball
command: "{{ item }}"
with_items:
- gzip -d /tmp/cli/imgpkg-linux-amd64-v0.29.0+vmware.1.gz
- chmod ugo+x /tmp/cli/imgpkg-linux-amd64-v0.29.0+vmware.1
- install /tmp/cli/imgpkg-linux-amd64-v0.29.0+vmware.1 /usr/local/bin/imgpkg
- gzip -d /tmp/cli/kapp-linux-amd64-v0.49.0+vmware.1.gz
- chmod ugo+x /tmp/cli/kapp-linux-amd64-v0.49.0+vmware.1
- install /tmp/cli/kapp-linux-amd64-v0.49.0+vmware.1 /usr/local/bin/kapp
- gzip -d /tmp/cli/kbld-linux-amd64-v0.34.0+vmware.1.gz
- chmod ugo+x /tmp/cli/kbld-linux-amd64-v0.34.0+vmware.1
- install /tmp/cli/kbld-linux-amd64-v0.34.0+vmware.1 /usr/local/bin/kbld
- gzip -d /tmp/cli/ytt-linux-amd64-v0.41.1+vmware.1.gz
- chmod ugo+x /tmp/cli/ytt-linux-amd64-v0.41.1+vmware.1
- install /tmp/cli/ytt-linux-amd64-v0.41.1+vmware.1 /usr/local/bin/ytt

How To Video

The following video demonstrates how to install and configure the TKG Bootstrap Server.