1
1
package controller
2
2
3
3
import (
4
- "fmt"
5
- "io/ioutil"
6
4
"path"
7
5
"time"
8
6
9
7
"k8s.io/apimachinery/pkg/runtime/schema"
10
- "k8s.io/client-go/util/cert"
11
8
"k8s.io/kubernetes/pkg/api/legacyscheme"
12
9
kapi "k8s.io/kubernetes/pkg/apis/core"
13
- kcontroller "k8s.io/kubernetes/pkg/controller"
14
10
serviceaccountadmission "k8s.io/kubernetes/plugin/pkg/admission/serviceaccount"
15
11
16
12
configapi "github.com/openshift/origin/pkg/cmd/server/apis/config"
17
- "github.com/openshift/origin/pkg/cmd/server/crypto"
18
13
"github.com/openshift/origin/pkg/cmd/util/variable"
19
14
)
20
15
@@ -56,8 +51,6 @@ func getOpenShiftClientEnvVars(options configapi.MasterConfig) ([]kapi.EnvVar, e
56
51
// OpenshiftControllerConfig is the runtime (non-serializable) config object used to
57
52
// launch the set of openshift (not kube) controllers.
58
53
type OpenshiftControllerConfig struct {
59
- ServiceAccountTokenControllerOptions ServiceAccountTokenControllerOptions
60
-
61
54
ServiceAccountControllerOptions ServiceAccountControllerOptions
62
55
63
56
BuildControllerConfig BuildControllerConfig
@@ -83,8 +76,6 @@ type OpenshiftControllerConfig struct {
83
76
func (c * OpenshiftControllerConfig ) GetControllerInitializers () (map [string ]InitFunc , error ) {
84
77
ret := map [string ]InitFunc {}
85
78
86
- ret ["openshift.io/serviceaccount" ] = c .ServiceAccountControllerOptions .RunController
87
-
88
79
ret ["openshift.io/serviceaccount-pull-secrets" ] = RunServiceAccountPullSecretsController
89
80
ret ["openshift.io/origin-namespace" ] = RunOriginNamespaceController
90
81
ret ["openshift.io/service-serving-cert" ] = c .ServiceServingCertsControllerOptions .RunController
@@ -115,63 +106,10 @@ func (c *OpenshiftControllerConfig) GetControllerInitializers() (map[string]Init
115
106
return ret , nil
116
107
}
117
108
118
- // NewOpenShiftControllerPreStartInitializers returns list of initializers for controllers
119
- // that needed to be run before any other controller is started.
120
- // Typically this has to done for the serviceaccount-token controller as it provides
121
- // tokens to other controllers.
122
- func (c * OpenshiftControllerConfig ) ServiceAccountContentControllerInit () InitFunc {
123
- return c .ServiceAccountTokenControllerOptions .RunController
124
- }
125
-
126
109
func BuildOpenshiftControllerConfig (options configapi.MasterConfig ) (* OpenshiftControllerConfig , error ) {
127
110
var err error
128
111
ret := & OpenshiftControllerConfig {}
129
112
130
- _ , loopbackClientConfig , err := configapi .GetInternalKubeClient (options .MasterClients .OpenShiftLoopbackKubeConfig , options .MasterClients .OpenShiftLoopbackClientConnectionOverrides )
131
- if err != nil {
132
- return nil , err
133
- }
134
-
135
- ret .ServiceAccountTokenControllerOptions = ServiceAccountTokenControllerOptions {
136
- RootClientBuilder : kcontroller.SimpleControllerClientBuilder {
137
- ClientConfig : loopbackClientConfig ,
138
- },
139
- }
140
- if len (options .ServiceAccountConfig .PrivateKeyFile ) > 0 {
141
- ret .ServiceAccountTokenControllerOptions .PrivateKey , err = cert .PrivateKeyFromFile (options .ServiceAccountConfig .PrivateKeyFile )
142
- if err != nil {
143
- return nil , fmt .Errorf ("error reading signing key for Service Account Token Manager: %v" , err )
144
- }
145
- }
146
- if len (options .ServiceAccountConfig .MasterCA ) > 0 {
147
- ret .ServiceAccountTokenControllerOptions .RootCA , err = ioutil .ReadFile (options .ServiceAccountConfig .MasterCA )
148
- if err != nil {
149
- return nil , fmt .Errorf ("error reading master ca file for Service Account Token Manager: %s: %v" , options .ServiceAccountConfig .MasterCA , err )
150
- }
151
- if _ , err := cert .ParseCertsPEM (ret .ServiceAccountTokenControllerOptions .RootCA ); err != nil {
152
- return nil , fmt .Errorf ("error parsing master ca file for Service Account Token Manager: %s: %v" , options .ServiceAccountConfig .MasterCA , err )
153
- }
154
- }
155
- if options .ControllerConfig .ServiceServingCert .Signer != nil && len (options .ControllerConfig .ServiceServingCert .Signer .CertFile ) > 0 {
156
- certFile := options .ControllerConfig .ServiceServingCert .Signer .CertFile
157
- serviceServingCA , err := ioutil .ReadFile (certFile )
158
- if err != nil {
159
- return nil , fmt .Errorf ("error reading ca file for Service Serving Certificate Signer: %s: %v" , certFile , err )
160
- }
161
- if _ , err := crypto .CertsFromPEM (serviceServingCA ); err != nil {
162
- return nil , fmt .Errorf ("error parsing ca file for Service Serving Certificate Signer: %s: %v" , certFile , err )
163
- }
164
-
165
- // if we have a rootCA bundle add that too. The rootCA will be used when hitting the default master service, since those are signed
166
- // using a different CA by default. The rootCA's key is more closely guarded than ours and if it is compromised, that power could
167
- // be used to change the trusted signers for every pod anyway, so we're already effectively trusting it.
168
- if len (ret .ServiceAccountTokenControllerOptions .RootCA ) > 0 {
169
- ret .ServiceAccountTokenControllerOptions .ServiceServingCA = append (ret .ServiceAccountTokenControllerOptions .ServiceServingCA , ret .ServiceAccountTokenControllerOptions .RootCA ... )
170
- ret .ServiceAccountTokenControllerOptions .ServiceServingCA = append (ret .ServiceAccountTokenControllerOptions .ServiceServingCA , []byte ("\n " )... )
171
- }
172
- ret .ServiceAccountTokenControllerOptions .ServiceServingCA = append (ret .ServiceAccountTokenControllerOptions .ServiceServingCA , serviceServingCA ... )
173
- }
174
-
175
113
ret .ServiceAccountControllerOptions = ServiceAccountControllerOptions {
176
114
ManagedNames : options .ServiceAccountConfig .ManagedNames ,
177
115
}
0 commit comments