Step: openstack-conf-generateconfig

Generates the necessary install-config.yaml file based on the requested CONFIG_TYPE. Saves the file as ${SHARED_DIR}/install-config.yaml. Load balancer IP and cluster name, are expected to be in ${SHARED}/API_IP and ${SHARED_DIR}/CLUSTER_NAME respectively. This ref is compatible with OCP 4.6+ and will break 4.5, because `ingressFloatingIP` was only introduced in 4.6.

Container image used for this step: openstack-installer

openstack-installer resolves to an image built or imported by the ci-operator configuration (documentation).

Environment

In addition to the default environment, the step exposes the following:

Variable Name Type Variable Content
OS_CLOUD Parameter[?] (default: openstack)
BASE_DOMAIN Parameter[?]
CONFIG_TYPE Parameter[?] (default: minimal)
NETWORK_TYPE Parameter[?] used to select the networkType to be used. For example, OpenShiftSDN, OVNKubernetes, or Kuryr (default: OpenShiftSDN)
OPENSTACK_EXTERNAL_NETWORK Parameter[?] Name of the OpenStack public-facing network. Defaults to the value in "${SHARED_DIR}/OPENSTACK_EXTERNAL_NETWORK"
OPENSTACK_PROVIDER_NETWORK Parameter[?] Name of the OpenStack provider network if any.
ADDITIONAL_WORKERS_NETWORKS Parameter[?] Space-separated list of Neutron network names that will be connected to the worker nodes.
OPENSTACK_CONTROLPLANE_FLAVOR Parameter[?] Name of the OpenStack flavor used for the servers hosting the OpenShift master nodes. Defaults to the value in "${SHARED_DIR}/OPENSTACK_CONTROLPLANE_FLAVOR"
OPENSTACK_COMPUTE_FLAVOR Parameter[?] Name of the OpenStack flavor used for the servers hosting the OpenShift worker nodes. Defaults to the value in "${SHARED_DIR}/OPENSTACK_COMPUTE_FLAVOR"
FIPS_ENABLED Parameter[?] (default: false)
ZONES Parameter[?] List of AZs that can be used when deploying the cluster. Defaults to the value in "${SHARED_DIR}/ZONES"
ZONES_COUNT Parameter[?] The number of AZs to present in the cluster. Accepted values are 0 and 1. (default: 0)
CONFIG_TYPE Parameter[?] The type of config for the environment to deploy. * 'minimal' - Configure the install-config with the minimal options to make it work on our tests, which requires the usage of floating IPs. This config type doesn't require a proxy server to be deployed. * 'byon' - Configure the install-config to use a pre-created network (BYON) so it wouln't require the usage of floating IPs. This config type will require a proxy server to be deployed. * 'proxy' - Configure the install-config to use a pre-created restricted network (BYON) and a Cluster Proxy.

Source Code

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env bash

set -o nounset
set -o errexit
set -o pipefail

export OS_CLIENT_CONFIG_FILE=${SHARED_DIR}/clouds.yaml

CLUSTER_NAME=$(<"${SHARED_DIR}/CLUSTER_NAME")
OPENSTACK_EXTERNAL_NETWORK="${OPENSTACK_EXTERNAL_NETWORK:-$(<"${SHARED_DIR}/OPENSTACK_EXTERNAL_NETWORK")}"
OPENSTACK_CONTROLPLANE_FLAVOR="${OPENSTACK_CONTROLPLANE_FLAVOR:-$(<"${SHARED_DIR}/OPENSTACK_CONTROLPLANE_FLAVOR")}"
OPENSTACK_COMPUTE_FLAVOR="${OPENSTACK_COMPUTE_FLAVOR:-$(<"${SHARED_DIR}/OPENSTACK_COMPUTE_FLAVOR")}"
ZONES="${ZONES:-$(<"${SHARED_DIR}/ZONES")}"
ZONES_COUNT="${ZONES_COUNT:-0}"

API_IP=$(<"${SHARED_DIR}"/API_IP)
INGRESS_IP=$(<"${SHARED_DIR}"/INGRESS_IP)

PULL_SECRET=$(<"${CLUSTER_PROFILE_DIR}"/pull-secret)
SSH_PUB_KEY=$(<"${CLUSTER_PROFILE_DIR}"/ssh-publickey)

CONFIG="${SHARED_DIR}/install-config.yaml"

case "$CONFIG_TYPE" in
  minimal|byon|proxy)
    ;;
  *)
    echo "No valid install config type specified. Please check CONFIG_TYPE"
    exit 1
    ;;
esac

