GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Maltazar/kubernetes-reflector: Custom Kubernetes controller that can be used to replicate secrets, configmaps and certificates.

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

336 Commits
336 Commits

Folders and files

NameName
Last commit message
Last commit date
.claude
.claude
 
 
.github
.github
 
 
assets
assets
 
 
examples
examples
 
 
src/ES.Kubernetes.Reflector
src/ES.Kubernetes.Reflector
 
 
tests/ES.Kubernetes.Reflector.Tests
tests/ES.Kubernetes.Reflector.Tests
 
 
.dockerignore
.dockerignore
 
 
.gitignore
.gitignore
 
 
Directory.Build.props
Directory.Build.props
 
 
Directory.Packages.props
Directory.Packages.props
 
 
ES.Kubernetes.Reflector.sln
ES.Kubernetes.Reflector.sln
 
 
ES.Kubernetes.Reflector.sln.DotSettings
ES.Kubernetes.Reflector.sln.DotSettings
 
 
GitVersion.yaml
GitVersion.yaml
 
 
LICENSE
LICENSE
 
 
NuGet.config
NuGet.config
 
 
README.md
README.md
 
 
Shared.DotSettings
Shared.DotSettings
 
 

Repository files navigation

Reflector

Reflector is a Kubernetes addon designed to monitor changes to resources (secrets and configmaps) and reflect changes to mirror resources in the same or other namespaces.

Pipeline Release Docker Image Docker Pulls license

Supports amd64, arm and arm64

Support

