@@ -3,7 +3,10 @@ package servicecacertpublisher
33import (
44 "context"
55 "fmt"
6+ "os"
67 "reflect"
8+ "strconv"
9+ "sync"
710 "time"
811
912 v1 "k8s.io/api/core/v1"
@@ -149,18 +152,52 @@ func (c *Publisher) processNextWorkItem() bool {
149152 return true
150153}
151154
155+ var (
156+ // default secure
157+ // This annotation prompts the service ca operator to inject
158+ // the service ca bundle into the configmap.
159+ injectionAnnotation = map [string ]string {
160+ "service.beta.openshift.io/inject-cabundle" : "true" ,
161+ }
162+ setAnnotationOnce = sync.Once {}
163+ )
164+
165+ func getInjectionAnnotation () map [string ]string {
166+ setAnnotationOnce .Do (func () {
167+ // this envvar can be used to get the kube-controller-manager to inject a vulnerable legacy service ca
168+ // the kube-controller-manager carries no existing patches to launch, so we aren't going add new
169+ // perma-flags.
170+ // it would be nicer to find a way to pass this more obviously. This is a deep side-effect.
171+ // though ideally, we see this age out over time.
172+ useVulnerable := os .Getenv ("OPENSHIFT_USE_VULNERABLE_LEGACY_SERVICE_CA_CRT" )
173+ if len (useVulnerable ) == 0 {
174+ return
175+ }
176+ useVulnerableBool , err := strconv .ParseBool (useVulnerable )
177+ if err != nil {
178+ // caller went crazy, don't use this unless you're careful
179+ panic (err )
180+ }
181+ if useVulnerableBool {
182+ // This annotation prompts the service ca operator to inject
183+ // the vulnerable, legacy service ca bundle into the configmap.
184+ injectionAnnotation = map [string ]string {
185+ "service.alpha.openshift.io/inject-vulnerable-legacy-cabundle" : "true" ,
186+ }
187+ }
188+ })
189+
190+ return injectionAnnotation
191+ }
192+
152193func (c * Publisher ) syncNamespace (ns string ) (err error ) {
153194 startTime := time .Now ()
154195 defer func () {
155196 recordMetrics (startTime , ns , err )
156197 klog .V (4 ).Infof ("Finished syncing namespace %q (%v)" , ns , time .Since (startTime ))
157198 }()
158199
159- annotations := map [string ]string {
160- // This annotation prompts the service ca operator to inject
161- // the service ca bundle into the configmap.
162- "service.beta.openshift.io/inject-cabundle" : "true" ,
163- }
200+ annotations := getInjectionAnnotation ()
164201
165202 cm , err := c .cmLister .ConfigMaps (ns ).Get (ServiceCACertConfigMapName )
166203 switch {
0 commit comments