Prepare the virtual machine template

To deploy Mirantis Container Cloud on the vSphere-based environment, prepare the virtual machine (VM) template for cluster machines that fits the following requirements:

  1. The VMware Tools package is installed.

  2. The cloud-init utility is installed and configured with the specific VMwareGuestInfo data source.

The following procedures describe how to meet the requirements above either using the Container Cloud script or manually.

Prepare the VM template using the Container Cloud script

  1. Prepare the Container Cloud bootstrap and modify templates/vsphere/vsphere-config.yaml.template and templates/vsphere/cluster.yaml.template as described in Bootstrap a management cluster, steps 1-9.

  2. Download or add to the vSphere datastore the ISO image depending on the target operating system:

    Export the environment variable for the ISO file depending on its placement:

    # On the seed node
    export VSPHERE_PACKER_ISO_FILE=$(pwd)/iso-file.dvd.iso
    
    # On the vSphere datastore
    export VSPHERE_PACKER_STORAGE_PATH="[<datastoreName>] /<path/to>/iso-file.dvd.iso"
    
  3. Verify that the Docker service is running and the bootstrap node user is added to the docker group.

    For RHEL, SELinux has to be in permissive mode or disabled.

    For more details about the bootstrap seed node prerequisites, see Prerequisites.

  4. Export the following variables:

    • The path to the downloaded ISO file.

    • The vSphere cluster name.

    • The OS name: rhel, ubuntu, or centos.

    • The OS version: 7.8, 7.9, or 8.4 (Technology Preview) for RHEL; 7.9 for CentOS (Technology Preview), 20.04 for Ubuntu.

    For example, for RHEL:

    export KAAS_VSPHERE_ENABLED=true
    export VSPHERE_CLUSTER_NAME=<vsphereClusterName>
    export VSPHERE_PACKER_IMAGE_OS_NAME=rhel
    export VSPHERE_PACKER_IMAGE_OS_VERSION=7.9
    
    Optional variables

    Variable

    Description

    VSPHERE_VM_TIMEZONE

    Time zone for virtual machines. Defaults to America/New_York.

    VSPHERE_PACKER_ACTION_ON_ERROR

    Packer action to apply if the template build fails. Defaults to cleanup. Set to abort to keep the VM in case of the build failure.

    KAAS_BOOTSTRAP_LOG_LVL

    Log level output for the packer build command. Set to 4 to display the full Docker command.

  5. Optional. If you require all Internet access to go through a proxy server, in bootstrap.env, add the following environment variables:

    • HTTP_PROXY

    • HTTPS_PROXY

    • NO_PROXY

    • PROXY_CA_CERTIFICATE_PATH

    Example snippet:

    export HTTP_PROXY=http://proxy.example.com:3128
    export HTTPS_PROXY=http://user:pass@proxy.example.com:3128
    export NO_PROXY=172.18.10.0,registry.internal.lan
    export PROXY_CA_CERTIFICATE_PATH="/home/ubuntu/.mitmproxy/mitmproxy-ca-cert.cer"
    

    The following formats of variables are accepted:

    Proxy configuration data

    Variable

    Format

    HTTP_PROXY
    HTTPS_PROXY
    • http://proxy.example.com:port - for anonymous access.

    • http://user:password@proxy.example.com:port - for restricted access.

    NO_PROXY

    Comma-separated list of IP addresses or domain names. Mandatory to add host[:port] of the vCenter server.

    PROXY_CA_CERTIFICATE_PATH

    Optional. Absolute path to the proxy CA certificate for man-in-the-middle (MITM) proxies. Must be placed on the bootstrap node to be trusted. For details, see Install a CA certificate for a MITM proxy on a bootstrap node.

    Warning

    If you require Internet access to go through a MITM proxy, ensure that the proxy has streaming enabled as described in Enable streaming for MITM.

    Note

    For MOSK-based deployments, the parameter is generally available since MOSK 22.4.

    For implementation details, see Proxy and cache support.

    Caution

    In MITM proxy deployments, use the internal Red Hat Satellite server to register RHEL machines so that a VM can access this server directly without a MITM proxy.

    For the list of Mirantis resources and IP addresses to be accessible from the Container Cloud clusters, see Requirements for a VMware vSphere-based cluster.

  6. Prepare the VM template:

    ./bootstrap.sh vsphere_template
    
  7. After the template is prepared, set the <vSphereVMTemplatePath> parameter in templates/vsphere/machines.yaml.template as described in Bootstrap a management cluster.

