-
Notifications
You must be signed in to change notification settings - Fork 130
feat: Add ability to patch dataplane Service, Deployment, and DaemonSet in NginxProxy #3630
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package v1alpha2 | |
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/nginx/nginx-gateway-fabric/apis/v1alpha1" | ||
|
@@ -388,6 +389,35 @@ type KubernetesSpec struct { | |
Service *ServiceSpec `json:"service,omitempty"` | ||
} | ||
|
||
// Patch defines a patch to apply to a Kubernetes object. | ||
type Patch struct { | ||
// Type is the type of patch. Defaults to StrategicMerge. | ||
// | ||
// +optional | ||
// +kubebuilder:default:=StrategicMerge | ||
Type *PatchType `json:"type,omitempty"` | ||
|
||
// Value is the patch data as raw JSON. | ||
// For StrategicMerge and Merge patches, this should be a JSON object. | ||
// For JSONPatch patches, this should be a JSON array of patch operations. | ||
// | ||
// +kubebuilder:validation:XPreserveUnknownFields | ||
Value *apiextv1.JSON `json:"value"` | ||
} | ||
|
||
// PatchType specifies the type of patch. | ||
// +kubebuilder:validation:Enum=StrategicMerge;Merge;JSONPatch | ||
type PatchType string | ||
|
||
const ( | ||
// PatchTypeStrategicMerge uses strategic merge patch. | ||
PatchTypeStrategicMerge PatchType = "StrategicMerge" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does k8s define these types at all? If so, it'd be nice to alias our types to theirs, instead of using the string literal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see there are some definitions here: https://github.com/kubernetes/apimachinery/blob/1ebcba2516a6683ca3be753b0b7e2cb203daf5dd/pkg/types/patch.go#L22 Which are used in the apiextentions-apiserver test code here: https://github.com/kubernetes/apiextensions-apiserver/blob/9fbc252b2071ab031a4011dd3d07fde4e281fe3c/test/integration/scope_test.go#L132-L138 |
||
// PatchTypeMerge uses merge patch (RFC 7386). | ||
PatchTypeMerge PatchType = "Merge" | ||
// PatchTypeJSONPatch uses JSON patch (RFC 6902). | ||
PatchTypeJSONPatch PatchType = "JSONPatch" | ||
) | ||
|
||
// Deployment is the configuration for the NGINX Deployment. | ||
type DeploymentSpec struct { | ||
// Number of desired Pods. | ||
|
@@ -404,6 +434,11 @@ type DeploymentSpec struct { | |
// | ||
// +optional | ||
Container ContainerSpec `json:"container"` | ||
|
||
// Patches are custom patches to apply to the NGINX Deployment. | ||
// | ||
// +optional | ||
Patches []Patch `json:"patches,omitempty"` | ||
} | ||
|
||
// DaemonSet is the configuration for the NGINX DaemonSet. | ||
|
@@ -417,6 +452,11 @@ type DaemonSetSpec struct { | |
// | ||
// +optional | ||
Container ContainerSpec `json:"container"` | ||
|
||
// Patches are custom patches to apply to the NGINX DaemonSet. | ||
// | ||
// +optional | ||
Patches []Patch `json:"patches,omitempty"` | ||
} | ||
|
||
// PodSpec defines Pod-specific fields. | ||
|
@@ -569,6 +609,11 @@ type ServiceSpec struct { | |
// | ||
// +optional | ||
NodePorts []NodePort `json:"nodePorts,omitempty"` | ||
|
||
// Patches are custom patches to apply to the NGINX Service. | ||
// | ||
// +optional | ||
Patches []Patch `json:"patches,omitempty"` | ||
} | ||
|
||
// ServiceType describes ingress method for the Service. | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this field be marked as optional?