2018-12-03 22:19:18 +03:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
// Licensed under the MIT license.
|
|
|
|
|
2017-08-18 19:06:43 +03:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
2017-09-22 03:30:21 +03:00
|
|
|
"encoding/json"
|
2018-04-13 01:35:33 +03:00
|
|
|
"strconv"
|
2017-09-22 03:30:21 +03:00
|
|
|
|
2017-08-18 19:06:43 +03:00
|
|
|
"github.com/Azure/acs-engine/pkg/api/agentPoolOnlyApi/v20170831"
|
2018-03-14 19:18:46 +03:00
|
|
|
"github.com/Azure/acs-engine/pkg/api/agentPoolOnlyApi/v20180331"
|
2017-08-18 19:06:43 +03:00
|
|
|
"github.com/Azure/acs-engine/pkg/api/agentPoolOnlyApi/vlabs"
|
2017-10-28 02:26:14 +03:00
|
|
|
"github.com/Azure/acs-engine/pkg/api/common"
|
2018-04-11 01:18:25 +03:00
|
|
|
"github.com/Azure/acs-engine/pkg/helpers"
|
2017-08-18 19:06:43 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// The converter exposes functions to convert the top level
|
|
|
|
// ContainerService resource
|
|
|
|
//
|
|
|
|
// All other functions are internal helper functions used
|
|
|
|
// for converting.
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// ConvertV20170831AgentPoolOnly converts an AgentPoolOnly object into an in-memory container service
|
2017-08-25 19:50:44 +03:00
|
|
|
func ConvertV20170831AgentPoolOnly(v20170831 *v20170831.ManagedCluster) *ContainerService {
|
2017-08-18 19:06:43 +03:00
|
|
|
c := &ContainerService{}
|
|
|
|
c.ID = v20170831.ID
|
2018-04-27 20:55:22 +03:00
|
|
|
c.Location = helpers.NormalizeAzureRegion(v20170831.Location)
|
2017-08-18 19:06:43 +03:00
|
|
|
c.Name = v20170831.Name
|
|
|
|
if v20170831.Plan != nil {
|
|
|
|
c.Plan = convertv20170831AgentPoolOnlyResourcePurchasePlan(v20170831.Plan)
|
|
|
|
}
|
|
|
|
c.Tags = map[string]string{}
|
|
|
|
for k, v := range v20170831.Tags {
|
|
|
|
c.Tags[k] = v
|
|
|
|
}
|
|
|
|
c.Type = v20170831.Type
|
|
|
|
c.Properties = convertV20170831AgentPoolOnlyProperties(v20170831.Properties)
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
2018-03-14 19:18:46 +03:00
|
|
|
// ConvertV20180331AgentPoolOnly converts an AgentPoolOnly object into an in-memory container service
|
|
|
|
func ConvertV20180331AgentPoolOnly(v20180331 *v20180331.ManagedCluster) *ContainerService {
|
|
|
|
c := &ContainerService{}
|
|
|
|
c.ID = v20180331.ID
|
2018-04-27 20:55:22 +03:00
|
|
|
c.Location = helpers.NormalizeAzureRegion(v20180331.Location)
|
2018-03-14 19:18:46 +03:00
|
|
|
c.Name = v20180331.Name
|
|
|
|
if v20180331.Plan != nil {
|
|
|
|
c.Plan = convertv20180331AgentPoolOnlyResourcePurchasePlan(v20180331.Plan)
|
|
|
|
}
|
|
|
|
c.Tags = map[string]string{}
|
|
|
|
for k, v := range v20180331.Tags {
|
|
|
|
c.Tags[k] = v
|
|
|
|
}
|
|
|
|
c.Type = v20180331.Type
|
|
|
|
c.Properties = convertV20180331AgentPoolOnlyProperties(v20180331.Properties)
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
2017-08-18 19:06:43 +03:00
|
|
|
func convertv20170831AgentPoolOnlyResourcePurchasePlan(v20170831 *v20170831.ResourcePurchasePlan) *ResourcePurchasePlan {
|
|
|
|
return &ResourcePurchasePlan{
|
|
|
|
Name: v20170831.Name,
|
|
|
|
Product: v20170831.Product,
|
|
|
|
PromotionCode: v20170831.PromotionCode,
|
|
|
|
Publisher: v20170831.Publisher,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func convertV20170831AgentPoolOnlyProperties(obj *v20170831.Properties) *Properties {
|
|
|
|
properties := &Properties{
|
|
|
|
ProvisioningState: ProvisioningState(obj.ProvisioningState),
|
|
|
|
MasterProfile: nil,
|
|
|
|
}
|
|
|
|
|
|
|
|
properties.HostedMasterProfile = &HostedMasterProfile{}
|
|
|
|
properties.HostedMasterProfile.DNSPrefix = obj.DNSPrefix
|
|
|
|
properties.HostedMasterProfile.FQDN = obj.FQDN
|
|
|
|
|
2017-10-09 19:51:26 +03:00
|
|
|
properties.OrchestratorProfile = convertV20170831AgentPoolOnlyOrchestratorProfile(obj.KubernetesVersion)
|
2017-08-18 19:06:43 +03:00
|
|
|
|
|
|
|
properties.AgentPoolProfiles = make([]*AgentPoolProfile, len(obj.AgentPoolProfiles))
|
|
|
|
for i := range obj.AgentPoolProfiles {
|
|
|
|
properties.AgentPoolProfiles[i] = convertV20170831AgentPoolOnlyAgentPoolProfile(obj.AgentPoolProfiles[i], AvailabilitySet)
|
|
|
|
}
|
|
|
|
if obj.LinuxProfile != nil {
|
|
|
|
properties.LinuxProfile = convertV20170831AgentPoolOnlyLinuxProfile(obj.LinuxProfile)
|
|
|
|
}
|
|
|
|
if obj.WindowsProfile != nil {
|
|
|
|
properties.WindowsProfile = convertV20170831AgentPoolOnlyWindowsProfile(obj.WindowsProfile)
|
|
|
|
}
|
|
|
|
|
|
|
|
if obj.ServicePrincipalProfile != nil {
|
|
|
|
properties.ServicePrincipalProfile = convertV20170831AgentPoolOnlyServicePrincipalProfile(obj.ServicePrincipalProfile)
|
|
|
|
}
|
|
|
|
|
|
|
|
return properties
|
|
|
|
}
|
|
|
|
|
2017-08-30 01:34:24 +03:00
|
|
|
// ConvertVLabsAgentPoolOnly converts a vlabs ContainerService to an unversioned ContainerService
|
2017-08-25 19:50:44 +03:00
|
|
|
func ConvertVLabsAgentPoolOnly(vlabs *vlabs.ManagedCluster) *ContainerService {
|
2017-08-18 19:06:43 +03:00
|
|
|
c := &ContainerService{}
|
|
|
|
c.ID = vlabs.ID
|
2018-04-27 20:55:22 +03:00
|
|
|
c.Location = helpers.NormalizeAzureRegion(vlabs.Location)
|
2017-08-18 19:06:43 +03:00
|
|
|
c.Name = vlabs.Name
|
|
|
|
if vlabs.Plan != nil {
|
|
|
|
c.Plan = &ResourcePurchasePlan{}
|
|
|
|
convertVLabsAgentPoolOnlyResourcePurchasePlan(vlabs.Plan, c.Plan)
|
|
|
|
}
|
|
|
|
c.Tags = map[string]string{}
|
|
|
|
for k, v := range vlabs.Tags {
|
|
|
|
c.Tags[k] = v
|
|
|
|
}
|
|
|
|
c.Type = vlabs.Type
|
|
|
|
c.Properties = &Properties{}
|
|
|
|
convertVLabsAgentPoolOnlyProperties(vlabs.Properties, c.Properties)
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
|
|
|
// convertVLabsResourcePurchasePlan converts a vlabs ResourcePurchasePlan to an unversioned ResourcePurchasePlan
|
|
|
|
func convertVLabsAgentPoolOnlyResourcePurchasePlan(vlabs *vlabs.ResourcePurchasePlan, api *ResourcePurchasePlan) {
|
|
|
|
api.Name = vlabs.Name
|
|
|
|
api.Product = vlabs.Product
|
|
|
|
api.PromotionCode = vlabs.PromotionCode
|
|
|
|
api.Publisher = vlabs.Publisher
|
|
|
|
}
|
|
|
|
|
|
|
|
func convertVLabsAgentPoolOnlyProperties(vlabs *vlabs.Properties, api *Properties) {
|
|
|
|
api.ProvisioningState = ProvisioningState(vlabs.ProvisioningState)
|
2017-10-09 19:51:26 +03:00
|
|
|
api.OrchestratorProfile = convertVLabsAgentPoolOnlyOrchestratorProfile(vlabs.KubernetesVersion)
|
2017-08-18 19:06:43 +03:00
|
|
|
api.MasterProfile = nil
|
|
|
|
|
|
|
|
api.HostedMasterProfile = &HostedMasterProfile{}
|
|
|
|
api.HostedMasterProfile.DNSPrefix = vlabs.DNSPrefix
|
|
|
|
api.HostedMasterProfile.FQDN = vlabs.FQDN
|
|
|
|
|
|
|
|
api.AgentPoolProfiles = []*AgentPoolProfile{}
|
|
|
|
for _, p := range vlabs.AgentPoolProfiles {
|
|
|
|
apiProfile := &AgentPoolProfile{}
|
|
|
|
convertVLabsAgentPoolOnlyAgentPoolProfile(p, apiProfile)
|
|
|
|
// by default vlabs will use managed disks for all orchestrators but kubernetes as it has encryption at rest.
|
|
|
|
if !api.OrchestratorProfile.IsKubernetes() {
|
|
|
|
// by default vlabs will use managed disks for all orchestrators but kubernetes as it has encryption at rest.
|
|
|
|
if len(p.StorageProfile) == 0 {
|
|
|
|
apiProfile.StorageProfile = ManagedDisks
|
|
|
|
}
|
|
|
|
}
|
|
|
|
api.AgentPoolProfiles = append(api.AgentPoolProfiles, apiProfile)
|
|
|
|
}
|
|
|
|
if vlabs.LinuxProfile != nil {
|
|
|
|
api.LinuxProfile = &LinuxProfile{}
|
|
|
|
convertVLabsAgentPoolOnlyLinuxProfile(vlabs.LinuxProfile, api.LinuxProfile)
|
|
|
|
}
|
|
|
|
if vlabs.WindowsProfile != nil {
|
|
|
|
api.WindowsProfile = &WindowsProfile{}
|
|
|
|
convertVLabsAgentPoolOnlyWindowsProfile(vlabs.WindowsProfile, api.WindowsProfile)
|
|
|
|
}
|
|
|
|
if vlabs.ServicePrincipalProfile != nil {
|
|
|
|
api.ServicePrincipalProfile = &ServicePrincipalProfile{}
|
|
|
|
convertVLabsAgentPoolOnlyServicePrincipalProfile(vlabs.ServicePrincipalProfile, api.ServicePrincipalProfile)
|
|
|
|
}
|
|
|
|
if vlabs.CertificateProfile != nil {
|
|
|
|
api.CertificateProfile = &CertificateProfile{}
|
|
|
|
convertVLabsAgentPoolOnlyCertificateProfile(vlabs.CertificateProfile, api.CertificateProfile)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func convertVLabsAgentPoolOnlyLinuxProfile(vlabs *vlabs.LinuxProfile, api *LinuxProfile) {
|
|
|
|
api.AdminUsername = vlabs.AdminUsername
|
|
|
|
api.SSH.PublicKeys = []PublicKey{}
|
|
|
|
for _, d := range vlabs.SSH.PublicKeys {
|
|
|
|
api.SSH.PublicKeys = append(api.SSH.PublicKeys,
|
|
|
|
PublicKey{KeyData: d.KeyData})
|
|
|
|
}
|
|
|
|
// api.Secrets = []KeyVaultSecrets{}
|
|
|
|
// for _, s := range vlabs.Secrets {
|
|
|
|
// secret := &KeyVaultSecrets{}
|
|
|
|
// convertVLabsKeyVaultSecrets(&s, secret)
|
|
|
|
// api.Secrets = append(api.Secrets, *secret)
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
func convertV20170831AgentPoolOnlyLinuxProfile(obj *v20170831.LinuxProfile) *LinuxProfile {
|
|
|
|
api := &LinuxProfile{
|
|
|
|
AdminUsername: obj.AdminUsername,
|
|
|
|
}
|
|
|
|
api.SSH.PublicKeys = []PublicKey{}
|
|
|
|
for _, d := range obj.SSH.PublicKeys {
|
|
|
|
api.SSH.PublicKeys = append(api.SSH.PublicKeys, PublicKey{KeyData: d.KeyData})
|
|
|
|
}
|
|
|
|
return api
|
|
|
|
}
|
|
|
|
|
|
|
|
func convertV20170831AgentPoolOnlyWindowsProfile(obj *v20170831.WindowsProfile) *WindowsProfile {
|
|
|
|
return &WindowsProfile{
|
|
|
|
AdminUsername: obj.AdminUsername,
|
|
|
|
AdminPassword: obj.AdminPassword,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func convertVLabsAgentPoolOnlyWindowsProfile(vlabs *vlabs.WindowsProfile, api *WindowsProfile) {
|
|
|
|
api.AdminUsername = vlabs.AdminUsername
|
|
|
|
api.AdminPassword = vlabs.AdminPassword
|
2017-09-15 21:15:57 +03:00
|
|
|
api.ImageVersion = vlabs.ImageVersion
|
2017-08-18 19:06:43 +03:00
|
|
|
// api.Secrets = []KeyVaultSecrets{}
|
|
|
|
// for _, s := range vlabs.Secrets {
|
|
|
|
// secret := &KeyVaultSecrets{}
|
|
|
|
// convertVLabsKeyVaultSecrets(&s, secret)
|
|
|
|
// api.Secrets = append(api.Secrets, *secret)
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
2017-10-09 19:51:26 +03:00
|
|
|
func convertV20170831AgentPoolOnlyOrchestratorProfile(kubernetesVersion string) *OrchestratorProfile {
|
2017-11-03 02:44:42 +03:00
|
|
|
return &OrchestratorProfile{
|
|
|
|
OrchestratorType: Kubernetes,
|
2018-05-30 01:35:34 +03:00
|
|
|
OrchestratorVersion: common.GetSupportedKubernetesVersion(kubernetesVersion, false),
|
2018-04-11 01:18:25 +03:00
|
|
|
KubernetesConfig: &KubernetesConfig{
|
|
|
|
EnableRbac: helpers.PointerToBool(false),
|
|
|
|
EnableSecureKubelet: helpers.PointerToBool(false),
|
2018-04-17 02:52:48 +03:00
|
|
|
// set network default for un-versioned model
|
2018-05-10 02:28:59 +03:00
|
|
|
NetworkPlugin: string(v20180331.Kubenet),
|
2018-04-26 03:15:40 +03:00
|
|
|
ClusterSubnet: DefaultKubernetesClusterSubnet,
|
2018-04-17 02:52:48 +03:00
|
|
|
ServiceCIDR: DefaultKubernetesServiceCIDR,
|
|
|
|
DNSServiceIP: DefaultKubernetesDNSServiceIP,
|
|
|
|
DockerBridgeSubnet: DefaultDockerBridgeSubnet,
|
2018-04-11 01:18:25 +03:00
|
|
|
},
|
2017-08-18 19:06:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-09 19:51:26 +03:00
|
|
|
func convertVLabsAgentPoolOnlyOrchestratorProfile(kubernetesVersion string) *OrchestratorProfile {
|
2017-11-03 02:44:42 +03:00
|
|
|
return &OrchestratorProfile{
|
|
|
|
OrchestratorType: Kubernetes,
|
2018-05-30 01:35:34 +03:00
|
|
|
OrchestratorVersion: common.GetSupportedKubernetesVersion(kubernetesVersion, false),
|
2017-08-18 19:06:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func convertV20170831AgentPoolOnlyAgentPoolProfile(v20170831 *v20170831.AgentPoolProfile, availabilityProfile string) *AgentPoolProfile {
|
|
|
|
api := &AgentPoolProfile{}
|
|
|
|
api.Name = v20170831.Name
|
|
|
|
api.Count = v20170831.Count
|
|
|
|
api.VMSize = v20170831.VMSize
|
|
|
|
api.OSDiskSizeGB = v20170831.OSDiskSizeGB
|
|
|
|
api.OSType = OSType(v20170831.OSType)
|
|
|
|
api.StorageProfile = v20170831.StorageProfile
|
|
|
|
api.VnetSubnetID = v20170831.VnetSubnetID
|
|
|
|
api.Subnet = v20170831.GetSubnet()
|
|
|
|
api.AvailabilityProfile = availabilityProfile
|
|
|
|
return api
|
|
|
|
}
|
|
|
|
|
|
|
|
func convertVLabsAgentPoolOnlyAgentPoolProfile(vlabs *vlabs.AgentPoolProfile, api *AgentPoolProfile) {
|
|
|
|
api.Name = vlabs.Name
|
|
|
|
api.Count = vlabs.Count
|
|
|
|
api.VMSize = vlabs.VMSize
|
|
|
|
api.OSDiskSizeGB = vlabs.OSDiskSizeGB
|
|
|
|
api.OSType = OSType(vlabs.OSType)
|
|
|
|
api.StorageProfile = vlabs.StorageProfile
|
|
|
|
api.AvailabilityProfile = vlabs.AvailabilityProfile
|
|
|
|
api.VnetSubnetID = vlabs.VnetSubnetID
|
|
|
|
api.Subnet = vlabs.GetSubnet()
|
|
|
|
}
|
|
|
|
|
|
|
|
func convertVLabsAgentPoolOnlyServicePrincipalProfile(vlabs *vlabs.ServicePrincipalProfile, api *ServicePrincipalProfile) {
|
|
|
|
api.ClientID = vlabs.ClientID
|
|
|
|
api.Secret = vlabs.Secret
|
|
|
|
// api.KeyvaultSecretRef = vlabs.KeyvaultSecretRef
|
|
|
|
}
|
|
|
|
|
|
|
|
func convertV20170831AgentPoolOnlyServicePrincipalProfile(obj *v20170831.ServicePrincipalProfile) *ServicePrincipalProfile {
|
|
|
|
return &ServicePrincipalProfile{
|
|
|
|
ClientID: obj.ClientID,
|
|
|
|
Secret: obj.Secret,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func convertVLabsAgentPoolOnlyCertificateProfile(vlabs *vlabs.CertificateProfile, api *CertificateProfile) {
|
|
|
|
api.CaCertificate = vlabs.CaCertificate
|
|
|
|
api.CaPrivateKey = vlabs.CaPrivateKey
|
|
|
|
api.APIServerCertificate = vlabs.APIServerCertificate
|
|
|
|
api.APIServerPrivateKey = vlabs.APIServerPrivateKey
|
|
|
|
api.ClientCertificate = vlabs.ClientCertificate
|
|
|
|
api.ClientPrivateKey = vlabs.ClientPrivateKey
|
|
|
|
api.KubeConfigCertificate = vlabs.KubeConfigCertificate
|
|
|
|
api.KubeConfigPrivateKey = vlabs.KubeConfigPrivateKey
|
|
|
|
}
|
2017-09-22 03:30:21 +03:00
|
|
|
|
|
|
|
func isAgentPoolOnlyClusterJSON(contents []byte) bool {
|
|
|
|
properties, propertiesPresent := propertiesAsMap(contents)
|
|
|
|
if !propertiesPresent {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
_, masterProfilePresent := properties["masterProfile"]
|
|
|
|
return !masterProfilePresent
|
|
|
|
}
|
|
|
|
|
|
|
|
func propertiesAsMap(contents []byte) (map[string]interface{}, bool) {
|
|
|
|
var raw interface{}
|
|
|
|
json.Unmarshal(contents, &raw)
|
|
|
|
jsonMap := raw.(map[string]interface{})
|
|
|
|
properties, propertiesPresent := jsonMap["properties"]
|
|
|
|
if !propertiesPresent {
|
|
|
|
return nil, false
|
|
|
|
}
|
|
|
|
return properties.(map[string]interface{}), true
|
|
|
|
}
|
2018-03-14 19:18:46 +03:00
|
|
|
|
|
|
|
func convertv20180331AgentPoolOnlyResourcePurchasePlan(v20180331 *v20180331.ResourcePurchasePlan) *ResourcePurchasePlan {
|
|
|
|
return &ResourcePurchasePlan{
|
|
|
|
Name: v20180331.Name,
|
|
|
|
Product: v20180331.Product,
|
|
|
|
PromotionCode: v20180331.PromotionCode,
|
|
|
|
Publisher: v20180331.Publisher,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func convertV20180331AgentPoolOnlyProperties(obj *v20180331.Properties) *Properties {
|
|
|
|
properties := &Properties{
|
|
|
|
ProvisioningState: ProvisioningState(obj.ProvisioningState),
|
|
|
|
MasterProfile: nil,
|
|
|
|
}
|
|
|
|
|
|
|
|
properties.HostedMasterProfile = &HostedMasterProfile{}
|
|
|
|
properties.HostedMasterProfile.DNSPrefix = obj.DNSPrefix
|
|
|
|
properties.HostedMasterProfile.FQDN = obj.FQDN
|
|
|
|
|
2018-04-13 01:35:33 +03:00
|
|
|
kubernetesConfig := convertV20180331AgentPoolOnlyKubernetesConfig(obj.EnableRBAC)
|
|
|
|
properties.OrchestratorProfile = convertV20180331AgentPoolOnlyOrchestratorProfile(obj.KubernetesVersion, obj.NetworkProfile, kubernetesConfig)
|
2018-03-14 19:18:46 +03:00
|
|
|
|
|
|
|
properties.AgentPoolProfiles = make([]*AgentPoolProfile, len(obj.AgentPoolProfiles))
|
|
|
|
for i := range obj.AgentPoolProfiles {
|
2018-04-19 02:18:45 +03:00
|
|
|
properties.AgentPoolProfiles[i] = convertV20180331AgentPoolOnlyAgentPoolProfile(obj.AgentPoolProfiles[i], AvailabilitySet, obj.NetworkProfile)
|
2018-03-14 19:18:46 +03:00
|
|
|
}
|
|
|
|
if obj.LinuxProfile != nil {
|
|
|
|
properties.LinuxProfile = convertV20180331AgentPoolOnlyLinuxProfile(obj.LinuxProfile)
|
|
|
|
}
|
2018-04-10 20:31:07 +03:00
|
|
|
|
2018-03-14 19:18:46 +03:00
|
|
|
if obj.WindowsProfile != nil {
|
|
|
|
properties.WindowsProfile = convertV20180331AgentPoolOnlyWindowsProfile(obj.WindowsProfile)
|
|
|
|
}
|
|
|
|
|
|
|
|
if obj.ServicePrincipalProfile != nil {
|
|
|
|
properties.ServicePrincipalProfile = convertV20180331AgentPoolOnlyServicePrincipalProfile(obj.ServicePrincipalProfile)
|
|
|
|
}
|
2018-05-15 02:23:42 +03:00
|
|
|
|
2018-03-14 19:18:46 +03:00
|
|
|
if obj.AddonProfiles != nil {
|
|
|
|
properties.AddonProfiles = convertV20180331AgentPoolOnlyAddonProfiles(obj.AddonProfiles)
|
|
|
|
}
|
|
|
|
|
2018-05-15 02:23:42 +03:00
|
|
|
if obj.AADProfile != nil {
|
|
|
|
properties.AADProfile = convertV20180331AgentPoolOnlyAADProfile(obj.AADProfile)
|
|
|
|
}
|
|
|
|
|
2018-03-14 19:18:46 +03:00
|
|
|
return properties
|
|
|
|
}
|
|
|
|
|
|
|
|
func convertV20180331AgentPoolOnlyLinuxProfile(obj *v20180331.LinuxProfile) *LinuxProfile {
|
|
|
|
api := &LinuxProfile{
|
|
|
|
AdminUsername: obj.AdminUsername,
|
|
|
|
}
|
|
|
|
api.SSH.PublicKeys = []PublicKey{}
|
|
|
|
for _, d := range obj.SSH.PublicKeys {
|
|
|
|
api.SSH.PublicKeys = append(api.SSH.PublicKeys, PublicKey{KeyData: d.KeyData})
|
|
|
|
}
|
|
|
|
return api
|
|
|
|
}
|
|
|
|
|
|
|
|
func convertV20180331AgentPoolOnlyWindowsProfile(obj *v20180331.WindowsProfile) *WindowsProfile {
|
|
|
|
return &WindowsProfile{
|
|
|
|
AdminUsername: obj.AdminUsername,
|
|
|
|
AdminPassword: obj.AdminPassword,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-11 01:18:25 +03:00
|
|
|
func convertV20180331AgentPoolOnlyKubernetesConfig(enableRBAC *bool) *KubernetesConfig {
|
2018-09-08 01:16:59 +03:00
|
|
|
if helpers.IsTrueBoolPointer(enableRBAC) {
|
2018-04-25 00:03:30 +03:00
|
|
|
// We set default behavior to be false
|
2018-04-11 01:18:25 +03:00
|
|
|
return &KubernetesConfig{
|
|
|
|
EnableRbac: helpers.PointerToBool(true),
|
|
|
|
EnableSecureKubelet: helpers.PointerToBool(true),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return &KubernetesConfig{
|
|
|
|
EnableRbac: helpers.PointerToBool(false),
|
|
|
|
EnableSecureKubelet: helpers.PointerToBool(false),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-13 01:35:33 +03:00
|
|
|
func convertV20180331AgentPoolOnlyOrchestratorProfile(kubernetesVersion string, networkProfile *v20180331.NetworkProfile, kubernetesConfig *KubernetesConfig) *OrchestratorProfile {
|
|
|
|
if kubernetesConfig == nil {
|
|
|
|
kubernetesConfig = &KubernetesConfig{}
|
|
|
|
}
|
|
|
|
|
|
|
|
if networkProfile != nil {
|
2018-04-17 02:52:48 +03:00
|
|
|
switch networkProfile.NetworkPlugin {
|
|
|
|
case v20180331.Azure:
|
2018-05-03 01:50:42 +03:00
|
|
|
kubernetesConfig.NetworkPlugin = "azure"
|
2018-04-17 02:52:48 +03:00
|
|
|
|
2018-05-22 23:54:54 +03:00
|
|
|
if networkProfile.NetworkPolicy != "" {
|
|
|
|
kubernetesConfig.NetworkPolicy = string(networkProfile.NetworkPolicy)
|
|
|
|
}
|
|
|
|
|
2018-04-17 02:52:48 +03:00
|
|
|
if networkProfile.ServiceCidr != "" {
|
|
|
|
kubernetesConfig.ServiceCIDR = networkProfile.ServiceCidr
|
|
|
|
} else {
|
|
|
|
kubernetesConfig.ServiceCIDR = DefaultKubernetesServiceCIDR
|
|
|
|
}
|
|
|
|
|
|
|
|
if networkProfile.DNSServiceIP != "" {
|
|
|
|
kubernetesConfig.DNSServiceIP = networkProfile.DNSServiceIP
|
|
|
|
} else {
|
|
|
|
kubernetesConfig.DNSServiceIP = DefaultKubernetesDNSServiceIP
|
|
|
|
}
|
|
|
|
|
|
|
|
if networkProfile.DockerBridgeCidr != "" {
|
|
|
|
kubernetesConfig.DockerBridgeSubnet = networkProfile.DockerBridgeCidr
|
|
|
|
} else {
|
|
|
|
kubernetesConfig.DockerBridgeSubnet = DefaultDockerBridgeSubnet
|
|
|
|
}
|
|
|
|
case v20180331.Kubenet:
|
2018-05-03 01:50:42 +03:00
|
|
|
kubernetesConfig.NetworkPlugin = "kubenet"
|
2018-04-17 02:52:48 +03:00
|
|
|
|
2018-05-22 23:54:54 +03:00
|
|
|
if networkProfile.NetworkPolicy != "" {
|
|
|
|
kubernetesConfig.NetworkPolicy = string(networkProfile.NetworkPolicy)
|
|
|
|
}
|
|
|
|
|
|
|
|
if networkProfile.PodCidr != "" {
|
|
|
|
kubernetesConfig.ClusterSubnet = networkProfile.PodCidr
|
|
|
|
} else {
|
|
|
|
kubernetesConfig.ClusterSubnet = DefaultKubernetesClusterSubnet
|
|
|
|
}
|
2018-04-26 03:15:40 +03:00
|
|
|
|
2018-04-17 02:52:48 +03:00
|
|
|
if networkProfile.ServiceCidr != "" {
|
|
|
|
kubernetesConfig.ServiceCIDR = networkProfile.ServiceCidr
|
|
|
|
} else {
|
|
|
|
kubernetesConfig.ServiceCIDR = DefaultKubernetesServiceCIDR
|
|
|
|
}
|
|
|
|
|
|
|
|
if networkProfile.DNSServiceIP != "" {
|
|
|
|
kubernetesConfig.DNSServiceIP = networkProfile.DNSServiceIP
|
|
|
|
} else {
|
|
|
|
kubernetesConfig.DNSServiceIP = DefaultKubernetesDNSServiceIP
|
|
|
|
}
|
|
|
|
|
|
|
|
if networkProfile.DockerBridgeCidr != "" {
|
|
|
|
kubernetesConfig.DockerBridgeSubnet = networkProfile.DockerBridgeCidr
|
|
|
|
} else {
|
|
|
|
kubernetesConfig.DockerBridgeSubnet = DefaultDockerBridgeSubnet
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// set network default for un-versioned model
|
2018-05-03 01:50:42 +03:00
|
|
|
kubernetesConfig.NetworkPlugin = string(v20180331.Kubenet)
|
2018-04-26 03:15:40 +03:00
|
|
|
kubernetesConfig.ClusterSubnet = DefaultKubernetesClusterSubnet
|
2018-04-17 02:52:48 +03:00
|
|
|
kubernetesConfig.ServiceCIDR = DefaultKubernetesServiceCIDR
|
|
|
|
kubernetesConfig.DNSServiceIP = DefaultKubernetesDNSServiceIP
|
|
|
|
kubernetesConfig.DockerBridgeSubnet = DefaultDockerBridgeSubnet
|
2018-04-13 01:35:33 +03:00
|
|
|
}
|
|
|
|
|
2018-03-14 19:18:46 +03:00
|
|
|
return &OrchestratorProfile{
|
|
|
|
OrchestratorType: Kubernetes,
|
2018-05-30 01:35:34 +03:00
|
|
|
OrchestratorVersion: common.GetSupportedKubernetesVersion(kubernetesVersion, false),
|
2018-04-13 01:35:33 +03:00
|
|
|
KubernetesConfig: kubernetesConfig,
|
2018-03-14 19:18:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-19 02:18:45 +03:00
|
|
|
func convertV20180331AgentPoolOnlyAgentPoolProfile(agentPoolProfile *v20180331.AgentPoolProfile, availabilityProfile string, networkProfile *v20180331.NetworkProfile) *AgentPoolProfile {
|
2018-03-14 19:18:46 +03:00
|
|
|
api := &AgentPoolProfile{}
|
2018-04-19 02:18:45 +03:00
|
|
|
api.Name = agentPoolProfile.Name
|
|
|
|
api.Count = agentPoolProfile.Count
|
|
|
|
api.VMSize = agentPoolProfile.VMSize
|
|
|
|
api.OSDiskSizeGB = agentPoolProfile.OSDiskSizeGB
|
|
|
|
api.OSType = OSType(agentPoolProfile.OSType)
|
|
|
|
api.StorageProfile = agentPoolProfile.StorageProfile
|
|
|
|
api.VnetSubnetID = agentPoolProfile.VnetSubnetID
|
|
|
|
var maxPods string
|
|
|
|
// agentPoolProfile.MaxPods is 0 if maxPods field is not provided in API model
|
|
|
|
if agentPoolProfile.MaxPods == nil {
|
2018-07-25 20:27:58 +03:00
|
|
|
if networkProfile != nil && networkProfile.NetworkPlugin == v20180331.Azure {
|
2018-04-19 02:18:45 +03:00
|
|
|
maxPods = DefaultKubernetesMaxPodsAzureCNI
|
2018-07-25 20:27:58 +03:00
|
|
|
} else {
|
|
|
|
maxPods = DefaultKubernetesMaxPodsKubenet
|
2018-04-19 02:18:45 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
maxPods = strconv.Itoa(*agentPoolProfile.MaxPods)
|
|
|
|
}
|
2018-04-13 01:35:33 +03:00
|
|
|
kubernetesConfig := &KubernetesConfig{
|
2018-04-19 02:18:45 +03:00
|
|
|
KubeletConfig: map[string]string{"--max-pods": maxPods},
|
2018-04-13 01:35:33 +03:00
|
|
|
}
|
|
|
|
api.KubernetesConfig = kubernetesConfig
|
2018-04-19 02:18:45 +03:00
|
|
|
api.Subnet = agentPoolProfile.GetSubnet()
|
2018-03-14 19:18:46 +03:00
|
|
|
api.AvailabilityProfile = availabilityProfile
|
|
|
|
return api
|
|
|
|
}
|
|
|
|
|
|
|
|
func convertV20180331AgentPoolOnlyServicePrincipalProfile(obj *v20180331.ServicePrincipalProfile) *ServicePrincipalProfile {
|
|
|
|
return &ServicePrincipalProfile{
|
|
|
|
ClientID: obj.ClientID,
|
|
|
|
Secret: obj.Secret,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func convertV20180331AgentPoolOnlyAddonProfiles(obj map[string]v20180331.AddonProfile) map[string]AddonProfile {
|
|
|
|
api := make(map[string]AddonProfile)
|
|
|
|
for k, v := range obj {
|
|
|
|
api[k] = AddonProfile{
|
|
|
|
Enabled: v.Enabled,
|
|
|
|
Config: v.Config,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return api
|
|
|
|
}
|
2018-05-15 02:23:42 +03:00
|
|
|
|
|
|
|
func convertV20180331AgentPoolOnlyAADProfile(obj *v20180331.AADProfile) *AADProfile {
|
|
|
|
return &AADProfile{
|
|
|
|
ClientAppID: obj.ClientAppID,
|
|
|
|
ServerAppID: obj.ServerAppID,
|
|
|
|
ServerAppSecret: obj.ServerAppSecret,
|
|
|
|
TenantID: obj.TenantID,
|
|
|
|
Authenticator: Webhook,
|
|
|
|
}
|
|
|
|
}
|