Skip to content

Commit ace9b55

Browse files
alex0chanjaswalkiranavtar
authored andcommitted
changes to support aws tags
Signed-off-by: Alex <[email protected]> Signed-off-by: Jeffrey Wong <[email protected]> Signed-off-by: Gaurav Jaswal <[email protected]>
1 parent 4d9f854 commit ace9b55

File tree

13 files changed

+206
-54
lines changed

13 files changed

+206
-54
lines changed

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ require (
2828
k8s.io/klog/v2 v2.130.1
2929
k8s.io/kubectl v0.31.1
3030
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6
31-
open-cluster-management.io/api v0.15.1-0.20250219064651-4281b7684d9b
31+
open-cluster-management.io/api v0.15.1-0.20250226073118-8c9793267c9e
3232
open-cluster-management.io/cluster-proxy v0.4.0
3333
open-cluster-management.io/managed-serviceaccount v0.6.0
34-
open-cluster-management.io/ocm v0.15.1-0.20250228202623-6c270f90a09a
34+
open-cluster-management.io/ocm v0.15.1-0.20250306192929-c4e706f12358
3535
open-cluster-management.io/sdk-go v0.15.1-0.20241125015855-1536c3970f8f
3636
sigs.k8s.io/apiserver-network-proxy v0.29.0
3737
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -563,14 +563,14 @@ k8s.io/kubectl v0.31.1 h1:ih4JQJHxsEggFqDJEHSOdJ69ZxZftgeZvYo7M/cpp24=
563563
k8s.io/kubectl v0.31.1/go.mod h1:aNuQoR43W6MLAtXQ/Bu4GDmoHlbhHKuyD49lmTC8eJM=
564564
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 h1:MDF6h2H/h4tbzmtIKTuctcwZmY0tY9mD9fNT47QO6HI=
565565
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
566-
open-cluster-management.io/api v0.15.1-0.20250219064651-4281b7684d9b h1:1ScdOKBMLbzA/k84P9Z64uSq3sxRclquej3tT1zhsqU=
567-
open-cluster-management.io/api v0.15.1-0.20250219064651-4281b7684d9b/go.mod h1:9erZEWEn4bEqh0nIX2wA7f/s3KCuFycQdBrPrRzi0QM=
566+
open-cluster-management.io/api v0.15.1-0.20250226073118-8c9793267c9e h1:4iQneGfxartfFSR+IHZRrjEuwtRpiHyKQ15Kd33YCVk=
567+
open-cluster-management.io/api v0.15.1-0.20250226073118-8c9793267c9e/go.mod h1:9erZEWEn4bEqh0nIX2wA7f/s3KCuFycQdBrPrRzi0QM=
568568
open-cluster-management.io/cluster-proxy v0.4.0 h1:rm0UDaDWe3/P3xLzwqdHtqNksKwSzsic02MkrEe6BnM=
569569
open-cluster-management.io/cluster-proxy v0.4.0/go.mod h1:gTvfDHAhGezhdg4BD3ECBn6jbg2Y5PbHhV2ceW5nrB0=
570570
open-cluster-management.io/managed-serviceaccount v0.6.0 h1:qIi5T9WQJBuoGqnYGIktXbtqfQoiN2H9XU2P/6lAQiw=
571571
open-cluster-management.io/managed-serviceaccount v0.6.0/go.mod h1:G4LUTbZiyrB8c0+rqi/xnDmGlsg7Rdr4T7MPLCWhyQI=
572-
open-cluster-management.io/ocm v0.15.1-0.20250228202623-6c270f90a09a h1:Im9vF1AQp9D6A7W1c8NBd58/6rYMP8o7b2SvtrbR1qA=
573-
open-cluster-management.io/ocm v0.15.1-0.20250228202623-6c270f90a09a/go.mod h1:Milw2tXtXFE4iJB2F4x2DtXxozLXYJhEyz9CuUfggzg=
572+
open-cluster-management.io/ocm v0.15.1-0.20250306192929-c4e706f12358 h1:cI1iF80iMHrO1GMB6c8HBXvWUqFDByW4aP0QWcI2fag=
573+
open-cluster-management.io/ocm v0.15.1-0.20250306192929-c4e706f12358/go.mod h1:TpRPBEiYJj8ZoVmuDIJS+nJlixRv2fnp/a54uXSWd38=
574574
open-cluster-management.io/sdk-go v0.15.1-0.20241125015855-1536c3970f8f h1:zeC7QrFNarfK2zY6jGtd+mX+yDrQQmnH/J8A7n5Nh38=
575575
open-cluster-management.io/sdk-go v0.15.1-0.20241125015855-1536c3970f8f/go.mod h1:fi5WBsbC5K3txKb8eRLuP0Sim/Oqz/PHX18skAEyjiA=
576576
oras.land/oras-go v1.2.5 h1:XpYuAwAb0DfQsunIyMfeET92emK8km3W4yEzZvUbsTo=

pkg/cmd/init/cmd.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ var example = `
1616
%[1]s init
1717
1818
# Initialize the hub cluster with the type of authentication. Either or both of csr,awsirsa
19-
%[1]s init --registration-drivers="awsirsa,csr" --hubClusterArn arn:aws:eks:us-west-2:123456789012:cluster/hub-cluster1
19+
%[1]s init --registration-drivers "awsirsa,csr"
20+
--hubClusterArn arn:aws:eks:us-west-2:123456789012:cluster/hub-cluster1
21+
--aws-resource-tags product:v1:tenant:app-name=My-App,product:v1:tenant:created-by=Team-1
22+
--auto-approved-csr-identities="user1,user2"
23+
--auto-approved-arn-patterns="arn:aws:eks:us-west-2:123456789013:cluster/.*,arn:aws:eks:us-west-2:123456789012:cluster/.*"
2024
`
2125

2226
// NewCmd ...
@@ -85,6 +89,8 @@ func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, stream
8589
"The type of authentication to use for registering and authenticating with hub. Only csr and awsirsa are accepted as valid inputs. This flag can be repeated to specify multiple authentication types.")
8690
cmd.Flags().StringVar(&o.hubClusterArn, "hub-cluster-arn", "",
8791
"The hubCluster ARN to be passed if awsirsa is one of the registrationAuths and the cluster name in EKS kubeconfig doesn't contain hubClusterArn")
92+
cmd.Flags().StringSliceVar(&o.awsResourceTags, "aws-resource-tags", []string{},
93+
"List of tags to be added to AWS resources created by hub while processing awsirsa registration request, for example: product:v1:tenant:app-name=My-App,product:v1:tenant:created-by=Team-1")
8894

