Skip to content

Commit 3d1a771

Browse files
committed
Initial changes for removal of terraform
1 parent e2dafac commit 3d1a771

File tree

7 files changed

+1119
-2
lines changed

7 files changed

+1119
-2
lines changed

images/installer/Dockerfile.upi.ci

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ RUN yum update -y && \
3737
unzip \
3838
openssh-clients \
3939
openssl \
40+
powershell \
4041
python3-pyOpenSSL \
4142
python2-pyyaml \
4243
python3-pyyaml \
@@ -91,6 +92,11 @@ RUN mkdir /output && HOME=/output && \
9192
ibmcloud version && \
9293
ibmcloud plugin list
9394

95+
# Install VMware plugin for powershell. Create settings directory /output/.local/share/VMware/PowerCLI
96+
RUN pwsh -Command 'Install-Module VMware.PowerCLI -Force -Scope AllUsers' && \
97+
pwsh -Command 'Install-Module -Name EPS -RequiredVersion 1.0 -Force -Scope AllUsers' && \
98+
mkdir -p /output/.local/share/VMware/PowerCLI && chmod -R 777 /output/.local
99+
94100
RUN chown 1000:1000 /output && chmod -R g=u "/output/.bluemix/"
95101
USER 1000:1000
96102
ENV PATH /bin