Prepare the VM template manually

  1. Run a VM on the vSphere Data Center with the DVD ISO of the selected operating system (OS) mounted to the VM.

    Specify the amount of resources that will be used in the Container Cloud setup. A minimal configuration of resources must match the Requirements for a VMware vSphere-based cluster.

    Caution

    Make sure that a VM has one hard disk with 120 GiB or more in size. Several hard disks per VM are not supported.

  2. Bootstrap the OS using vSphere Web Console with the following configuration:

    • Select a minimal setup in the installation configuration of the VM.

    • For Ubuntu, select the openssh server installation.

    • Create a user with root or sudo permissions to access the VM.

  3. Log in to the VM using SSH with the previously created user.

  4. For RHEL, attach your RHEL license for the Virtual Datacenter to the VM using your user name with password or activation key with organization ID:

    1. Optional. Configure proxy:

      subscription-manager config \
         --server.proxy_scheme=$SCHEME \
         --server.proxy_hostname=$HOST \
         --server.proxy_port=$PORT \
         --server.proxy_user=$USER \
         --server.proxy_password=$PASS \
         --server.no_proxy=$NO_PROXY
      
    2. Optional. Configure the Satellite server:

      yum install -y <katello-RPM-URL>
      
    3. Attach the subscription to the VM:

      # Username/Password:
      subscription-manager register --username <username> --password <password>
      
      # Activation key/Organization ID:
      subscription-manager register --activationkey=<key> --org=<organizationIDorName>
      
      # automatic subscription selection:
      subscription-manager attach --auto
      
      # or specify pool id:
      subscription-manager attach --pool=<poolID>
      
      # verify subscription status
      subscription-manager status
      
  5. Select from the following options:

    • Automatically configure cloud-init:

      1. Download and run the automation script:

        curl https://gerrit.mcp.mirantis.com/plugins/gitiles/kubernetes/vmware-guestinfo/+/refs/tags/v1.1.6/install.sh?format=TEXT | base64 -d > install.sh
        
        chmod +x install.sh
        
        ./install.sh
        
    • Manually configure cloud-init:

      1. Install the open-vm-tools package version 11.0.5 or later with dependencies and verify its version:

        # RHEL/CentOS:
        yum install open-vm-tools net-tools perl -y
        
        # Ubuntu:
        apt-get update
        apt-get install open-vm-tools net-tools perl -y
        
        # Verify version:
        vmtoolsd --version
        vmware-toolbox-cmd --version
        
      2. Install and configure cloud-init:

        1. Install the cloud-init package and verify its version:

          • 19.4 or later for RHEL 7.8 and 7.9, or CentOS 7.9 TechPreview

          • 20.3 or later for RHEL 8.4 TechPreview

          • 22.1 or later for Ubuntu 20.04

          # RHEL/CentOS:
          yum install cloud-init -y
          
          # Ubuntu:
          apt-get install cloud-init -y
          
          # Verify version:
          cloud-init --version
          
        2. For RHEL or CentOS, add the VMware data source for cloud-init:

          1. Download the VMwareGuestInfo data source files:

            curl https://gerrit.mcp.mirantis.com/plugins/gitiles/kubernetes/vmware-guestinfo/+/refs/tags/v1.1.6/DataSourceVMwareGuestInfo.py?format=TEXT | base64 -d > DataSourceVMwareGuestInfo.py
            
            curl https://gerrit.mcp.mirantis.com/plugins/gitiles/kubernetes/vmware-guestinfo/+/refs/tags/v1.1.6/99-DataSourceVMwareGuestInfo.cfg?format=TEXT | base64 -d > 99-DataSourceVMwareGuestInfo.cfg
            
          2. Add 99-DataSourceVMwareGuestInfo.cfg to /etc/cloud/cloud.cfg.d/.

          3. Depending on the Python version on the VM operating system, add DataSourceVMwareGuestInfo.py to the cloud-init sources folder. Obtain the cloud-init folder on the OS:

            python -c 'import os; from cloudinit import sources; print(os.path.dirname(sources.__file__));'
            
        3. For Ubuntu, create /etc/cloud/cloud.cfg.d/99_mcc.cfg with the following content:

          datasource_list: [ VMware ]
          package_update: false
          package_upgrade: false
          apt:
             preserve_sources_list: true
          
  6. For CentOS, verify that .yum mirrors are set to use only the *.centos.org URLs. Otherwise, access to other mirrors may be blocked by squid-proxy on managed clusters. Refer to Configure squid-proxy on how to allow access to custom mirrors.

  7. Configure the interface name for eth0:

    1. In /etc/default/grub, add the following parameters to GRUB_CMDLINE_LINUX:

      GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
      
    2. Update the GRUB configuration:

      # RHEL/CentOS:
      grub2-mkconfig -o /boot/grub2/grub.cfg
      
      # Ubuntu:
      update-grub2
      
  8. Clean up the apt or yum cache and the cloud init metadata:

    # RHEL/Centos:
    yum clean all
    rm -rf /var/lib/cloud/instances
    
    # Ubuntu:
    apt-get clean
    rm -f /etc/cloud/cloud.cfg.d/99-installer.cfg
    rm -f /etc/cloud/cloud.cfg.d/curtin-preserve-sources.cfg
    rm -f /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg
    rm -rf /var/lib/cloud/instances
    
  9. For RHEL, remove the RHEL subscription and proxy configuration from the node.

    subscription-manager remove --all
    subscription-manager unregister
    subscription-manager clean
    subscription-manager config \
      --remove=server.proxy_scheme \
      --remove=server.proxy_hostname \
      --remove=server.proxy_port \
      --remove=server.proxy_user \
      --remove=server.proxy_password \
      --remove=server.no_proxy
    
  10. Shut down the VM.

  11. Clone the VM to the template.

Now, proceed to Bootstrap a management cluster.