serviceaccount

This commit is contained in:
kkb0318
2024-05-16 22:21:17 +09:00
parent 75cc0af730
commit a3a1a6d59a
4 changed files with 37 additions and 13 deletions
+1 -2
View File
@@ -49,8 +49,7 @@ type IRSAReconciler struct {
func (r *IRSAReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
_ = log.FromContext(ctx)
// TODO(user): your logic here
// roleArn: arn:aws:iam::{accountId}:role/{roleName}
return ctrl.Result{}, nil
}
@@ -1 +0,0 @@
package manifests
+34
View File
@@ -0,0 +1,34 @@
package manifests
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)
type ServiceAccountBuilder struct {
annotation map[string]string
}
func NewServiceAccountBuilder() *ServiceAccountBuilder {
return &ServiceAccountBuilder{}
}
func (b *ServiceAccountBuilder) WithAnnotation(annotation map[string]string) *ServiceAccountBuilder {
b.annotation = annotation
return b
}
func (b *ServiceAccountBuilder) Build(namespacedName types.NamespacedName) *corev1.ServiceAccount {
return &corev1.ServiceAccount{
TypeMeta: metav1.TypeMeta{
APIVersion: corev1.SchemeGroupVersion.String(),
Kind: "ServiceAccount",
},
ObjectMeta: metav1.ObjectMeta{
Name: namespacedName.Name,
Namespace: namespacedName.Namespace,
Annotations: b.annotation,
},
}
}
+2 -10
View File
@@ -1,6 +1,7 @@
package webhook
import (
"github.com/kkb0318/irsa-manager/internal/manifests"
regv1 "k8s.io/api/admissionregistration/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
@@ -136,16 +137,7 @@ func (b *baseManifestFactory) deployment() *appsv1.Deployment {
}
func (b *baseManifestFactory) serviceAccount() *corev1.ServiceAccount {
return &corev1.ServiceAccount{
TypeMeta: metav1.TypeMeta{
APIVersion: corev1.SchemeGroupVersion.String(),
Kind: "ServiceAccount",
},
ObjectMeta: metav1.ObjectMeta{
Name: b.serviceAccountMeta.Name,
Namespace: b.serviceAccountMeta.Namespace,
},
}
return manifests.NewServiceAccountBuilder().Build(b.serviceAccountMeta)
}
func (b *baseManifestFactory) clusterRole() *rbacv1.ClusterRole {