Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci-kal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ linters:
#- "maxlength" # Ensure all strings and arrays have maximum lengths/maximum items.
#- "nobools" # Bools do not evolve over time, should use enums instead.
#- "nofloats" # Ensure floats are not used.
#- "optionalorrequired" # Every field should be marked as `+optional` or `+required`.
- "optionalorrequired" # Every field should be marked as `+optional` or `+required`.
# - "requiredfields" # Required fields should not be pointers, and should not have `omitempty`.
- "statussubresource" # All root objects that have a `status` field should have a status subresource.

Expand Down
37 changes: 29 additions & 8 deletions api/v1beta1/awscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

const (
Expand All @@ -34,9 +35,11 @@ const (
// AWSClusterSpec defines the desired state of an EC2-based Kubernetes cluster.
type AWSClusterSpec struct {
// NetworkSpec encapsulates all things related to AWS network.
// +optional
NetworkSpec NetworkSpec `json:"network,omitempty"`

// The AWS Region the cluster lives in.
// +optional
Region string `json:"region,omitempty"`

// SSHKeyName is the name of the ssh key to attach to the bastion host. Valid values are empty string (do not use SSH keys), a valid SSH key name, or omitted (use the default SSH key name)
Expand All @@ -45,7 +48,7 @@ type AWSClusterSpec struct {

// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
// +optional
ControlPlaneEndpoint clusterv1beta1.APIEndpoint `json:"controlPlaneEndpoint"`
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`

// AdditionalTags is an optional set of tags to add to AWS resources managed by the AWS provider, in addition to the
// ones added by default.
Expand Down Expand Up @@ -81,6 +84,7 @@ type AWSClusterSpec struct {
// up machine images when a machine does not specify an AMI. When set, this
// will be used for all cluster machines unless a machine specifies a
// different ImageLookupBaseOS.
// +optional
ImageLookupBaseOS string `json:"imageLookupBaseOS,omitempty"`

// Bastion contains options to configure the bastion host.
Expand All @@ -91,6 +95,7 @@ type AWSClusterSpec struct {

// IdentityRef is a reference to an identity to be used when reconciling the managed control plane.
// If no identity is specified, the default identity for this controller will be used.
// +optional
IdentityRef *AWSIdentityReference `json:"identityRef,omitempty"`

// S3Bucket contains options to configure a supporting S3 bucket for this
Expand Down Expand Up @@ -119,10 +124,12 @@ var (
type AWSIdentityReference struct {
// Name of the identity.
// +kubebuilder:validation:MinLength=1
// +required
Name string `json:"name"`

// Kind of the identity.
// +kubebuilder:validation:Enum=AWSClusterControllerIdentity;AWSClusterRoleIdentity;AWSClusterStaticIdentity
// +required
Kind AWSIdentityKind `json:"kind"`
}

Expand All @@ -146,6 +153,7 @@ type Bastion struct {
// InstanceType will use the specified instance type for the bastion. If not specified,
// Cluster API Provider AWS will use t3.micro for all regions except us-east-1, where t2.micro
// will be the default.
// +optional
InstanceType string `json:"instanceType,omitempty"`

// AMI will use the specified AMI to boot the bastion. If not specified,
Expand Down Expand Up @@ -200,27 +208,35 @@ type AWSLoadBalancerSpec struct {
// AWSClusterStatus defines the observed state of AWSCluster.
type AWSClusterStatus struct {
// +kubebuilder:default=false
Ready bool `json:"ready"`
Network NetworkStatus `json:"networkStatus,omitempty"`
// +required
Ready bool `json:"ready"`
// +optional
Network NetworkStatus `json:"networkStatus,omitempty"`
// +optional
FailureDomains clusterv1beta1.FailureDomains `json:"failureDomains,omitempty"`
Bastion *Instance `json:"bastion,omitempty"`
Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"`
// +optional
Bastion *Instance `json:"bastion,omitempty"`
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
}

// S3Bucket defines a supporting S3 bucket for the cluster, currently can be optionally used for Ignition.
type S3Bucket struct {
// ControlPlaneIAMInstanceProfile is a name of the IAMInstanceProfile, which will be allowed
// to read control-plane node bootstrap data from S3 Bucket.
// +required
ControlPlaneIAMInstanceProfile string `json:"controlPlaneIAMInstanceProfile"`

// NodesIAMInstanceProfiles is a list of IAM instance profiles, which will be allowed to read
// worker nodes bootstrap data from S3 Bucket.
// +required
NodesIAMInstanceProfiles []string `json:"nodesIAMInstanceProfiles"`

// Name defines name of S3 Bucket to be created.
// +kubebuilder:validation:MinLength:=3
// +kubebuilder:validation:MaxLength:=63
// +kubebuilder:validation:Pattern=`^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$`
// +required
Name string `json:"name"`
}

Expand All @@ -236,10 +252,13 @@ type S3Bucket struct {

// AWSCluster is the schema for Amazon EC2 based Kubernetes Cluster API.
type AWSCluster struct {
metav1.TypeMeta `json:",inline"`
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AWSClusterSpec `json:"spec,omitempty"`
// +optional
Spec AWSClusterSpec `json:"spec,omitempty"`
// +optional
Status AWSClusterStatus `json:"status,omitempty"`
}

Expand All @@ -249,8 +268,10 @@ type AWSCluster struct {
// AWSClusterList contains a list of AWSCluster.
type AWSClusterList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
Items []AWSCluster `json:"items"`
// +required
Items []AWSCluster `json:"items"`
}

// GetConditions returns the observations of the operational state of the AWSCluster resource.
Expand Down
16 changes: 11 additions & 5 deletions api/v1beta1/awsclustertemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ package v1beta1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
)

// AWSClusterTemplateSpec defines the desired state of AWSClusterTemplate.
type AWSClusterTemplateSpec struct {
// +required
Template AWSClusterTemplateResource `json:"template"`
}

Expand All @@ -34,9 +35,11 @@ type AWSClusterTemplateSpec struct {

// AWSClusterTemplate is the schema for Amazon EC2 based Kubernetes Cluster Templates.
type AWSClusterTemplate struct {
metav1.TypeMeta `json:",inline"`
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

// +optional
Spec AWSClusterTemplateSpec `json:"spec,omitempty"`
}

Expand All @@ -45,8 +48,10 @@ type AWSClusterTemplate struct {
// AWSClusterTemplateList contains a list of AWSClusterTemplate.
type AWSClusterTemplateList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
Items []AWSClusterTemplate `json:"items"`
// +required
Items []AWSClusterTemplate `json:"items"`
}

func init() {
Expand All @@ -58,6 +63,7 @@ type AWSClusterTemplateResource struct {
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
// +optional
ObjectMeta clusterv1beta1.ObjectMeta `json:"metadata,omitempty"`
Spec AWSClusterSpec `json:"spec"`
ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"`
// +required
Spec AWSClusterSpec `json:"spec"`
}
19 changes: 19 additions & 0 deletions api/v1beta1/awsidentity_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,24 @@ type AllowedNamespaces struct {
// AWSRoleSpec defines the specifications for all identities based around AWS roles.
type AWSRoleSpec struct {
// The Amazon Resource Name (ARN) of the role to assume.
// +required
RoleArn string `json:"roleARN"`
// An identifier for the assumed role session
// +optional
SessionName string `json:"sessionName,omitempty"`
// The duration, in seconds, of the role session before it is renewed.
// +kubebuilder:validation:Minimum:=900
// +kubebuilder:validation:Maximum:=43200
// +optional
DurationSeconds int32 `json:"durationSeconds,omitempty"`
// An IAM policy as a JSON-encoded string that you want to use as an inline session policy.
// +optional
InlinePolicy string `json:"inlinePolicy,omitempty"`

// The Amazon Resource Names (ARNs) of the IAM managed policies that you want
// to use as managed session policies.
// The policies must exist in the same account as the role.
// +optional
PolicyARNs []string `json:"policyARNs,omitempty"`
}

Expand All @@ -77,9 +82,11 @@ type AWSRoleSpec struct {
// It represents a reference to an AWS access key ID and secret access key, stored in a secret.
type AWSClusterStaticIdentity struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec for this AWSClusterStaticIdentity
// +optional
Spec AWSClusterStaticIdentitySpec `json:"spec,omitempty"`
}

Expand All @@ -89,7 +96,9 @@ type AWSClusterStaticIdentity struct {
// AWSClusterStaticIdentityList contains a list of AWSClusterStaticIdentity.
type AWSClusterStaticIdentityList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
// +required
Items []AWSClusterStaticIdentity `json:"items"`
}

Expand All @@ -101,6 +110,7 @@ type AWSClusterStaticIdentitySpec struct {
// AccessKeyID: AKIAIOSFODNN7EXAMPLE
// SecretAccessKey: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
// SessionToken: Optional
// +required
SecretRef string `json:"secretRef"`
}

Expand All @@ -112,9 +122,11 @@ type AWSClusterStaticIdentitySpec struct {
// It is used to assume a role using the provided sourceRef.
type AWSClusterRoleIdentity struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec for this AWSClusterRoleIdentity.
// +optional
Spec AWSClusterRoleIdentitySpec `json:"spec,omitempty"`
}

Expand All @@ -124,7 +136,9 @@ type AWSClusterRoleIdentity struct {
// AWSClusterRoleIdentityList contains a list of AWSClusterRoleIdentity.
type AWSClusterRoleIdentityList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
// +required
Items []AWSClusterRoleIdentity `json:"items"`
}

Expand All @@ -146,6 +160,7 @@ type AWSClusterRoleIdentitySpec struct {

// SourceIdentityRef is a reference to another identity which will be chained to do
// role assumption. All identity types are accepted.
// +optional
SourceIdentityRef *AWSIdentityReference `json:"sourceIdentityRef,omitempty"`
}

Expand All @@ -157,9 +172,11 @@ type AWSClusterRoleIdentitySpec struct {
// It is used to grant access to use Cluster API Provider AWS Controller credentials.
type AWSClusterControllerIdentity struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec for this AWSClusterControllerIdentity.
// +optional
Spec AWSClusterControllerIdentitySpec `json:"spec,omitempty"`
}

Expand All @@ -169,7 +186,9 @@ type AWSClusterControllerIdentity struct {
// AWSClusterControllerIdentityList contains a list of AWSClusterControllerIdentity.
type AWSClusterControllerIdentityList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
// +required
Items []AWSClusterControllerIdentity `json:"items"`
}

Expand Down
Loading