mapfile -t ZONES < <(printf ${ZONES}) >/dev/null
MAX_ZONES_COUNT=${#ZONES[@]}

if [[ ${ZONES_COUNT} -gt ${MAX_ZONES_COUNT} ]]; then
  echo "Too many zones were requested: ${ZONES_COUNT}; only ${MAX_ZONES_COUNT} are available: ${ZONES[*]}"
  exit 1
fi

if [[ "${ZONES_COUNT}" == "0" ]]; then
  ZONES_STR="[]"
elif [[ "${ZONES_COUNT}" == "1" ]]; then
  function join_by { local IFS="$1"; shift; echo "$*"; }
  ZONES=("${ZONES[@]:0:${ZONES_COUNT}}")
  ZONES_STR="[ "
  ZONES_STR+=$(join_by , "${ZONES[@]}")
  ZONES_STR+=" ]"
else
  # For now, we only support a cluster within a single AZ.
  # This will change in the future.
  echo "Wrong ZONE_COUNT, can only be 0 or 1, got ${ZONES_COUNT}"
  exit 1
fi
echo "OpenStack Availability Zones: ${ZONES_STR}"

cat > "${CONFIG}" << EOF
apiVersion: v1
baseDomain: ${BASE_DOMAIN}
metadata:
  name: ${CLUSTER_NAME}
networking:
  networkType: ${NETWORK_TYPE}
EOF
if [[ "${CONFIG_TYPE}" == "byon" || "${CONFIG_TYPE}" == "proxy" ]]; then
cat >> "${CONFIG}" << EOF
  machineNetwork:
  - cidr: $(<"${SHARED_DIR}"/MACHINES_SUBNET_RANGE)
EOF
fi
cat >> "${CONFIG}" << EOF
platform:
  openstack:
    cloud:             ${OS_CLOUD}
EOF
if [[ "${CONFIG_TYPE}" == "minimal" ]]; then
cat >> "${CONFIG}" << EOF
    externalDNS:
      - 1.1.1.1
      - 1.0.0.1
    lbFloatingIP:      ${API_IP}
    ingressFloatingIP: ${INGRESS_IP}
    externalNetwork:   ${OPENSTACK_EXTERNAL_NETWORK}
EOF
elif [[ "${CONFIG_TYPE}" == "byon" || "${CONFIG_TYPE}" == "proxy" ]]; then
cat >> "${CONFIG}" << EOF
    machinesSubnet:    $(<"${SHARED_DIR}"/MACHINES_SUBNET_ID)
    apiVIP:            ${API_IP}
    ingressVIP:        ${INGRESS_IP}
EOF
fi
cat >> "${CONFIG}" << EOF
compute:
- name: worker
  replicas: 3
  platform:
    openstack:
      type: ${OPENSTACK_COMPUTE_FLAVOR}
      zones: ${ZONES_STR}
EOF
if [[ ${ADDITIONAL_WORKERS_NETWORKS} != "" ]]; then
    cat >> "${CONFIG}" << EOF
      additionalNetworkIDs:
EOF
    for network in $ADDITIONAL_WORKERS_NETWORKS; do
        if ! openstack network show "${network}" > /dev/null 2>&1; then
            echo "Network ${network} does not exist"
            exit 1
        fi
        net_id=$(openstack network show -f value -c id "${network}")
        cat >> "${CONFIG}" << EOF
      - ${net_id}
EOF
    done
fi

cat >> "${CONFIG}" << EOF
controlPlane:
  name: master
  platform:
    openstack:
      type: ${OPENSTACK_CONTROLPLANE_FLAVOR}
      zones: ${ZONES_STR}
  replicas: 3
pullSecret: >
  ${PULL_SECRET}
sshKey: |
  ${SSH_PUB_KEY}
EOF
if [[ "${CONFIG_TYPE}" == "proxy" && -f "${SHARED_DIR}"/PROXY_INTERFACE ]]; then
  PROXY_INTERFACE=$(<"${SHARED_DIR}"/PROXY_INTERFACE)
  SQUID_AUTH=$(<"${SHARED_DIR}"/SQUID_AUTH)
cat >> "${CONFIG}" << EOF
proxy:
  httpProxy: http://${SQUID_AUTH}@${PROXY_INTERFACE}:3128/
  httpsProxy: https://${SQUID_AUTH}@${PROXY_INTERFACE}:3130/
additionalTrustBundle: |
$(cat "${SHARED_DIR}"/domain.crt | awk '{print "  "$0}')
EOF
fi

if [ ${FIPS_ENABLED} = "true" ]; then
  echo "Adding 'fips: true' to install-config.yaml"
  cat >> "${CONFIG}" << EOF
fips: true
EOF
fi

# Lets  check the syntax of yaml file by reading it.
python -c 'import yaml;
import sys;
data = yaml.safe_load(open(sys.argv[1]))' "${SHARED_DIR}/install-config.yaml"

# This block will remove the ports created in openstack-provision-machinesubnet-commands.sh
# since the installer will create them again, based on install-config.yaml.
if [[ ${OPENSTACK_PROVIDER_NETWORK} != "" ]]; then
  echo "Provider network detected, will clean-up reserved ports"
  for p in api ingress; do
    if openstack port show ${CLUSTER_NAME}-${CONFIG_TYPE}-${p} >/dev/null; then
      echo "Port exists for ${CLUSTER_NAME}-${CONFIG_TYPE}-${p}: removing it"
      openstack port delete ${CLUSTER_NAME}-${CONFIG_TYPE}-${p}
    fi
  done
fi

Properties

Property Value Description
Resource requests (cpu) 10m Used in .resources.requests of the pod running this step.
Resource requests (memory) 100Mi Used in .resources.requests of the pod running this step.

GitHub Link:

https://github.com/openshift/release/blob/master/ci-operator/step-registry/openstack/conf/generateconfig/openstack-conf-generateconfig-ref.yaml

Owners:

Approvers:

Reviewers:

Source code for this page located on GitHub