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

Add enableSnippets cli argument support #11

Merged
merged 1 commit into from
Jul 9, 2020
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
4 changes: 4 additions & 0 deletions deploy/crds/k8s.nginx.org_nginxingresscontrollers_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ spec:
the controller reporting the status of Ingress resources – only
one replica will report status.
type: boolean
enableSnippets:
description: Enable custom NGINX configuration snippets in VirtualServer
and VirtualServerRoute resources. Requires enableCRDs set to true.
type: boolean
enableTLSPassthrough:
description: Enable TLS Passthrough on port 443. Requires enableCRDs
set to true.
Expand Down
6 changes: 4 additions & 2 deletions docs/nginx-ingress-controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ spec:
replicas: 3
serviceType: NodePort
enableCRDs: true
enableSnippets: false
defaultSecret: my-nginx-ingress/default-secret
ingressClass: my-nginx-ingress
useIngressClassOnly: true
Expand Down Expand Up @@ -78,6 +79,7 @@ spec:
| `defaultSecret` | `string` | The TLS Secret for TLS termination of the default server. The format is namespace/name. If not specified, the operator will generate and deploy a TLS Secret with a self-signed certificate and key. | No |
| `serviceType` | `string` | The type of the Service for the Ingress Controller. Valid Service types are `NodePort` or `LoadBalancer`. | Yes |
| `enableCRDs` | `boolean` | Enables the use of NGINX Ingress Resource Definitions (VirtualServer and VirtualServerRoute). | No |
| `enableSnippets` | `boolean` | Enable custom NGINX configuration snippets in VirtualServer and VirtualServerRoute resources. Requires enableCRDs set to true. | No |
| `ingressClass` | `string` | A class of the Ingress controller. The Ingress controller only processes Ingress resources that belong to its class (in other words, have the annotation `kubernetes.io/ingress.class`. Additionally, the Ingress controller processes Ingress resources that do not have that annotation, which can be disabled by setting `useIngressClassOnly` to `true`. Default is `nginx`. | No |
| `useIngressClassOnly` | `boolean` | Ignore Ingress resources without the `kubernetes.io/ingress.class` annotation. | No |
| `watchNamespace` | `boolean` | Namespace to watch for Ingress resources. By default the Ingress controller watches all namespaces. | No |
Expand All @@ -90,8 +92,8 @@ spec:
| `wildcardTLS` | `string` | A Secret with a TLS certificate and key for TLS termination of every Ingress host for which TLS termination is enabled but the Secret is not specified. If the argument is not set, for such Ingress hosts NGINX will break any attempt to establish a TLS connection. 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`. | No |
| `prometheus` | [prometheus](#nginxingresscontrollerprometheus) | Configures NGINX or NGINX Plus metrics in the Prometheus format. | No |
| `configMapData` | `map[string]string` | Initial values of the Ingress Controller ConfigMap. Check the [ConfigMap docs](https://docs.nginx.com/nginx-ingress-controller/configuration/global-configuration/configmap-resource/) for more information about possible values. | No |
| `globalConfiguration` | `string` | The GlobalConfiguration resource for global configuration of the Ingress Controller. Format is namespace/name. Requires enableCRDs set to true. | No |
| `enableTLSPassthrough` | `boolean` | Enable TLS Passthrough on port 443. Requires enableCRDs set to true. | No |
| `globalConfiguration` | `string` | The GlobalConfiguration resource for global configuration of the Ingress Controller. Format is namespace/name. Requires enableCRDs set to true. | No |
| `enableTLSPassthrough` | `boolean` | Enable TLS Passthrough on port 443. Requires enableCRDs set to true. | No |

## NginxIngressController.Image

Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/k8s/v1alpha1/nginxingresscontroller_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ type NginxIngressControllerSpec struct {
// Enables the use of NGINX Ingress Resource Definitions (VirtualServer and VirtualServerRoute).
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
EnableCRDs bool `json:"enableCRDs"`
// Enable custom NGINX configuration snippets in VirtualServer and VirtualServerRoute resources.
// +kubebuilder:validation:Optional
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
EnableSnippets bool `json:"enableSnippets"`
// +kubebuilder:validation:Optional
// A class of the Ingress controller. The Ingress controller only processes Ingress resources that belong to its
// class (in other words, have the annotation “kubernetes.io/ingress.class”).
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/nginxingresscontroller/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ func generatePodArgs(instance *k8sv1alpha1.NginxIngressController) []string {
if instance.Spec.GlobalConfiguration != "" {
args = append(args, fmt.Sprintf("-global-configuration=%v", instance.Spec.GlobalConfiguration))
}

if instance.Spec.EnableSnippets {
args = append(args, "-enable-snippets")
}
}

return args
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/nginxingresscontroller/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func TestGeneratePodArgs(t *testing.T) {
},
Spec: k8sv1alpha1.NginxIngressControllerSpec{
EnableCRDs: true,
EnableSnippets: true,
EnableTLSPassthrough: true,
GlobalConfiguration: "my-nginx-ingress/globalconfiguration",
},
Expand All @@ -140,6 +141,7 @@ func TestGeneratePodArgs(t *testing.T) {
"-default-server-tls-secret=my-nginx-ingress/my-nginx-ingress",
"-enable-tls-passthrough",
"-global-configuration=my-nginx-ingress/globalconfiguration",
"-enable-snippets",
},
},
{
Expand Down Expand Up @@ -177,6 +179,7 @@ func TestGeneratePodArgs(t *testing.T) {
Port: &promPort,
},
GlobalConfiguration: "my-nginx-ingress/globalconfiguration",
EnableSnippets: true,
EnableTLSPassthrough: true,
},
},
Expand Down