Skip to content
This repository was archived by the owner on May 24, 2023. It is now read-only.

Commit 8238e10

Browse files
committed
Add IngressLink support
1 parent 6465221 commit 8238e10

File tree

8 files changed

+108
-24
lines changed

8 files changed

+108
-24
lines changed

deploy/crds/k8s.nginx.org_nginxingresscontrollers_crd.yaml

+18-7
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ spec:
8484
description: Enable TLS Passthrough on port 443. Requires enableCRDs
8585
set to true.
8686
type: boolean
87-
extraLabels:
88-
additionalProperties:
89-
type: string
90-
description: Specifies extra labels of the service.
91-
type: object
9287
globalConfiguration:
9388
description: The GlobalConfiguration resource for global configuration
9489
of the Ingress Controller. Format is namespace/name. Requires enableCRDs
@@ -212,12 +207,28 @@ spec:
212207
description: 'Specifies the name of the service with the type LoadBalancer
213208
through which the Ingress controller pods are exposed externally.
214209
The external address of the service is used when reporting the
215-
status of Ingress resources. Note: Only if ServiceType is different
216-
than LoadBalancer.'
210+
status of Ingress resources. Note: Only if serviceType is NodePort.'
211+
type: string
212+
ingressLink:
213+
description: 'Specifies the name of the IngressLink resource, which
214+
exposes the Ingress Controller pods via a BIG-IP system. The IP
215+
of the BIG-IP system is used when reporting the status of Ingress,
216+
VirtualServer and VirtualServerRoute resources. Requires reportIngressStatus.enable
217+
set to true. Note: Only if serviceType is NodePort and reportIngressStatus.externalService
218+
is not set.'
217219
type: string
218220
required:
219221
- enable
220222
type: object
223+
service:
224+
description: The service of the Ingress controller.
225+
properties:
226+
extraLabels:
227+
additionalProperties:
228+
type: string
229+
description: Specifies extra labels of the service.
230+
type: object
231+
type: object
221232
serviceType:
222233
description: 'The type of the Service for the Ingress Controller. Valid
223234
Service types are: NodePort and LoadBalancer.'

