-
Notifications
You must be signed in to change notification settings - Fork 51
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
Create AccessLogPolicy CRD #420
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9a4e9e7
Change unwanted error logs to debug, remove unwanted info logs, add r…
833839a
Added AccessLogPolicy CRD
309cfc5
Merge branch 'main' into access-logs-crd
f322ba4
Fixed alp shortname and destinationArn json, plus added kubebuilder v…
a26ce02
Added missing yaml changes
6e0b988
Fixed documentation for support access log policy target ref kinds
969edac
Added status to Access Log Policy
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
config/crds/bases/application-networking.k8s.aws_accesslogpolicies.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.13.0 | ||
name: accesslogpolicies.application-networking.k8s.aws | ||
spec: | ||
group: application-networking.k8s.aws | ||
names: | ||
categories: | ||
- gateway-api | ||
kind: AccessLogPolicy | ||
listKind: AccessLogPolicyList | ||
plural: accesslogpolicies | ||
shortNames: | ||
- alp | ||
singular: accesslogpolicy | ||
scope: Namespaced | ||
versions: | ||
- additionalPrinterColumns: | ||
- jsonPath: .metadata.creationTimestamp | ||
name: Age | ||
type: date | ||
name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
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: AccessLogPolicySpec defines the desired state of AccessLogPolicy. | ||
properties: | ||
destinationArn: | ||
description: "The Amazon Resource Name (ARN) of the destination that | ||
will store access logs. Supported values are S3 Bucket, CloudWatch | ||
Log Group, and Firehose Delivery Stream ARNs. \n Changes to this | ||
value results in replacement of the VPC Lattice Access Log Subscription." | ||
pattern: ^arn(:[a-z0-9]+([.-][a-z0-9]+)*){2}(:([a-z0-9]+([.-][a-z0-9]+)*)?){2}:([^/].*)? | ||
type: string | ||
targetRef: | ||
description: "TargetRef points to the Kubernetes Gateway, HTTPRoute, | ||
or GRPCRoute resource that will have this policy attached. \n This | ||
field is following the guidelines of Kubernetes Gateway API policy | ||
attachment." | ||
properties: | ||
group: | ||
description: Group is the group of the target resource. | ||
maxLength: 253 | ||
pattern: ^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ | ||
type: string | ||
kind: | ||
description: Kind is kind of the target resource. | ||
maxLength: 63 | ||
minLength: 1 | ||
pattern: ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ | ||
type: string | ||
name: | ||
description: Name is the name of the target resource. | ||
maxLength: 253 | ||
minLength: 1 | ||
type: string | ||
namespace: | ||
description: Namespace is the namespace of the referent. When | ||
unspecified, the local namespace is inferred. Even when policy | ||
targets a resource in a different namespace, it MUST only apply | ||
to traffic originating from the same namespace as the policy. | ||
maxLength: 63 | ||
minLength: 1 | ||
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ | ||
type: string | ||
required: | ||
- group | ||
- kind | ||
- name | ||
type: object | ||
required: | ||
- targetRef | ||
type: object | ||
required: | ||
- spec | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
helm/crds/application-networking.k8s.aws_accesslogpolicies.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.13.0 | ||
name: accesslogpolicies.application-networking.k8s.aws | ||
spec: | ||
group: application-networking.k8s.aws | ||
names: | ||
categories: | ||
- gateway-api | ||
kind: AccessLogPolicy | ||
listKind: AccessLogPolicyList | ||
plural: accesslogpolicies | ||
shortNames: | ||
- alp | ||
singular: accesslogpolicy | ||
scope: Namespaced | ||
versions: | ||
- additionalPrinterColumns: | ||
- jsonPath: .metadata.creationTimestamp | ||
name: Age | ||
type: date | ||
name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
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: AccessLogPolicySpec defines the desired state of AccessLogPolicy. | ||
properties: | ||
destinationArn: | ||
description: "The Amazon Resource Name (ARN) of the destination that | ||
will store access logs. Supported values are S3 Bucket, CloudWatch | ||
Log Group, and Firehose Delivery Stream ARNs. \n Changes to this | ||
value results in replacement of the VPC Lattice Access Log Subscription." | ||
pattern: ^arn(:[a-z0-9]+([.-][a-z0-9]+)*){2}(:([a-z0-9]+([.-][a-z0-9]+)*)?){2}:([^/].*)? | ||
type: string | ||
targetRef: | ||
description: "TargetRef points to the Kubernetes Gateway, HTTPRoute, | ||
or GRPCRoute resource that will have this policy attached. \n This | ||
field is following the guidelines of Kubernetes Gateway API policy | ||
attachment." | ||
properties: | ||
group: | ||
description: Group is the group of the target resource. | ||
maxLength: 253 | ||
pattern: ^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ | ||
type: string | ||
kind: | ||
description: Kind is kind of the target resource. | ||
maxLength: 63 | ||
minLength: 1 | ||
pattern: ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ | ||
type: string | ||
name: | ||
description: Name is the name of the target resource. | ||
maxLength: 253 | ||
minLength: 1 | ||
type: string | ||
namespace: | ||
description: Namespace is the namespace of the referent. When | ||
unspecified, the local namespace is inferred. Even when policy | ||
targets a resource in a different namespace, it MUST only apply | ||
to traffic originating from the same namespace as the policy. | ||
maxLength: 63 | ||
minLength: 1 | ||
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ | ||
type: string | ||
required: | ||
- group | ||
- kind | ||
- name | ||
type: object | ||
required: | ||
- targetRef | ||
type: object | ||
required: | ||
- spec | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
pkg/apis/applicationnetworking/v1alpha1/accesslogpolicy_types.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/types" | ||
"sigs.k8s.io/gateway-api/apis/v1alpha2" | ||
|
||
"github.com/aws/aws-application-networking-k8s/pkg/k8s" | ||
"github.com/aws/aws-application-networking-k8s/pkg/model/core" | ||
) | ||
|
||
const ( | ||
AccessLogPolicyKind = "AccessLogPolicy" | ||
) | ||
|
||
// +genclient | ||
// +kubebuilder:object:root=true | ||
// +kubebuilder:resource:categories=gateway-api,shortName=alp | ||
// +kubebuilder:storageversion | ||
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` | ||
type AccessLogPolicy struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec AccessLogPolicySpec `json:"spec"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// AccessLogPolicyList contains a list of AccessLogPolicies. | ||
type AccessLogPolicyList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []AccessLogPolicy `json:"items"` | ||
} | ||
|
||
// AccessLogPolicySpec defines the desired state of AccessLogPolicy. | ||
type AccessLogPolicySpec struct { | ||
// The Amazon Resource Name (ARN) of the destination that will store access logs. | ||
// Supported values are S3 Bucket, CloudWatch Log Group, and Firehose Delivery Stream ARNs. | ||
// | ||
// Changes to this value results in replacement of the VPC Lattice Access Log Subscription. | ||
// +optional | ||
// +kubebuilder:validation:Pattern=`^arn(:[a-z0-9]+([.-][a-z0-9]+)*){2}(:([a-z0-9]+([.-][a-z0-9]+)*)?){2}:([^/].*)?` | ||
DestinationArn *string `json:"destinationArn,omitempty"` | ||
|
||
// TargetRef points to the Kubernetes Gateway, HTTPRoute, or GRPCRoute resource that will have this policy attached. | ||
// | ||
// This field is following the guidelines of Kubernetes Gateway API policy attachment. | ||
TargetRef *v1alpha2.PolicyTargetReference `json:"targetRef"` | ||
} | ||
|
||
func (p *AccessLogPolicy) GetTargetRef() *v1alpha2.PolicyTargetReference { | ||
return p.Spec.TargetRef | ||
} | ||
|
||
func (p *AccessLogPolicy) GetNamespacedName() types.NamespacedName { | ||
return k8s.NamespacedName(p) | ||
} | ||
|
||
func (pl *AccessLogPolicyList) GetItems() []core.Policy { | ||
items := make([]core.Policy, len(pl.Items)) | ||
for i, item := range pl.Items { | ||
items[i] = &item | ||
} | ||
return items | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why we duplicate crd and template to helm? may be there is a difference that I couldn't spot
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.
I noticed this is how we did it with previous CRD additions, such as https://github.com/aws/aws-application-networking-k8s/pull/339/files