Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/azurerm: Example of Openshift origin #15294

Merged
merged 117 commits into from
Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
9f0d990
initial commit - 101-vm-from-user-image
anniehedgpeth Apr 18, 2017
6f577a8
changed branch name
anniehedgpeth Apr 19, 2017
611d70a
not deploying - storage problems
anniehedgpeth Apr 21, 2017
fdff23a
provisions vm but image not properly prepared
anniehedgpeth Apr 21, 2017
0dac5ec
storage not correct
anniehedgpeth Apr 21, 2017
81e2559
provisions properly
anniehedgpeth Apr 22, 2017
7dc8150
changed main.tf to azuredeploy.tf
anniehedgpeth Apr 22, 2017
5c079fa
added tfvars and info for README
anniehedgpeth Apr 22, 2017
c86ef6f
tfvars ignored and corrected file ext
anniehedgpeth Apr 22, 2017
534b236
added CI config; added sane defaults for variables; updated deploymen…
Apr 24, 2017
0cf888b
deploy.sh to be executable
Apr 24, 2017
68f0003
executable deploy files
Apr 24, 2017
c898510
added CI files; changed vars
anniehedgpeth Apr 25, 2017
9d1541c
merge upstream/master
Apr 25, 2017
5c8ecd8
prep for PR
Apr 25, 2017
0267fca
removal of old folder
Apr 25, 2017
f9bf6ba
prep for PR
Apr 25, 2017
cec0679
wrong args for travis
Apr 25, 2017
d78e8bd
more PR prep
Apr 26, 2017
6bf2df2
updated README
anniehedgpeth Apr 26, 2017
b22cff0
commented out variables in terraform.tfvars
Apr 26, 2017
09175de
Merge branch 'topic-101-vm-from-user-image' of https://github.com/10t…
anniehedgpeth Apr 26, 2017
0843f45
Topic 101 vm from user image (#2)
scottzilla Apr 26, 2017
49caea5
added new template
Apr 26, 2017
2236828
oops, left off master
Apr 26, 2017
27167b5
Merge branch 'master' of github.com:harijayms/terraform
Apr 26, 2017
5b8f7bb
merge upstream; prep for PR
Apr 26, 2017
7f8fe25
prep for PR
Apr 27, 2017
eecb2d2
correct repository for destination
Apr 27, 2017
92e341d
renamed scripts to be more intuitive; added check for docker
Apr 27, 2017
23627c8
merge vm simple; vm from image
Apr 27, 2017
0fdf4cb
merge upstream
Apr 27, 2017
ac2e5c2
initial commit
anniehedgpeth Apr 27, 2017
935c19a
deploys locally
anniehedgpeth Apr 27, 2017
66b7441
updated deploy
anniehedgpeth Apr 27, 2017
c98b1d1
consolidated deploy and after_deploy into a single script; simplified…
Apr 27, 2017
0ef07bc
added terraform show
Apr 27, 2017
50e8d8a
changed to allow http & https (like ARM tmplt)
anniehedgpeth Apr 27, 2017
ace9b0b
changed host_name & host_name variable desc
anniehedgpeth Apr 27, 2017
5e99f81
added az cli check
Apr 28, 2017
ce1f573
merge upstream master
Apr 28, 2017
65826c1
on this branch, only build test_dir; master will aggregate all the ex…
Apr 28, 2017
2675c55
merge master
Apr 28, 2017
072a51a
added new constructs/naming for deploy scripts, etc.
Apr 28, 2017
06f1a7f
suppress az login output
Apr 28, 2017
3523ed3
suppress az login output
Apr 28, 2017
21837a9
forgot about line breaks
Apr 28, 2017
e1e3aa2
breaking build as an example
Apr 28, 2017
a0a7643
fixing broken build example
Apr 28, 2017
fd0231b
added cdn branch; ci uses running vm to test
anniehedgpeth Apr 28, 2017
02bfac9
Merge remote-tracking branch 'origin' into topic-101-vnet-two-subnets
Apr 28, 2017
74c4f6c
Merge branch 'topic-101-vnet-two-subnets'
anniehedgpeth May 1, 2017
2c02115
merge of CI config
anniehedgpeth May 1, 2017
487d9cd
fixed grammar in readme
May 1, 2017
d8ef7b1
prep for PR
May 1, 2017
25ef50c
took out armviz button and minor README changes
anniehedgpeth May 2, 2017
63c494d
changed host_name
anniehedgpeth May 2, 2017
9a5a15a
fixed merge conflicts
anniehedgpeth May 2, 2017
d821717
Sync with upstream
StephenWeatherford May 2, 2017
d7e2acb
changed host_name variable
anniehedgpeth May 2, 2017
dbaf8d1
updating Hashicorp's changes to merged simple linux branch
anniehedgpeth May 3, 2017
b850cd5
updating files to merge w/master and prep for Hashicorp pr
anniehedgpeth May 3, 2017
a6151bc
Revert "updating files to merge w/master and prep for Hashicorp pr"
anniehedgpeth May 3, 2017
5426739
Revert "updating Hashicorp's changes to merged simple linux branch"
anniehedgpeth May 3, 2017
9b809ac
Merge branch 'master' into topic-201-cdn-with-storage-account
anniehedgpeth May 3, 2017
5174369
removing vm from user image example from this branch
anniehedgpeth May 4, 2017
007ea39
Merge branch 'master' into topic-101-vm-from-user-image
anniehedgpeth May 4, 2017
f6c13d4
Merge pull request #10 from 10thmagnitude/topic-101-vm-from-user-image
anniehedgpeth May 4, 2017
1366980
removed old branch
anniehedgpeth May 4, 2017
6a1813e
azure-2-vms-loadbalancer-lbrules (#13)
scottzilla May 5, 2017
888b578
add CI build tag
scottzilla May 8, 2017
1bf851f
initial commit; in progress
anniehedgpeth May 9, 2017
10be49f
in progress; merged Hashicorp master into this branch
anniehedgpeth May 16, 2017
af9d247
in progress; merged Hashicorp master into this branch
anniehedgpeth May 16, 2017
3d69711
in progress
anniehedgpeth May 16, 2017
5a28545
pulling hashi master
anniehedgpeth May 19, 2017
948e695
in progress; created nsg
anniehedgpeth May 19, 2017
de60db4
added vars to deploy; added vnet
anniehedgpeth May 19, 2017
fa2b680
chmod on deploy
anniehedgpeth May 19, 2017
075c2b0
edited vars
anniehedgpeth May 19, 2017
8855a24
added var in travis
anniehedgpeth May 19, 2017
e7a20cb
added var
anniehedgpeth May 19, 2017
2ed634b
added var to deploy
anniehedgpeth May 19, 2017
d9a9545
added storage accounts
anniehedgpeth May 19, 2017
9683cef
fixed storage typos
anniehedgpeth May 19, 2017
6a86c06
removed storage tags
anniehedgpeth May 19, 2017
65df767
added PIPs
anniehedgpeth May 19, 2017
a14dab9
changed dns name vars
anniehedgpeth May 19, 2017
1de2edb
corrected PIP naming convention
anniehedgpeth May 19, 2017
97a59e1
added availability sets
anniehedgpeth May 19, 2017
4199638
added master-lb & rules
anniehedgpeth May 19, 2017
dbceea4
added infra lb & rules
anniehedgpeth May 20, 2017
d0e460f
added nics
anniehedgpeth May 20, 2017
9fc1f1e
added VMs, ready for VM extensions, can modularize in the future
May 25, 2017
656589a
added vm exts.; nsg is possibly broken; can't ssh
anniehedgpeth May 26, 2017
75cd61f
in progress
anniehedgpeth May 26, 2017
fbd38b1
master ext succeeds
anniehedgpeth May 27, 2017
40222dd
in progress, infra and nodes exts not succeeding
anniehedgpeth May 27, 2017
26d5ba9
infra and node extensions fail
anniehedgpeth May 27, 2017
99218f0
provisions with extensions
anniehedgpeth May 29, 2017
0d02685
disabled password auth; ssh config added
anniehedgpeth May 29, 2017
2ff6400
changed ssh key vars
anniehedgpeth May 29, 2017
3a5d9c4
adding ssh var to deploy
anniehedgpeth May 29, 2017
fc352ab
commenting out validation
anniehedgpeth May 29, 2017
1dc1bb8
in progress; building openshift ext
anniehedgpeth May 29, 2017
04ab89f
troubleshooting openshift deploy script
anniehedgpeth May 30, 2017
3136fdd
changed vm names; added container
anniehedgpeth May 31, 2017
ab00527
increased os disk size
anniehedgpeth Jun 1, 2017
d33c751
in progress; troubleshooting deploy opnshft script
anniehedgpeth Jun 2, 2017
1f35ce8
Updated the readme
scottzilla Jun 14, 2017
e118170
updated deployment scripts; cleaned up variables, use remote-exec
Jun 14, 2017
bbcb948
Merge branch 'topic-openshift-origin' of github.com:harijayms/terrafo…
Jun 14, 2017
0ef7ca5
more variable cleanup
Jun 14, 2017
ae9caca
more cleanup
Jun 14, 2017
9586b5a
simplified password; got rid of a needless comment
Jun 14, 2017
7473a8f
merging hashi master into this branch
anniehedgpeth Jun 15, 2017
71ff782
merge conflicts resolved
anniehedgpeth Jun 15, 2017
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
114 changes: 114 additions & 0 deletions examples/azure-openshift-origin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# OpenShift Origin Deployment Template

This Terraform template was based on [this](https://github.com/Microsoft/openshift-origin) Azure Quickstart Template. Changes to the ARM template that may have occurred since the creation of this example may not be reflected here.

## OpenShift Origin with Username / Password

Current template deploys OpenShift Origin 1.5 RC0.

This template deploys OpenShift Origin with basic username / password for authentication to OpenShift. You can select to use either CentOS or RHEL for the OS. It includes the following resources:

|Resource |Properties |
|-------------------|------------------------------------------------------------------------------------------------------------------------------------|
|Virtual Network |**Address prefix:** 10.0.0.0/16<br />**Master subnet:** 10.0.0.0/24<br />**Node subnet:** 10.0.1.0/24 |
|Load Balancer |2 probes and two rules for TCP 80 and TCP 443 |
|Public IP Addresses|OpenShift Master public IP<br />OpenShift Router public IP attached to Load Balancer |
|Storage Accounts |2 Storage Accounts |
|Virtual Machines |Single master<br />User-defined number of nodes<br />All VMs include a single attached data disk for Docker thin pool logical volume|

If you have a Red Hat subscription and would like to deploy an OpenShift Container Platform (formerly OpenShift Enterprise) cluster, please visit: https://github.com/Microsoft/openshift-container-platform

### Generate SSH Keys

You'll need to generate an SSH key pair in order to provision this template. Ensure that you do not include a passcode with the private key. <br/>
If you are using a Windows computer, you can download `puttygen.exe`. You will need to export to OpenSSH (from Conversions menu) to get a valid Private Key for use in the Template.<br/>
From a Linux or Mac, you can just use the `ssh-keygen` command. Once you are finished deploying the cluster, you can always generate a new key pair that uses a passphrase and replaces the original one used during initial deployment.

### Create Key Vault to store SSH Private Key

You will need to create a Key Vault to store your SSH Private Key that will then be used as part of the deployment.

1. **Create Key Vault using Powershell**<br/>
a. Create new resource group: New-AzureRMResourceGroup -Name 'ResourceGroupName' -Location 'West US'<br/>
b. Create key vault: New-AzureRmKeyVault -VaultName 'KeyVaultName' -ResourceGroup 'ResourceGroupName' -Location 'West US'<br/>
c. Create variable with sshPrivateKey: $securesecret = ConvertTo-SecureString -String '[copy ssh Private Key here - including line feeds]' -AsPlainText -Force<br/>
d. Create Secret: Set-AzureKeyVaultSecret -Name 'SecretName' -SecretValue $securesecret -VaultName 'KeyVaultName'<br/>
e. Enable the Key Vault for Template Deployments: Set-AzureRmKeyVaultAccessPolicy -VaultName 'KeyVaultName' -ResourceGroupName 'ResourceGroupName' -EnabledForTemplateDeployment

2. **Create Key Vault using Azure CLI 1.0**<br/>
a. Create new Resource Group: azure group create \<name\> \<location\><br/>
Ex: `azure group create ResourceGroupName 'East US'`<br/>
b. Create Key Vault: azure keyvault create -u \<vault-name\> -g \<resource-group\> -l \<location\><br/>
Ex: `azure keyvault create -u KeyVaultName -g ResourceGroupName -l 'East US'`<br/>
c. Create Secret: azure keyvault secret set -u \<vault-name\> -s \<secret-name\> --file \<private-key-file-name\><br/>
Ex: `azure keyvault secret set -u KeyVaultName -s SecretName --file ~/.ssh/id_rsa`<br/>
d. Enable the Keyvvault for Template Deployment: azure keyvault set-policy -u \<vault-name\> --enabled-for-template-deployment true<br/>
Ex: `azure keyvault set-policy -u KeyVaultName --enabled-for-template-deployment true`<br/>

3. **Create Key Vault using Azure CLI 2.0**<br/>
a. Create new Resource Group: az group create -n \<name\> -l \<location\><br/>
Ex: `az group create -n ResourceGroupName -l 'East US'`<br/>
b. Create Key Vault: az keyvault create -n \<vault-name\> -g \<resource-group\> -l \<location\> --enabled-for-template-deployment true<br/>
Ex: `az keyvault create -n KeyVaultName -g ResourceGroupName -l 'East US' --enabled-for-template-deployment true`<br/>
c. Create Secret: az keyvault secret set --vault-name \<vault-name\> -n \<secret-name\> --file \<private-key-file-name\><br/>
Ex: `az keyvault secret set --vault-name KeyVaultName -n SecretName --file ~/.ssh/id_rsa`<br/>
3. **Clone the Openshift repository [here](https://github.com/Microsoft/openshift-origin)**<br/>
a. Note the local script path, this will be needed for remote-execs on the remote machines.<br/>

## Deploy Template

Once you have collected all of the prerequisites for the template, you can deploy the template via terraform.

Monitor deployment via Terraform and get the console URL from outputs of successful deployment which will look something like (if using sample parameters file and "West US 2" location):

`https://me-master1.westus2.cloudapp.azure.com:8443/console`

The cluster will use self-signed certificates. Accept the warning and proceed to the login page.

### NOTE

Ensure combination of openshiftMasterPublicIpDnsLabelPrefix, and nodeLbPublicIpDnsLabelPrefix parameters, combined with the deployment location give you globally unique URL for the cluster or deployment will fail at the step of allocating public IPs with fully-qualified-domain-names as above.

### NOTE

This template deploys a bastion host, merely for the connection provisioner and allowing remote-exec to run commands on machines without public IPs; notice the specific dependencies on the order in which VMs are created for this to work properly.

### NOTE

The OpenShift Ansible playbook does take a while to run when using VMs backed by Standard Storage. VMs backed by Premium Storage are faster. If you want Premimum Storage, select a DS or GS series VM.
<hr />
Be sure to follow the OpenShift instructions to create the ncessary DNS entry for the OpenShift Router for access to applications.

## Post-Deployment Operations

This template creates an OpenShift user but does not make it a full OpenShift user. To do that, please perform the following.

1. SSH in to master node
2. Execute the following command:

```sh
sudo oadm policy add-cluster-role-to-user cluster-admin <user>
```
### Additional OpenShift Configuration Options

You can configure additional settings per the official [OpenShift Origin Documentation](https://docs.openshift.org/latest/welcome/index.html).

Few options you have

1. Deployment Output

a. openshiftConsoleUrl the openshift console url<br/>
b. openshiftMasterSsh ssh command for master node<br/>
c. openshiftNodeLoadBalancerFQDN node load balancer<br/>

get the deployment output data

a. portal.azure.com -> choose 'Resource groups' select your group select 'Deployments' and there the deployment 'Microsoft.Template'. As output from the deployment it contains information about the openshift console url, ssh command and load balancer url.<br/>
b. With the Azure CLI : azure group deployment list &lt;resource group name>

2. add additional users. you can find much detail about this in the openshift.org documentation under 'Cluster Administration' and 'Managing Users'. This installation uses htpasswd as the identity provider. To add more user ssh in to master node and execute following command:

```sh
sudo htpasswd /etc/origin/master/htpasswd user1
```
Now this user can login with the 'oc' CLI tool or the openshift console url.
46 changes: 46 additions & 0 deletions examples/azure-openshift-origin/deploy.ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

set -o errexit -o nounset

docker run --rm -it \
-e ARM_CLIENT_ID \
-e ARM_CLIENT_SECRET \
-e ARM_SUBSCRIPTION_ID \
-e ARM_TENANT_ID \
-e AAD_CLIENT_ID \
-e AAD_CLIENT_SECRET \
-e KEY_ENCRYPTION_KEY_URL \
-e SSH_PUBLIC_KEY \
-v /:/data \
--workdir=/data/$(pwd) \
--entrypoint "/bin/sh" \
hashicorp/terraform:light \
-c "/bin/terraform get; \
/bin/terraform validate; \
/bin/terraform plan -out=out.tfplan \
-var subscription_id=$ARM_SUBSCRIPTION_ID \
-var tenant_id=$ARM_TENANT_ID \
-var aad_client_id=$ARM_CLIENT_ID \
-var aad_client_secret=$ARM_CLIENT_SECRET \
-var resource_group_name=$KEY \
-var key_vault_name=$KEY_VAULT_NAME \
-var key_vault_resource_group=$KEY_VAULT_RESOURCE_GROUP \
-var key_vault_secret=$KEY_VAULT_SECRET \
-var openshift_cluster_prefix=$KEY \
-var openshift_password=$PASSWORD \
-var openshift_script_path=$LOCAL_SCRIPT_PATH \
-var ssh_public_key=\"$OS_PUBLIC_KEY\" \
-var connection_private_ssh_key_path=$CONTAINER_PRIVATE_KEY_PATH \
-var master_instance_count=$MASTER_COUNT \
-var infra_instance_count=$INFRA_COUNT \
-var node_instance_count=$NODE_COUNT; \
/bin/terraform apply out.tfplan;"

# cleanup deployed azure resources via azure-cli
# docker run --rm -it \
# azuresdk/azure-cli-python \
# sh -c "az login --service-principal -u $ARM_CLIENT_ID -p $ARM_CLIENT_SECRET --tenant $ARM_TENANT_ID > /dev/null; \
# az vm show -g $KEY -n $KEY; \
# az vm encryption show -g $KEY -n $KEY"

# cleanup deployed azure resources via terraform
24 changes: 24 additions & 0 deletions examples/azure-openshift-origin/deploy.mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -o errexit -o nounset

if docker -v; then

# generate a unique string for CI deployment
export KEY=$(cat /dev/urandom | env LC_CTYPE=C tr -cd 'a-z' | head -c 12)
export PASSWORD="P4ssw0rd1"
export KEY_VAULT_RESOURCE_GROUP=permanent
export KEY_VAULT_NAME=TerraformVault
export KEY_VAULT_SECRET=OpenShiftSSH
export OS_PUBLIC_KEY='ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCvdOGspeeBhsOZw6OK2WmP3bBUOeZj1yaz6Dw+lzsRmjwNSmJIoGZPzlbdy1lzlkXIm2JaT4h/cUi39w+Q2RZRjxmr7TbLyuidJfFLvRJ35RDullUYLWEPx3csBroPkCv+0qgmTW/MqqjqS4yhlJ01uc9RNx9Jt3XZN7LNr8SUoBzdLCWJa1rpCTtUckO1Jyzi4VwZ2ek+nYPJuJ8hG0KeHnyXDXV4hQZTFtGvtbmgoyoybppFQMbM3a31KZeaWXUeZkZczBsdNRkX8XCDjb6zUmUMQUzZpalFlL1O+rZD0kaXKr0uZWiYOKu2LjnWeDW9x4tig1mf+L84vniP+lLKFW8na3Lzx11ysEpuhIJGPMMI8sjTCnu51PmiwHW2U9OR06skPUO7ZGD0QHg7jKXdz5bHT+1OqXeAStULDiPVRIPrxxpurPXiJRm7JPbPvPqrMqZJ3K7J9W6OGHG3CoDR5RfYlPWURTaVH10stb4hKevasCd+YoLStB1XgMaL/cG9bM0TIWmODV/+pfn800PgxeBn1vABpL0NF8K2POLs37vGJoh/RyGCDVd0HEKArpZj0/g+fv7tr3tFFOCY5bHSuDTZcY8sWPhxKXSismoApM3a+USF5HkDkWSTEiETs2wgUdTSt4MuN2maRXOK2JboQth1Qw+vCOvqcls0dMa0NQ== [email protected]'
export CONTAINER_PRIVATE_KEY_PATH="/data/Users/$USER/.ssh/id_rsa"
export LOCAL_SCRIPT_PATH="/data/Users/$USER/Code/10thmagnitude/openshift-origin/scripts"
export MASTER_COUNT=1
export INFRA_COUNT=1
export NODE_COUNT=1

/bin/sh ./deploy.ci.sh

else
echo "Docker is used to run terraform commands, please install before run: https://docs.docker.com/docker-for-mac/install/"
fi
Loading