SampleScripts/configurevSphereWithTanzuDeveloperReadyInrastructure.ps1

<#
    .NOTES
    ===========================================================================
    Created by: Jason Shiplett - Staff II Solutions Architect
    Date: 07/30/2021
    Copyright 2021 VMware, Inc.
    ===========================================================================
#>


$sddcManagerFqdn = "sfo-vcf01.sfo.rainpole.io"
$sddcManagerUsername = "administrator@vsphere.local"
$sddcManagerPassword = "VMw@re1!"
$wldName = "sfo-w01"
$tagCategoryName = "vsphere-with-tanzu-tag-category"
$tagName = "vsphere-with-tanzu-tag"
$wldDatastoreName = "sfo-w01-cl01-ds-vsan01"
$spbmPolicyName = "vsphere-with-tanzu-policy"
$spbmRuleSetName = "sphere-with-tanzu-ruleset"
$contentLibraryUrl = "https://wp-content.vmware.com/v2/latest/lib.json"
$contentLibraryName = "Kubernetes"
$wmClusterName = "sfo-w01-cl01"
$wmNamespaceName = "sfo-w01-ns01"
$wmTkcNamespaceName = "sfo-w01-tkc01"
$domainName = "sfo.rainpole.io"
$wmNamespaceEditUserGroup = "ug-kub-admins"
$wmNamespaceViewUserGroup = "ug-kub-viewonly"
$principalEditRole = "edit"
$principalViewRole = "view"
$principalType = "group"
$kubectlBinLocation = "c:\kube\bin\"
$YAML = "C:\kube\yaml\tkgsCluster.yaml"
$env:PATH = "$kubectlBinLocation;$env:PATH"

$wmClusterInput = @{
    Server = "sfo-vcf01.sfo.rainpole.io"                
    User = "administrator@vsphere.local"
    Pass = "VMw@re1!"                                
    Domain = "sfo-m01"
    SizeHint = "Tiny"                       
    ManagementVirtualNetwork = "sfo-m01-kub-seg01"
    ManagementNetworkMode = "StaticRange"
    ManagementNetworkStartIpAddress = "192.168.20.10"
    ManagementNetworkAddressRangeSize = "5"
    ManagementNetworkGateway = "192.168.20.1"
    ManagementNetworkSubnetMask = "255.255.255.0"
    Cluster = "sfo-m01-cl01"
    ContentLibrary = "Kubernetes1"
    EphemeralStoragePolicy = "vsphere-with-tanzu-policy"
    ImageStoragePolicy = "vsphere-with-tanzu-policy"
    MasterStoragePolicy = "vsphere-with-tanzu-policy"
    NsxEdgeCluster = "sfo-m01-ec01"
    DistributedSwitch = "sfo-m01-cl01-vds01"
    PodCIDRs = "100.100.0.0/20"
    ServiceCIDR = "100.200.0.0/22"
    ExternalIngressCIDRs = "192.168.21.0/24"
    ExternalEgressCIDRs = "192.168.22.0/24"
    NtpServer1IpAddress = "172.16.11.253"
    NtpServer2IpAddress = "172.16.12.253"
    DnsServer1IpAddress = "172.16.11.4"
    DnsServer2IpAddress = "172.16.11.5"
    MasterDnsSearchDomain = "sfo.rainpole.io"
}

Import-Module VMware.PowerCLI
Import-Module PowerVCF
Import-Module PowerValidatedSolutions
Import-Module Await -MinimumVersion 0.8

Set-DriDatastoreTag -Server $sddcManagerFqdn -User $sddcManagerUsername -Pass $sddcManagerPassword -Domain $wldName -TagName $tagName -TagCategoryName $tagCategoryName -Datastore $wldDatastoreName

New-DriSpbmStoragePolicy -Server $sddcManagerFqdn -User $sddcManagerUsername -Pass $sddcManagerPassword -Domain $wldName -PolicyName $spbmPolicyName -RuleSetName $spbmRuleSetName -TagName $tagName

New-DriContentLibrary -Server $sddcManagerFqdn -User $sddcManagerUsername -Pass $sddcManagerPassword -Domain $wldName -ContentLibraryName $contentLibraryName -Datastore $wldDatastoreName -SubscriptionUrl $contentLibraryUrl

Enable-DriWMCluster @wmClusterInput

New-DriWMNamespace -Server $sddcManagerFqdn -User $sddcManagerUsername -Pass $sddcManagerPassword -Domain $wldName -Cluster $wmClusterName -Namespace $wmNamespaceName -StoragePolicy $spbmPolicyName
New-WMNamespacePermission -Namespace (Get-WMNamespace -Name $wmNamespaceName) -Role $principalEditRole -Domain $domainName -PrincipalType $principalType -PrincipalName $wmNamespaceEditUserGroup
New-WMNamespacePermission -Namespace (Get-WMNamespace -Name $wmNamespaceName) -Role $principalViewRole -Domain $domainName -PrincipalType $principalType -PrincipalName $wmNamespaceViewUserGroup

New-DriWMNamespace -Server $sddcManagerFqdn -User $sddcManagerUsername -Pass $sddcManagerPassword -Domain $wldName -Cluster $wmClusterName -Namespace $wmTkcNamespaceName -StoragePolicy $spbmPolicyName
New-WMNamespacePermission -Namespace (Get-WMNamespace -Name $wmTkcNamespaceName) -Role $principalEditRole -Domain $domainName -PrincipalType $principalType -PrincipalName $wmNamespaceEditUserGroup
New-WMNamespacePermission -Namespace (Get-WMNamespace -Name $wmTkcNamespaceName) -Role $principalViewRole -Domain $domainName -PrincipalType $principalType -PrincipalName $wmNamespaceViewUserGroup

Enable-DriWMRegistry -Server $sddcManagerFqdn -User $sddcManagerUsername -Pass $sddcManagerPassword -Domain $wldName -Cluster $wmClusterName -StoragePolicy $spbmPolicyName

New-DriTanzuKubernetesCluster -Server $sddcManagerFqdn -User $sddcManagerUsername -Pass $sddcManagerPassword -Domain $wldName -Cluster $wmClusterName -YAML $YAML