docs/nginx-ingress-controller.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ spec:
8585
| `enableCRDs` | `boolean` | Enables the use of NGINX Ingress Resource Definitions (VirtualServer and VirtualServerRoute). | No |
8686
| `enableSnippets` | `boolean` | Enable custom NGINX configuration snippets in VirtualServer and VirtualServerRoute resources. Requires enableCRDs set to true. | No |
8787
| `ingressClass` | `string` | A class of the Ingress controller. For Kubernetes >= 1.18, the Ingress controller only processes resources that belong to its class - i.e. have the "ingressClassName" field resource equal to the class. Additionally the Ingress Controller processes all the VirtualServer/VirtualServerRoute resources that do not have the "ingressClassName" field. For Kubernetes < 1.18, the Ingress Controller only processes resources that belong to its class - i.e have the annotation "kubernetes.io/ingress.class" (for Ingress resources) or field "ingressClassName" (for VirtualServer/VirtualServerRoute resources) equal to the class. Additionally, the Ingress Controller processes resources that do not have the class set, which can be disabled by setting `useIngressClassOnly` to `true`. Default is `nginx`. | No |
88+
| `service` | [service](#nginxingresscontrollerservice) | The service of the Ingress Controller. | No |
8889
| `useIngressClassOnly` | `boolean` | Ignore Ingress resources without the `"kubernetes.io/ingress.class"` annotation. For kubernetes versions >= 1.18 this flag will be IGNORED. | No |
8990
| `watchNamespace` | `boolean` | Namespace to watch for Ingress resources. By default the Ingress controller watches all namespaces. | No |
9091
| `healthStatus` | [healthStatus](#nginxingresscontrollerhealthstatus) | Adds a new location to the default server. The location responds with the 200 status code for any request. Useful for external health-checking of the Ingress Controller. | No |
@@ -124,12 +125,19 @@ spec:
124125
| `port` | `int` | Set the port where the NGINX stub_status or the NGINX Plus API is exposed. Default is `8080`. Format is `1023 - 65535` | No |
125126
| `allowCidrs` | `string` | Whitelist IPv4 IP/CIDR blocks to allow access to NGINX stub_status or the NGINX Plus API. Separate multiple IP/CIDR by commas. (default `127.0.0.1`) | No |
126127

128+
## NginxIngressController.Service
129+
130+
| Field | Type | Description | Required |
131+
| --- | --- | --- | --- |
132+
| `extraLabels` | `map[string]string` | Specifies extra labels of the service. | No |
133+
127134
## NginxIngressController.ReportIngressStatus
128135

129136
| Field | Type | Description | Required |
130137
| --- | --- | --- | --- |
131138
| `enable` | `boolean` | Enable reporting of the Ingress status. | Yes |
132-
| `externalService` | `string` | Specifies the name of the service with the type LoadBalancer through which the Ingress controller pods are exposed externally. The external address of the service is used when reporting the status of Ingress resources. Note: Only if ServiceType is different than LoadBalancer. | No |
139+
| `externalService` | `string` | Specifies the name of the service with the type LoadBalancer through which the Ingress controller pods are exposed externally. The external address of the service is used when reporting the status of Ingress resources. Note: Only if ServiceType is `NodePort`. | No |
140+
| `ingressLink` | `string` | Specifies the name of the IngressLink resource, which exposes the Ingress Controller pods via a BIG-IP system. The IP of the BIG-IP system is used when reporting the status of Ingress, VirtualServer and VirtualServerRoute resources. Requires `reportIngressStatus.enable` set to `true`. Note: Only if ServiceType is `NodePort` and externalService is not set. | No |
133141

134142
## NginxIngressController.Prometheus
135143

pkg/apis/k8s/v1alpha1/nginxingresscontroller_types.go

+18-5
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,17 @@ type NginxIngressControllerSpec struct {
4545
// +kubebuilder:validation:Optional
4646
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
4747
EnablePreviewPolicies bool `json:"enablePreviewPolicies"`
48-
// +kubebuilder:validation:Optional
4948
// A class of the Ingress controller. The Ingress controller only processes Ingress resources that belong to its
5049
// class (in other words, have the annotation “kubernetes.io/ingress.class”).
5150
// Additionally, the Ingress controller processes Ingress resources that do not have that annotation,
5251
// which can be disabled by setting UseIngressClassOnly to true. Default is `nginx`.
5352
// +kubebuilder:validation:Optional
5453
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
5554
IngressClass string `json:"ingressClass"`
56-
// Specifies extra labels of the service.
55+
// The service of the Ingress controller.
5756
// +kubebuilder:validation:Optional
5857
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
59-
ExtraLabels map[string]string `json:"extraLabels,omitempty"`
58+
Service *Service `json:"service"`
6059
// Ignore Ingress resources without the “kubernetes.io/ingress.class” annotation.
6160
// +kubebuilder:validation:Optional
6261
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
@@ -189,9 +188,16 @@ type ReportIngressStatus struct {
189188
Enable bool `json:"enable"`
190189
// Specifies the name of the service with the type LoadBalancer through which the Ingress controller pods are exposed externally.
191190
// The external address of the service is used when reporting the status of Ingress resources.
192-
// Note: Only if ServiceType is different than LoadBalancer.
191+
// Note: Only if serviceType is NodePort.
193192
// +kubebuilder:validation:Optional
194193
ExternalService string `json:"externalService"`
194+
// Specifies the name of the IngressLink resource, which exposes the Ingress Controller pods via a BIG-IP system.
195+
// The IP of the BIG-IP system is used when reporting the status of Ingress, VirtualServer and VirtualServerRoute resources.
196+
// Requires reportIngressStatus.enable set to true.
197+
// Note: Only if serviceType is NodePort and reportIngressStatus.externalService is not set.
198+
// +kubebuilder:validation:Optional
199+
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
200+
IngressLink string `json:"ingressLink,omitempty"`
195201
}
196202

197203
// Prometheus defines the Prometheus metrics for the Ingress Controller.
@@ -207,12 +213,19 @@ type Prometheus struct {
207213
Port *uint16 `json:"port"`
208214
}
209215

210-
// App Protect support configuration.
216+
// AppProtect support configuration.
211217
type AppProtect struct {
212218
// Enable App Protect.
213219
Enable bool `json:"enable"`
214220
}
215221

222+
// Service defines the Service for the Ingress Controller.
223+
type Service struct {
224+
// Specifies extra labels of the service.
225+
// +kubebuilder:validation:Optional
226+
ExtraLabels map[string]string `json:"extraLabels,omitempty"`
227+
}
228+
216229
// NginxIngressControllerStatus defines the observed state of NginxIngressController
217230
type NginxIngressControllerStatus struct {
218231
// Deployed is true if the Operator has finished the deployment of the NginxIngressController.

pkg/apis/k8s/v1alpha1/zz_generated.deepcopy.go

+27-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/controller/nginxingresscontroller/service.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func serviceForNginxIngressController(instance *k8sv1alpha1.NginxIngressControll
1212
ObjectMeta: v1.ObjectMeta{
1313
Name: instance.Name,
1414
Namespace: instance.Namespace,
15-
Labels: instance.Spec.ExtraLabels,
15+
Labels: instance.Spec.Service.ExtraLabels,
1616
},
1717
Spec: corev1.ServiceSpec{
1818
Ports: []corev1.ServicePort{

pkg/controller/nginxingresscontroller/service_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ func TestServiceForNginxIngressController(t *testing.T) {
2424
},
2525
Spec: k8sv1alpha1.NginxIngressControllerSpec{
2626
ServiceType: serviceType,
27-
ExtraLabels: extraLabels,
27+
Service: &k8sv1alpha1.Service{
28+
ExtraLabels: extraLabels,
29+
},
2830
},
2931
}
3032
expected := &corev1.Service{

pkg/controller/nginxingresscontroller/utils.go

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ func generatePodArgs(instance *k8sv1alpha1.NginxIngressController) []string {
9090
args = append(args, fmt.Sprintf("-external-service=%v", instance.Spec.ReportIngressStatus.ExternalService))
9191
} else if instance.Spec.ServiceType == "LoadBalancer" {
9292
args = append(args, fmt.Sprintf("-external-service=%v", instance.Name))
93+
} else if instance.Spec.ReportIngressStatus.IngressLink != "" {
94+
args = append(args, fmt.Sprintf("-ingresslink=%v", instance.Spec.ReportIngressStatus.IngressLink))
9395
}
9496
}
9597

pkg/controller/nginxingresscontroller/utils_test.go

+30-3
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,35 @@ func TestGeneratePodArgs(t *testing.T) {
111111
Namespace: namespace,
112112
},
113113
Spec: k8sv1alpha1.NginxIngressControllerSpec{
114-
DefaultSecret: "my-nginx-ingress/my-secret",
115-
ServiceType: "LoadBalancer",
116-
ReportIngressStatus: &k8sv1alpha1.ReportIngressStatus{Enable: true},
114+
DefaultSecret: "my-nginx-ingress/my-secret",
115+
ServiceType: "NodePort",
116+
ReportIngressStatus: &k8sv1alpha1.ReportIngressStatus{
117+
Enable: true,
118+
IngressLink: "my-ingresslink",
119+
},
120+
},
121+
},
122+
expected: []string{
123+
"-nginx-configmaps=my-nginx-ingress/my-nginx-ingress",
124+
"-default-server-tls-secret=my-nginx-ingress/my-secret",
125+
"-enable-custom-resources=false",
126+
"-report-ingress-status",
127+
"-ingresslink=my-ingresslink",
128+
},
129+
},
130+
{
131+
instance: &k8sv1alpha1.NginxIngressController{
132+
ObjectMeta: metav1.ObjectMeta{
133+
Name: name,
134+
Namespace: namespace,
135+
},
136+
Spec: k8sv1alpha1.NginxIngressControllerSpec{
137+
DefaultSecret: "my-nginx-ingress/my-secret",
138+
ServiceType: "LoadBalancer",
139+
ReportIngressStatus: &k8sv1alpha1.ReportIngressStatus{
140+
Enable: true,
141+
IngressLink: "my-invalid-ingresslink",
142+
},
117143
},
118144
},
119145
expected: []string{
@@ -173,6 +199,7 @@ func TestGeneratePodArgs(t *testing.T) {
173199
ReportIngressStatus: &k8sv1alpha1.ReportIngressStatus{
174200
Enable: true,
175201
ExternalService: "external",
202+
IngressLink: "my-invalid-ingressLink",
176203
},
177204
EnableLeaderElection: true,
178205
WildcardTLS: "my-nginx-ingress/wildcard-secret",

0 commit comments

Comments
 (0)