[[install-config-configuring-gce]]
= Configuring for GCE
{product-author}
{product-version}
:data-uri:
:icons:
:experimental:
:toc: macro
:toc-title:

toc::[]

== Overview
{product-title} can be configured to access a
link:https://cloud.google.com/compute/docs/disks/[Google Compute Engine (GCE) infrastructure], including
xref:../install_config/persistent_storage/persistent_storage_gce.adoc#install-config-persistent-storage-persistent-storage-gce[using GCE
volumes as persistent storage] for application data. After GCE is configured
properly, some additional configurations will need to be completed on the
{product-title} hosts.

[[configuring-gcp-permissions]]
== Permissions
Configuring GCE for {product-title} requires the following role:

[cols='1,3']
|===

| roles/owner
| To create service accounts, cloud storage, instances, images, templates, Cloud
DNS entries, and deploy load balancers and health checks. It is helpful to also
have `delete` permissions to be able to redeploy the environment while testing.

|===

[[gce-configuring-masters]]
== Configuring Masters

You can set the GCE configuration on your {product-title} master hosts in two ways:

- xref:gce-configuring-masters-ansible[Using Ansible]
- xref:gce-configuring-masters-manual[Manually by modifying the *_master-config.yaml_* file]


[[gce-configuring-masters-ansible]]
=== Configuring {product-title} Masters for GCE with Ansible

During cluster installations, GCE can be configured using the
`openshift_cloudprovider_kind` parameter, which is configurable in the
xref:../install/configuring_inventory_file.adoc#configuring-ansible[inventory file].

[IMPORTANT]
====
* When using GCE, the `openshift_gcp_project` and `openshift_gcp_prefix`
parameters must be defined.
* For running load balancer services using the Google compute platform, the nodes
(Compute Engine VM instances) must be tagged with `<openshift_gcp_prefix>ocp`
(add `ocp` suffix). For example, if the value of `openshift_gcp_prefix`
parameter is set to `mycluster`, the nodes must be tagged with `myclusterocp`.
See link:https://cloud.google.com/vpc/docs/add-remove-network-tags[Adding and
Removing Network Tags] for more information on how to add network tags to
Compute Engine VM instances.
====

.Example GCE Configuration with Ansible

----
# Cloud Provider Configuration
# openshift_cloudprovider_kind=gce
# openshift_gcp_project=<projectid> <1>
# openshift_gcp_prefix=<uid> <2>
# openshift_gcp_multizone=False <3>
----
<1> `openshift_gcp_project` is the project-id.
<2> `openshift_gcp_prefix` is a unique string to identify each OpenShift
cluster.
<3> Use the `openshift_gcp_multizone` parameter to trigger multizone deployments on GCE. Its default value is `False`.

[NOTE]
====
When Ansible configures GCE, the following files are created for you:

- *_/etc/origin/cloudprovider/gce.conf_*
- *_/etc/origin/master/master-config.yaml_*
- *_/etc/origin/node/node-config.yaml_*
====

The cluster installation process configures single-zone support by default. If
you want multizone support, edit the *_/etc/origin/cloudprovider/gce.conf_* file as
shown in xref:configuring-gce-multizone[Configuring Multizone Support in a GCE Deployment].

[[gce-configuring-masters-manual]]
=== Manually Configuring {product-title} Masters for GCE

To configure the {product-title} masters for GCE:

. Edit or
xref:../install_config/master_node_configuration.adoc#creating-new-configuration-files[create] the
master configuration file (*_/etc/origin/master/master-config.yaml_* by default) on all masters and update the
contents of the `*apiServerArguments*` and `*controllerArguments*` sections:
+
[source,yaml]
----
kubernetesMasterConfig:
  ...
  apiServerArguments:
    cloud-provider:
      - "gce"
    cloud-config:
      - "/etc/origin/cloudprovider/gce.conf"
  controllerArguments:
    cloud-provider:
      - "gce"
    cloud-config:
      - "/etc/origin/cloudprovider/gce.conf"
----
+
[IMPORTANT]
====
When triggering a containerized installation, only the directories of
*_/etc/origin_* and *_/var/lib/origin_* are mounted to the master and node
container. Therefore, *_master-config.yaml_* should be in *_/etc/origin/master_*
instead of *_/etc/_*.
====

. Start or restart the {product-title} services:
+
----
# master-restart api
# master-restart controllers
----

[[gce-configuring-nodes]]
== Configuring Nodes

To configure the {product-title} nodes for GCE:

. Edit or
xref:../install_config/master_node_configuration.adoc#creating-new-configuration-files[create]
the node configuration file (*_/etc/origin/node/node-config.yaml_*
by default) on all nodes and update the contents of the `*kubeletArguments*` section:
+
====
[source,yaml]
----
kubeletArguments:
  cloud-provider:
    - "gce"
  cloud-config:
    - "/etc/origin/cloudprovider/gce.conf"

----
====

Currently, the `nodeName` *must* match the instance name in GCE in order
for the cloud provider integration to work properly. The name must also be
RFC1123 compliant.

[IMPORTANT]
====
When triggering a containerized installation, only the directories of
*_/etc/origin_* and *_/var/lib/origin_* are mounted to the master and node
container. Therefore, *_node-config.yaml_* should be in *_/etc/origin/node_*
instead of *_/etc/_*.
====

. Start or restart the {product-title} services all nodes.
+
ifdef::openshift-enterprise[]
----
# systemctl restart atomic-openshift-node
----
endif::[]
ifdef::openshift-origin[]
----
# systemctl restart origin-node
----
endif::[]


[[configuring-gce-multizone]]

== Configuring Multizone Support in a GCE Deployment

If manually congifuring GCE, multizone support is not configured by default.

[NOTE]
====
The cluster installation process configures single-zone support by default.
====

If you want multizone support:

. Edit or create a *_/etc/origin/cloudprovider/gce.conf_* file on all of your {product-title} hosts, both masters and nodes.
. Add the following contents:
+
----
[Global]
project-id = <project-id>
network-name = <network-name>
node-tags = <node-tags>
node-instance-prefix = <instance-prefix>
multizone = true
----

To return to single-zone support, set the `multizone` value to `false`.

[[gce-applying-configuration-changes]]
== Applying Configuration Changes
include::install_config/topics/applying_configuration_changes.adoc[]