If you need help or found a bug, please feel free to open an Issue on GitHub (https://github.com/emberstack/kubernetes-reflector/issues).

Deployment

Reflector is deployed by applying the release manifest to your cluster.

Prerequisites

  • Kubernetes 1.22+

Deployment

Each release (found on the Releases GitHub page) contains the deployment manifest (reflector.yaml).

$ kubectl -n kube-system apply -f https://github.com/emberstack/kubernetes-reflector/releases/latest/download/reflector.yaml

Usage

1. Annotate the source secret or configmap

  • Add reflector.v1.k8s.emberstack.com/reflection-allowed: "true" to the resource annotations to permit reflection to mirrors.
  • Add reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "<list>" to the resource annotations to permit reflection from only the list of comma separated namespaces or regular expressions. Note: If this annotation is omitted or is empty, all namespaces are allowed.
  • Add reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces-selector: "<selector>" to the resource annotations to permit reflection only to namespaces matching the given Kubernetes label selector (e.g. env=production, team in (a,b)). If both this and reflection-allowed-namespaces are set, a namespace matches if it satisfies either condition.

Label and annotation reflection:

By default, only the resource data is reflected. Labels and annotations from the source can optionally be copied to mirrors using regex filters:

  • Add reflector.v1.k8s.emberstack.com/label-filter: "<pattern>" to copy source labels whose keys match the pattern. Supports comma-separated regex patterns with full-match semantics (e.g. app\.kubernetes\.io/.*,my-label). If omitted, no labels are copied.
  • Add reflector.v1.k8s.emberstack.com/annotation-filter: "<pattern>" to copy source annotations whose keys match the pattern. Same syntax as the label filter. If omitted, no user annotations are copied.

Note: The annotation filter always excludes internal annotations regardless of the pattern. The following prefixes are excluded:

  • reflector.v1.k8s.emberstack.com/ (reflector's own annotations)
  • kubectl.kubernetes.io/ (e.g. last-applied-configuration)
  • deployment.kubernetes.io/ (e.g. revision)
  • argocd.argoproj.io/ (e.g. tracking-id)

Automatic mirror creation:

Reflector can create mirrors with the same name in other namespaces automatically. The following annotations control if and how the mirrors are created:

  • Add reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true" to the resource annotations to automatically create mirrors in other namespaces. Note: Requires reflector.v1.k8s.emberstack.com/reflection-allowed to be true since mirrors need to able to reflect the source.
  • Add reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: "<list>" to the resource annotations specify in which namespaces to automatically create mirrors. Note: If this annotation is omitted or is empty, all namespaces are allowed. Namespaces in this list will also be checked by reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces since mirrors need to be in namespaces from where reflection is permitted.
  • Add reflector.v1.k8s.emberstack.com/reflection-auto-namespaces-selector: "<selector>" to the resource annotations to select namespaces for automatic mirrors using a Kubernetes label selector. If both this and reflection-auto-namespaces are set, a namespace matches if it satisfies either condition.

Important: If the source is deleted, automatic mirrors are deleted. Also if either reflection or automirroring is turned off or the automatic mirror's namespace is no longer a valid match for the allowed namespaces, the automatic mirror is deleted.

Important: Reflector will skip any conflicting resource when creating auto-mirrors. If there is already a resource with the source's name in a namespace where an automatic mirror is to be created, that namespace is skipped and logged as a warning.

Example source secret:

apiVersion: v1
kind: Secret
metadata:
 name: source-secret
 annotations:
   reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
   reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "namespace-1,namespace-2,namespace-[0-9]*"
   reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces-selector: "env=production"
   reflector.v1.k8s.emberstack.com/label-filter: "app\\.kubernetes\\.io/.*"
   reflector.v1.k8s.emberstack.com/annotation-filter: "my-org\\.io/.*"
data:
 ...

Example source configmap:

apiVersion: v1
kind: ConfigMap
metadata:
 name: source-config-map
 annotations:
   reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
   reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "namespace-1,namespace-2,namespace-[0-9]*"
   reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces-selector: "env=production"
   reflector.v1.k8s.emberstack.com/label-filter: "app\\.kubernetes\\.io/.*"
   reflector.v1.k8s.emberstack.com/annotation-filter: "my-org\\.io/.*"
data:
 ...

2. Annotate the mirror secret or configmap

  • Add reflector.v1.k8s.emberstack.com/reflects: "<source namespace>/<source name>" to the mirror object. The value of the annotation is the full name of the source object in namespace/name format.

Note: Add reflector.v1.k8s.emberstack.com/reflected-version: "" to the resource annotations when doing any manual changes to the mirror (for example when re-applying the deployment manifest). This will reset the reflected version of the mirror.

Example mirror secret:

apiVersion: v1
kind: Secret
metadata:
 name: mirror-secret
 annotations:
   reflector.v1.k8s.emberstack.com/reflects: "default/source-secret"
data:
 ...

Example mirror configmap:

apiVersion: v1
kind: ConfigMap
metadata:
 name: mirror-config-map
 annotations:
   reflector.v1.k8s.emberstack.com/reflects: "default/source-config-map"
data:
 ...

3. Done!

Reflector will monitor any changes done to the source objects and copy the following fields:

  • data for secrets
  • data and binaryData for configmaps
  • labels matching the label-filter pattern (if set)
  • annotations matching the annotation-filter pattern (if set, excluding internal annotations)

Reflector keeps track of what was copied by annotating mirrors with the source object version.


cert-manager support

Since version 1.5 of cert-manager you can annotate secrets created from certificates for mirroring using secretTemplate (see https://cert-manager.io/docs/usage/certificate/).

apiVersion: cert-manager.io/v1
kind: Certificate
...
spec:
  secretTemplate:
    annotations:
      reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
      reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: ""
      reflector.v1.k8s.emberstack.com/label-filter: ".*"  # optional: reflect all labels
  ...

=======

Since version 1.15 of cert-manager you can annotate Ingress to create secrets created from certificates for mirroring using cert-manager.io/secret-template annotation (see cert-manager/cert-manager#6839).

apiVersion: networking.k8s.io/v1
kind: Ingress
...
metadata:
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
    cert-manager.io/secret-template: |
      {"annotations": {"reflector.v1.k8s.emberstack.com/reflection-allowed": "true", "reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces": ""}}
  ...

About

Custom Kubernetes controller that can be used to replicate secrets, configmaps and certificates.

Resources

Readme
License
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.