├── .gitignore ├── LICENSE ├── README.md ├── config.tf ├── docs └── CreateAzureSpn.md ├── infra.tf ├── main.tf ├── master.tf ├── network.tf ├── node.tf ├── scripts ├── deployOpenShift.sh ├── masterPrep.sh └── nodePrep.sh └── terraform.tfvars.example /.gitignore: -------------------------------------------------------------------------------- 1 | *.tfstate 2 | *.tfstate.backup 3 | .terraform.tfstate.lock.info 4 | terraform.tfvars -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Sertaç Özercan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenShift-Azure-Terraform 2 | Deploy OpenShift Origin v3.6.0 on Azure using Terraform and Ansible 3 | ================== 4 | 5 | This script allow you to deploy an OpenShift Origin v3.6.0 in best practices on Microsoft Azure. 6 | 7 | # Terraform Usage # 8 | 9 | #### WARNING: Be sure that you are not overriding existing Azure resources that are in use. This Terraform process will create a resource group to contain all dependent resources within. This makes it easy to cleanup. 10 | 11 | #### NOTE: This deployment is not meant to obviate the need to understand the install process or read the docs. Please spend some time to understand both [OpenShift](https://www.openshift.com/) and the [install process](https://install.openshift.com/). 12 | 13 | ## Preperation Steps ## 14 | 15 | * It is assumed that you have a functioning Azure client installed. You can do so [here](https://github.com/Azure/azure-cli) 16 | 17 | * Install [Terraform](https://www.terraform.io/downloads.html) and create credentials for Terraform to access Azure. To do so, you will need to following environment variables : 18 | 19 | * ARM_SUBSCRIPTION_ID= 20 | * ARM_CLIENT_ID= 21 | * ARM_CLIENT_SECRET= 22 | * ARM_TENANT_ID= 23 | 24 | * You can also fill the following values in the tfvars file if you prefeer. 25 | 26 | * The values for the above environment variables can be obtained through the Azure CLI. 27 | 28 | [Click here to get the step by step about it](/docs/CreateAzureSpn.md) 29 | 30 | ## Deploy the Azure infrastructure and OpenShift 31 | 32 | * First rename the `terraform.tfvars.example` to `terraform.tfvars` and review the default configuration. Most common options are available inside. The full list of available options are in `config.tf`. CentOS is the default as it has pre-requirements built in. 33 | 34 | * Update `terraform.tfvars` with the path to your passwordless SSH public and private keys. (openshift_azure_public_key and openshift_azure_private_key) 35 | 36 | * Change `openshift_azure_resource_prefix` (and optionally `openshift_azure_resource_suffix`) to something unique 37 | 38 | * Optionally, customize the `openshift_azure_master_vm_count` (default 1), the `openshift_azure_node_vm_count` (default 1) and `openshift_azure_infra_vm_count` for master (default 1), the agents size is Standard_D2_V2 per default, but you can change it for your need. 39 | 40 | * Create the OpenShift cluster by executing: 41 | ```bash 42 | $ EXPORT ARM_SUBSCRIPTION_ID= 43 | $ EXPORT ARM_CLIENT_ID= 44 | $ EXPORT ARM_CLIENT_SECRET= 45 | $ EXPORT ARM_TENANT_ID= 46 | 47 | $ cd && terraform apply 48 | ``` 49 | ### Connection to console 50 | 51 | After your deployment your should be able to reach the OS console 52 | 53 | ```https://..cloudapp.azure.com:8443/console``` 54 | 55 | The cluster will use self-signed certificates. Accept the warning and proceed to the login page. 56 | 57 | * If you didn't change it, the default username/password is `ocpadmin/password123`. 58 | 59 | ## ADDITIONAL ## 60 | 61 | ### Cleanup ### 62 | 63 | To restart and cleanup the Azure assets run the following commands from the directory 64 | 65 | ```bash 66 | $ az group delete 67 | info: Executing command group delete 68 | Delete resource group ? [y/n] y 69 | + Deleting resource group 70 | info: group delete command OK 71 | 72 | $ cd && rm *terraform.tfstate 73 | 74 | ``` 75 | 76 | ### Troubleshooting ### 77 | 78 | If the deployment gets in an inconsistent state (repeated `terraform apply` commands fail, or output references to leases that no longer exist), you may need to manually reconcile. Destroy the `` resource group, run `terraform remote config -disable` and delete all `terraform.tfstate*` files from `os`, follow the above instructions again. 79 | 80 | * You could also check this repo : [Microsoft/openshift-origin](https://github.com/Microsoft/openshift-origin) to get more informations -------------------------------------------------------------------------------- /config.tf: -------------------------------------------------------------------------------- 1 | variable "azure_client_id" { 2 | type = "string" 3 | description = "Azure Client ID" 4 | default = "" 5 | } 6 | 7 | variable "azure_client_secret" { 8 | type = "string" 9 | description = "Azure Client Secret" 10 | default = "" 11 | } 12 | 13 | variable "azure_tenant_id" { 14 | type = "string" 15 | description = "Azure Tenant ID" 16 | default = "" 17 | } 18 | 19 | variable "azure_subscription_id" { 20 | type = "string" 21 | description = "Azure Subscription ID" 22 | default = "" 23 | } 24 | 25 | variable "openshift_azure_resource_prefix" { 26 | type = "string" 27 | description = "Prefix for all the resources" 28 | default = "os" 29 | } 30 | 31 | variable "openshift_azure_resource_suffix" { 32 | type = "string" 33 | description = "Suffix for all the resources" 34 | default = "tf" 35 | } 36 | 37 | variable "openshift_azure_resource_group" { 38 | type = "string" 39 | description = "Azure resource group" 40 | default = "azure" 41 | } 42 | 43 | variable "openshift_azure_region" { 44 | type = "string" 45 | description = "Azure region for deployment" 46 | default = "East US" 47 | } 48 | 49 | variable "openshift_azure_public_key" { 50 | type = "string" 51 | description = "SSH Public key" 52 | default = "" 53 | } 54 | 55 | variable "openshift_azure_private_key" { 56 | type = "string" 57 | description = "SSH Private key" 58 | default = "" 59 | } 60 | 61 | variable "openshift_azure_master_vm_count" { 62 | description = "Master VM count" 63 | default = 1 64 | } 65 | 66 | variable "openshift_azure_infra_vm_count" { 67 | description = "Infra VM count" 68 | default = 1 69 | } 70 | 71 | variable "openshift_azure_node_vm_count" { 72 | description = "Node VM count" 73 | default = 1 74 | } 75 | 76 | variable "openshift_azure_master_vm_size" { 77 | type = "string" 78 | description = "Master VM size" 79 | default = "Standard_DS2_v2" 80 | } 81 | 82 | variable "openshift_azure_infra_vm_size" { 83 | type = "string" 84 | description = "Infra VM size" 85 | default = "Standard_DS2_v2" 86 | } 87 | 88 | variable "openshift_azure_node_vm_size" { 89 | type = "string" 90 | description = "Node VM size" 91 | default = "Standard_DS2_v2" 92 | } 93 | 94 | variable "openshift_azure_data_disk_size" { 95 | description = "Size of Datadisk in GB for Docker volume" 96 | default = 128 97 | } 98 | 99 | variable "openshift_azure_vm_os" { 100 | type = "map" 101 | 102 | default = { 103 | publisher = "OpenLogic" 104 | offer = "CentOS" 105 | sku = "7.3" 106 | version = "latest" 107 | } 108 | } 109 | 110 | variable "openshift_azure_vm_username" { 111 | type = "string" 112 | description = "VM Username" 113 | default = "ocpadmin" 114 | } 115 | 116 | variable "openshift_master_dns_name" { 117 | type = "string" 118 | description = "DNS prefix name for the master" 119 | default = "osmaster" 120 | } 121 | 122 | variable "openshift_infra_dns_name" { 123 | type = "string" 124 | description = "DNS prefix name for the infra" 125 | default = "osinfra" 126 | } 127 | 128 | variable "openshift_initial_password" { 129 | type = "string" 130 | description = "initial password for OpenShift" 131 | default = "password123" 132 | } 133 | 134 | variable "openshift_azure_default_subdomain" { 135 | type = "string" 136 | description = "The wildcard DNS name you would like to use for routing" 137 | default = "xip.io" 138 | } 139 | 140 | variable "openshift_azure_master_prep_script" { 141 | type = "string" 142 | description = "URL for Master Prep script" 143 | default = "https://raw.githubusercontent.com/sozercan/OpenShift-Azure-Terraform/master/scripts/masterPrep.sh" 144 | } 145 | 146 | variable "openshift_azure_node_prep_script" { 147 | type = "string" 148 | description = "URL for Node Prep script" 149 | default = "https://raw.githubusercontent.com/sozercan/OpenShift-Azure-Terraform/master/scripts/nodePrep.sh" 150 | } 151 | 152 | variable "openshift_azure_deploy_openshift_script" { 153 | type = "string" 154 | description = "URL for Deploy Openshift script" 155 | default = "https://raw.githubusercontent.com/sozercan/OpenShift-Azure-Terraform/master/scripts/deployOpenShift.sh" 156 | } 157 | 158 | variable "openshift_ansible_url" { 159 | type = "string" 160 | description = "URL for openshift-ansible repo" 161 | default = "https://github.com/openshift/openshift-ansible.git" 162 | } 163 | 164 | variable "openshift_ansible_branch" { 165 | type = "string" 166 | description = "Branch of the openshift-ansible repo" 167 | default = "master" 168 | } -------------------------------------------------------------------------------- /docs/CreateAzureSpn.md: -------------------------------------------------------------------------------- 1 | # Create a Service Principal for your Subscription 2 | 3 | *NOTE: A more detailed overview can be found on the [Terraform Site](https://www.terraform.io/docs/providers/azurerm/index.html)* 4 | 5 | * Login with the [Azure CLI 2.0](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) 6 | 7 | ```bash 8 | az login 9 | ``` 10 | 11 | * After a succesfull login, you will get a list of all the subscriptions related to your account. 12 | 13 | ```bash 14 | { 15 | "environmentName": "AzureCloud", 16 | "id": "a97d7ca2-18ca-426f-b7c4-1a2cdaa4d9d1", 17 | "isDefault": true, 18 | "name": "My_Azure_Subscription", 19 | "state": "Enabled", 20 | "tenantId": "34a934ff-86a1-34af-34cd-2d7cd0134bd34", 21 | "user": { 22 | "name": "juliens@microsoft.com", 23 | "type": "user" 24 | } 25 | } 26 | ``` 27 | 28 | * Store the subscription ID from the default subsciption. 29 | 30 | ```bash 31 | export SUBSCRIPTIONID=`az account show --output tsv | cut -f2` 32 | ``` 33 | 34 | * Create a Service Principal as a contributor to your Subscription 35 | 36 | ```bash 37 | az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/${SUBSCRIPTIONID}" 38 | ``` 39 | 40 | * Store Service Principal, you will use it in your tfvars file. 41 | 42 | ```json 43 | { 44 | "appId": "23xxxxx-xxxx-xxxx-xxxx-7e83xxxb1", 45 | "displayName": "azure-cli-2017-07-31-xx-xx-xx", 46 | "name": "http://azure-cli-2017-07-31-xx-xx-xx", 47 | "password": "1219e938-72ad-439c-xxx-517ab8b60xxx", 48 | "tenant": "72f988bf-xxxx-xxxx-xxxx-2d7cd011db47" 49 | } 50 | ``` 51 | 52 | Now, you can fill up your `terraform.tfvars` 53 | 54 | ```csharp 55 | azure_client_id => appId 56 | azure_client_secret => password 57 | azure_tenant_id => tenant 58 | azure_subscription_id => SUBSCRIPTIONID 59 | ``` 60 | 61 | *NOTE: A more detailed overview can be found on the [Terraform Site](https://www.terraform.io/docs/providers/azurerm/index.html)* 62 | 63 | ### Create a Client ID / Password using Docker 64 | 65 | You just have to run the following command : 66 | 67 | ```docker run -it julienstroheker/add-azure-spn ``` 68 | 69 | For example : 70 | 71 | ```$ docker run -it julienstroheker/add-azure-spn MyAwesomeApplication MyAw3s0meP@ssw0rd!``` 72 | 73 | After less than 1 minute, you will have a nice output like this, ready to be copy and paste : 74 | 75 | ``` 76 | ================== Informations about your new App ============================== 77 | Subscription ID XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX 78 | Subscription Name Your Subscription Name 79 | Service Principal Client ID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX 80 | Service Principal Key: YourPasswordOrGeneratingARandomOne 81 | Tenant ID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX 82 | ================================================================================= 83 | ``` -------------------------------------------------------------------------------- /infra.tf: -------------------------------------------------------------------------------- 1 | resource "azurerm_availability_set" "osinfraas" { 2 | name = "${var.openshift_azure_resource_prefix}-as-infra-${var.openshift_azure_resource_suffix}" 3 | location = "${azurerm_resource_group.osrg.location}" 4 | resource_group_name = "${azurerm_resource_group.osrg.name}" 5 | managed = true 6 | } 7 | 8 | resource "azurerm_network_interface" "osinfranic" { 9 | name = "${var.openshift_azure_resource_prefix}-nic-infra-${var.openshift_azure_resource_suffix}-${format("%01d", count.index)}" 10 | count = "${var.openshift_azure_infra_vm_count}" 11 | location = "${azurerm_resource_group.osrg.location}" 12 | resource_group_name = "${azurerm_resource_group.osrg.name}" 13 | network_security_group_id = "${azurerm_network_security_group.osinfransg.id}" 14 | 15 | ip_configuration { 16 | name = "configuration-${count.index}" 17 | subnet_id = "${azurerm_subnet.osmastersubnet.id}" 18 | private_ip_address_allocation = "dynamic" 19 | load_balancer_backend_address_pools_ids = ["${azurerm_lb_backend_address_pool.osinfralbbepool.id}"] 20 | } 21 | } 22 | 23 | resource "azurerm_lb_backend_address_pool" "osinfralbbepool" { 24 | resource_group_name = "${azurerm_resource_group.osrg.name}" 25 | loadbalancer_id = "${azurerm_lb.osinfralb.id}" 26 | name = "BackEndAddressPool" 27 | } 28 | 29 | resource "azurerm_public_ip" "osinfraip" { 30 | name = "${var.openshift_azure_resource_prefix}-vip-infra-${var.openshift_azure_resource_suffix}" 31 | location = "${azurerm_resource_group.osrg.location}" 32 | resource_group_name = "${azurerm_resource_group.osrg.name}" 33 | public_ip_address_allocation = "static" 34 | domain_name_label = "${var.openshift_azure_resource_prefix}-${var.openshift_infra_dns_name}-${var.openshift_azure_resource_suffix}" 35 | } 36 | 37 | resource "azurerm_lb" "osinfralb" { 38 | name = "${var.openshift_azure_resource_prefix}-nlb-infra-${var.openshift_azure_resource_suffix}" 39 | location = "${azurerm_resource_group.osrg.location}" 40 | resource_group_name = "${azurerm_resource_group.osrg.name}" 41 | 42 | frontend_ip_configuration { 43 | name = "PublicIPAddress" 44 | public_ip_address_id = "${azurerm_public_ip.osinfraip.id}" 45 | } 46 | } 47 | 48 | resource "azurerm_lb_rule" "osinfralbrule80" { 49 | resource_group_name = "${azurerm_resource_group.osrg.name}" 50 | loadbalancer_id = "${azurerm_lb.osinfralb.id}" 51 | name = "OpenShiftRouterHTTP" 52 | protocol = "Tcp" 53 | frontend_port = 80 54 | backend_port = 80 55 | frontend_ip_configuration_name = "PublicIPAddress" 56 | probe_id = "${azurerm_lb_probe.osinfralbprobe80.id}" 57 | backend_address_pool_id = "${azurerm_lb_backend_address_pool.osinfralbbepool.id}" 58 | } 59 | 60 | resource "azurerm_lb_probe" "osinfralbprobe80" { 61 | resource_group_name = "${azurerm_resource_group.osrg.name}" 62 | loadbalancer_id = "${azurerm_lb.osinfralb.id}" 63 | name = "httpProbe" 64 | port = 80 65 | number_of_probes = 2 66 | } 67 | 68 | resource "azurerm_lb_rule" "osinfralbrule443" { 69 | resource_group_name = "${azurerm_resource_group.osrg.name}" 70 | loadbalancer_id = "${azurerm_lb.osinfralb.id}" 71 | name = "OpenShiftRouterHTTPS" 72 | protocol = "Tcp" 73 | frontend_port = 443 74 | backend_port = 443 75 | frontend_ip_configuration_name = "PublicIPAddress" 76 | probe_id = "${azurerm_lb_probe.osinfralbprobe443.id}" 77 | backend_address_pool_id = "${azurerm_lb_backend_address_pool.osinfralbbepool.id}" 78 | } 79 | 80 | resource "azurerm_lb_probe" "osinfralbprobe443" { 81 | resource_group_name = "${azurerm_resource_group.osrg.name}" 82 | loadbalancer_id = "${azurerm_lb.osinfralb.id}" 83 | name = "httpsProbe" 84 | port = 443 85 | number_of_probes = 2 86 | } 87 | 88 | resource "azurerm_virtual_machine" "osinfravm" { 89 | name = "${var.openshift_azure_resource_prefix}-vm-infra-${var.openshift_azure_resource_suffix}-${format("%01d", count.index)}" 90 | count = "${var.openshift_azure_infra_vm_count}" 91 | location = "${azurerm_resource_group.osrg.location}" 92 | resource_group_name = "${azurerm_resource_group.osrg.name}" 93 | network_interface_ids = ["${element(azurerm_network_interface.osinfranic.*.id, count.index)}"] 94 | availability_set_id = "${azurerm_availability_set.osinfraas.id}" 95 | vm_size = "${var.openshift_azure_infra_vm_size}" 96 | 97 | storage_image_reference { 98 | publisher = "${var.openshift_azure_vm_os["publisher"]}" 99 | offer = "${var.openshift_azure_vm_os["offer"]}" 100 | sku = "${var.openshift_azure_vm_os["sku"]}" 101 | version = "${var.openshift_azure_vm_os["version"]}" 102 | } 103 | 104 | storage_os_disk { 105 | name = "${var.openshift_azure_resource_prefix}-disk-os-infra-${var.openshift_azure_resource_suffix}-${format("%01d", count.index)}" 106 | caching = "ReadWrite" 107 | create_option = "FromImage" 108 | managed_disk_type = "Standard_LRS" 109 | } 110 | 111 | storage_data_disk { 112 | name = "${var.openshift_azure_resource_prefix}-disk-data-infra-${var.openshift_azure_resource_suffix}-${format("%01d", count.index)}" 113 | managed_disk_type = "Standard_LRS" 114 | create_option = "Empty" 115 | lun = 0 116 | disk_size_gb = "${var.openshift_azure_data_disk_size}" 117 | } 118 | 119 | os_profile { 120 | computer_name = "${var.openshift_azure_resource_prefix}-vm-infra-${var.openshift_azure_resource_suffix}-${format("%01d", count.index)}" 121 | admin_username = "${var.openshift_azure_vm_username}" 122 | admin_password = "${uuid()}" 123 | } 124 | 125 | os_profile_linux_config { 126 | disable_password_authentication = true 127 | 128 | ssh_keys { 129 | path = "/home/${var.openshift_azure_vm_username}/.ssh/authorized_keys" 130 | key_data = "${file(var.openshift_azure_public_key)}" 131 | } 132 | } 133 | } 134 | 135 | resource "azurerm_virtual_machine_extension" "osinfravmextension" { 136 | name = "osinfravmextension" 137 | count = "${var.openshift_azure_infra_vm_count}" 138 | location = "${azurerm_resource_group.osrg.location}" 139 | resource_group_name = "${azurerm_resource_group.osrg.name}" 140 | virtual_machine_name = "${element(azurerm_virtual_machine.osinfravm.*.name, count.index)}" 141 | publisher = "Microsoft.Azure.Extensions" 142 | type = "CustomScript" 143 | type_handler_version = "2.0" 144 | 145 | settings = < ~/.ssh/id_rsa" 40 | runuser -l $SUDOUSER -c "chmod 600 ~/.ssh/id_rsa*" 41 | 42 | echo $(date) "- Configuring SSH ControlPath to use shorter path name" 43 | 44 | sed -i -e "s/^# control_path = %(directory)s\/%%h-%%r/control_path = %(directory)s\/%%h-%%r/" /etc/ansible/ansible.cfg 45 | sed -i -e "s/^#host_key_checking = False/host_key_checking = False/" /etc/ansible/ansible.cfg 46 | sed -i -e "s/^#pty=False/pty=False/" /etc/ansible/ansible.cfg 47 | 48 | # Temporary workaround: https://access.redhat.com/solutions/3165971 49 | mkdir -p /etc/origin/node/ 50 | touch /etc/origin/node/resolv.conf 51 | 52 | # Create playbook to update ansible.cfg file 53 | 54 | cat > updateansiblecfg.yaml < /home/${SUDOUSER}/addocpuser.yml < /home/${SUDOUSER}/assignclusteradminrights.yml < /home/${SUDOUSER}/dockerregistry.yml < /home/${SUDOUSER}/configurestorageclass.yml < /home/${SUDOUSER}/vars.yml < /home/${SUDOUSER}/setup-azure-master.yml < /home/${SUDOUSER}/setup-azure-master.yml < /home/${SUDOUSER}/setup-azure-node-master.yml < /home/${SUDOUSER}/setup-azure-node.yml < /home/${SUDOUSER}/deletestucknodes.yml < /etc/ansible/hosts <> /etc/ansible/hosts 508 | done 509 | 510 | # Loop to add Nodes 511 | 512 | for (( c=0; c<$NODECOUNT; c++ )) 513 | do 514 | echo "$NODE-$c openshift_node_labels=\"{'type': 'app', 'zone': 'default'}\" openshift_hostname=$NODE-$c" >> /etc/ansible/hosts 515 | done 516 | 517 | # Create new_nodes group 518 | 519 | cat >> /etc/ansible/hosts < /etc/ansible/hosts <> /etc/ansible/hosts 590 | done 591 | 592 | # Loop to add Infra Nodes 593 | 594 | for (( c=0; c<$INFRACOUNT; c++ )) 595 | do 596 | echo "$INFRA-$c openshift_node_labels=\"{'type': 'infra', 'zone': 'default'}\" openshift_hostname=$INFRA-$c" >> /etc/ansible/hosts 597 | done 598 | 599 | # Loop to add Nodes 600 | 601 | for (( c=0; c<$NODECOUNT; c++ )) 602 | do 603 | echo "$NODE-$c openshift_node_labels=\"{'type': 'app', 'zone': 'default'}\" openshift_hostname=$NODE-$c" >> /etc/ansible/hosts 604 | done 605 | 606 | # Create new_nodes group 607 | 608 | cat >> /etc/ansible/hosts </dev/null 23 | then 24 | echo $(date) " - Installing Ansible and pyOpenSSL" 25 | yum -y --enablerepo=epel install ansible pyOpenSSL 26 | fi 27 | 28 | # Install Docker 1.12.x 29 | echo $(date) " - Installing Docker 1.12.x" 30 | 31 | yum -y install docker 32 | sed -i -e "s#^OPTIONS='--selinux-enabled'#OPTIONS='--selinux-enabled --insecure-registry 172.30.0.0/16'#" /etc/sysconfig/docker 33 | 34 | # Create thin pool logical volume for Docker 35 | echo $(date) " - Creating thin pool logical volume for Docker and staring service" 36 | 37 | DOCKERVG=$( parted -m /dev/sda print all 2>/dev/null | grep unknown | grep /dev/sd | cut -d':' -f1 ) 38 | 39 | echo "DEVS=${DOCKERVG}" >> /etc/sysconfig/docker-storage-setup 40 | echo "VG=docker-vg" >> /etc/sysconfig/docker-storage-setup 41 | docker-storage-setup 42 | if [ $? -eq 0 ] 43 | then 44 | echo "Docker thin pool logical volume created successfully" 45 | else 46 | echo "Error creating logical volume for Docker" 47 | exit 5 48 | fi 49 | 50 | # Enable and start Docker services 51 | 52 | systemctl enable docker 53 | systemctl start docker 54 | 55 | # Create Storage Class yml files on MASTER-0 56 | 57 | if hostname -f|grep -- "-0" >/dev/null 58 | then 59 | cat < /home/${SUDOUSER}/scgeneric1.yml 60 | kind: StorageClass 61 | apiVersion: storage.k8s.io/v1beta1 62 | metadata: 63 | name: generic 64 | annotations: 65 | storageclass.beta.kubernetes.io/is-default-class: "true" 66 | provisioner: kubernetes.io/azure-disk 67 | parameters: 68 | storageAccount: ${STORAGEACCOUNT1} 69 | EOF 70 | 71 | fi 72 | 73 | echo $(date) " - Script Complete" 74 | -------------------------------------------------------------------------------- /scripts/nodePrep.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo $(date) " - Starting Script" 3 | 4 | # Update system to latest packages and install dependencies 5 | echo $(date) " - Update system to latest packages and install dependencies" 6 | 7 | yum -y install wget git net-tools bind-utils iptables-services bridge-utils bash-completion 8 | yum -y update --exclude=WALinuxAgent 9 | 10 | # Install EPEL repository 11 | echo $(date) " - Installing EPEL" 12 | 13 | yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 14 | 15 | sed -i -e "s/^enabled=1/enabled=0/" /etc/yum.repos.d/epel.repo 16 | 17 | # Install Docker 1.12.x 18 | echo $(date) " - Installing Docker 1.12.x" 19 | 20 | yum -y install docker 21 | sed -i -e "s#^OPTIONS='--selinux-enabled'#OPTIONS='--selinux-enabled --insecure-registry 172.30.0.0/16'#" /etc/sysconfig/docker 22 | 23 | # Create thin pool logical volume for Docker 24 | echo $(date) " - Creating thin pool logical volume for Docker and staring service" 25 | 26 | DOCKERVG=$( parted -m /dev/sda print all 2>/dev/null | grep unknown | grep /dev/sd | cut -d':' -f1 ) 27 | 28 | echo "DEVS=${DOCKERVG}" >> /etc/sysconfig/docker-storage-setup 29 | echo "VG=docker-vg" >> /etc/sysconfig/docker-storage-setup 30 | docker-storage-setup 31 | if [ $? -eq 0 ] 32 | then 33 | echo "Docker thin pool logical volume created successfully" 34 | else 35 | echo "Error creating logical volume for Docker" 36 | exit 5 37 | fi 38 | 39 | # Enable and start Docker services 40 | 41 | systemctl enable docker 42 | systemctl start docker 43 | 44 | # Temporary workaround: https://access.redhat.com/solutions/3165971 45 | 46 | mkdir -p /etc/origin/node/ 47 | touch /etc/origin/node/resolv.conf 48 | 49 | echo $(date) " - Script Complete" 50 | -------------------------------------------------------------------------------- /terraform.tfvars.example: -------------------------------------------------------------------------------- 1 | azure_client_id = "" 2 | azure_client_secret = "" 3 | azure_tenant_id = "" 4 | azure_subscription_id = "" 5 | 6 | openshift_azure_resource_prefix = "os" 7 | openshift_azure_resource_suffix = "test" 8 | 9 | openshift_azure_resource_group = "osrg123" 10 | 11 | openshift_azure_region = "East US" 12 | 13 | openshift_azure_vm_username = "ocpadmin" 14 | openshift_initial_password = "password123" 15 | 16 | openshift_azure_public_key = "~/.ssh/randomKey.pub" 17 | openshift_azure_private_key = "~/.ssh/randomKey" 18 | 19 | openshift_azure_master_vm_count = 1 20 | openshift_azure_node_vm_count = 1 21 | openshift_azure_infra_vm_count = 1 22 | 23 | openshift_azure_master_vm_size = "Standard_DS2_v2" 24 | openshift_azure_data_disk_size = 128 25 | 26 | openshift_azure_vm_os = { 27 | publisher = "OpenLogic" 28 | offer = "CentOS" 29 | sku = "7.3" 30 | version = "latest" 31 | } 32 | 33 | openshift_master_dns_name = "osmaster" 34 | openshift_infra_dns_name = "osinfra" 35 | 36 | openshift_azure_default_subdomain = "xip.io" --------------------------------------------------------------------------------