项目作者: waynedovey

项目描述 :
OCP4 on VMware vSphere UPI Automation
高级语言: Shell
项目地址: git://github.com/waynedovey/ocp4-vsphere-upi-automation.git
创建时间: 2020-01-16T10:57:20Z
项目社区:https://github.com/waynedovey/ocp4-vsphere-upi-automation

开源协议:

下载


OCP4 on VMware vSphere UPI Automation

The goal of this repo is to make deploying and redeploying a new Openshift v4 cluster fully automated. This has been created to avoid any manual operation for a VMware OpenShift User Provisioned Infrastructure (UPI) implementation.

Prerequisites

With all the details in hand from the prerequisites, populate the vars/vars-${BUILD_LAB}.yml in the root folder of this repo and trigger the installation seen in the example runs.

Requirements

  • Ansible 2.X
  • Python module openshift-0.10.3 or higher (you might have to do alternatives --install /usr/bin/python python /usr/bin/python3 1 ; pip3 install openshift --user)
  • MacOS pip install requests
  • MacOS pip install PyVmomi

Examples Runs

First Step: Create the Helper Node

Note requires VMware rhel7.7-template (Vanilla RHEL) and Cloud-init installation:

https://github.com/waynedovey/ocp4-vsphere-upi-automation#rhel-or-centos-template-node-cloud-init-install

Helper Node Deploy and Build

  1. ./helper-deploy.sh
  2. Specify Build Name (gsslab, pek2lab, <custom> ): (Press ENTER for default: gsslab)
  3. * Cluster Name: gsslab

Helper Node Build (Standalone)

  1. ./helpernode-build.sh
  2. Specify Build Name (gsslab, pek2lab, <custom> ): (Press ENTER for default: gsslab)
  3. * Cluster Name: gsslab

Helper Node destroy

  1. ./helper-destroy.sh
  2. Specify Build Name (gsslab, pek2lab, <custom> ): (Press ENTER for default: gsslab)
  3. * Cluster Name: gsslab

Automated Build with Prompted options with Vault Encrypted Vars and Version Status Checking

  1. ./cluster-build.sh
  2. Specify Build Name (gsslab, pek2lab, <custom> ): (Press ENTER for default: gsslab)
  3. pek2lab
  4. * Cluster Name: pek2lab
  5. Enter OpenShift Version: (Press ENTER for default: 4.3.8)
  6. 4.3.9
  7. * Using: 4.3.9
  8. Enter OpenShift Cluster Size (small [8gb,2vcpu],medium [32gb,4vcpu],large [64gb,8vcpu]): (Press ENTER for default: small )
  9. medium
  10. * Using: medium Cluster Settings Memory 32768 CPU 4
  11. Enter OpenShift Disconnected setting true/false: (Press ENTER for default: false)
  12. false
  13. * Disconnected Setting: false
  14. Enable OpenShift Container Storage (OCS) true/false: (Press ENTER for default: false)
  15. true
  16. * OpenShift Container Storage (OCS) Setting: true

Automated Build with Prompted options No Vault Encrypted Vars and Version Status Checking

  1. ./cluster-build-novault.sh

Manual install

Prepare OCP OVA, Ignition and install configuration

  1. ansible-playbook -e "ocp_version=${DEFAULT_OCPVERSION} disconnected_setting=${DISCONNECTED}" -e @./vars/vars-${BUILD_LAB}.yml setup-ocp-vsphere.yml --ask-vault-pass

Transfer Ignition files

  1. cp install-dir/bootstrap.ign /var/www/html/ignition

Change file permissions

  1. chmod 644 /var/www/html/ignition/bootstrap.ign

Configure the vSphere cluster with the OpenShift instances

  1. ansible-playbook -e "ocp_version=${DEFAULT_OCPVERSION} worker_memory=${WORKER_MEMORY} worker_cpu=${WORKER_CPU} disconnected_setting=${DISCONNECTED}" -e @./vars/vars-${BUILD_LAB}.yml setup-vcenter-vms.yml --ask-vault-pass

Export the Kubernetes Authentication variable

  1. export KUBECONFIG=/root/ocp4-vsphere-upi-automation/install-dir/auth/kubeconfig

Review the installation progress

  1. bin/openshift-install wait-for install-complete --dir=/root/ocp4-vsphere-upi-automation/install-dir

SSH to the Bootstrap node

  1. ssh core@192.168.0.xxx

Review the Boostrap service

  1. journalctl -b -f -u bootkube.service

