Skip to content

Commit

Permalink
Move DNS and TLS Policies to v1
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Nairn <[email protected]>
  • Loading branch information
mikenairn committed Nov 5, 2024
1 parent a3579b1 commit 6847045
Show file tree
Hide file tree
Showing 53 changed files with 224 additions and 232 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ endef

.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) crd paths="./api/v1alpha1;./api/v1beta1;./api/v1beta3" output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) crd paths="./api/v1beta1;./api/v1beta3;./api/v1" output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) rbac:roleName=manager-role webhook paths="./..."

.PHONY: dependencies-manifests
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ to operate the cluster ingress gateway to provide API management with **authenti

The kuadrant control plane owns the following [Custom Resource Definitions, CRDs](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/):

| CRD | Description | Example |
|-----------------------------------------------------------------------------------------------------|----------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| AuthPolicy CRD [\[doc\]](doc/auth.md) [[reference]](doc/reference/authpolicy.md) | Enable AuthN and AuthZ based access control on workloads | [AuthPolicy CR](https://github.com/Kuadrant/kuadrant-operator/blob/main/examples/toystore/authpolicy.yaml) |
| CRD | Description | Example |
|-----------------------------------------------------------------------------------------------------|----------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------|
| AuthPolicy CRD [\[doc\]](doc/auth.md) [[reference]](doc/reference/authpolicy.md) | Enable AuthN and AuthZ based access control on workloads | [AuthPolicy CR](https://github.com/Kuadrant/kuadrant-operator/blob/main/examples/toystore/authpolicy.yaml) |
| RateLimitPolicy CRD [\[doc\]](doc/rate-limiting.md) [[reference]](doc/reference/ratelimitpolicy.md) | Enable access control on workloads based on HTTP rate limiting | [RateLimitPolicy CR](https://raw.githubusercontent.com/Kuadrant/kuadrant-operator/main/examples/toystore/ratelimitpolicy_httproute.yaml) |
| DNSPolicy CRD [\[doc\]](doc/dns.md) [[reference]](doc/reference/dnspolicy.md) | Enable DNS management | [DNSPolicy CR](config/samples/kuadrant_v1alpha1_dnspolicy.yaml) |
| TLSPolicy CRD [\[doc\]](doc/tls.md) [[reference]](doc/reference/tlspolicy.md) | Enable TLS management | [TLSPolicy CR](config/samples/kuadrant_v1alpha1_tlspolicy.yaml) |
| DNSPolicy CRD [\[doc\]](doc/dns.md) [[reference]](doc/reference/dnspolicy.md) | Enable DNS management | [DNSPolicy CR](config/samples/kuadrant_v1_dnspolicy.yaml) |
| TLSPolicy CRD [\[doc\]](doc/tls.md) [[reference]](doc/reference/tlspolicy.md) | Enable TLS management | [TLSPolicy CR](config/samples/kuadrant_v1_tlspolicy.yaml) |

Additionally, Kuadrant provides the following CRDs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1
package v1

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the kuadrant.io v1alpha1 API group
// Package v1 contains API Schema definitions for the v1 API group
// +kubebuilder:object:generate=true
// +groupName=kuadrant.io
package v1alpha1
package v1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
Expand All @@ -26,7 +26,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "kuadrant.io", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: "kuadrant.io", Version: "v1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
1 change: 1 addition & 0 deletions api/v1/merge_strategies.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func NewMergeableRule(rule MergeableRule, defaultSource string) MergeableRule {

// MergeableRule is a policy rule that contains a spec which can be traced back to its source,
// i.e. to the policy where the rule spec was defined.
// +kubebuilder:object:generate=false
type MergeableRule interface {
GetSpec() any
GetSource() string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1
package v1

import (
certmanv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/topology.go → api/v1/topology.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1alpha1
package v1

// Contains of this file allow the DNSPolicy and TLSPolicy to adhere to the machinery.Policy interface

Expand Down

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

10 changes: 5 additions & 5 deletions bundle/manifests/kuadrant-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
alm-examples: |-
[
{
"apiVersion": "kuadrant.io/v1alpha1",
"apiVersion": "kuadrant.io/v1",
"kind": "DNSPolicy",
"metadata": {
"name": "dnspolicy-sample"
Expand All @@ -23,7 +23,7 @@ metadata:
}
},
{
"apiVersion": "kuadrant.io/v1alpha1",
"apiVersion": "kuadrant.io/v1",
"kind": "TLSPolicy",
"metadata": {
"name": "tlspolicy-sample"
Expand Down Expand Up @@ -106,7 +106,7 @@ metadata:
capabilities: Basic Install
categories: Integration & Delivery
containerImage: quay.io/kuadrant/kuadrant-operator:latest
createdAt: "2024-11-05T09:44:13Z"
createdAt: "2024-11-05T10:52:01Z"
description: A Kubernetes Operator to manage the lifecycle of the Kuadrant system
operators.operatorframework.io/builder: operator-sdk-v1.32.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
Expand All @@ -126,7 +126,7 @@ spec:
displayName: DNSPolicy
kind: DNSPolicy
name: dnspolicies.kuadrant.io
version: v1alpha1
version: v1
- description: Kuadrant configures installations of Kuadrant Service Protection
components
displayName: Kuadrant
Expand All @@ -144,7 +144,7 @@ spec:
displayName: TLSPolicy
kind: TLSPolicy
name: tlspolicies.kuadrant.io
version: v1alpha1
version: v1
description: A Kubernetes Operator to manage the lifecycle of the Kuadrant system
displayName: Kuadrant Operator
icon:
Expand Down
2 changes: 1 addition & 1 deletion bundle/manifests/kuadrant.io_dnspolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
name: v1
schema:
openAPIV3Schema:
description: DNSPolicy is the Schema for the dnspolicies API
Expand Down
2 changes: 1 addition & 1 deletion bundle/manifests/kuadrant.io_tlspolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
name: v1
schema:
openAPIV3Schema:
description: TLSPolicy is the Schema for the tlspolicies API
Expand Down
4 changes: 2 additions & 2 deletions charts/kuadrant-operator/templates/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6854,7 +6854,7 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
name: v1
schema:
openAPIV3Schema:
description: DNSPolicy is the Schema for the dnspolicies API
Expand Down Expand Up @@ -8081,7 +8081,7 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
name: v1
schema:
openAPIV3Schema:
description: TLSPolicy is the Schema for the tlspolicies API
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/kuadrant.io_dnspolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
name: v1
schema:
openAPIV3Schema:
description: DNSPolicy is the Schema for the dnspolicies API
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/kuadrant.io_tlspolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
name: v1
schema:
openAPIV3Schema:
description: TLSPolicy is the Schema for the tlspolicies API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,16 @@ spec:
kind: RateLimitPolicy
name: ratelimitpolicies.kuadrant.io
version: v1beta3
- description: DNSHealthCheckProbe enables performing health checks against a DNS endpoint (A or CNAME record)
displayName: DNSHealthCheckProbe
kind: DNSHealthCheckProbe
name: dnshealthcheckprobes.kuadrant.io
version: v1alpha1
- description: DNSPolicy configures how North-South based traffic should be balanced and reach the gateways
displayName: DNSPolicy
kind: DNSPolicy
name: dnspolicies.kuadrant.io
version: v1alpha1
- description: DNSRecord represents DNS endpoints for gateway network services
displayName: DNSRecord
kind: DNSRecord
name: dnsrecords.kuadrant.io
version: v1alpha1
version: v1
- description: TLSPolicy provides tls for gateway listeners by managing the lifecycle of tls certificates
displayName: TLSPolicy
kind: TLSPolicy
name: tlspolicies.kuadrant.io
version: v1alpha1
version: v1
description: A Kubernetes Operator to manage the lifecycle of the Kuadrant system
displayName: Kuadrant Operator
icon:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: kuadrant.io/v1alpha1
apiVersion: kuadrant.io/v1
kind: DNSPolicy
metadata:
name: dnspolicy-sample
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: kuadrant.io/v1alpha1
apiVersion: kuadrant.io/v1
kind: TLSPolicy
metadata:
name: tlspolicy-sample
Expand Down
4 changes: 2 additions & 2 deletions config/samples/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ resources:
- kuadrant_v1beta1_kuadrant.yaml
- kuadrant_v1beta3_authpolicy.yaml
- kuadrant_v1beta3_ratelimitpolicy.yaml
- kuadrant_v1alpha1_dnspolicy.yaml
- kuadrant_v1alpha1_tlspolicy.yaml
- kuadrant_v1_dnspolicy.yaml
- kuadrant_v1_tlspolicy.yaml
#+kubebuilder:scaffold:manifestskustomizesamples
21 changes: 10 additions & 11 deletions controllers/dns_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ import (
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

kuadrantdnsv1alpha1 "github.com/kuadrant/dns-operator/api/v1alpha1"
"github.com/kuadrant/policy-machinery/controller"
"github.com/kuadrant/policy-machinery/machinery"

kuadrantdnsv1alpha1 "github.com/kuadrant/dns-operator/api/v1alpha1"

"github.com/kuadrant/kuadrant-operator/api/v1alpha1"
kuadrantv1 "github.com/kuadrant/kuadrant-operator/api/v1"
"github.com/kuadrant/kuadrant-operator/pkg/library/utils"
)

Expand Down Expand Up @@ -74,14 +73,14 @@ func LinkListenerToDNSRecord(objs controller.Store) machinery.LinkFunc {
}

func LinkDNSPolicyToDNSRecord(objs controller.Store) machinery.LinkFunc {
policies := lo.Map(objs.FilterByGroupKind(v1alpha1.DNSPolicyGroupKind), controller.ObjectAs[*v1alpha1.DNSPolicy])
policies := lo.Map(objs.FilterByGroupKind(kuadrantv1.DNSPolicyGroupKind), controller.ObjectAs[*kuadrantv1.DNSPolicy])

return machinery.LinkFunc{
From: v1alpha1.DNSPolicyGroupKind,
From: kuadrantv1.DNSPolicyGroupKind,
To: DNSRecordGroupKind,
Func: func(child machinery.Object) []machinery.Object {
if dnsRecord, ok := child.(*controller.RuntimeObject).Object.(*kuadrantdnsv1alpha1.DNSRecord); ok {
return lo.FilterMap(policies, func(dnsPolicy *v1alpha1.DNSPolicy, _ int) (machinery.Object, bool) {
return lo.FilterMap(policies, func(dnsPolicy *kuadrantv1.DNSPolicy, _ int) (machinery.Object, bool) {

Check warning on line 83 in controllers/dns_workflow.go

View check run for this annotation

Codecov / codecov/patch

controllers/dns_workflow.go#L83

Added line #L83 was not covered by tests
return dnsPolicy, utils.IsOwnedBy(dnsRecord, dnsPolicy)
})
}
Expand All @@ -106,7 +105,7 @@ func dnsPolicyAcceptedStatusFunc(state *sync.Map) func(policy machinery.Policy)
}

func dnsPolicyAcceptedStatus(policy machinery.Policy) (accepted bool, err error) {
p, ok := policy.(*v1alpha1.DNSPolicy)
p, ok := policy.(*kuadrantv1.DNSPolicy)

Check warning on line 108 in controllers/dns_workflow.go

View check run for this annotation

Codecov / codecov/patch

controllers/dns_workflow.go#L108

Added line #L108 was not covered by tests
if !ok {
return
}
Expand All @@ -131,11 +130,11 @@ func dnsPolicyErrorFunc(state *sync.Map) func(policy machinery.Policy) error {
}
}

type dnsPolicyTypeFilter func(item machinery.Policy, index int) (*v1alpha1.DNSPolicy, bool)
type dnsPolicyTypeFilter func(item machinery.Policy, index int) (*kuadrantv1.DNSPolicy, bool)

func dnsPolicyTypeFilterFunc() func(item machinery.Policy, _ int) (*v1alpha1.DNSPolicy, bool) {
return func(item machinery.Policy, _ int) (*v1alpha1.DNSPolicy, bool) {
p, ok := item.(*v1alpha1.DNSPolicy)
func dnsPolicyTypeFilterFunc() func(item machinery.Policy, _ int) (*kuadrantv1.DNSPolicy, bool) {
return func(item machinery.Policy, _ int) (*kuadrantv1.DNSPolicy, bool) {
p, ok := item.(*kuadrantv1.DNSPolicy)
return p, ok
}
}
Loading

0 comments on commit 6847045

Please sign in to comment.