From 8738395ede6b3ecc2cf90cf5ecaba307108d676f Mon Sep 17 00:00:00 2001 From: Richard Su Date: Fri, 22 Sep 2023 17:24:23 -0400 Subject: [PATCH] AGENT-724: Deploy vSphere clusters with credentials Fake credentials are added to install-config.yaml for vSphere platform. In combination with https://github.com/openshift-metal3/dev-scripts/pull/1588, this patch allows testng of installer and assisted-service validations for the vSphere platform. A complete install for vSphere using dev-scripts is currently not possible because the vSphere environment is partially simulated using libvirt VMs. Any cloud controller manager interactions with vSphere will fail in libvirt because there isn't an actual vSphere environment that is being exercised. In this setup, only "agent wait-for bootstrap-complete" will succeed. For vSphere, "agent wait-for install-complete" will fail and is skipped. --- agent/06_agent_create_cluster.sh | 5 + .../roles/manifests/tasks/install-config.yml | 8 +- .../templates/install-config_vsphere_yaml.j2 | 99 +++++++++++++++++++ common.sh | 3 + config_example.sh | 8 +- 5 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 agent/roles/manifests/templates/install-config_vsphere_yaml.j2 diff --git a/agent/06_agent_create_cluster.sh b/agent/06_agent_create_cluster.sh index 6d9937918..f494c6635 100755 --- a/agent/06_agent_create_cluster.sh +++ b/agent/06_agent_create_cluster.sh @@ -219,6 +219,11 @@ function wait_for_cluster_ready() { exit 1 fi + if [ "${AGENT_WAIT_FOR_INSTALL_COMPLETE}" == "false" ]; then + echo "Skipping agent wait-for install-complete" + exit 0 + fi + echo "Waiting for cluster ready... " "${openshift_install}" --dir="${dir}" --log-level=debug agent wait-for install-complete 2>&1 | grep --line-buffered -v 'password' if [ ${PIPESTATUS[0]} != 0 ]; then diff --git a/agent/roles/manifests/tasks/install-config.yml b/agent/roles/manifests/tasks/install-config.yml index 82927ff44..c1bf1fc8a 100644 --- a/agent/roles/manifests/tasks/install-config.yml +++ b/agent/roles/manifests/tasks/install-config.yml @@ -7,7 +7,7 @@ template: src: "templates/install-config_yaml.j2" dest: "{{ install_path }}/install-config.yaml" - when: platform_type != "baremetal" + when: platform_type != "baremetal" and platform_type != "vsphere" - name: write the install-config.yaml template: @@ -15,6 +15,12 @@ dest: "{{ install_path }}/install-config.yaml" when: platform_type == "baremetal" +- name: write the install-config.yaml + template: + src: "templates/install-config_vsphere_yaml.j2" + dest: "{{ install_path }}/install-config.yaml" + when: platform_type == "vsphere" + - name: write the agent-config.yaml template: src: "agent-config_yaml.j2" diff --git a/agent/roles/manifests/templates/install-config_vsphere_yaml.j2 b/agent/roles/manifests/templates/install-config_vsphere_yaml.j2 new file mode 100644 index 000000000..861eb2ce8 --- /dev/null +++ b/agent/roles/manifests/templates/install-config_vsphere_yaml.j2 @@ -0,0 +1,99 @@ +apiVersion: v1 +baseDomain: {{ base_domain }} +compute: +- hyperthreading: Enabled + name: worker + replicas: {{ num_workers }} + architecture: {{ goCPUArchitecture }} +controlPlane: + architecture: {{ goCPUArchitecture }} + hyperthreading: Enabled + name: master + replicas: {{ num_masters }} +fips: {{ fips_mode }} +metadata: + name: {{ cluster_name }} +{% if boot_mode != "DISKIMAGE" %} + namespace: {{ cluster_namespace }} +{% endif %} +networking: +{% if ip_stack == "v4" %} + clusterNetwork: + - cidr: {{ cluster_subnet_v4 }} + hostPrefix: {{ cluster_host_prefix_v4 }} + machineNetwork: + - cidr: {{ external_subnet_v4 }} + serviceNetwork: + - {{ service_subnet_v4 }} +{% elif ip_stack == "v6" %} + clusterNetwork: + - cidr: {{ cluster_subnet_v6 }} + hostPrefix: {{ cluster_host_prefix_v6 }} + machineNetwork: + - cidr: {{ external_subnet_v6 }} + serviceNetwork: + - {{ service_subnet_v6 }} +{% else %} + clusterNetwork: + - cidr: {{ cluster_subnet_v4 }} + hostPrefix: {{ cluster_host_prefix_v4 }} + - cidr: {{ cluster_subnet_v6 }} + hostPrefix: {{ cluster_host_prefix_v6 }} + machineNetwork: + - cidr: {{ external_subnet_v4 }} + - cidr: {{ external_subnet_v6 }} + serviceNetwork: + - {{ service_subnet_v4 }} + - {{ service_subnet_v6 }} +{% endif %} + networkType: {{ network_type }} +platform: + vsphere: + vcenters: + - datacenters: + - testDatacenter + password: testPassword + server: vcenter.test.com + user: testUser@vcenter.test.com + failuredomains: + - name: test-failure-baseDomain + server: vcenter.test.com + region: testRegion + topology: + datacenter: testDatacenter + datastore: /testDatacenter/datastore/testDatastore + computeCluster: /testDatacenter/host/testClusters + folder: /testDatacenter/vm/testFolder + networks: + - testNetwork + zone: testZone + apiVIPs: +{% set a_vips = api_vips.split(',') %} +{% for api_vip in a_vips %} + - {{ api_vip }} +{% endfor %} + ingressVIPs: +{% set i_vips = ingress_vips.split(',') %} +{% for ingress_vip in i_vips %} + - {{ ingress_vip }} +{% endfor %} +pullSecret: {{ pull_secret_contents }} +sshKey: {{ ssh_pub_key }} +{% if mirror_images %} +imageContentSources: +{{ image_content_sources }} +{% if (mirror_command == "oc-mirror") and (agent_deploy_mce == "true") %} +- mirrors: + - "{{ local_registry_dns_name }}:{{ local_registry_port }}/multicluster-engine" + source: "registry.redhat.io/multicluster-engine" +- mirrors: + - "{{ local_registry_dns_name }}:{{ local_registry_port }}/rhel8" + source: "registry.redhat.io/rhel8" +- mirrors: + - "{{ local_registry_dns_name }}:{{ local_registry_port }}/redhat" + source: "registry.redhat.io/redhat" +{% endif %} +additionalTrustBundle: {{ ca_bundle_crt }} +{% elif enable_local_registry %} +additionalTrustBundle: {{ registry_certificate }} +{% endif %} diff --git a/common.sh b/common.sh index 57928bca0..79a1a71fc 100644 --- a/common.sh +++ b/common.sh @@ -373,6 +373,9 @@ export ENABLE_LOCAL_REGISTRY=${ENABLE_LOCAL_REGISTRY:-} # Defaults the DISABLE_MULTICAST variable export DISABLE_MULTICAST=${DISABLE_MULTICAST:-false} +# Defaults the AGENT_WAIT_FOR_INSTALL_COMPLETE variable +export AGENT_WAIT_FOR_INSTALL_COMPLETE=${AGENT_WAIT_FOR_INSTALL_COMPLETE:-true} + # Agent specific configuration function invalidAgentValue() { diff --git a/config_example.sh b/config_example.sh index e124c1b95..34e9d38bb 100755 --- a/config_example.sh +++ b/config_example.sh @@ -205,7 +205,6 @@ set -x # for the cluster image-registry # export PERSISTENT_IMAGEREG=true - ################################################################################ ## Network Settings ## @@ -805,6 +804,13 @@ set -x # agent-config.yaml. # export AGENT_BM_HOSTS_IN_INSTALL_CONFIG=false +# AGENT_WAIT_FOR_INSTALL_COMPLETE +# Default: true +# +# Setting this to false skips the "wait-for install-complete" step. +# +# export AGENT_WAIT_FOR_INSTALL_COMPLETE=false + # Image reference for OpenShift-based Appliance Builder. # See: https://github.com/openshift/appliance # Default: "quay.io/edge-infrastructure/openshift-appliance:latest"