|
| 1 | +package v1alpha1 |
| 2 | + |
| 3 | +import ( |
| 4 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 5 | +) |
| 6 | + |
| 7 | +func init() { |
| 8 | + SchemeBuilder.Register(&HTTP01Proxy{}, &HTTP01ProxyList{}) |
| 9 | +} |
| 10 | + |
| 11 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 12 | +// +kubebuilder:object:root=true |
| 13 | + |
| 14 | +// HTTP01ProxyList is a list of HTTP01Proxy objects. |
| 15 | +type HTTP01ProxyList struct { |
| 16 | + metav1.TypeMeta `json:",inline"` |
| 17 | + |
| 18 | + // metadata is the standard list's metadata. |
| 19 | + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata |
| 20 | + metav1.ListMeta `json:"metadata"` |
| 21 | + Items []HTTP01Proxy `json:"items"` |
| 22 | +} |
| 23 | + |
| 24 | +// +genclient |
| 25 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 26 | +// +kubebuilder:object:root=true |
| 27 | +// +kubebuilder:subresource:status |
| 28 | +// +kubebuilder:resource:path=http01proxies,scope=Namespaced,categories={cert-manager-operator},shortName=http01proxy |
| 29 | +// +kubebuilder:printcolumn:name="Mode",type="string",JSONPath=".spec.mode" |
| 30 | +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" |
| 31 | +// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].message" |
| 32 | +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" |
| 33 | +// +kubebuilder:metadata:labels={"app.kubernetes.io/name=http01proxy", "app.kubernetes.io/part-of=cert-manager-operator"} |
| 34 | + |
| 35 | +// HTTP01Proxy describes the configuration for the HTTP01 challenge proxy |
| 36 | +// that redirects traffic from the API endpoint on port 80 to ingress routers. |
| 37 | +// This enables cert-manager to perform HTTP01 ACME challenges for API endpoint certificates. |
| 38 | +// The name must be `default` to make HTTP01Proxy a singleton. |
| 39 | +// |
| 40 | +// When an HTTP01Proxy is created, the proxy DaemonSet is deployed on control plane nodes. |
| 41 | +// |
| 42 | +// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'default'",message="http01proxy is a singleton, .metadata.name must be 'default'" |
| 43 | +// +operator-sdk:csv:customresourcedefinitions:displayName="HTTP01Proxy" |
| 44 | +type HTTP01Proxy struct { |
| 45 | + metav1.TypeMeta `json:",inline"` |
| 46 | + |
| 47 | + // metadata is the standard object's metadata. |
| 48 | + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata |
| 49 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 50 | + |
| 51 | + // spec is the specification of the desired behavior of the HTTP01Proxy. |
| 52 | + // +kubebuilder:validation:Required |
| 53 | + // +required |
| 54 | + Spec HTTP01ProxySpec `json:"spec"` |
| 55 | + |
| 56 | + // status is the most recently observed status of the HTTP01Proxy. |
| 57 | + // +kubebuilder:validation:Optional |
| 58 | + // +optional |
| 59 | + Status HTTP01ProxyStatus `json:"status,omitempty"` |
| 60 | +} |
| 61 | + |
| 62 | +// HTTP01ProxyMode controls how the HTTP01 challenge proxy is deployed. |
| 63 | +// +kubebuilder:validation:Enum=DefaultDeployment;CustomDeployment |
| 64 | +type HTTP01ProxyMode string |
| 65 | + |
| 66 | +const ( |
| 67 | + // HTTP01ProxyModeDefault enables the proxy with default configuration. |
| 68 | + HTTP01ProxyModeDefault HTTP01ProxyMode = "DefaultDeployment" |
| 69 | + |
| 70 | + // HTTP01ProxyModeCustom enables the proxy with user-specified configuration. |
| 71 | + HTTP01ProxyModeCustom HTTP01ProxyMode = "CustomDeployment" |
| 72 | +) |
| 73 | + |
| 74 | +// HTTP01ProxySpec is the specification of the desired behavior of the HTTP01Proxy. |
| 75 | +// +kubebuilder:validation:XValidation:rule="self.mode == 'CustomDeployment' ? has(self.customDeployment) : !has(self.customDeployment)",message="customDeployment is required when mode is CustomDeployment and forbidden otherwise" |
| 76 | +type HTTP01ProxySpec struct { |
| 77 | + // mode controls whether the HTTP01 challenge proxy is active and how it should be deployed. |
| 78 | + // DefaultDeployment enables the proxy with default configuration. |
| 79 | + // CustomDeployment enables the proxy with user-specified configuration. |
| 80 | + // +kubebuilder:validation:Required |
| 81 | + // +required |
| 82 | + Mode HTTP01ProxyMode `json:"mode"` |
| 83 | + |
| 84 | + // customDeployment contains configuration options when mode is CustomDeployment. |
| 85 | + // This field is only valid when mode is CustomDeployment. |
| 86 | + // +kubebuilder:validation:Optional |
| 87 | + // +optional |
| 88 | + CustomDeployment *HTTP01ProxyCustomDeploymentSpec `json:"customDeployment,omitempty"` |
| 89 | +} |
| 90 | + |
| 91 | +// HTTP01ProxyCustomDeploymentSpec contains configuration for custom proxy deployment. |
| 92 | +type HTTP01ProxyCustomDeploymentSpec struct { |
| 93 | + // internalPort specifies the internal port used by the proxy service. |
| 94 | + // Valid values are 1024-65535. |
| 95 | + // +kubebuilder:validation:Minimum=1024 |
| 96 | + // +kubebuilder:validation:Maximum=65535 |
| 97 | + // +kubebuilder:default=8888 |
| 98 | + // +optional |
| 99 | + InternalPort int32 `json:"internalPort,omitempty"` |
| 100 | +} |
| 101 | + |
| 102 | +// HTTP01ProxyStatus is the most recently observed status of the HTTP01Proxy. |
| 103 | +type HTTP01ProxyStatus struct { |
| 104 | + // conditions holds information about the current state of the HTTP01 proxy deployment. |
| 105 | + ConditionalStatus `json:",inline,omitempty"` |
| 106 | + |
| 107 | + // proxyImage is the name of the image and the tag used for deploying the proxy. |
| 108 | + ProxyImage string `json:"proxyImage,omitempty"` |
| 109 | +} |
0 commit comments