@@ -3,7 +3,10 @@ package servicecacertpublisher
3
3
import (
4
4
"context"
5
5
"fmt"
6
+ "os"
6
7
"reflect"
8
+ "strconv"
9
+ "sync"
7
10
"time"
8
11
9
12
v1 "k8s.io/api/core/v1"
@@ -149,18 +152,52 @@ func (c *Publisher) processNextWorkItem() bool {
149
152
return true
150
153
}
151
154
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
+
152
193
func (c * Publisher ) syncNamespace (ns string ) (err error ) {
153
194
startTime := time .Now ()
154
195
defer func () {
155
196
recordMetrics (startTime , ns , err )
156
197
klog .V (4 ).Infof ("Finished syncing namespace %q (%v)" , ns , time .Since (startTime ))
157
198
}()
158
199
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 ()
164
201
165
202
cm , err := c .cmLister .ConfigMaps (ns ).Get (ServiceCACertConfigMapName )
166
203
switch {
0 commit comments