diff --git a/Makefile b/Makefile index 528b635..b6c5096 100644 --- a/Makefile +++ b/Makefile @@ -165,7 +165,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest ## Tool Versions KUSTOMIZE_VERSION ?= v3.8.7 -CONTROLLER_TOOLS_VERSION ?= v0.8.0 +CONTROLLER_TOOLS_VERSION ?= v0.11.3 KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" .PHONY: kustomize diff --git a/api/v1alpha1/upstream_types.go b/api/v1alpha1/upstream_types.go index d1ddfc4..8440d3b 100644 --- a/api/v1alpha1/upstream_types.go +++ b/api/v1alpha1/upstream_types.go @@ -22,9 +22,11 @@ import ( // UpstreamSpec defines the desired state of Upstream type UpstreamSpec struct { - Client string `json:"client"` - TCP *UpstreamSpec_TCP `json:"tcp"` - UDP *UpstreamSpec_UDP `json:"udp"` + Client string `json:"client"` + // +optional + TCP *UpstreamSpec_TCP `json:"tcp"` + // +optional + UDP *UpstreamSpec_UDP `json:"udp"` } type UpstreamSpec_TCP struct { @@ -33,8 +35,9 @@ type UpstreamSpec_TCP struct { Server UpstreamSpec_TCP_Server `json:"server"` // +kubebuilder:validation:Enum=v1;v2 // +optional - ProxyProtocol *string `json:"proxyProtocol"` - HealthCheck *UpstreamSpec_TCP_HealthCheck `json:"healthCheck"` + ProxyProtocol *string `json:"proxyProtocol"` + // +optional + HealthCheck *UpstreamSpec_TCP_HealthCheck `json:"healthCheck"` } type UpstreamSpec_TCP_Server struct { diff --git a/charts/frp-operator/crds/crds.yaml b/charts/frp-operator/crds/crds.yaml index 12242eb..78e6e37 100644 --- a/charts/frp-operator/crds/crds.yaml +++ b/charts/frp-operator/crds/crds.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.8.0 + controller-gen.kubebuilder.io/version: v0.11.3 creationTimestamp: null name: clients.frp.zufardhiyaulhaq.com spec: @@ -77,18 +77,12 @@ spec: storage: true subresources: status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.8.0 + controller-gen.kubebuilder.io/version: v0.11.3 creationTimestamp: null name: upstreams.frp.zufardhiyaulhaq.com spec: @@ -154,7 +148,6 @@ spec: - port type: object required: - - healthCheck - host - port - server @@ -179,8 +172,6 @@ spec: type: object required: - client - - tcp - - udp type: object status: description: UpstreamStatus defines the observed state of Upstream @@ -190,9 +181,3 @@ spec: storage: true subresources: status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/charts/releases/frp-operator-1.1.0.tgz b/charts/releases/frp-operator-1.1.0.tgz index d24e0f9..1be2b42 100644 Binary files a/charts/releases/frp-operator-1.1.0.tgz and b/charts/releases/frp-operator-1.1.0.tgz differ diff --git a/charts/releases/index.yaml b/charts/releases/index.yaml index 8d6e6ad..9da9f3b 100644 --- a/charts/releases/index.yaml +++ b/charts/releases/index.yaml @@ -3,10 +3,10 @@ entries: frp-operator: - apiVersion: v2 appVersion: 0.3.0 - created: "2024-04-04T22:25:33.990033+07:00" + created: "2024-04-13T22:50:20.361732+07:00" description: Expose your service in Kubernetes to the Internet with open source FRP! - digest: b3c9f018a4f8fbd3a94f2c19ed72e99276b5fd7e59468f8109ab479e7230aab7 + digest: 96f342725e362414480ad385e0ad6db348754e8e3bf5db0d9a7e74ee9c5905a7 home: https://github.com/zufardhiyaulhaq/frp-operator maintainers: - email: zufardhiyaulhaq@gmail.com @@ -19,7 +19,7 @@ entries: version: 1.1.0 - apiVersion: v2 appVersion: 0.2.0 - created: "2024-04-04T22:25:33.988819+07:00" + created: "2024-04-13T22:50:20.360889+07:00" description: Expose your service in Kubernetes to the Internet with open source FRP! digest: 5f80631b3ce1dad5ed2039abb144506fa5795d378f4d465d33c475f216b77df1 @@ -33,4 +33,4 @@ entries: urls: - frp-operator-1.0.0.tgz version: 1.0.0 -generated: "2024-04-04T22:25:33.985268+07:00" +generated: "2024-04-13T22:50:20.359307+07:00" diff --git a/config/crd/bases/frp.zufardhiyaulhaq.com_clients.yaml b/config/crd/bases/frp.zufardhiyaulhaq.com_clients.yaml index aba268b..28bb299 100644 --- a/config/crd/bases/frp.zufardhiyaulhaq.com_clients.yaml +++ b/config/crd/bases/frp.zufardhiyaulhaq.com_clients.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.8.0 + controller-gen.kubebuilder.io/version: v0.11.3 creationTimestamp: null name: clients.frp.zufardhiyaulhaq.com spec: @@ -77,9 +77,3 @@ spec: storage: true subresources: status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/config/crd/bases/frp.zufardhiyaulhaq.com_upstreams.yaml b/config/crd/bases/frp.zufardhiyaulhaq.com_upstreams.yaml index 38b886c..8c78902 100644 --- a/config/crd/bases/frp.zufardhiyaulhaq.com_upstreams.yaml +++ b/config/crd/bases/frp.zufardhiyaulhaq.com_upstreams.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.8.0 + controller-gen.kubebuilder.io/version: v0.11.3 creationTimestamp: null name: upstreams.frp.zufardhiyaulhaq.com spec: @@ -69,7 +69,6 @@ spec: - port type: object required: - - healthCheck - host - port - server @@ -94,8 +93,6 @@ spec: type: object required: - client - - tcp - - udp type: object status: description: UpstreamStatus defines the observed state of Upstream @@ -105,9 +102,3 @@ spec: storage: true subresources: status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/pkg/client/models/config.go b/pkg/client/models/config.go index e134403..0ba2efa 100644 --- a/pkg/client/models/config.go +++ b/pkg/client/models/config.go @@ -113,6 +113,10 @@ func NewConfig(k8sclient client.Client, clientObject *frpv1alpha1.Client, upstre Name: upstreamObject.Name, } + if upstreamObject.Spec.TCP == nil && upstreamObject.Spec.UDP == nil { + return config, errors.NewBadRequest("TCP or UDP upstream is required") + } + if upstreamObject.Spec.TCP != nil && upstreamObject.Spec.UDP != nil { return config, errors.NewBadRequest("Multiple protocol on the same Upstream object") }