1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/installation-creating-gcp-vpc.adoc
2025-10-28 14:54:43 -04:00

150 lines
4.1 KiB
Plaintext

// Module included in the following assemblies:
//
// * installing/installing_gcp/installing-gcp-user-infra.adoc
// * installing/installing_gcp/installing-restricted-networks-gcp.adoc
// * installing/installing_gcp/installing-gcp-user-infra-vpc.adoc
ifeval::["{context}" == "installing-gcp-user-infra-vpc"]
:shared-vpc:
endif::[]
:_mod-docs-content-type: PROCEDURE
[id="installation-creating-gcp-vpc_{context}"]
= Creating a VPC in {gcp-short}
You must create a VPC in {gcp-first} for your {product-title}
cluster to use. You can customize the VPC to meet your requirements. One way to
create the VPC is to modify the provided Deployment Manager template.
[NOTE]
====
If you do not use the provided Deployment Manager template to create your {gcp-short}
infrastructure, you must review the provided information and manually create
the infrastructure. If your cluster does not initialize correctly, you might
have to contact Red Hat support with your installation logs.
====
.Prerequisites
* You have defined the variables in the _Exporting common variables_ section.
.Procedure
. Copy the template from the *Deployment Manager template for the VPC*
section of this topic and save it as `01_vpc.py` on your computer. This template
describes the VPC that your cluster requires.
ifdef::shared-vpc[]
. Export the following variables required by the resource definition:
.. Export the control plane CIDR:
+
[source,terminal]
----
$ export MASTER_SUBNET_CIDR='10.0.0.0/17'
----
.. Export the compute CIDR:
+
[source,terminal]
----
$ export WORKER_SUBNET_CIDR='10.0.128.0/17'
----
.. Export the region to deploy the VPC network and cluster to:
+
[source,terminal]
----
$ export REGION='<region>'
----
. Export the variable for the ID of the project that hosts the shared VPC:
+
[source,terminal]
----
$ export HOST_PROJECT=<host_project>
----
. Export the variable for the email of the service account that belongs to host project:
+
[source,terminal]
----
$ export HOST_PROJECT_ACCOUNT=<host_service_account_email>
----
endif::shared-vpc[]
. Create a `01_vpc.yaml` resource definition file:
+
[source,terminal]
----
$ cat <<EOF >01_vpc.yaml
imports:
- path: 01_vpc.py
resources:
- name: cluster-vpc
type: 01_vpc.py
properties:
ifndef::shared-vpc[]
infra_id: '${INFRA_ID}' <1>
endif::shared-vpc[]
ifdef::shared-vpc[]
infra_id: '<prefix>' <1>
endif::shared-vpc[]
region: '${REGION}' <2>
master_subnet_cidr: '${MASTER_SUBNET_CIDR}' <3>
worker_subnet_cidr: '${WORKER_SUBNET_CIDR}' <4>
EOF
----
ifndef::shared-vpc[]
<1> `infra_id` is the `INFRA_ID` infrastructure name from the extraction step.
endif::shared-vpc[]
ifdef::shared-vpc[]
<1> `infra_id` is the prefix of the network name.
endif::shared-vpc[]
<2> `region` is the region to deploy the cluster into, for example `us-central1`.
<3> `master_subnet_cidr` is the CIDR for the master subnet, for example `10.0.0.0/17`.
<4> `worker_subnet_cidr` is the CIDR for the worker subnet, for example `10.0.128.0/17`.
. Create the deployment by using the `gcloud` CLI:
+
ifndef::shared-vpc[]
[source,terminal]
----
$ gcloud deployment-manager deployments create ${INFRA_ID}-vpc --config 01_vpc.yaml
----
endif::shared-vpc[]
ifdef::shared-vpc[]
[source,terminal]
----
$ gcloud deployment-manager deployments create <vpc_deployment_name> --config 01_vpc.yaml --project ${HOST_PROJECT} --account ${HOST_PROJECT_ACCOUNT} <1>
----
<1> For `<vpc_deployment_name>`, specify the name of the VPC to deploy.
. Export the VPC variable that other components require:
.. Export the name of the host project network:
+
[source,terminal]
----
$ export HOST_PROJECT_NETWORK=<vpc_network>
----
.. Export the name of the host project control plane subnet:
+
[source,terminal]
----
$ export HOST_PROJECT_CONTROL_SUBNET=<control_plane_subnet>
----
.. Export the name of the host project compute subnet:
+
[source,terminal]
----
$ export HOST_PROJECT_COMPUTE_SUBNET=<compute_subnet>
----
. Set up the shared VPC. See link:https://cloud.google.com/vpc/docs/provisioning-shared-vpc#setting_up[Setting up Shared VPC] in the {gcp-short} documentation.
endif::shared-vpc[]
ifeval::["{context}" == "installing-gcp-user-infra-vpc"]
:!shared-vpc:
endif::[]