Skip to content

Commit

Permalink
Implementation for new Ingress API introduced in Single Node + Worker…
Browse files Browse the repository at this point in the history
  • Loading branch information
omertuc committed Mar 29, 2022
1 parent 8107b7a commit 747fe81
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 11 deletions.
7 changes: 7 additions & 0 deletions config/v1/0000_10_config-operator_01_ingress.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,13 @@ spec:
resource:
description: resource of the referent.
type: string
defaultPlacement:
description: "defaultPlacement is set at installation time to control which nodes will host the ingress router pods by default. The options are control-plane nodes or worker nodes. \n This field works by dictating how the Cluster Ingress Operator will consider unset replicas and nodePlacement fields in IngressController resources when creating the corresponding Deployments. \n See the documentation for the IngressController replicas and nodePlacement fields for more information. \n When omitted, the default value is Workers"
type: string
default: Workers
enum:
- ControlPlane
- Workers
served: true
storage: true
subresources:
Expand Down
29 changes: 29 additions & 0 deletions config/v1/types_ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@ type IngressStatus struct {
// hostnames and serving certificates can be customized by the cluster-admin.
// +optional
ComponentRoutes []ComponentRouteStatus `json:"componentRoutes,omitempty"`

// defaultPlacement is set at installation time to control which
// nodes will host the ingress router pods by default. The options are
// control-plane nodes or worker nodes.
//
// This field works by dictating how the Cluster Ingress Operator will
// consider unset replicas and nodePlacement fields in IngressController
// resources when creating the corresponding Deployments.
//
// See the documentation for the IngressController replicas and nodePlacement
// fields for more information.
//
// When omitted, the default value is Workers
//
// +kubebuilder:validation:Enum:="ControlPlane";"Workers"
// +kubebuilder:default:="Workers"
// +optional
DefaultPlacement DefaultPlacement `json:"defaultPlacement"`
}

// ComponentRouteSpec allows for configuration of a route's hostname and serving certificate.
Expand Down Expand Up @@ -222,3 +240,14 @@ type IngressList struct {

Items []Ingress `json:"items"`
}

// DefaultPlacement defines the default placement of ingress router pods.
type DefaultPlacement string

const (
// "Workers" is for having router pods placed on worker nodes by default
DefaultPlacementWorkers DefaultPlacement = "Workers"

// "ControlPlane" is for having router pods placed on control-plane nodes by default
DefaultPlacementControlPlane DefaultPlacement = "ControlPlane"
)
3 changes: 2 additions & 1 deletion config/v1/zz_generated.swagger_doc_generated.go

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

22 changes: 17 additions & 5 deletions operator/v1/0000_50_ingress-operator_00-ingresscontroller.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -806,9 +806,14 @@ spec:
properties:
nodeSelector:
description: "nodeSelector is the node selector applied to ingress
controller deployments. \n If unset, the default is: \n kubernetes.io/os:
linux node-role.kubernetes.io/worker: '' \n If set, the specified
selector is used and replaces the default."
controller deployments. \n If set, the specified selector is
used and replaces the default. \n If unset, the default depends
on the value of the defaultPlacement field in the cluster config.openshift.io/v1/ingresses
status. \n When defaultPlacement is Workers, the default is:
\n kubernetes.io/os: linux node-role.kubernetes.io/worker:
'' \n When defaultPlacement is ControlPlane, the default is:
\n kubernetes.io/os: linux node-role.kubernetes.io/master:
''"
properties:
matchExpressions:
description: matchExpressions is a list of label selector
Expand Down Expand Up @@ -896,8 +901,15 @@ spec:
type: array
type: object
replicas:
description: replicas is the desired number of ingress controller
replicas. If unset, defaults to 2.
description: "replicas is the desired number of ingress controller
replicas. If unset, the default depends on the value of the defaultPlacement
field in the cluster config.openshift.io/v1/ingresses status. \n
The value of replicas is set based on the value of a chosen field
in the Infrastructure CR. If defaultPlacement is set to ControlPlane,
the chosen field will be controlPlaneTopology. If it is set to Workers
the chosen field will be infrastructureTopology. Replicas will then
be set to 1 or 2 based whether the chosen field's value is SingleReplica
or HighlyAvailable, respectively."
format: int32
type: integer
routeAdmission:
Expand Down
22 changes: 19 additions & 3 deletions operator/v1/types_ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ type IngressControllerSpec struct {
HttpErrorCodePages configv1.ConfigMapNameReference `json:"httpErrorCodePages,omitempty"`

// replicas is the desired number of ingress controller replicas. If unset,
// defaults to 2.
// the default depends on the value of the defaultPlacement field in the
// cluster config.openshift.io/v1/ingresses status.
//
// The value of replicas is set based on the value of a chosen field in the
// Infrastructure CR. If defaultPlacement is set to ControlPlane, the
// chosen field will be controlPlaneTopology. If it is set to Workers the
// chosen field will be infrastructureTopology. Replicas will then be set to 1
// or 2 based whether the chosen field's value is SingleReplica or
// HighlyAvailable, respectively.
//
// +optional
Replicas *int32 `json:"replicas,omitempty"`
Expand Down Expand Up @@ -292,12 +300,20 @@ type NodePlacement struct {
// nodeSelector is the node selector applied to ingress controller
// deployments.
//
// If unset, the default is:
// If set, the specified selector is used and replaces the default.
//
// If unset, the default depends on the value of the defaultPlacement
// field in the cluster config.openshift.io/v1/ingresses status.
//
// When defaultPlacement is Workers, the default is:
//
// kubernetes.io/os: linux
// node-role.kubernetes.io/worker: ''
//
// If set, the specified selector is used and replaces the default.
// When defaultPlacement is ControlPlane, the default is:
//
// kubernetes.io/os: linux
// node-role.kubernetes.io/master: ''
//
// +optional
NodeSelector *metav1.LabelSelector `json:"nodeSelector,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions operator/v1/zz_generated.swagger_doc_generated.go

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

0 comments on commit 747fe81

Please sign in to comment.