Post Deployment Tasks (Default HTPasswd Auth Provider)

  1. ./postinstall.sh
  2. Specify Build Name (gsslab, pek2lab, <custom> ): (Press ENTER for default: gsslab)
  3. * Cluster Name: gsslab
  4. Confirm OpenShift Disconnected setting true/false: (Press ENTER for default: false)
  5. * Disconnected Setting: false
  6. Confirm OpenShift Container Storage (OCS) true/false: (Press ENTER for default: false)
  7. * OpenShift Container Storage (OCS) Setting: false
  8. Confirm HTPassword Auth true/false: (Press ENTER for default: true)
  9. * HTPassword Auth Setting: true
  10. Confirm LDAP Auth true/false: (Press ENTER for default: false)
  11. * LDAP Auth Setting: false
  12. Confirm NFS Storage true/false: (Press ENTER for default: false)
  13. * NFS Storage Setting: false

Cluster Node Scaling

Scale Up Worker Nodes (Default 3 nodes)

  1. ./scale-up-nodes.sh
  2. Specify Build Name (gsslab, pek2lab, <custom> ): (Press ENTER for default: gsslab)
  3. * Cluster Name: gsslab
  4. Enter OpenShift Worker Node Size (small [8gb,2vcpu],medium [32gb,4vcpu],large [64gb,8vcpu]): (Press ENTER for default: small )
  5. * Using: Cluster Settings Memory 8192 CPU 2

Scale Down Worker Nodes (Default 3 nodes)

  1. ./scale-down-nodes.sh
  2. Specify Build Name (gsslab, pek2lab, <custom> ): (Press ENTER for default: gsslab)
  3. * Cluster Name: gsslab

Disconnected Setup

Repo Sync with versioning

  1. ./disconnected-sync.sh
  2. Enter OpenShift Version: (Press ENTER for default: 4.3.8)
  3. 4.3.8
  4. * Using: 4.3.8
  5. info: Mirroring 103 images to registry.ocp4.gsslab.brq.redhat.com:443/openshift/ocp4.3.8-x86_64 ...

OLM Sync

  1. ./disconnected-operators.sh

Destroy Cluster

Cluster Destroy Vault

  1. ./cluster-destroy.sh
  2. Specify Cluster Name (gsslab, pek2lab, <custom> ): (Press ENTER for default: gsslab)
  3. * Cluster Name: gsslab

Cluster Destroy No Vault

  1. ./cluster-destroy-novault.sh
  2. Specify Cluster Name (gsslab, pek2lab, <custom> ): (Press ENTER for default: gsslab)
  3. * Cluster Name: gsslab

VMware Cloud-Init Image Guide

RHEL or CentOS Template Node Cloud-Init install

Creating a Generic Cloud-Init OS Image rhel7/CentOS

  1. yum -y install cloud-init

Alernative Pip install

  1. curl -O https://bootstrap.pypa.io/get-pip.py
  1. python get-pip.py --user

VMware Custom Cloud-init profile install

  1. yum install -y https://github.com/vmware/cloud-init-vmware-guestinfo/releases/download/v1.1.0/cloud-init-vmware-guestinfo-1.1.0-1.el7.noarch.rpm
  1. curl -sSL https://raw.githubusercontent.com/vmware/cloud-init-vmware-guestinfo/master/install.sh | sh -

MetaData and UserData Creation (Currently Automated on Helper Create)

  1. cat <<EOF > metadata.yaml
  2. instance-id: helper-boot
  3. local-hostname: helper-boot
  4. network:
  5. version: 2
  6. ethernets:
  7. nics:
  8. match:
  9. name: ens*
  10. dhcp4: yes
  11. EOF
  1. cat <<EOF > userdata.yaml
  2. #cloud-config
  3. users:
  4. - default
  5. - name: openshift
  6. primary_group: openshift
  7. sudo: ALL=(ALL) NOPASSWD:ALL
  8. groups: sudo, wheel
  9. ssh_import_id: None
  10. lock_passwd: true
  11. ssh_authorized_keys:
  12. - ssh-rsa xxxxxxxxxxxxxxx
  13. EOF
  1. export VM="/VMLAB/vm/rhel7.7-template"
  1. export METADATA=$(gzip -c9 <metadata.yaml | { base64 -w0 2>/dev/null || base64; }) \
  2. USERDATA=$(gzip -c9 <userdata.yaml | { base64 -w0 2>/dev/null || base64; })

Update RHEL/CentOS template on VMware service (Ensure GOVC profile has been exported for the relevant Cluster)

  1. govc vm.change -vm "${VM}" \
  2. -e guestinfo.metadata="${METADATA}" \
  3. -e guestinfo.metadata.encoding="gzip+base64" \
  4. -e guestinfo.userdata="${USERDATA}" \
  5. -e guestinfo.userdata.encoding="gzip+base64"