strutture:lnf:dr:calcolo:sistemi:okd:okd_on_vsphere
Differences
This shows you the differences between two versions of the page.
| strutture:lnf:dr:calcolo:sistemi:okd:okd_on_vsphere [2022/12/13 00:18] – created rorru@infn.it | strutture:lnf:dr:calcolo:sistemi:okd:okd_on_vsphere [2022/12/13 00:22] (current) – rorru@infn.it | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== OKD on vSphere ====== | ||
| + | |||
| + | This [[https:// | ||
| + | |||
| + | The main goal is to require the insertion only of a minimal set of needed information and let Terraform, Ansible and OKD/OCP installer do the hard work. | ||
| + | |||
| + | Included scripts are meant to be ran from a workstation/ | ||
| + | |||
| + | * Terraform v1.3.5 with provider hashicorp/ | ||
| + | * Ansible [core 2.13.6] | ||
| + | |||
| + | ===== What is included ===== | ||
| + | |||
| + | * vSphere env (Terraform): | ||
| + | * bastion host creation, from an existing template | ||
| + | * definition of a set of roles needed by OKD/OCP installer to perform a smooth deploy | ||
| + | * given a vSphere user (used as a service account), defined roles are automatically assigned | ||
| + | * definition of Ansible inventory and templates to be used in the next step | ||
| + | * returning of the bastion IP | ||
| + | * Bastion host configuration: | ||
| + | * '' | ||
| + | * '' | ||
| + | * OKD/OCP installer download and installation | ||
| + | * OKD/OCP client download and installation | ||
| + | * enabling '' | ||
| + | * download and trusting of vCenter certificates | ||
| + | * dir installation configuration as a git repo (and commiting '' | ||
| + | |||
| + | ===== What is NOT included ===== | ||
| + | |||
| + | This scripts don’t include: | ||
| + | |||
| + | * vSphere service account creation, it needs to be created **BEFORE** Terraform execution | ||
| + | * A proper VM template on vSphere env running a Linux OS (a RH-like one if it’s possible) | ||
| + | * Avoiding plain passwords in Terraform state files and Ansible vars, use enrypted dirs and/or vaults by your own | ||
| + | * Additional configuration and anything not mentioned in the [[# | ||
| + | * Any further installation/ | ||
| + | * Something that can guess your desired configuration and/or env details, so carefully fill out config and var files as indicated below prior to run Terraform/ | ||
| + | |||
| + | In general, all requirements are the same for common OKD/OCP installation: | ||
| + | |||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | |||
| + | All design, requirements validation and preparative activities are always needed in advance like a “manual” installation, | ||
| + | |||
| + | ===== Information to be gathered ===== | ||
| + | |||
| + | ==== vSphere env ==== | ||
| + | |||
| + | * vCenter URL/ | ||
| + | * Computing cluster | ||
| + | * Datacenter | ||
| + | * Network (to be used as machine network) | ||
| + | * Administrator level account (to perform Terraform runs) | ||
| + | * Service account user (used by OKD/OCP installer/ | ||
| + | * Service account password | ||
| + | * Default Datastore | ||
| + | * VM template name | ||
| + | * VM template guest OS type | ||
| + | * Folder name | ||
| + | * Bastion VM details: | ||
| + | * name | ||
| + | * vCPUs | ||
| + | * assigned RAM (in MB) | ||
| + | * disk size (in GB) | ||
| + | |||
| + | ==== OKD/OCP target cluster ==== | ||
| + | |||
| + | * OKD/OCP version to be installed (list of releases [[https:// | ||
| + | * Base domain | ||
| + | * Cluster name | ||
| + | * Installation dir location (inside the bastion host) | ||
| + | * Compute (worker) nodes sizing: | ||
| + | * Assigned cores | ||
| + | * Cores per socket | ||
| + | * Assigned RAM memory (in MB) | ||
| + | * Disk size (in GB) | ||
| + | * Cardinality (number of replicas) | ||
| + | * Controlplane (master) nodes sizing: | ||
| + | * Assigned cores | ||
| + | * Cores per socket | ||
| + | * Assigned RAM memory (in MB) | ||
| + | * Disk size (in GB) | ||
| + | * Cardinality (number of replicas) **3 is a magic number, don’t change it** | ||
| + | * Cluster network CIDR (if different from default) | ||
| + | * Service network CIDR (if different from default) | ||
| + | * Machine network CIDR | ||
| + | * VIPs: | ||
| + | * api ('' | ||
| + | * ingress ('' | ||
| + | * Pull secret (if RH Insight, etc. are needed, if not, leave the default fake pull secret) | ||
| + | * Management public key (allows ssh into the nodes while bootstrapping - recommended) | ||
| + | |||
| + | ==== Management pubkeys ==== | ||
| + | |||
| + | Is strongly recommended to use one or more management public keys, they can be found useful when troubleshooting the installation. | ||
| + | |||
| + | Management public keys can be inserted in : | ||
| + | |||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | ===== Usage walkthrough ===== | ||
| + | |||
| + | Preface: in order to be executed, Terraform scripts need to use an administrative user account password. To avoid to store it inside configuration files, it can be passed using an environment variable previously valued from different sources like a password manager. | ||
| + | |||
| + | For example, the env var can be defined, used and destroyed in a short bash one-liner while using [[https:// | ||
| + | |||
| + | < | ||
| + | export TF_VAR_vsphere_password=$(pass vcenter/ | ||
| + | </ | ||
| + | |||
| + | In the following, when '' | ||
| + | |||
| + | **NOTE: when passwords are passed to Terraform, related credentials are stored as PLAIN TEXT in '' | ||
| + | |||
| + | As mentioned before, a dedicated user needs to be created in advance on vSphere as a service account. | ||
| + | |||
| + | Installation phase can be resumed to the following steps: | ||
| + | |||
| + | - Clone this repo and cd into the local copy: | ||
| + | |||
| + | < | ||
| + | git clone git@baltig.infn.it: | ||
| + | cd okd-on-vsphere | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | < | ||
| + | |||
| + | < | ||
| + | cp terraform.tfvars.example terraform.tfvars | ||
| + | cp vars/ | ||
| + | cp vars/ | ||
| + | vim terraform.tfvars | ||
| + | vim vars/ | ||
| + | vim vars/ | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | < | ||
| + | |||
| + | < | ||
| + | terraform init | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | < | ||
| + | |||
| + | < | ||
| + | terraform plan | ||
| + | </ | ||
| + | |||
| + | and **//ALWAYS REVIEW YOUR PLAN OUTPUT//** | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | |||
| + | < | ||
| + | terraform apply | ||
| + | </ | ||
| + | |||
| + | and **//ALWAYS REVIEW YOUR APPLY OUTPUT BEFORE CONFIRM// | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | |||
| + | < | ||
| + | ansible-playbook -k enable_ansible_access.yaml | ||
| + | </ | ||
| + | |||
| + | If your template allow for access using a sudoer user (often using a pubkey), use the form: | ||
| + | |||
| + | < | ||
| + | ansible-playbook -b -u < | ||
| + | </ | ||
| + | |||
| + | Add '' | ||
| + | |||
| + | < | ||
| + | < | ||
| + | |||
| + | < | ||
| + | ansible-playbook bastion_setup.yaml | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | < | ||
| + | |||
| + | < | ||
| + | ssh -l ansible < | ||
| + | </ | ||
| + | |||
| + | Escalate to super user privileges (if needed): | ||
| + | |||
| + | < | ||
| + | [ansible@bastion ~]$ sudo -i | ||
| + | [root@bastion ~]# | ||
| + | </ | ||
| + | |||
| + | and cd to the install dir location specified in the '' | ||
| + | |||
| + | < | ||
| + | platform: | ||
| + | version: 4.10.0-0.okd-2022-07-09-073606 | ||
| + | ... | ||
| + | install_location: | ||
| + | home_path: "/ | ||
| + | install_dir: | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | you need to cd into '' | ||
| + | |||
| + | < | ||
| + | < | ||
| + | |||
| + | < | ||
| + | openshift-install create cluster --dir < | ||
| + | </ | ||
| + | |||
| + | Complete installation takes aproximatively 40 mins using default sizing parameters for master and worker nodes. Before execution stops, the installer will show administrative credential to access your new cluster. If you lose or forget related access information open '' | ||
| + | |||
| + | < | ||
| + | export KUBECONFIG=< | ||
| + | </ | ||
| + | |||
| + | Alternatively, | ||
| + | |||
| + | To obtain the OKD/OCP web console URL, type: | ||
| + | |||
| + | < | ||
| + | oc whoami --show-console | ||
| + | </ | ||
| + | |||
| + | ===== Destroying the cluster ===== | ||
| + | |||
| + | To destroy the cluster, follow the steps: | ||
| + | |||
| + | - Access your bastion, if you don’t remember your bastion assigned IP, run '' | ||
| + | |||
| + | < | ||
| + | ssh -l ansible < | ||
| + | </ | ||
| + | |||
| + | Escalate to super user privileges (if needed): | ||
| + | |||
| + | < | ||
| + | [ansible@bastion ~]$ sudo -i | ||
| + | [root@bastion ~]# | ||
| + | </ | ||
| + | |||
| + | and cd in your install directory. | ||
| + | |||
| + | < | ||
| + | < | ||
| + | |||
| + | < | ||
| + | openshift-install destroy cluster --dir < | ||
| + | </ | ||
| + | |||
| + | All PKD/OCP nodes VMs will be deleted. Now the bastion need to be destroyed itself. | ||
| + | |||
| + | < | ||
| + | < | ||
| + | |||
| + | < | ||
| + | terraform destroy | ||
| + | </ | ||
| + | |||
| + | and **//ALWAYS REVIEW YOUR DESTROY OUTPUT BEFORE CONFIRM//** The bastion host will be destroyed and all permission assigned to the given service account user will be revoked. | ||
| + | |||
| + | ===== Main caveat ===== | ||
| + | |||
| + | Some permission automatically assigned to the given service account user are related to the root of vSphere computing resources, at “vCenter” level. | ||
| + | |||
| + | When updating an existing plan using '' | ||
| + | |||
| + | - Stop the current Terraform execution (CTRL-c) | ||
| + | - Delete “vCenter” level permissions and related role state on Terraform files: | ||
| + | |||
| + | < | ||
| + | terraform state rm vsphere_entity_permissions.vcenter-permissions vsphere_role.okd-sa-vcenter-role | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
