Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stubbed NginxProxy CRD and watcher #1216

Merged
merged 9 commits into from
Nov 3, 2023
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
68 changes: 68 additions & 0 deletions apis/v1alpha1/nginxproxy_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package v1alpha1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

// +kubebuilder:object:root=true
// +kubebuilder:storageversion
// +kubebuilder:subresource:status

// NginxProxy represents the dynamic configuration for an NGINX Gateway Fabric data plane.
type NginxProxy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// NginxProxySpec defines the desired state of the NginxProxy.
Spec NginxProxySpec `json:"spec"`

// NginxProxyStatus defines the state of the NginxProxy.
Status NginxProxyStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// NginxProxyList contains a list of NginxProxies.
type NginxProxyList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NginxProxy `json:"items"`
}

// NginxProxySpec defines the desired state of the NginxProxy.
type NginxProxySpec struct{}

// NginxProxyStatus defines the state of the NginxProxy.
type NginxProxyStatus struct {
// +optional
// +listType=map
// +listMapKey=type
// +kubebuilder:validation:MaxItems=8
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// NginxProxyConditionType is a type of condition associated with an
// NginxProxy. This type should be used with the NginxProxyStatus.Conditions field.
type NginxProxyConditionType string

// NginxProxyConditionReason defines the set of reasons that explain why a
// particular NginxProxy condition type has been raised.
type NginxProxyConditionReason string

const (
// NginxProxyConditionAccepted is a condition that is true when the NginxProxy
// configuration is syntactically and semantically valid.
NginxProxyConditionAccepted NginxProxyConditionType = "Accepted"

// NginxProxyReasonAccepted is a reason that is used with the "Accepted" condition when the condition is True.
NginxProxyReasonAccepted NginxProxyConditionReason = "Accepted"

// NginxProxyConditionProgrammed is a condition that is true when the NginxProxy has resulted in
// successful nginx configuration.
NginxProxyConditionProgrammed NginxProxyConditionType = "Programmed"

// NginxProxyReasonProgrammed is a reason that is used with the "Programmed" condition when the condition is True.
NginxProxyReasonProgrammed NginxProxyConditionReason = "Programmed"

// NginxProxyReasonInvalid is a reason that is used with the "Accepted" or "Programmed" condition when
// an error occurs with validation or reloading nginx.
NginxProxyReasonInvalid NginxProxyConditionReason = "Invalid"
)
2 changes: 2 additions & 0 deletions apis/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&NginxGateway{},
&NginxGatewayList{},
&NginxProxy{},
&NginxProxyList{},
)
// AddToGroupVersion allows the serialization of client types like ListOptions.
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
Expand Down
96 changes: 96 additions & 0 deletions apis/v1alpha1/zz_generated.deepcopy.go

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

3 changes: 2 additions & 1 deletion deploy/helm-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ To uninstall/delete the release `my-release`:
```shell
helm uninstall my-release -n nginx-gateway
kubectl delete ns nginx-gateway
kubectl delete crd nginxgateways.gateway.nginx.org
kubectl delete crd nginxgateways.gateway.nginx.org nginxproxies.gateway.nginx.org
sjberman marked this conversation as resolved.
Show resolved Hide resolved
```

These commands remove all the Kubernetes components associated with the release and deletes the release.
Expand Down Expand Up @@ -225,6 +225,7 @@ The following tables lists the configurable parameters of the NGINX Gateway Fabr
| `nginx.image.repository` | The repository for the NGINX image. | ghcr.io/nginxinc/nginx-gateway-fabric/nginx |
| `nginx.image.tag` | The tag for the NGINX image. | edge |
| `nginx.image.pullPolicy` | The `imagePullPolicy` for the NGINX image. | Always |
| `nginx.config` | The configuration for the data plane that is contained in the NginxProxy resource. | [See nginx.config section](values.yaml) |
| `nginx.lifecycle` | The `lifecycle` of the nginx container. | {} |
| `nginx.extraVolumeMounts` | Extra `volumeMounts` for the nginx container. | {} |
| `terminationGracePeriodSeconds` | The termination grace period of the NGINX Gateway Fabric pod. | 30 |
Expand Down
120 changes: 120 additions & 0 deletions deploy/helm-chart/crds/gateway.nginx.org_nginxproxies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
name: nginxproxies.gateway.nginx.org
spec:
group: gateway.nginx.org
names:
kind: NginxProxy
listKind: NginxProxyList
plural: nginxproxies
singular: nginxproxy
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: NginxProxy represents the dynamic configuration for an NGINX
Gateway Fabric data plane.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: NginxProxySpec defines the desired state of the NginxProxy.
type: object
status:
description: NginxProxyStatus defines the state of the NginxProxy.
properties:
conditions:
items:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
use as an array at the field path .status.conditions. For example,
\n type FooStatus struct{ // Represents the observations of a
foo's current state. // Known .status.conditions.type are: \"Available\",
\"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge
// +listType=map // +listMapKey=type Conditions []metav1.Condition
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"
protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition
transitioned from one status to another. This should be when
the underlying condition changed. If that is not known, then
using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: message is a human readable message indicating
details about the transition. This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: observedGeneration represents the .metadata.generation
that the condition was set based upon. For instance, if .metadata.generation
is currently 12, but the .status.conditions[x].observedGeneration
is 9, the condition is out of date with respect to the current
state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: reason contains a programmatic identifier indicating
the reason for the condition's last transition. Producers
of specific condition types may define expected values and
meanings for this field, and whether the values are considered
a guaranteed API. The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase.
--- Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
maxItems: 8
type: array
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
8 changes: 8 additions & 0 deletions deploy/helm-chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ Create control plane config name.
{{- printf "%s-config" $name | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create data plane config name.
*/}}
{{- define "nginx-gateway.proxy-config-name" -}}
{{- $name := default .Release.Name .Values.nameOverride }}
{{- printf "%s-proxy-config" $name | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
Expand Down
5 changes: 5 additions & 0 deletions deploy/helm-chart/templates/gatewayclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ metadata:
{{- include "nginx-gateway.labels" . | nindent 4 }}
spec:
controllerName: {{ .Values.nginxGateway.gatewayControllerName }}
parametersRef:
group: gateway.nginx.org
kind: NginxProxy
name: {{ include "nginx-gateway.proxy-config-name" . }}
namespace: {{ .Release.Namespace }}
9 changes: 9 additions & 0 deletions deploy/helm-chart/templates/nginxproxy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: gateway.nginx.org/v1alpha1
kind: NginxProxy
metadata:
name: {{ include "nginx-gateway.proxy-config-name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "nginx-gateway.labels" . | nindent 4 }}
spec:
{{- toYaml .Values.nginx.config | nindent 2 }}
2 changes: 2 additions & 0 deletions deploy/helm-chart/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ rules:
- gateway.nginx.org
resources:
- nginxgateways
- nginxproxies
verbs:
- get
- list
Expand All @@ -68,6 +69,7 @@ rules:
- gateway.nginx.org
resources:
- nginxgateways/status
- nginxproxies/status
verbs:
- update
{{- if .Values.nginxGateway.leaderElection.enable }}
Expand Down
3 changes: 3 additions & 0 deletions deploy/helm-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ nginx:
tag: edge
pullPolicy: Always

## The configuration for the data plane that is contained in the NginxProxy resource.
config: {}

## The lifecycle of the nginx container.
lifecycle: {}

Expand Down
Loading
Loading