Skip to content

Commit eeed105

Browse files
committed
Address PR review comments
Co-authored-by: Richard Case <[email protected]> Make OIDC IAM permissions optional rename feature to distinguish from managed mode Rework OIDC reconcile to work mgmt side only Fixes and tidy up Add OIDC provider flavor use keyIDFromPublicKey from k8s code Gate OIDC reconcile behind feature flag. Revert unneeded awsmachine_controller test changes fix clusterawsadm template tests Fix lints & tests bump pod ID webhook to latest (v0.6.6)
1 parent 31fa7c2 commit eeed105

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+15316
-310
lines changed

api/v1beta2/awscluster_spec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ func (s *AWSClusterSpec) Validate() []*field.Error {
1111
var errs field.ErrorList
1212

1313
// Check the feature gate is enabled for OIDC Provider.
14-
if s.AssociateOIDCProvider && !feature.Gates.Enabled(feature.OIDCProviderSupport) {
14+
if s.AssociateOIDCProvider && !feature.Gates.Enabled(feature.OIDCProviderUnmanagedClusters) {
1515
errs = append(errs,
1616
field.Forbidden(field.NewPath("spec", "associateOIDCProvider"),
17-
"can be enabled only if the OIDCProviderSupport feature gate is enabled"),
17+
"can be enabled only if the OIDCProviderUnmanagedClusters feature gate is enabled"),
1818
)
1919
return errs
2020
}

api/v1beta2/awscluster_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ type AWSClusterSpec struct {
108108
// S3Bucket contains options to configure a supporting S3 bucket for this
109109
// cluster - Used for nodes requiring Ignition (https://coreos.github.io/ignition/) for bootstrapping (requires
110110
// BootstrapFormatIgnition feature flag to be enabled) and/or for storing OIDC endpoint certificates for use
111-
// with IRSA (requires OIDCProviderSupport feature flag to be enabled).
111+
// with IRSA (requires OIDCProviderUnmanagedClusters feature flag to be enabled).
112112
// +optional
113113
S3Bucket *S3Bucket `json:"s3Bucket,omitempty"`
114114

@@ -290,7 +290,7 @@ type AWSClusterStatus struct {
290290

291291
// OIDCProvider holds the status of the identity provider for this cluster
292292
// +optional
293-
OIDCProvider OIDCProviderStatus `json:"oidcProvider,omitempty"`
293+
OIDCProvider *OIDCProviderStatus `json:"oidcProvider,omitempty"`
294294
}
295295

296296
// S3Bucket defines a supporting S3 bucket for the cluster, currently can be optionally used for Ignition.

api/v1beta2/s3bucket.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ func (b *S3Bucket) Validate() []*field.Error {
3737
errs = append(errs, field.Required(field.NewPath("spec", "s3Bucket", "name"), "can't be empty"))
3838
}
3939

40-
// Feature gate is not enabled but ignition is enabled then send a forbidden error.
41-
if !feature.Gates.Enabled(feature.BootstrapFormatIgnition) && !feature.Gates.Enabled(feature.OIDCProviderSupport) {
40+
// Either the BootstrapFormatIgnition or OIDCProviderUnmanagedClusters feature gate must be enabled.
41+
// Otherwise send a forbidden error.
42+
if !feature.Gates.Enabled(feature.BootstrapFormatIgnition) && !feature.Gates.Enabled(feature.OIDCProviderUnmanagedClusters) {
4243
errs = append(errs, field.Forbidden(field.NewPath("spec", "s3Bucket"),
43-
"can be set only if the BootstrapFormatIgnition or OIDCProviderSupport feature gate is enabled"))
44+
"can be set only if the BootstrapFormatIgnition or OIDCProviderUnmanagedClusters feature gate is enabled"))
4445
}
4546

4647
if b.PresignedURLDuration == nil {

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/clusterawsadm/api/bootstrap/v1alpha1/zz_generated.conversion.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/clusterawsadm/api/bootstrap/v1beta1/defaults.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ func SetDefaults_AWSIAMConfigurationSpec(obj *AWSIAMConfigurationSpec) { //nolin
106106
if obj.S3Buckets.NamePrefix == "" {
107107
obj.S3Buckets.NamePrefix = DefaultS3BucketPrefix
108108
}
109+
if obj.IAMIdentityProviders == nil {
110+
obj.IAMIdentityProviders = &IAMIdentityProviders{
111+
Enable: false,
112+
}
113+
}
109114
}
110115

111116
// SetDefaults_AWSIAMConfiguration is used by defaulter-gen.

cmd/clusterawsadm/api/bootstrap/v1beta1/types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ type S3Buckets struct {
178178
NamePrefix string `json:"namePrefix"`
179179
}
180180

181+
// IAMIdentityProviders controls the configuration of the AWS IAM role for IAM
182+
// Identity providers, which can be created to support IRSA for unmanaged clusters.
183+
type IAMIdentityProviders struct {
184+
// Enable controls whether permissions are granted to manage IAM Identity Providers
185+
Enable bool `json:"enable,omitempty"`
186+
}
187+
181188
// AWSIAMConfigurationSpec defines the specification of the AWSIAMConfiguration.
182189
type AWSIAMConfigurationSpec struct {
183190
// NamePrefix will be prepended to every AWS IAM role, user and policy created by clusterawsadm. Defaults to "".
@@ -235,6 +242,11 @@ type AWSIAMConfigurationSpec struct {
235242

236243
// AllowAssumeRole enables the sts:AssumeRole permission within the CAPA policies
237244
AllowAssumeRole bool `json:"allowAssumeRole,omitempty"`
245+
246+
// IAMIdentityProviders, when enabled, will add controller nodes permissions to
247+
// create IAM Identity Providers for kubeadm workload clusters.
248+
// +optional
249+
IAMIdentityProviders *IAMIdentityProviders `json:"iamIdentityProviders,omitempty"`
238250
}
239251

240252
// GetObjectKind returns the AAWSIAMConfiguration's TypeMeta.

cmd/clusterawsadm/api/bootstrap/v1beta1/zz_generated.deepcopy.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/clusterawsadm/cloudformation/bootstrap/cluster_api_controller.go

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,6 @@ func (t Template) ControllersPolicy() *iamv1.PolicyDocument {
185185
"ec2:DeleteLaunchTemplateVersions",
186186
"ec2:DescribeKeyPairs",
187187
"ec2:ModifyInstanceMetadataOptions",
188-
"iam:CreateOpenIDConnectProvider",
189-
"iam:DeleteOpenIDConnectProvider",
190-
"iam:ListOpenIDConnectProviders",
191-
"iam:GetOpenIDConnectProvider",
192-
"iam:TagOpenIDConnectProvider",
193188
},
194189
},
195190
{
@@ -301,6 +296,16 @@ func (t Template) ControllersPolicy() *iamv1.PolicyDocument {
301296
"s3:DeleteObject",
302297
"s3:PutBucketPolicy",
303298
"s3:PutBucketTagging",
299+
},
300+
})
301+
}
302+
if t.Spec.IAMIdentityProviders.Enable {
303+
statement = append(statement, iamv1.StatementEntry{
304+
Effect: iamv1.EffectAllow,
305+
Resource: iamv1.Resources{
306+
fmt.Sprintf("arn:*:s3:::%s*", t.Spec.S3Buckets.NamePrefix),
307+
},
308+
Action: iamv1.Actions{
304309
"s3:PutBucketOwnershipControls",
305310
"s3:PutObjectAcl",
306311
"s3:PutBucketPublicAccessBlock",
@@ -328,6 +333,19 @@ func (t Template) ControllersPolicy() *iamv1.PolicyDocument {
328333
},
329334
})
330335
}
336+
if t.Spec.IAMIdentityProviders.Enable {
337+
statement = append(statement, iamv1.StatementEntry{
338+
Effect: iamv1.EffectAllow,
339+
Resource: iamv1.Resources{iamv1.Any},
340+
Action: iamv1.Actions{
341+
"iam:CreateOpenIDConnectProvider",
342+
"iam:DeleteOpenIDConnectProvider",
343+
"iam:ListOpenIDConnectProviders",
344+
"iam:GetOpenIDConnectProvider",
345+
"iam:TagOpenIDConnectProvider",
346+
},
347+
})
348+
}
331349

332350
return &iamv1.PolicyDocument{
333351
Version: iamv1.CurrentVersion,

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/customsuffix.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,6 @@ Resources:
245245
- ec2:DeleteLaunchTemplateVersions
246246
- ec2:DescribeKeyPairs
247247
- ec2:ModifyInstanceMetadataOptions
248-
- iam:CreateOpenIDConnectProvider
249-
- iam:DeleteOpenIDConnectProvider
250-
- iam:ListOpenIDConnectProviders
251-
- iam:GetOpenIDConnectProvider
252-
- iam:TagOpenIDConnectProvider
253248
Effect: Allow
254249
Resource:
255250
- '*'

0 commit comments

Comments
 (0)