upi/vsphere/README.md

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,84 @@
1-
# Pre-Requisites
1+
This project shows two ways to install an UPI cluster. We will discuss how to install using one of these two techniques:
2+
- Terraform
3+
- PowerShell
4+
5+
# Table of Contents
6+
- [PowerShell](#PowerShell)
7+
- [Pre-Requisites](#pre-requisites)
8+
- [PowerShell Setup](#powershell-setup)
9+
- [VMware.PowerCLI](#vmwarepowercli)
10+
- [EPS](#eps)
11+
- [Script Configuration]
12+
- [OpenShift Installation Configuration]()
13+
- [Terraform](#Terraform)
14+
- [Pre-Requisites](#pre-requisites-1)
15+
- [Build a Cluster](#build-a-cluster-1)
16+
17+
# PowerShell
18+
This section will describe the process to generate the vSphere VMs using PowerShell and the supplied scripts in this module.
19+
20+
## Pre-requisites
21+
* PowerShell
22+
* PowerShell VMware.PowerCLI Module
23+
* PowerShell EPS Module
24+
25+
## PowerShell Setup
26+
27+
PowerShell will need to have a couple of plugin installed in order for our script to work. The plugins we need to install are VMware.PowerCLI and EPS.
28+
29+
### VMware.PowerCLI
30+
31+
To install the VMware.PowerCLI, you can run the following command:
32+
33+
```shell
34+
pwsh -Command 'Install-Module VMware.PowerCLI -Force -Scope CurrentUser'
35+
```
36+
37+
### EPS
38+
39+
To install the EPS module, you can run the following command:
40+
41+
```shell
42+
pwsh -Command 'Install-Module -Name EPS -RequiredVersion 1.0 -Force -Scope CurrentUser'
43+
```
44+
45+
### Generating CLI Credentials
46+
47+
The PowerShell scripts require that a credentials file be generated with the credentials to be used for generating the vSphere resources. This does not have to be the credentials used by the OpenShift cluster via the install-config.yaml, but must have all permissions to create folders, tags, templates, and vms. To generate the credentials files, run:
48+
49+
```shell
50+
pwsh -command "\$User='<username>';\$Password=ConvertTo-SecureString -String '<password>' -AsPlainText -Force;\$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList \$User, \$Password;\$Credential | Export-Clixml secrets/vcenter-creds.xml"
51+
```
52+
53+
Be sure to modify `<username>` to be the username for vCenter and `<password>` to the your password. The output of this needs to go into `secrets/vcenter-creds.xml`. Make sure the secrets directory exists before running the credentials generation command above.
54+
55+
## Script Configuration
56+
57+
The PowerShell script provided by this project provides examples on how to do several aspects to creating a UPI cluster environment. It is configurable to do as much or as little as you need. For the CI build process, we will handle all install-config.yaml configuration, uploading of templates, and monitoring of installation progress. This project can handle doing all that as well if configured appropriately.
58+
59+
### Behavioral Configurations
60+
61+
| Property | Description |
62+
|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
63+
| createInstallConfig | Enable script to create install config based on configuration of variables.ps1 |
64+
| downloadInstaller | Enable script to download installer to be used. If not downloading the installer, the installer must be placed in the same directory as this script. |
65+
| uploadTemplateOva | Enable script to upload OVA template to be used for all VM being created. |
66+
| generateIgnitions | Enable script to generate ignition configs. This is normally used when install-config.yaml is provided to script, but need script to generate the ignition configs for VMs. |
67+
| waitForComplete | This option has the script step through the process of waiting for installation complete. Most of this functionality is provided by `openshift-install wait-for`. The script will will check for when api is ready, bootstrap complete, accept CSRs and then for all COs to be done installing. |
68+
| delayVMStart | This option has the script delay the start of the VMs after their creation. |
69+
70+
## Build a Cluster
71+
72+
# Terraform
73+
This section will walk you through generating a cluster using Terraform.
74+
75+
<a id="terraform-pre-requisites"></a>
76+
## Pre-Requisites
277

378
* terraform
479
* jq
580

6-
# Build a Cluster
81+
## Build a Cluster
782

883
1. Create an install-config.yaml.
984
The machine CIDR for the dev cluster is 139.178.89.192/26.

upi/vsphere/lb/haproxy.erb.tmpl

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
defaults
2+
maxconn 20000
3+
mode tcp
4+
log /var/run/haproxy/haproxy-log.sock local0
5+
option dontlognull
6+
retries 3
7+
timeout http-request 10s
8+
timeout queue 1m
9+
timeout connect 10s
10+
timeout client 86400s
11+
timeout server 86400s
12+
timeout tunnel 86400s
13+
14+
frontend api-server
15+
bind <%= $lb_ip_address %>:6443
16+
default_backend api-server
17+
18+
frontend machine-config-server
19+
bind <%= $lb_ip_address %>:22623
20+
default_backend machine-config-server
21+
22+
frontend router-http
23+
bind <%= $lb_ip_address %>:80
24+
default_backend router-http
25+
26+
frontend router-https
27+
bind <%= $lb_ip_address %>:443
28+
default_backend router-https
29+
30+
backend api-server
31+
option httpchk GET /readyz HTTP/1.0
32+
option log-health-checks
33+
balance roundrobin
34+
<% foreach ($addr in $api) { -%>
35+
server <%= $addr %> <%= $addr %>:6443 weight 1 verify none check check-ssl inter 1s fall 2 rise 3
36+
<% } -%>
37+
38+
backend machine-config-server
39+
balance roundrobin
40+
<% foreach ($addr in $api) { -%>
41+
server <%= $addr %> <%= $addr %>:22623 check
42+
<% } -%>
43+
44+
backend router-http
45+
balance source
46+
mode tcp
47+
<% foreach ($addr in $ingress) { -%>
48+
server <%= $addr %> <%= $addr %>:80 check
49+
<% } -%>
50+
51+
backend router-https
52+
balance source
53+
mode tcp
54+
<% foreach ($addr in $ingress) { -%>
55+
server <%= $addr %> <%= $addr %>:443 check
56+
<% } -%>
57+

upi/vsphere/upi-destroy.ps1

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/pwsh
2+
3+
. .\variables.ps1
4+
5+
$ErrorActionPreference = "Stop"
6+
7+
# since we do not have ca for vsphere certs, we'll just set insecure
8+
Set-PowerCLIConfiguration -InvalidCertificateAction:Ignore -Confirm:$false | Out-Null
9+
$Env:GOVC_INSECURE = 1
10+
11+
# Connect to vCenter
12+
Connect-VIServer -Server $vcenter -Credential (Import-Clixml $vcentercredpath)
13+
14+
# Convert the installer metadata to a powershell object
15+
$metadata = Get-Content -Path ./metadata.json | ConvertFrom-Json
16+
17+
# Get tag for all resources we created
18+
$tagCategory = Get-TagCategory -Name "openshift-$($metadata.infraID)"
19+
$tag = Get-Tag -Category $tagCategory -Name "$($metadata.infraID)"
20+
21+
# Clean up all VMs
22+
$vms = Get-VM -Tag $tag
23+
foreach ($vm in $vms) {
24+
if ($vm.PowerState -eq "PoweredOn") {
25+
Write-Output "Stopping VM $vm"
26+
Stop-VM -VM $vm -confirm:$false > $null
27+
}
28+
Write-Output "Removing VM $vm"
29+
Remove-VM -VM $vm -DeletePermanently -confirm:$false
30+
}
31+
32+
# Clean up all templates
33+
$templates = Get-TagAssignment -Tag $tag -Entity (Get-Template)
34+
foreach ($template in $templates) {
35+
Write-Output "Removing template $($template.Entity)"
36+
Remove-Template -Template $($template.Entity) -DeletePermanently -confirm:$false
37+
}
38+
39+
# Clean up storage policy
40+
$storagePolicies = Get-SpbmStoragePolicy -Tag $tag
41+
42+
foreach ($policy in $storagePolicies) {
43+
44+
$clusterInventory = @()
45+
$splitResults = @($policy.Name -split "openshift-storage-policy-")
46+
47+
if ($splitResults.Count -eq 2) {
48+
$clusterId = $splitResults[1]
49+
if ($clusterId -ne "") {
50+
Write-Host $clusterId
51+
$clusterInventory = @(Get-Inventory -Name "$($clusterId)*" -ErrorAction Continue)
52+
53+
if ($clusterInventory.Count -eq 0) {
54+
Write-Host "Removing policy: $($policy.Name)"
55+
$policy | Remove-SpbmStoragePolicy -Confirm:$false
56+
}
57+
else {
58+
Write-Host "not deleting: $($clusterInventory)"
59+
}
60+
}
61+
}
62+
}
63+
64+
# Clean up all folders
65+
$folders = Get-TagAssignment -Tag $tag -Entity (Get-Folder)
66+
foreach ($folder in $folders) {
67+
Write-Output "Removing folder $($folder.Entity)"
68+
Remove-Folder -Folder $($folder.Entity) -DeletePermanently -confirm:$false
69+
}
70+
71+
# Clean up tags
72+
Remove-Tag -Tag $tag -confirm:$false
73+
Remove-TagCategory -Category $tagCategory -confirm:$false

0 commit comments

Comments
 (0)