@@ -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"
@@ -155,18 +158,52 @@ func (c *Publisher) processNextWorkItem() bool {
155158 return true
156159}
157160
161+ var (
162+ // default secure
163+ // This annotation prompts the service ca operator to inject
164+ // the service ca bundle into the configmap.
165+ injectionAnnotation = map [string ]string {
166+ "service.beta.openshift.io/inject-cabundle" : "true" ,
167+ }
168+ setAnnotationOnce = sync.Once {}
169+ )
170+
171+ func getInjectionAnnotation () map [string ]string {
172+ setAnnotationOnce .Do (func () {
173+ // this envvar can be used to get the kube-controller-manager to inject a vulnerable legacy service ca
174+ // the kube-controller-manager carries no existing patches to launch, so we aren't going add new
175+ // perma-flags.
176+ // it would be nicer to find a way to pass this more obviously. This is a deep side-effect.
177+ // though ideally, we see this age out over time.
178+ useVulnerable := os .Getenv ("OPENSHIFT_USE_VULNERABLE_LEGACY_SERVICE_CA_CRT" )
179+ if len (useVulnerable ) == 0 {
180+ return
181+ }
182+ useVulnerableBool , err := strconv .ParseBool (useVulnerable )
183+ if err != nil {
184+ // caller went crazy, don't use this unless you're careful
185+ panic (err )
186+ }
187+ if useVulnerableBool {
188+ // This annotation prompts the service ca operator to inject
189+ // the vulnerable, legacy service ca bundle into the configmap.
190+ injectionAnnotation = map [string ]string {
191+ "service.alpha.openshift.io/inject-vulnerable-legacy-cabundle" : "true" ,
192+ }
193+ }
194+ })
195+
196+ return injectionAnnotation
197+ }
198+
158199func (c * Publisher ) syncNamespace (ns string ) (err error ) {
159200 startTime := time .Now ()
160201 defer func () {
161202 recordMetrics (startTime , ns , err )
162203 klog .V (4 ).Infof ("Finished syncing namespace %q (%v)" , ns , time .Since (startTime ))
163204 }()
164205
165- annotations := map [string ]string {
166- // This annotation prompts the service ca operator to inject
167- // the service ca bundle into the configmap.
168- "service.beta.openshift.io/inject-cabundle" : "true" ,
169- }
206+ annotations := getInjectionAnnotation ()
170207
171208 cm , err := c .cmLister .ConfigMaps (ns ).Get (ServiceCACertConfigMapName )
172209 switch {
0 commit comments