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

Add tls secret option #131

Merged
merged 1 commit into from
Jul 7, 2021
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: 2 additions & 0 deletions api/v1alpha1/nginxingresscontroller_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ type Prometheus struct {
// +kubebuilder:validation:Optional
// +nullable
Port *uint16 `json:"port"`
// Specifies an TLS Secret in the format namespace/name to use to secure the Prometheus endpoint.
Secret string `json:"secret"`
}

// AppProtect support configuration.
Expand Down
7 changes: 7 additions & 0 deletions bundle/manifests/k8s.nginx.org_nginxingresscontrollers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ spec:
minimum: 1023
nullable: true
type: integer
secret:
description: A Secret with a TLS certificate and key for TLS termination
of the Prometheus endpoint. If the argument is set,
but the Ingress controller is not able to fetch the Secret from
Kubernetes API, the Ingress Controller will fail to start. Format
is namespace/name.
type: string
required:
- enable
type: object
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/k8s.nginx.org_nginxingresscontrollers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,13 @@ spec:
minimum: 1023
nullable: true
type: integer
secret:
description: Specifies an TLS Secret in the format namespace/name
to use to secure the Prometheus endpoint.
type: string
required:
- enable
- secret
type: object
replicas:
description: The number of replicas of the Ingress Controller pod.
Expand Down
4 changes: 4 additions & 0 deletions controllers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ func generatePodArgs(instance *k8sv1alpha1.NginxIngressController) []string {
if instance.Spec.EnableLatencyMetrics {
args = append(args, "-enable-latency-metrics")
}

if instance.Spec.Prometheus.Secret != "" {
args = append(args, fmt.Sprintf("-prometheus-tls-secret=%v", instance.Spec.Prometheus.Secret))
}
}

if instance.Spec.EnableCRDs != nil && !*instance.Spec.EnableCRDs {
Expand Down
2 changes: 2 additions & 0 deletions controllers/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ func TestGeneratePodArgs(t *testing.T) {
Prometheus: &k8sv1alpha1.Prometheus{
Enable: true,
Port: &promPort,
Secret: "my-nginx-ingress/prometheus-secret",
},
EnableLatencyMetrics: true,
GlobalConfiguration: "my-nginx-ingress/globalconfiguration",
Expand Down Expand Up @@ -260,6 +261,7 @@ func TestGeneratePodArgs(t *testing.T) {
"-enable-prometheus-metrics",
"-prometheus-metrics-listen-port=9114",
"-enable-latency-metrics",
"-prometheus-tls-secret=my-nginx-ingress/prometheus-secret",
"-enable-custom-resources=false",
"-nginx-reload-timeout=5000",
},
Expand Down
2 changes: 2 additions & 0 deletions docs/nginx-ingress-controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ spec:
prometheus:
enable: true
port: 9114
secret: my-nginx-ingress/prometheus-secret
enableLatencyMetrics: false
configMapData:
error-log-level: debug
Expand Down Expand Up @@ -147,6 +148,7 @@ spec:
| --- | --- | --- | --- |
| `enable` | `boolean` | Enable Prometheus metrics. | Yes |
| `port` | `int` | Sets the port where the Prometheus metrics are exposed. Default is 9113. Format is `1023 - 65535`. | No |
| `secret` | `string` | Sets the namespace/name of a TLS Secret Resource to use to enable TLS for the Prometheus endpoint. | No |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think need to add arg above line 76 too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the example if that's what you mean? I don't see anywhere else to add it

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep that was it

| `enableLatencyMetrics` | `boolean` | Bucketed response times from when NGINX establishes a connection to an upstream server to when the last byte of the response body is received by NGINX. **Note** The metric for the upstream isn't available until traffic is sent to the upstream. Requires prometheus set to true | No |

## NginxIngressController.AppProtect
Expand Down