Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Make secret type field configurable
Alex Birca377a79f17da8
diff --git a/k8-operator/api/v1alpha1/infisicalsecret_types.go b/k8-operator/api/v1alpha1/infisicalsecret_types.goindex 3b61bd215f..50a11e4344 100644--- a/k8-operator/api/v1alpha1/infisicalsecret_types.go+++ b/k8-operator/api/v1alpha1/infisicalsecret_types.go@@ -41,6 +41,10 @@ type KubeSecretReference struct {// The name space where the Kubernetes Secret is located// +kubebuilder:validation:RequiredSecretNamespace string `json:"secretNamespace"`++ // The Kubernetes Secret type. More info: https://kubernetes.io/docs/concepts/configuration/secret/#secret-types+ // +kubebuilder:validation:Optional+ SecretType string `json:"secretType"`}// InfisicalSecretSpec defines the desired state of InfisicalSecretdiff --git a/k8-operator/config/crd/bases/secrets.infisical.com_infisicalsecrets.yaml b/k8-operator/config/crd/bases/secrets.infisical.com_infisicalsecrets.yamlindex 07433f7817..eb170fb36b 100644--- a/k8-operator/config/crd/bases/secrets.infisical.com_infisicalsecrets.yaml+++ b/k8-operator/config/crd/bases/secrets.infisical.com_infisicalsecrets.yaml@@ -52,6 +52,9 @@ spec:description: The name space where the Kubernetes Secretis locatedtype: string+ secretType:+ description: 'The Kubernetes Secret type. More info: https://kubernetes.io/docs/concepts/configuration/secret/#secret-types'+ type: stringrequired:- secretName- secretNamespace@@ -82,6 +85,9 @@ spec:description: The name space where the Kubernetes Secretis locatedtype: string+ secretType:+ description: 'The Kubernetes Secret type. More info: https://kubernetes.io/docs/concepts/configuration/secret/#secret-types'+ type: stringrequired:- secretName- secretNamespace@@ -102,6 +108,9 @@ spec:secretNamespace:description: The name space where the Kubernetes Secret is locatedtype: string+ secretType:+ description: 'The Kubernetes Secret type. More info: https://kubernetes.io/docs/concepts/configuration/secret/#secret-types'+ type: stringrequired:- secretName- secretNamespace@@ -117,6 +126,9 @@ spec:secretNamespace:description: The name space where the Kubernetes Secret is locatedtype: string+ secretType:+ description: 'The Kubernetes Secret type. More info: https://kubernetes.io/docs/concepts/configuration/secret/#secret-types'+ type: stringrequired:- secretName- secretNamespacediff --git a/k8-operator/controllers/auto_redeployment.go b/k8-operator/controllers/auto_redeployment.goindex e4fa6d00fe..e63ac88af4 100644--- a/k8-operator/controllers/auto_redeployment.go+++ b/k8-operator/controllers/auto_redeployment.go@@ -36,6 +36,8 @@ func (r *InfisicalSecretReconciler) ReconcileDeploymentsWithManagedSecrets(ctx cvar wg sync.WaitGroup// Iterate over the deployments and check if they use the managed secretfor _, deployment := range listOfDeployments.Items {+ // Adding bc of https://github.com/golang/go/issues/16520+ deployment := deploymentif deployment.Annotations[AUTO_RELOAD_DEPLOYMENT_ANNOTATION] == "true" && r.IsDeploymentUsingManagedSecret(deployment, infisicalSecret) {// Start a goroutine to reconcile the deploymentwg.Add(1)diff --git a/k8-operator/controllers/infisicalsecret_helper.go b/k8-operator/controllers/infisicalsecret_helper.goindex 509de94ac8..066d0e24ed 100644--- a/k8-operator/controllers/infisicalsecret_helper.go+++ b/k8-operator/controllers/infisicalsecret_helper.go@@ -72,7 +72,6 @@ func (r *InfisicalSecretReconciler) GetInfisicalTokenFromKubeSecret(ctx context.// default to new secret ref structuresecretName := infisicalSecret.Spec.Authentication.ServiceToken.ServiceTokenSecretReference.SecretNamesecretNamespace := infisicalSecret.Spec.Authentication.ServiceToken.ServiceTokenSecretReference.SecretNamespace-// fall back to previous secret refif secretName == "" {secretName = infisicalSecret.Spec.TokenSecretReference.SecretName@@ -129,6 +128,13 @@ func (r *InfisicalSecretReconciler) GetInfisicalServiceAccountCredentialsFromKubfunc (r *InfisicalSecretReconciler) CreateInfisicalManagedKubeSecret(ctx context.Context, infisicalSecret v1alpha1.InfisicalSecret, secretsFromAPI []model.SingleEnvironmentVariable, encryptedSecretsResponse api.GetEncryptedSecretsV3Response) error {plainProcessedSecrets := make(map[string][]byte)+ secretType := infisicalSecret.Spec.ManagedSecretReference.SecretType++ // Set the default secret type to "Opaque" if not provided+ if secretType == "" {+ secretType = "Opaque"+ }+for _, secret := range secretsFromAPI {plainProcessedSecrets[secret.Key] = []byte(secret.Value) // plain process}@@ -142,7 +148,7 @@ func (r *InfisicalSecretReconciler) CreateInfisicalManagedKubeSecret(ctx contextSECRET_VERSION_ANNOTATION: encryptedSecretsResponse.ETag,},},- Type: "Opaque",+ Type: corev1.SecretType(secretType),Data: plainProcessedSecrets,}@@ -151,7 +157,7 @@ func (r *InfisicalSecretReconciler) CreateInfisicalManagedKubeSecret(ctx contextreturn fmt.Errorf("unable to create the managed Kubernetes secret : %w", err)}- fmt.Println("Successfully created a managed Kubernetes secret with your Infisical secrets")+ fmt.Printf("Successfully created a managed Kubernetes secret with your Infisical secrets. Type: %s\n", secretType)return nil}