Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .sha256sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
d2e11a7924d0cbb70672fb0dd6b1a387ccaec8b97a6968adf5a1516d325374eb swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2020-04-30/redhatopenshift.json
bbdf867021e306b60677d1d6840e5059fe92f058f09e861a10e7c000d36868f9 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2021-01-31-preview/redhatopenshift.json
6c79802ca5f49f0ef49d5d12d0bc424657569dd00428db1af51bd82fcc948f70 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2021-01-31-preview/redhatopenshift.json
11 changes: 11 additions & 0 deletions pkg/api/admin/openshiftcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,19 @@ type ServicePrincipalProfile struct {
SPObjectID string `json:"spObjectId,omitempty"`
}

// SDNProvider constants.
type SDNProvider string

const (
SDNProviderOVNKubernetes SDNProvider = "OVNKubernetes"
SDNProviderOpenShiftSDN SDNProvider = "OpenShiftSDN"
)

// NetworkProfile represents a network profile.
type NetworkProfile struct {
// The SDNProvider to use when installing the cluster.
SDNProvider SDNProvider `json:"sdnProvider,omitempty"`

PodCIDR string `json:"podCidr,omitempty"`
ServiceCIDR string `json:"serviceCidr,omitempty"`

Expand Down
2 changes: 2 additions & 0 deletions pkg/api/admin/openshiftcluster_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfa
SPObjectID: oc.Properties.ServicePrincipalProfile.SPObjectID,
},
NetworkProfile: NetworkProfile{
SDNProvider: SDNProvider(oc.Properties.NetworkProfile.SDNProvider),
PodCIDR: oc.Properties.NetworkProfile.PodCIDR,
ServiceCIDR: oc.Properties.NetworkProfile.ServiceCIDR,
APIServerPrivateEndpointIP: oc.Properties.NetworkProfile.APIServerPrivateEndpointIP,
Expand Down Expand Up @@ -171,6 +172,7 @@ func (c *openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShi
out.Properties.ServicePrincipalProfile.SPObjectID = oc.Properties.ServicePrincipalProfile.SPObjectID
out.Properties.NetworkProfile.PodCIDR = oc.Properties.NetworkProfile.PodCIDR
out.Properties.NetworkProfile.ServiceCIDR = oc.Properties.NetworkProfile.ServiceCIDR
out.Properties.NetworkProfile.SDNProvider = api.SDNProvider(oc.Properties.NetworkProfile.SDNProvider)
out.Properties.NetworkProfile.APIServerPrivateEndpointIP = oc.Properties.NetworkProfile.APIServerPrivateEndpointIP
out.Properties.MasterProfile.VMSize = api.VMSize(oc.Properties.MasterProfile.VMSize)
out.Properties.MasterProfile.SubnetID = oc.Properties.MasterProfile.SubnetID
Expand Down
14 changes: 14 additions & 0 deletions pkg/api/admin/openshiftcluster_validatestatic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,20 @@ func TestOpenShiftClusterStaticValidateDelta(t *testing.T) {
},
wantErr: "400: PropertyChangeNotAllowed: properties.servicePrincipalProfile.spObjectId: Changing property 'properties.servicePrincipalProfile.spObjectId' is not allowed.",
},
{
name: "sdnProvider change is not allowed",
oc: func() *OpenShiftCluster {
return &OpenShiftCluster{
Properties: OpenShiftClusterProperties{
NetworkProfile: NetworkProfile{
SDNProvider: SDNProviderOVNKubernetes,
},
},
}
},
modify: func(oc *OpenShiftCluster) { oc.Properties.NetworkProfile.SDNProvider = "anything" },
wantErr: "400: PropertyChangeNotAllowed: properties.networkProfile.sdnProvider: Changing property 'properties.networkProfile.sdnProvider' is not allowed.",
},
{
name: "podCidr change is not allowed",
oc: func() *OpenShiftCluster {
Expand Down
13 changes: 11 additions & 2 deletions pkg/api/openshiftcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,21 @@ type ServicePrincipalProfile struct {
SPObjectID string `json:"spObjectId,omitempty"`
}

// SDNProvider
type SDNProvider string

const (
SDNProviderOVNKubernetes SDNProvider = "OVNKubernetes"
SDNProviderOpenShiftSDN SDNProvider = "OpenShiftSDN"
)

// NetworkProfile represents a network profile
type NetworkProfile struct {
MissingFields

PodCIDR string `json:"podCidr,omitempty"`
ServiceCIDR string `json:"serviceCidr,omitempty"`
PodCIDR string `json:"podCidr,omitempty"`
ServiceCIDR string `json:"serviceCidr,omitempty"`
SDNProvider SDNProvider `json:"sdnProvider,omitempty"`

APIServerPrivateEndpointIP string `json:"privateEndpointIp,omitempty"`
}
Expand Down
11 changes: 11 additions & 0 deletions pkg/api/v20210131preview/openshiftcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,19 @@ type ServicePrincipalProfile struct {
ClientSecret string `json:"clientSecret,omitempty" mutable:"true"`
}

// SDNProvider constants.
type SDNProvider string

const (
SDNProviderOVNKubernetes SDNProvider = "OVNKubernetes"
SDNProviderOpenShiftSDN SDNProvider = "OpenShiftSDN"
)

// NetworkProfile represents a network profile.
type NetworkProfile struct {
// The SDNProvider to use when installing the cluster.
SDNProvider SDNProvider `json:"sdnProvider,omitempty"`

// The CIDR used for OpenShift/Kubernetes Pods.
PodCIDR string `json:"podCidr,omitempty"`

Expand Down
2 changes: 2 additions & 0 deletions pkg/api/v20210131preview/openshiftcluster_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfa
NetworkProfile: NetworkProfile{
PodCIDR: oc.Properties.NetworkProfile.PodCIDR,
ServiceCIDR: oc.Properties.NetworkProfile.ServiceCIDR,
SDNProvider: SDNProvider(oc.Properties.NetworkProfile.SDNProvider),
},
MasterProfile: MasterProfile{
VMSize: VMSize(oc.Properties.MasterProfile.VMSize),
Expand Down Expand Up @@ -140,6 +141,7 @@ func (c *openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShi
out.Properties.ServicePrincipalProfile.ClientSecret = api.SecureString(oc.Properties.ServicePrincipalProfile.ClientSecret)
out.Properties.NetworkProfile.PodCIDR = oc.Properties.NetworkProfile.PodCIDR
out.Properties.NetworkProfile.ServiceCIDR = oc.Properties.NetworkProfile.ServiceCIDR
out.Properties.NetworkProfile.SDNProvider = api.SDNProvider(oc.Properties.NetworkProfile.SDNProvider)
out.Properties.MasterProfile.VMSize = api.VMSize(oc.Properties.MasterProfile.VMSize)
out.Properties.MasterProfile.SubnetID = oc.Properties.MasterProfile.SubnetID
out.Properties.MasterProfile.EncryptionAtHost = oc.Properties.MasterProfile.EncryptionAtHost
Expand Down
6 changes: 6 additions & 0 deletions pkg/api/v20210131preview/openshiftcluster_validatestatic.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ func (sv *openShiftClusterStaticValidator) validateNetworkProfile(path string, n
}
}

switch np.SDNProvider {
case SDNProviderOVNKubernetes, SDNProviderOpenShiftSDN:
default:
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".sdnProvider", "The provided SDNProvider '%s' is invalid.", np.SDNProvider)
}

return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func validOpenShiftCluster() *OpenShiftCluster {
NetworkProfile: NetworkProfile{
PodCIDR: "10.128.0.0/14",
ServiceCIDR: "172.30.0.0/16",
SDNProvider: SDNProviderOVNKubernetes,
},
MasterProfile: MasterProfile{
VMSize: VMSizeStandardD8sV3,
Expand Down Expand Up @@ -410,7 +411,16 @@ func TestOpenShiftClusterStaticValidateServicePrincipalProfile(t *testing.T) {
}

func TestOpenShiftClusterStaticValidateNetworkProfile(t *testing.T) {
tests := []*validateTest{
createtests := []*validateTest{
{
name: "sdnProvider create as OpenShiftSDN",
modify: func(oc *OpenShiftCluster) {
oc.Properties.NetworkProfile.SDNProvider = SDNProviderOpenShiftSDN
},
},
}

commontests := []*validateTest{
{
name: "valid",
},
Expand Down Expand Up @@ -456,10 +466,25 @@ func TestOpenShiftClusterStaticValidateNetworkProfile(t *testing.T) {
},
wantErr: "400: InvalidParameter: properties.networkProfile.serviceCidr: The provided vnet CIDR '10.0.0.0/23' is invalid: must be /22 or larger.",
},
{
name: "sdnProvider given as empty",
modify: func(oc *OpenShiftCluster) {
oc.Properties.NetworkProfile.SDNProvider = ""
},
wantErr: "400: InvalidParameter: properties.networkProfile.sdnProvider: The provided SDNProvider '' is invalid.",
},
{
name: "sdnProvider given InvalidOption",
modify: func(oc *OpenShiftCluster) {
oc.Properties.NetworkProfile.SDNProvider = "InvalidOption"
},
wantErr: "400: InvalidParameter: properties.networkProfile.sdnProvider: The provided SDNProvider 'InvalidOption' is invalid.",
},
}

runTests(t, testModeCreate, tests)
runTests(t, testModeUpdate, tests)
runTests(t, testModeCreate, commontests)
runTests(t, testModeUpdate, commontests)
runTests(t, testModeCreate, createtests)
}

func TestOpenShiftClusterStaticValidateMasterProfile(t *testing.T) {
Expand Down Expand Up @@ -809,6 +834,11 @@ func TestOpenShiftClusterStaticValidateDelta(t *testing.T) {
name: "clientSecret change",
modify: func(oc *OpenShiftCluster) { oc.Properties.ServicePrincipalProfile.ClientSecret = "invalid" },
},
{
name: "sdnProvider should fail to change from OVNKubernetes to OpenShiftSDN",
modify: func(oc *OpenShiftCluster) { oc.Properties.NetworkProfile.SDNProvider = SDNProviderOpenShiftSDN },
wantErr: "400: PropertyChangeNotAllowed: properties.networkProfile.sdnProvider: Changing property 'properties.networkProfile.sdnProvider' is not allowed.",
},
{
name: "podCidr change",
modify: func(oc *OpenShiftCluster) { oc.Properties.NetworkProfile.PodCIDR = "0.0.0.0/0" },
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion pkg/cluster/generateconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ func (m *manager) generateInstallConfig(ctx context.Context) (*installconfig.Ins
workerZones = []string{""}
}

SDNProvider := string(api.SDNProviderOpenShiftSDN)
if m.doc.OpenShiftCluster.Properties.NetworkProfile.SDNProvider != "" {
SDNProvider = string(m.doc.OpenShiftCluster.Properties.NetworkProfile.SDNProvider)
}

installConfig := &installconfig.InstallConfig{
Config: &types.InstallConfig{
TypeMeta: metav1.TypeMeta{
Expand All @@ -116,7 +121,7 @@ func (m *manager) generateInstallConfig(ctx context.Context) (*installconfig.Ins
CIDR: *ipnet.MustParseCIDR("127.0.0.0/8"), // dummy
},
},
NetworkType: "OpenShiftSDN",
NetworkType: SDNProvider,
ClusterNetwork: []types.ClusterNetworkEntry{
{
CIDR: *ipnet.MustParseCIDR(m.doc.OpenShiftCluster.Properties.NetworkProfile.PodCIDR),
Expand Down
1 change: 1 addition & 0 deletions pkg/util/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ func (c *Cluster) createCluster(ctx context.Context, vnetResourceGroup, clusterN
NetworkProfile: api.NetworkProfile{
PodCIDR: "10.128.0.0/14",
ServiceCIDR: "172.30.0.0/16",
SDNProvider: api.SDNProviderOVNKubernetes,
},
MasterProfile: api.MasterProfile{
VMSize: api.VMSizeStandardD8sV3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
from ._paged_models import OperationPaged
from ._azure_red_hat_open_shift_client_enums import (
VMSize,
SDNProvider,
CreatedByType,
)

Expand Down Expand Up @@ -95,5 +96,6 @@
'OperationPaged',
'OpenShiftClusterPaged',
'VMSize',
'SDNProvider',
'CreatedByType',
]
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ class VMSize(str, Enum):
standard_m128ms = "Standard_M128ms"


class SDNProvider(str, Enum):

ovn_kubernetes = "OVNKubernetes"
open_shift_sdn = "OpenShiftSDN"


class CreatedByType(str, Enum):

user = "User"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,19 +325,25 @@ def __init__(self, **kwargs):
class NetworkProfile(Model):
"""NetworkProfile represents a network profile.

:param sdn_provider: The SDNProvider to use when installing the cluster.
Possible values include: 'OVNKubernetes', 'OpenShiftSDN'
:type sdn_provider: str or
~azure.mgmt.redhatopenshift.v2021_01_31_preview.models.SDNProvider
:param pod_cidr: The CIDR used for OpenShift/Kubernetes Pods.
:type pod_cidr: str
:param service_cidr: The CIDR used for OpenShift/Kubernetes Services.
:type service_cidr: str
"""

_attribute_map = {
'sdn_provider': {'key': 'sdnProvider', 'type': 'str'},
'pod_cidr': {'key': 'podCidr', 'type': 'str'},
'service_cidr': {'key': 'serviceCidr', 'type': 'str'},
}

def __init__(self, **kwargs):
super(NetworkProfile, self).__init__(**kwargs)
self.sdn_provider = kwargs.get('sdn_provider', None)
self.pod_cidr = kwargs.get('pod_cidr', None)
self.service_cidr = kwargs.get('service_cidr', None)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,19 +325,25 @@ def __init__(self, *, vm_size=None, subnet_id: str=None, encryption_at_host: boo
class NetworkProfile(Model):
"""NetworkProfile represents a network profile.

:param sdn_provider: The SDNProvider to use when installing the cluster.
Possible values include: 'OVNKubernetes', 'OpenShiftSDN'
:type sdn_provider: str or
~azure.mgmt.redhatopenshift.v2021_01_31_preview.models.SDNProvider
:param pod_cidr: The CIDR used for OpenShift/Kubernetes Pods.
:type pod_cidr: str
:param service_cidr: The CIDR used for OpenShift/Kubernetes Services.
:type service_cidr: str
"""

_attribute_map = {
'sdn_provider': {'key': 'sdnProvider', 'type': 'str'},
'pod_cidr': {'key': 'podCidr', 'type': 'str'},
'service_cidr': {'key': 'serviceCidr', 'type': 'str'},
}

def __init__(self, *, pod_cidr: str=None, service_cidr: str=None, **kwargs) -> None:
def __init__(self, *, sdn_provider=None, pod_cidr: str=None, service_cidr: str=None, **kwargs) -> None:
super(NetworkProfile, self).__init__(**kwargs)
self.sdn_provider = sdn_provider
self.pod_cidr = pod_cidr
self.service_cidr = service_cidr

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,10 @@
"NetworkProfile": {
"description": "NetworkProfile represents a network profile.",
"properties": {
"sdnProvider": {
"$ref": "#/definitions/SDNProvider",
"description": "The SDNProvider to use when installing the cluster."
},
"podCidr": {
"description": "The CIDR used for OpenShift/Kubernetes Pods.",
"type": "string"
Expand Down Expand Up @@ -768,6 +772,18 @@
],
"type": "string"
},
"SDNProvider": {
"description": "SDNProvider constants.",
"enum": [
"OVNKubernetes",
"OpenShiftSDN"
],
"type": "string",
"x-ms-enum": {
"name": "SDNProvider",
"modelAsString": true
}
},
"ServicePrincipalProfile": {
"description": "ServicePrincipalProfile represents a service principal profile.",
"properties": {
Expand Down