Preparing OpenShift resources for the GitLab chart

This document walks you through using the automation scripts in this project to create an OpenShift cluster in Google Cloud.

Preparation

First, you should have a Red Hat account associated with your GitLab email. Contact our Red Hat Alliance liaison; they will arrange to send you an account invitation email. Once you activate your Red Hat account, you will have access the to licenses and subscriptions needed to run OpenShift.

To launch a cluster in Google Cloud, a public Cloud DNS zone must be connected to a registered domain and configured in Google Cloud DNS. If a domain is not already available, follow the steps in this guide to create one.

Get the CLI tools and Pull Secret

Two CLI tools are required to create an OpenShift cluster (openshift-install) and then interact with the cluster (oc).

A pull secret is required to fetch images from Red Hat’s private Docker registry. Every developer has a different pull secret associated with their Red Hat account.

To get the CLI tools and your pull secret, go to Red Hat’s cloud and log in with your Red Hat account. On this page, download the latest version of the installer and command-line tools with the links provided. Extract these packages and place openshift-install and oc in your PATH.

Copy the pull secret to your clipboard and write the content to a file pull_secret in the root of this repository. This file is gitignored.

Create a Google Cloud (GCP) Service Account

Follow these instructions to create a Service Account in the Google Cloud cloud-native project. Attach all roles marked as Required in that document. Once the Service Account is created, generate a JSON key and save it as gcloud.json in the root of this repository. This file is gitignored.

Create your OpenShift cluster

To create the OpenShift cluster:

  1. Clone the GitLab Operator repository:

    git clone https://gitlab.com/gitlab-org/cloud-native/gitlab-operator.git
    
  2. Run the script to create the OpenShift cluster in Google Cloud:

    cd gitlab-operator
    ./scripts/create_openshift_cluster.sh
    

This will be a 6 node cluster with 3 control plane (master) nodes and 3 worker nodes. The process takes around 40 minutes. Follow the instructions at the end of the console output to connect to the cluster.

Once created, you should be able to see your cluster registered in Red Hat cloud. All installation logs and metadata will be stored in the install-$CLUSTER_NAME/ directory in this repository. This directory is gitignored.

Configuration options

Configuration can be applied during runtime by setting environment variables. All options have defaults, so no options are required.

VariableDescriptionDefault
CLUSTER_NAMEName of clusterocp-$USER
BASE_DOMAINRoot domain for clusterk8s-ft.win
GCP_PROJECT_IDGoogle Cloud project IDcloud-native-182609
GCP_REGIONGoogle Cloud region for clusterus-central1
GOOGLE_APPLICATION_CREDENTIALSPath to Google Cloud service account JSON filegcloud.json
GOOGLE_CREDENTIALSContent of Google Cloud service account JSON fileContent of $GOOGLE_APPLICATION_CREDENTIALS
PULL_SECRET_FILEPath to Red Hat pull secret filepull_secret
PULL_SECRETContent of Red Hat pull secret fileContent of $PULL_SECRET_FILE
SSH_PUBLIC_KEY_FILEPath to SSH public key file$HOME/.ssh/id_rsa.pub
SSH_PUBLIC_KEYContent of SSH public key fileContent of $SSH_PUBLIC_KEY_FILE
LOG_LEVELVerbosity of openshift-install outputinfo
INSTALL_DIRDirectory for install assets, useful for launching multiple clustersinstall-$CLUSTER_NAME
note
The variables CLUSTER_NAME and BASE_DOMAIN are combined to build the domain name for the cluster.

Destroy your OpenShift cluster

To destroy the OpenShift cluster:

  1. Clone the GitLab Operator repository:

    git clone https://gitlab.com/gitlab-org/cloud-native/gitlab-operator.git
    
  2. Run the script to destroy the OpenShift cluster in Google Cloud. This takes around 4 minutes:

    cd gitlab-operator
    ./scripts/destroy_openshift_cluster.sh
    

Configuration can be applied during runtime by setting the following environment variables. All options have defaults, no options are required.

VariableDescriptionDefault
GOOGLE_APPLICATION_CREDENTIALSPath to Google Cloud service account JSON filegcloud.json
GOOGLE_CREDENTIALSContent of Google Cloud service account JSON fileContent of $GOOGLE_APPLICATION_CREDENTIALS
LOG_LEVELVerbosity of openshift-install outputinfo
INSTALL_DIRDirectory for install assets, useful for launching multiple clustersinstall-$CLUSTER_NAME

Next steps

When the cluster is up and running, you can continue installing GitLab.

Resources