**Description**
<!--
Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that
are required for this change.
-->
⚒️ Fixes #8634
**⚙️ Type of change**
- [ ] ⚙️ Feature/App addition
- [ ] 🪛 Bugfix
- [X] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] 🔃 Refactor of current code
**🧪 How Has This Been Tested?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->
**📃 Notes:**
<!-- Please enter any other relevant information here -->
**✔️ Checklist:**
- [ ] ⚖️ My code follows the style guidelines of this project
- [ ] 👀 I have performed a self-review of my own code
- [ ] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [ ] 📄 I have made corresponding changes to the documentation
- [ ] ⚠️ My changes generate no new warnings
- [ ] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [X] ⬆️ I increased versions for any altered app according to semantic
versioning
**➕ App addition**
If this PR is an app addition please make sure you have done the
following.
- [ ] 🪞 I have opened a PR on
[truecharts/containers](https://github.com/truecharts/containers) adding
the container to TrueCharts mirror repo.
- [ ] 🖼️ I have added an icon in the Chart's root directory called
`icon.png`
---
_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._
**Description**
<!--
Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that
are required for this change.
-->
Although Kubernetes-reflector can be used to mirror both generic
Configmaps and Secrets across k8s namespaces, with this PR I
specifically intend to lay the groundwork for supporting wildcard
certificates in Truecharts.
To keep things small this PR only adds the app needed to support secrets
mirroring across namespaces. The rest of the functionality will be added
through separate PRs.
A high-level overview of how I picture this to work:
- A user will gain the ability to create "cluster-wide" certificates in
the `clusterIssuer` app config. This will generate the certificates and
store them in the app's namespace
- The created/updated certificates will be mirrored automatically to all
namespaces matching the regex `ix-.+` (or configurable for helm users)
with the help of the `kubernetes-reflector` app
- The user will gain the ability to use a "cluster-wide" certificate
when setting up an ingress for an app. Similar to how they can currently
use a custom secret for an ingress cert.
To achieve this in next PRs I will be:
- Submitting small patches to the common lib. So far I think the only
change needed is to allow setting annotations to `Certificate` CRDs,
which is needed to allow `kubernetes-reflector` to replicate them (see
[cert-manager
docs](https://cert-manager.io/docs/devops-tips/syncing-secrets-across-namespaces/#using-reflector))
- Submitting small patches to the clusterIssuer app and the
`Ingress{*}.yaml` files
Relevant issue: #8634
I have not yet added the image to the TC repo. Will do that after the
review process, before merging.
⚒️ Fixes # <!--(issue)-->
**⚙️ Type of change**
- [X] ⚙️ Feature/App addition
- [ ] 🪛 Bugfix
- [ ] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] 🔃 Refactor of current code
**🧪 How Has This Been Tested?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->
I have tested this by deploying the `kubernetes-reflector` app and then
applying the following yaml:
```yaml
apiVersion: v1
kind: Namespace
metadata:
name: origin
---
apiVersion: v1
kind: Namespace
metadata:
name: destination1
---
apiVersion: v1
kind: Namespace
metadata:
name: destination2
---
apiVersion: v1
kind: Namespace
metadata:
name: another-destination1
---
apiVersion: v1
kind: Namespace
metadata:
name: another-destination2
---
apiVersion: v1
kind: Secret
metadata:
annotations:
# Allow reflection from source namespaces
reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
# Namespaces from/to which reflection is allowed
reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "origin,(another-)?destination\\d+"
# Auto reflect secrets/configmaps to destination namespaces
reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true"
# Destination namespaces
reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: "(another-)?destination\\d+"
name: my-secret
namespace: origin
type: Opaque
data:
mydata: c2VjcmV0Cg==
# mydata: c3VwZXJzdXBlcnNlY3JldAo=
```
Exact commands and output:
```bash
$ kubectl create ns ix-kubernetes-reflector
$ helm install -n ix-kubernetes-reflector kubernetes-reflector .
$ kubectl get secrets --all-namespaces
NAMESPACE NAME TYPE DATA AGE
kube-system pop-os.node-password.k3s Opaque 1 144d
kube-system k3s-serving kubernetes.io/tls 2 144d
ix-kubernetes-reflector sh.helm.release.v1.kubernetes-reflector.v1 helm.sh/release.v1 1 8s
$ kubectl apply -f test-reflect.yaml
namespace/origin created
namespace/destination1 created
namespace/destination2 created
namespace/another-destination1 created
namespace/another-destination2 created
secret/my-secret created
$ kubectl get secrets --all-namespaces
NAMESPACE NAME TYPE DATA AGE
kube-system pop-os.node-password.k3s Opaque 1 144d
kube-system k3s-serving kubernetes.io/tls 2 144d
ix-kubernetes-reflector sh.helm.release.v1.kubernetes-reflector.v1 helm.sh/release.v1 1 29s
origin my-secret Opaque 1 5s
destination1 my-secret Opaque 1 5s
destination2 my-secret Opaque 1 5s
another-destination1 my-secret Opaque 1 5s
another-destination2 my-secret Opaque 1 5s
$ kubectl describe secret -n destination1 my-secret | tail -1
mydata: 7 bytes
$ # Change the secret value (uncomment the other key and comment the first one)
$ kubectl apply -f test-reflect.yaml
$ kubectl describe secret -n destination1 my-secret | tail -1
mydata: 17 bytes
$ kubectl delete secret -n origin my-secret
secret "my-secret" deleted
$ kubectl get secrets --all-namespaces
NAMESPACE NAME TYPE DATA AGE
kube-system pop-os.node-password.k3s Opaque 1 144d
kube-system k3s-serving kubernetes.io/tls 2 144d
ix-kubernetes-reflector sh.helm.release.v1.kubernetes-reflector.v1 helm.sh/release.v1 1 3m24s
```
**📃 Notes:**
<!-- Please enter any other relevant information here -->
**✔️ Checklist:**
- [X] ⚖️ My code follows the style guidelines of this project
- [X] 👀 I have performed a self-review of my own code
- [X] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [ ] 📄 I have made corresponding changes to the documentation
- [X] ⚠️ My changes generate no new warnings
- [X] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [X] ⬆️ I increased versions for any altered app according to semantic
versioning
**➕ App addition**
If this PR is an app addition please make sure you have done the
following.
- [ ] 🪞 I have opened a PR on
[truecharts/containers](https://github.com/truecharts/containers) adding
the container to TrueCharts mirror repo.
- [X] 🖼️ I have added an icon in the Chart's root directory called
`icon.png`
---
_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._
---------
Signed-off-by: sdimovv <36302090+sdimovv@users.noreply.github.com>
Signed-off-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
Co-authored-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>