While there is an open issue for SealedSecret support (#702), it seems to be focused on generating sealed secrets from files, rather than using existing sealed secrets.
The issue I'm currently facing is as follows:
I have the following files (see below for abbreviated file content):
Both the SealedSecret and the generated Secret have the correct suffix, but the references in the deployment/ingress objects retain the unmodified secret references, instead of appending the suffix to those as well.
Is there a way to prevent the '-staging' suffix to be attached to specific files or the SealedSecret type in general (this would also forgo the need to add the "sealedsecrets.bitnami.com/namespace-wide": "true" annotation to allow renaming of secrets defined within sealed secrets)?
For now, I'm using a patch defined in my kustomization.yaml to ovewrite the references to the secrets and add the suffix manually, but I'm wondering if there's an easier way to handle this problem?
kustomization.yaml
resources:
- deployment.yaml
- sealedsecret.json
nameSuffix: '-staging'
sealedSecret.json
{
"kind": "SealedSecret",
"apiVersion": "bitnami.com/v1alpha1",
"metadata": {
"name": "mysecret",
[...]
"annotations": {
"sealedsecrets.bitnami.com/namespace-wide": "true"
}
},
[...]
}
deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
[...]
name: my-deployment
spec:
[...]
template:
[...]
spec:
[...]
volumes:
- name: mysecret-volume
secret:
secretName: mysecret
As a small aside: while name prefix/suffix is applied to the Sealed Secrets and the corresponding Secrets, common labels are not applied.
Another approach that allows kustomize to properly replace sealed secrets names is to create a Custom Resource Definition (actually a Name reference transformer) to detail all the possible fields that can refer to a SealedSecret in your application.
The CRD definition for your example should be (in base/kustomizeconfig/sealedsecret.yaml file):
nameReference:
- kind: SealedSecret
fieldSpecs:
# Deployment references
- path: spec/template/spec/volumes/secret/secretName
kind: Deployment
# Add all kind/paths depending on which resources use your sealed secrets
Then in your base/kustomization.yaml add the reference to the configuration
configurations:
- kustomizeconfig/sealedsecret.yaml
You should be able to follow the same approach for common labels. Here is a tutorial for Supporting Custom Resources
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
@fejta-bot: Closing this issue.
In response to this:
Rotten issues close after 30d of inactivity.
Reopen the issue with/reopen.
Mark the issue as fresh with/remove-lifecycle rotten.Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Most helpful comment
Another approach that allows kustomize to properly replace sealed secrets names is to create a Custom Resource Definition (actually a Name reference transformer) to detail all the possible fields that can refer to a
SealedSecretin your application.The CRD definition for your example should be (in
base/kustomizeconfig/sealedsecret.yamlfile):Then in your
base/kustomization.yamladd the reference to the configurationYou should be able to follow the same approach for common labels. Here is a tutorial for Supporting Custom Resources