8995
cmd.Flags().StringSliceVar(&o.autoApprovedCSRIdentities, "auto-approved-csr-identities", []string{},
9096
"The users or identities that can be auto approved for CSR and auto accepted to join with hub cluster")

pkg/cmd/init/exec.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,15 @@ func getRegistrationDrivers(o *Options) ([]operatorv1.RegistrationDriverHub, err
390390

391391
for _, driver := range o.registrationDrivers {
392392
if driver == "csr" {
393-
registrationDriver = operatorv1.RegistrationDriverHub{AuthType: driver, AutoApprovedIdentities: o.autoApprovedCSRIdentities}
393+
csr := &operatorv1.CSRConfig{AutoApprovedIdentities: o.autoApprovedCSRIdentities}
394+
registrationDriver = operatorv1.RegistrationDriverHub{AuthType: driver, CSR: csr}
394395
} else if driver == "awsirsa" {
395396
hubClusterArn, err := getHubClusterArn(o)
396397
if err != nil {
397398
return registrationDrivers, err
398399
}
399-
registrationDriver = operatorv1.RegistrationDriverHub{AuthType: driver, AutoApprovedIdentities: o.autoApprovedARNPatterns, HubClusterArn: hubClusterArn}
400+
awsirsa := &operatorv1.AwsIrsaConfig{HubClusterArn: hubClusterArn, Tags: o.awsResourceTags, AutoApprovedIdentities: o.autoApprovedARNPatterns}
401+
registrationDriver = operatorv1.RegistrationDriverHub{AuthType: driver, AwsIrsa: awsirsa}
400402
}
401403
registrationDrivers = append(registrationDrivers, registrationDriver)
402404
}

pkg/cmd/init/options.go

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ type Options struct {
6161
autoApprovedCSRIdentities []string
6262
// A list of AWS EKS ARN patterns that are accepted and whatever matches can be auto accepted to join hub cluster
6363
autoApprovedARNPatterns []string
64+
// List of tags to be added to AWS resources created by hub while processing awsirsa registration request
65+
awsResourceTags []string
6466
}
6567

6668
func newOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *Options {

test/e2e/clusteradm/init_test.go

+16-6
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,22 @@ var _ = ginkgo.Describe("test clusteradm with bootstrap token in singleton mode"
5555
"--bundle-version=latest",
5656
"--registration-drivers=awsirsa,csr",
5757
"--hub-cluster-arn=arn:aws:eks:us-west-2:123456789012:cluster/hub-cluster1",
58+
"--aws-resource-tags=product:v1:tenant:app-name=My-App,product:v1:tenant:created-by=Team-1",
5859
)
5960
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "clusteradm init error")
6061

6162
cm, err = operatorClient.OperatorV1().ClusterManagers().Get(context.TODO(), "cluster-manager", metav1.GetOptions{})
6263
gomega.Expect(err).NotTo(gomega.HaveOccurred())
6364
// Ensure that awsirsa and csr is passed as registration-drivers both the values are set.
6465
gomega.Expect(len(cm.Spec.RegistrationConfiguration.RegistrationDrivers)).Should(gomega.Equal(2))
66+
6567
gomega.Expect(cm.Spec.RegistrationConfiguration.RegistrationDrivers[0].AuthType).Should(gomega.Equal("awsirsa"))
66-
gomega.Expect(cm.Spec.RegistrationConfiguration.RegistrationDrivers[1].AuthType).Should(gomega.Equal("csr"))
67-
gomega.Expect(cm.Spec.RegistrationConfiguration.RegistrationDrivers[0].HubClusterArn).
68+
gomega.Expect(cm.Spec.RegistrationConfiguration.RegistrationDrivers[0].AwsIrsa.HubClusterArn).
6869
Should(gomega.Equal("arn:aws:eks:us-west-2:123456789012:cluster/hub-cluster1"))
70+
gomega.Expect(cm.Spec.RegistrationConfiguration.RegistrationDrivers[0].AwsIrsa.Tags).
71+
Should(gomega.Equal("product:v1:tenant:app-name=My-App,product:v1:tenant:created-by=Team-1"))
72+
73+
gomega.Expect(cm.Spec.RegistrationConfiguration.RegistrationDrivers[1].AuthType).Should(gomega.Equal("csr"))
6974

7075
err = e2e.Clusteradm().Init(
7176
"--use-bootstrap-token",
@@ -74,17 +79,22 @@ var _ = ginkgo.Describe("test clusteradm with bootstrap token in singleton mode"
7479
"--registration-drivers=awsirsa,csr",
7580
"--hub-cluster-arn=arn:aws:eks:us-west-2:123456789012:cluster/hub-cluster1",
7681
"--feature-gates=ManagedClusterAutoApproval=true",
77-
"--auto-approved-csr-identities=csr1",
78-
"--auto-approved-arn-patterns=arn:aws:eks:us-west-2:123456789012:cluster/*",
82+
"--auto-approved-csr-identities=user1,user2",
83+
"--auto-approved-arn-patterns=arn:aws:eks:us-west-2:123456789013:cluster/.*,arn:aws:eks:us-west-2:123456789012:cluster/.*",
7984
)
8085
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "clusteradm init error")
8186
cm, err = operatorClient.OperatorV1().ClusterManagers().Get(context.TODO(), "cluster-manager", metav1.GetOptions{})
8287
gomega.Expect(err).NotTo(gomega.HaveOccurred())
8388
// Ensure that the auto approval identities contain user for CSR and pattern for AWS
8489
gomega.Expect(cm.Spec.RegistrationConfiguration.RegistrationDrivers[0].AuthType).Should(gomega.Equal("awsirsa"))
90+
gomega.Expect(cm.Spec.RegistrationConfiguration.RegistrationDrivers[0].AwsIrsa.HubClusterArn).
91+
Should(gomega.Equal("arn:aws:eks:us-west-2:123456789012:cluster/hub-cluster1"))
92+
gomega.Expect(cm.Spec.RegistrationConfiguration.RegistrationDrivers[0].AwsIrsa.AutoApprovedIdentities).
93+
Should(gomega.Equal("arn:aws:eks:us-west-2:123456789013:cluster/.*,arn:aws:eks:us-west-2:123456789012:cluster/.*"))
94+
8595
gomega.Expect(cm.Spec.RegistrationConfiguration.RegistrationDrivers[1].AuthType).Should(gomega.Equal("csr"))
86-
gomega.Expect(cm.Spec.RegistrationConfiguration.RegistrationDrivers[1].AutoApprovedIdentities[0]).Should(gomega.Equal("csr1"))
87-
gomega.Expect(cm.Spec.RegistrationConfiguration.RegistrationDrivers[0].AutoApprovedIdentities[0]).Should(gomega.Equal("arn:aws:eks:us-west-2:123456789012:cluster/*"))
96+
gomega.Expect(cm.Spec.RegistrationConfiguration.RegistrationDrivers[1].CSR.AutoApprovedIdentities).
97+
Should(gomega.Equal("user1,user2"))
8898

8999
err = e2e.Clusteradm().Init(
90100
"--use-bootstrap-token",

vendor/modules.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ k8s.io/utils/pointer
12451245
k8s.io/utils/ptr
12461246
k8s.io/utils/strings/slices
12471247
k8s.io/utils/trace
1248-
# open-cluster-management.io/api v0.15.1-0.20250219064651-4281b7684d9b
1248+
# open-cluster-management.io/api v0.15.1-0.20250226073118-8c9793267c9e
12491249
## explicit; go 1.22.0
12501250
open-cluster-management.io/api/addon/v1alpha1
12511251
open-cluster-management.io/api/client/addon/clientset/versioned
@@ -1288,7 +1288,7 @@ open-cluster-management.io/managed-serviceaccount/pkg/generated/clientset/versio
12881288
open-cluster-management.io/managed-serviceaccount/pkg/generated/clientset/versioned/scheme
12891289
open-cluster-management.io/managed-serviceaccount/pkg/generated/clientset/versioned/typed/authentication/v1alpha1
12901290
open-cluster-management.io/managed-serviceaccount/pkg/generated/clientset/versioned/typed/authentication/v1beta1
1291-
# open-cluster-management.io/ocm v0.15.1-0.20250228202623-6c270f90a09a
1291+
# open-cluster-management.io/ocm v0.15.1-0.20250306192929-c4e706f12358
12921292
## explicit; go 1.22.5
12931293
open-cluster-management.io/ocm/deploy/cluster-manager/chart
12941294
open-cluster-management.io/ocm/deploy/klusterlet/chart

vendor/open-cluster-management.io/api/operator/v1/0000_01_operator.open-cluster-management.io_clustermanagers.crd.yaml

+34-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/open-cluster-management.io/api/operator/v1/types_clustermanager.go

+22-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/open-cluster-management.io/api/operator/v1/zz_generated.deepcopy.go

+56-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/open-cluster-management.io/api/operator/v1/zz_generated.swagger_doc_generated.go

+21-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)