Adding supported regions for Azure Provider (#92)
This commit is contained in:
committed by
Robbie Zhang
parent
f4ebbfc7a3
commit
a99f2d08c1
@@ -20,7 +20,7 @@ The best description is "Kubernetes API on top, programmable back."
|
|||||||
+ [Adding a New Provider via the Provider Interface](#adding-a-new-provider-via-the-provider-interface)
|
+ [Adding a New Provider via the Provider Interface](#adding-a-new-provider-via-the-provider-interface)
|
||||||
* [Testing](#testing)
|
* [Testing](#testing)
|
||||||
+ [Testing the Azure Provider Client](#testing-the-azure-provider-client)
|
+ [Testing the Azure Provider Client](#testing-the-azure-provider-client)
|
||||||
* [Known quirks and workarounds](#known-quirks-and-workaroundss)
|
* [Known quirks and workarounds](#known-quirks-and-workarounds)
|
||||||
* [Contributing](#contributing)
|
* [Contributing](#contributing)
|
||||||
|
|
||||||
## How It Works
|
## How It Works
|
||||||
|
|||||||
@@ -52,6 +52,28 @@ type AuthConfig struct {
|
|||||||
RegistryToken string `json:"registrytoken,omitempty"`
|
RegistryToken string `json:"registrytoken,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See https://docs.microsoft.com/en-us/azure/container-instances/container-instances-quotas for valid regions.
|
||||||
|
var validAciRegions = []string{
|
||||||
|
"westeurope",
|
||||||
|
"westus",
|
||||||
|
"eastus",
|
||||||
|
"southeastasia",
|
||||||
|
}
|
||||||
|
|
||||||
|
// isValidACIRegion checks to make sure we're using a valid ACI region
|
||||||
|
func isValidACIRegion(region string) bool {
|
||||||
|
regionLower := strings.ToLower(region)
|
||||||
|
regionTrimmed := strings.Replace(regionLower, " ", "", -1)
|
||||||
|
|
||||||
|
for _, validRegion := range validAciRegions {
|
||||||
|
if regionTrimmed == validRegion {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// NewACIProvider creates a new ACIProvider.
|
// NewACIProvider creates a new ACIProvider.
|
||||||
func NewACIProvider(config string, rm *manager.ResourceManager, nodeName, operatingSystem string, internalIP string, daemonEndpointPort int32) (*ACIProvider, error) {
|
func NewACIProvider(config string, rm *manager.ResourceManager, nodeName, operatingSystem string, internalIP string, daemonEndpointPort int32) (*ACIProvider, error) {
|
||||||
var p ACIProvider
|
var p ACIProvider
|
||||||
@@ -139,6 +161,12 @@ func NewACIProvider(config string, rm *manager.ResourceManager, nodeName, operat
|
|||||||
if p.region == "" {
|
if p.region == "" {
|
||||||
return nil, errors.New("Region can not be empty please set ACI_REGION")
|
return nil, errors.New("Region can not be empty please set ACI_REGION")
|
||||||
}
|
}
|
||||||
|
if r := p.region; !isValidACIRegion(r) {
|
||||||
|
unsupportedRegionMessage := fmt.Sprintf("Region %s is invalid. Current supported regions are: %s",
|
||||||
|
r, strings.Join(validAciRegions, ", "))
|
||||||
|
|
||||||
|
return nil, errors.New(unsupportedRegionMessage)
|
||||||
|
}
|
||||||
|
|
||||||
// Set sane defaults for Capacity in case config is not supplied
|
// Set sane defaults for Capacity in case config is not supplied
|
||||||
p.cpu = "20"
|
p.cpu = "20"
|
||||||
@@ -508,7 +536,7 @@ func (p *ACIProvider) getVolumes(pod *v1.Pod) ([]aci.Volume, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if secret == nil {
|
if secret == nil {
|
||||||
return nil, fmt.Errorf("Getting secret for AzureFile volume returned an empty secret.")
|
return nil, fmt.Errorf("Getting secret for AzureFile volume returned an empty secret")
|
||||||
}
|
}
|
||||||
|
|
||||||
volumes = append(volumes, aci.Volume{
|
volumes = append(volumes, aci.Volume{
|
||||||
|
|||||||
Reference in New Issue
Block a user