mirror of
https://github.com/storytold/irsa-manager.git
synced 2026-10-09 00:09:43 +00:00
cleanup option
This commit is contained in:
@@ -29,6 +29,11 @@ const (
|
|||||||
|
|
||||||
// IRSASetupSpec defines the desired state of IRSASetup
|
// IRSASetupSpec defines the desired state of IRSASetup
|
||||||
type IRSASetupSpec struct {
|
type IRSASetupSpec struct {
|
||||||
|
// Cleanup, when enabled, allows the IRSASetup to perform garbage collection
|
||||||
|
// of resources that are no longer needed or managed.
|
||||||
|
// +required
|
||||||
|
Cleanup bool `json:"cleanup"`
|
||||||
|
|
||||||
// Mode specifies the mode of operation. Can be either "selfhosted" or "eks".
|
// Mode specifies the mode of operation. Can be either "selfhosted" or "eks".
|
||||||
Mode string `json:"mode"`
|
Mode string `json:"mode"`
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,11 @@ spec:
|
|||||||
required:
|
required:
|
||||||
- secretRef
|
- secretRef
|
||||||
type: object
|
type: object
|
||||||
|
cleanup:
|
||||||
|
description: |-
|
||||||
|
Cleanup, when enabled, allows the IRSASetup to perform garbage collection
|
||||||
|
of resources that are no longer needed or managed.
|
||||||
|
type: boolean
|
||||||
discovery:
|
discovery:
|
||||||
description: |-
|
description: |-
|
||||||
Discovery configures the IdP Discovery process, essential for setting up IRSA by locating
|
Discovery configures the IdP Discovery process, essential for setting up IRSA by locating
|
||||||
@@ -90,6 +95,7 @@ spec:
|
|||||||
or "eks".
|
or "eks".
|
||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
|
- cleanup
|
||||||
- discovery
|
- discovery
|
||||||
- mode
|
- mode
|
||||||
type: object
|
type: object
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ _Appears in:_
|
|||||||
|
|
||||||
| Field | Description | Default | Validation |
|
| Field | Description | Default | Validation |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
|
| `cleanup` _boolean_ | Cleanup, when enabled, allows the IRSASetup to perform garbage collection<br />of resources that are no longer needed or managed. | | |
|
||||||
| `mode` _string_ | Mode specifies the mode of operation. Can be either "selfhosted" or "eks". | | |
|
| `mode` _string_ | Mode specifies the mode of operation. Can be either "selfhosted" or "eks". | | |
|
||||||
| `discovery` _[Discovery](#discovery)_ | Discovery configures the IdP Discovery process, essential for setting up IRSA by locating<br />the OIDC provider information. | | |
|
| `discovery` _[Discovery](#discovery)_ | Discovery configures the IdP Discovery process, essential for setting up IRSA by locating<br />the OIDC provider information. | | |
|
||||||
| `auth` _[Auth](#auth)_ | Auth contains authentication configuration details. | | |
|
| `auth` _[Auth](#auth)_ | Auth contains authentication configuration details. | | |
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
apiVersion: irsa.kkb0318.github.io/v1alpha1
|
||||||
|
kind: IRSASetup
|
||||||
|
metadata:
|
||||||
|
name: irsa-init
|
||||||
|
namespace: irsa-manager-system
|
||||||
|
spec:
|
||||||
|
cleanup: false
|
||||||
|
mode: selfhosted
|
||||||
|
discovery:
|
||||||
|
s3:
|
||||||
|
region: ap-northeast-1
|
||||||
|
bucketName: irsa-manager-test-kkb0010101
|
||||||
@@ -130,7 +130,7 @@ func (r *IRSASetupReconciler) reconcileDelete(ctx context.Context, obj *irsav1al
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
kubeHandler := handler.NewKubernetesHandler(kubeClient)
|
kubeHandler := handler.NewKubernetesHandler(kubeClient, obj.Spec.Cleanup)
|
||||||
kubeHandler.Append(secret)
|
kubeHandler.Append(secret)
|
||||||
webhookSetup, err := webhook.NewWebHookSetup()
|
webhookSetup, err := webhook.NewWebHookSetup()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -180,7 +180,7 @@ func reconcileSelfhosted(ctx context.Context, obj *irsav1alpha1.IRSASetup, awsCl
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
kubeHandler := handler.NewKubernetesHandler(kubeClient)
|
kubeHandler := handler.NewKubernetesHandler(kubeClient, obj.Spec.Cleanup)
|
||||||
kubeHandler.Append(secret)
|
kubeHandler.Append(secret)
|
||||||
|
|
||||||
// for webhook setup
|
// for webhook setup
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ var _ = Describe("IRSASetup Controller", func() {
|
|||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
},
|
},
|
||||||
Spec: irsav1alpha1.IRSASetupSpec{
|
Spec: irsav1alpha1.IRSASetupSpec{
|
||||||
Mode: "selfhosted",
|
Cleanup: true,
|
||||||
|
Mode: "selfhosted",
|
||||||
Discovery: irsav1alpha1.Discovery{
|
Discovery: irsav1alpha1.Discovery{
|
||||||
S3: irsav1alpha1.S3Discovery{
|
S3: irsav1alpha1.S3Discovery{
|
||||||
Region: "ap-northeast-1",
|
Region: "ap-northeast-1",
|
||||||
@@ -132,7 +133,8 @@ var _ = Describe("IRSASetup Controller", func() {
|
|||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
},
|
},
|
||||||
Spec: irsav1alpha1.IRSASetupSpec{
|
Spec: irsav1alpha1.IRSASetupSpec{
|
||||||
Mode: "selfhoted",
|
Cleanup: true,
|
||||||
|
Mode: "selfhoted",
|
||||||
Discovery: irsav1alpha1.Discovery{
|
Discovery: irsav1alpha1.Discovery{
|
||||||
S3: irsav1alpha1.S3Discovery{
|
S3: irsav1alpha1.S3Discovery{
|
||||||
Region: "ap-northeast-1",
|
Region: "ap-northeast-1",
|
||||||
|
|||||||
@@ -10,14 +10,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type KubernetesHandler struct {
|
type KubernetesHandler struct {
|
||||||
client KubernetesClient
|
client KubernetesClient
|
||||||
objs []client.Object
|
objs []client.Object
|
||||||
|
cleanup bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewKubernetesHandler(c KubernetesClient) *KubernetesHandler {
|
func NewKubernetesHandler(c KubernetesClient, cleanup bool) *KubernetesHandler {
|
||||||
return &KubernetesHandler{
|
return &KubernetesHandler{
|
||||||
client: c,
|
client: c,
|
||||||
objs: []client.Object{},
|
objs: []client.Object{},
|
||||||
|
cleanup: cleanup,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user