Skip to content
This repository has been archived by the owner on Aug 18, 2023. It is now read-only.

Add support for local registry #62

Merged
merged 1 commit into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,11 @@ Do not manually clean up your environment unless both of the following are true:

1. You know what you are doing
2. Something went wrong with an automated deletion.

### Setup Local Registry Variables

Update the following variables specific to OCP local registry. Note that this is required only for restricted network install.

* `enable_local_registry` : (Optional) Set to true to enable usage of local registry for restricted network install.
* `local_registry_image` : (Optional) This is the name of the image used for creating the local registry container.
* `ocp_release_tag` : (Optional) The version of OpenShift you want to sync. Determine the tag by referring the [Repository Tags](https://quay.io/repository/openshift-release-dev/ocp-release?tab=tags) page.
17 changes: 15 additions & 2 deletions modules/3_helpernode/helpernode.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@

locals {
forwarders = tolist(split(";", var.dns_forwarders))

local_registry = {
enable_local_registry = var.enable_local_registry
registry_image = var.local_registry_image
ocp_release_repo = "ocp4/openshift4"
ocp_release_tag = var.ocp_release_tag
}

helpernode_vars = {
cluster_domain = var.cluster_domain
cluster_id = var.cluster_id
Expand Down Expand Up @@ -55,7 +61,8 @@ locals {
name = "worker-${ix}"
}
]


local_registry = local.local_registry
client_tarball = var.openshift_client_tarball
install_tarball = var.openshift_install_tarball
}
Expand All @@ -78,13 +85,19 @@ resource "null_resource" "config" {

provisioner "remote-exec" {
inline = [
"mkdir -p .openshift",
"rm -rf ocp4-helpernode",
"echo 'Cloning into ocp4-helpernode...'",
"git clone https://github.com/RedHatOfficial/ocp4-helpernode --quiet",
"cd ocp4-helpernode && git checkout ${var.helpernode_tag}"
]
}

provisioner "file" {
source = "data/pull-secret.txt"
destination = "~/.openshift/pull-secret"
}

provisioner "file" {
content = templatefile("${path.module}/templates/helpernode_inventory", local.helpernode_inventory)
destination = "~/ocp4-helpernode/inventory"
Expand Down
11 changes: 11 additions & 0 deletions modules/3_helpernode/templates/helpernode_vars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,14 @@ ocp_installer: "${install_tarball}"
ocp_bios: "file:///dev/null"
ocp_initramfs: "file:///dev/null"
ocp_install_kernel: "file:///dev/null"

%{ if local_registry.enable_local_registry }
setup_registry:
deploy: true
autosync_registry: true
registry_image: "${local_registry.registry_image}"
local_repo: "${local_registry.ocp_release_repo}"
product_repo: "openshift-release-dev"
release_name: "ocp-release"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Prajyot-Parab better have this as a variable? The way we had done this for PowerVS?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that makes sense but then in ocp4-playbook, we stick to this quay.io/openshift-release-dev/ocp-release so won't really matter. If @pravin-dsilva Can try to parameterize it in ocp4-playbook as well then we can make it a variable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok then it makes sense.. but you think it is good to make it a user variables please open new PRs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure we can get this PR merged and as a next step, I will focus on converting whatever remains into variables inline with ocp4-playbook changes.

release_tag: "${local_registry.ocp_release_tag}"
%{ endif }
4 changes: 4 additions & 0 deletions modules/3_helpernode/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@ variable "openshift_install_tarball" {}
variable "helpernode_tag" {}

variable "ansible_extra_options" {}

variable "enable_local_registry" {}
variable "local_registry_image" {}
variable "ocp_release_tag" {}
12 changes: 11 additions & 1 deletion modules/5_install/install.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,31 @@
################################################################

locals {
local_registry = {
enable_local_registry = var.enable_local_registry
registry_image = var.local_registry_image
ocp_release_repo = "ocp4/openshift4"
ocp_release_tag = var.ocp_release_tag
}

inventory = {
bastion_ip = var.bastion_ip
bootstrap_ip = var.bootstrap_ip
master_ips = var.master_ips
worker_ips = var.worker_ips
}

local_registry_ocp_image = "registry.${var.cluster_id}.${var.cluster_domain}:5000/${local.local_registry.ocp_release_repo}:${var.ocp_release_tag}"

install_vars = {
cluster_id = var.cluster_id
cluster_domain = var.cluster_domain
pull_secret = var.pull_secret
public_ssh_key = var.public_key
storage_type = var.storage_type
enable_local_registry = var.enable_local_registry
release_image_override = var.enable_local_registry ? "${local.local_registry_ocp_image}" : var.release_image_override
log_level = var.log_level
release_image_override = var.release_image_override
chrony_config = var.chrony_config
chrony_config_servers = var.chrony_config_servers
}
Expand Down
1 change: 1 addition & 0 deletions modules/5_install/templates/install_vars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ chronyconfig:
%{ endif ~}
powervm_rmc: false

enable_local_registry: ${enable_local_registry}
4 changes: 4 additions & 0 deletions modules/5_install/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ variable "upgrade_version" {}
variable "upgrade_channel" {}
variable "upgrade_pause_time" {}
variable "upgrade_delay_time" {}

variable "enable_local_registry" {}
variable "local_registry_image" {}
variable "ocp_release_tag" {}
6 changes: 6 additions & 0 deletions ocp.tf
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ module "helpernode" {
helpernode_tag = var.helpernode_tag
openshift_install_tarball = var.openshift_install_tarball
openshift_client_tarball = var.openshift_client_tarball
enable_local_registry = var.enable_local_registry
local_registry_image = var.local_registry_image
ocp_release_tag = var.ocp_release_tag
ansible_extra_options = var.ansible_extra_options
}

Expand Down Expand Up @@ -175,6 +178,9 @@ module "install" {
pull_secret = file(coalesce(var.pull_secret_file, "/dev/null"))
storage_type = var.storage_type
release_image_override = var.release_image_override
enable_local_registry = var.enable_local_registry
local_registry_image = var.local_registry_image
ocp_release_tag = var.ocp_release_tag
install_playbook_tag = var.install_playbook_tag
log_level = var.installer_log_level
ansible_extra_options = var.ansible_extra_options
Expand Down
6 changes: 6 additions & 0 deletions var.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ volume_size = "300" # Value in GB
#upgrade_channel = "" #(stable-4.x, fast-4.x, candidate-4.x) eg. stable-4.5
#upgrade_pause_time = "90"
#upgrade_delay_time = "600"

### Local registry variables
enable_local_registry = false #Set to true to enable usage of the local registry for restricted network install.

#local_registry_image = "docker.io/ibmcom/registry-ppc64le:2.6.2.5"
#ocp_release_tag = "4.6.1-ppc64le"
19 changes: 19 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,22 @@ variable "upgrade_delay_time" {
description = "Number of seconds to wait before re-checking the upgrade status once the playbook execution resumes."
default = "600"
}

################################################################
# Local registry variables ( used only in disconnected install )
################################################################
variable "enable_local_registry" {
description = "Set to true to enable usage of local registry for restricted network install."
type = bool
default = false
}

variable "local_registry_image" {
description = "Name of the image used for creating the local registry container."
default = "docker.io/ibmcom/registry-ppc64le:2.6.2.5"
}

variable "ocp_release_tag" {
description = "The version of OpenShift you want to sync."
default = "4.6.1-ppc64le"
}