Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
7b242533
Commit
7b242533
authored
Sep 12, 2018
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apiserver: separate transport setting from storagebackend.Config
parent
483d2578
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
101 additions
and
78 deletions
+101
-78
options_test.go
cmd/kube-apiserver/app/options/options_test.go
+7
-5
server.go
cmd/kube-apiserver/app/server.go
+2
-2
objectmeta_test.go
...iextensions-apiserver/test/integration/objectmeta_test.go
+4
-4
etcd.go
staging/src/k8s.io/apiserver/pkg/server/options/etcd.go
+5
-5
etcd_test.go
staging/src/k8s.io/apiserver/pkg/server/options/etcd_test.go
+31
-23
storage_factory.go
...rc/k8s.io/apiserver/pkg/server/storage/storage_factory.go
+6
-6
storage_factory_test.go
...s.io/apiserver/pkg/server/storage/storage_factory_test.go
+9
-7
utils.go
...ng/src/k8s.io/apiserver/pkg/storage/etcd/testing/utils.go
+6
-4
config.go
...src/k8s.io/apiserver/pkg/storage/storagebackend/config.go
+14
-7
etcd3.go
....io/apiserver/pkg/storage/storagebackend/factory/etcd3.go
+3
-3
tls_test.go
.../apiserver/pkg/storage/storagebackend/factory/tls_test.go
+8
-6
apiserver_test.go
test/integration/examples/apiserver_test.go
+1
-1
setup_test.go
test/integration/examples/setup_test.go
+1
-1
master_utils.go
test/integration/framework/master_utils.go
+2
-2
transformation_testcase.go
test/integration/master/transformation_testcase.go
+1
-1
utils.go
test/integration/utils.go
+1
-1
No files found.
cmd/kube-apiserver/app/options/options_test.go
View file @
7b242533
...
@@ -141,12 +141,14 @@ func TestAddFlags(t *testing.T) {
...
@@ -141,12 +141,14 @@ func TestAddFlags(t *testing.T) {
},
},
Etcd
:
&
apiserveroptions
.
EtcdOptions
{
Etcd
:
&
apiserveroptions
.
EtcdOptions
{
StorageConfig
:
storagebackend
.
Config
{
StorageConfig
:
storagebackend
.
Config
{
Type
:
"etcd3"
,
Type
:
"etcd3"
,
ServerList
:
nil
,
Transport
:
storagebackend
.
TransportConfig
{
ServerList
:
nil
,
KeyFile
:
"/var/run/kubernetes/etcd.key"
,
CAFile
:
"/var/run/kubernetes/etcdca.crt"
,
CertFile
:
"/var/run/kubernetes/etcdce.crt"
,
},
Prefix
:
"/registry"
,
Prefix
:
"/registry"
,
KeyFile
:
"/var/run/kubernetes/etcd.key"
,
CAFile
:
"/var/run/kubernetes/etcdca.crt"
,
CertFile
:
"/var/run/kubernetes/etcdce.crt"
,
CompactionInterval
:
storagebackend
.
DefaultCompactInterval
,
CompactionInterval
:
storagebackend
.
DefaultCompactInterval
,
CountMetricPollPeriod
:
time
.
Minute
,
CountMetricPollPeriod
:
time
.
Minute
,
},
},
...
...
cmd/kube-apiserver/app/server.go
View file @
7b242533
...
@@ -287,8 +287,8 @@ func CreateKubeAPIServerConfig(
...
@@ -287,8 +287,8 @@ func CreateKubeAPIServerConfig(
return
return
}
}
if
_
,
port
,
err
:=
net
.
SplitHostPort
(
s
.
Etcd
.
StorageConfig
.
ServerList
[
0
]);
err
==
nil
&&
port
!=
"0"
&&
len
(
port
)
!=
0
{
if
_
,
port
,
err
:=
net
.
SplitHostPort
(
s
.
Etcd
.
StorageConfig
.
Transport
.
ServerList
[
0
]);
err
==
nil
&&
port
!=
"0"
&&
len
(
port
)
!=
0
{
if
err
:=
utilwait
.
PollImmediate
(
etcdRetryInterval
,
etcdRetryLimit
*
etcdRetryInterval
,
preflight
.
EtcdConnection
{
ServerList
:
s
.
Etcd
.
StorageConfig
.
ServerList
}
.
CheckEtcdServers
);
err
!=
nil
{
if
err
:=
utilwait
.
PollImmediate
(
etcdRetryInterval
,
etcdRetryLimit
*
etcdRetryInterval
,
preflight
.
EtcdConnection
{
ServerList
:
s
.
Etcd
.
StorageConfig
.
Transport
.
ServerList
}
.
CheckEtcdServers
);
err
!=
nil
{
lastErr
=
fmt
.
Errorf
(
"error waiting for etcd connection: %v"
,
err
)
lastErr
=
fmt
.
Errorf
(
"error waiting for etcd connection: %v"
,
err
)
return
return
}
}
...
...
staging/src/k8s.io/apiextensions-apiserver/test/integration/objectmeta_test.go
View file @
7b242533
...
@@ -110,16 +110,16 @@ func TestInvalidObjectMetaInStorage(t *testing.T) {
...
@@ -110,16 +110,16 @@ func TestInvalidObjectMetaInStorage(t *testing.T) {
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
tlsInfo
:=
transport
.
TLSInfo
{
tlsInfo
:=
transport
.
TLSInfo
{
CertFile
:
restOptions
.
StorageConfig
.
CertFile
,
CertFile
:
restOptions
.
StorageConfig
.
Transport
.
CertFile
,
KeyFile
:
restOptions
.
StorageConfig
.
KeyFile
,
KeyFile
:
restOptions
.
StorageConfig
.
Transport
.
KeyFile
,
CAFile
:
restOptions
.
StorageConfig
.
CAFile
,
CAFile
:
restOptions
.
StorageConfig
.
Transport
.
CAFile
,
}
}
tlsConfig
,
err
:=
tlsInfo
.
ClientConfig
()
tlsConfig
,
err
:=
tlsInfo
.
ClientConfig
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
etcdConfig
:=
clientv3
.
Config
{
etcdConfig
:=
clientv3
.
Config
{
Endpoints
:
restOptions
.
StorageConfig
.
ServerList
,
Endpoints
:
restOptions
.
StorageConfig
.
Transport
.
ServerList
,
TLS
:
tlsConfig
,
TLS
:
tlsConfig
,
}
}
etcdclient
,
err
:=
clientv3
.
New
(
etcdConfig
)
etcdclient
,
err
:=
clientv3
.
New
(
etcdConfig
)
...
...
staging/src/k8s.io/apiserver/pkg/server/options/etcd.go
View file @
7b242533
...
@@ -81,7 +81,7 @@ func (s *EtcdOptions) Validate() []error {
...
@@ -81,7 +81,7 @@ func (s *EtcdOptions) Validate() []error {
}
}
allErrors
:=
[]
error
{}
allErrors
:=
[]
error
{}
if
len
(
s
.
StorageConfig
.
ServerList
)
==
0
{
if
len
(
s
.
StorageConfig
.
Transport
.
ServerList
)
==
0
{
allErrors
=
append
(
allErrors
,
fmt
.
Errorf
(
"--etcd-servers must be specified"
))
allErrors
=
append
(
allErrors
,
fmt
.
Errorf
(
"--etcd-servers must be specified"
))
}
}
...
@@ -148,19 +148,19 @@ func (s *EtcdOptions) AddFlags(fs *pflag.FlagSet) {
...
@@ -148,19 +148,19 @@ func (s *EtcdOptions) AddFlags(fs *pflag.FlagSet) {
fs
.
IntVar
(
&
dummyCacheSize
,
"deserialization-cache-size"
,
0
,
"Number of deserialized json objects to cache in memory."
)
fs
.
IntVar
(
&
dummyCacheSize
,
"deserialization-cache-size"
,
0
,
"Number of deserialized json objects to cache in memory."
)
fs
.
MarkDeprecated
(
"deserialization-cache-size"
,
"the deserialization cache was dropped in 1.13 with support for etcd2"
)
fs
.
MarkDeprecated
(
"deserialization-cache-size"
,
"the deserialization cache was dropped in 1.13 with support for etcd2"
)
fs
.
StringSliceVar
(
&
s
.
StorageConfig
.
ServerList
,
"etcd-servers"
,
s
.
StorageConfig
.
ServerList
,
fs
.
StringSliceVar
(
&
s
.
StorageConfig
.
Transport
.
ServerList
,
"etcd-servers"
,
s
.
StorageConfig
.
Transport
.
ServerList
,
"List of etcd servers to connect with (scheme://ip:port), comma separated."
)
"List of etcd servers to connect with (scheme://ip:port), comma separated."
)
fs
.
StringVar
(
&
s
.
StorageConfig
.
Prefix
,
"etcd-prefix"
,
s
.
StorageConfig
.
Prefix
,
fs
.
StringVar
(
&
s
.
StorageConfig
.
Prefix
,
"etcd-prefix"
,
s
.
StorageConfig
.
Prefix
,
"The prefix to prepend to all resource paths in etcd."
)
"The prefix to prepend to all resource paths in etcd."
)
fs
.
StringVar
(
&
s
.
StorageConfig
.
KeyFile
,
"etcd-keyfile"
,
s
.
StorageConfig
.
KeyFile
,
fs
.
StringVar
(
&
s
.
StorageConfig
.
Transport
.
KeyFile
,
"etcd-keyfile"
,
s
.
StorageConfig
.
Transport
.
KeyFile
,
"SSL key file used to secure etcd communication."
)
"SSL key file used to secure etcd communication."
)
fs
.
StringVar
(
&
s
.
StorageConfig
.
CertFile
,
"etcd-certfile"
,
s
.
StorageConfig
.
CertFile
,
fs
.
StringVar
(
&
s
.
StorageConfig
.
Transport
.
CertFile
,
"etcd-certfile"
,
s
.
StorageConfig
.
Transport
.
CertFile
,
"SSL certification file used to secure etcd communication."
)
"SSL certification file used to secure etcd communication."
)
fs
.
StringVar
(
&
s
.
StorageConfig
.
CAFile
,
"etcd-cafile"
,
s
.
StorageConfig
.
CAFile
,
fs
.
StringVar
(
&
s
.
StorageConfig
.
Transport
.
CAFile
,
"etcd-cafile"
,
s
.
StorageConfig
.
Transport
.
CAFile
,
"SSL Certificate Authority file used to secure etcd communication."
)
"SSL Certificate Authority file used to secure etcd communication."
)
fs
.
StringVar
(
&
s
.
EncryptionProviderConfigFilepath
,
"experimental-encryption-provider-config"
,
s
.
EncryptionProviderConfigFilepath
,
fs
.
StringVar
(
&
s
.
EncryptionProviderConfigFilepath
,
"experimental-encryption-provider-config"
,
s
.
EncryptionProviderConfigFilepath
,
...
...
staging/src/k8s.io/apiserver/pkg/server/options/etcd_test.go
View file @
7b242533
...
@@ -36,12 +36,14 @@ func TestEtcdOptionsValidate(t *testing.T) {
...
@@ -36,12 +36,14 @@ func TestEtcdOptionsValidate(t *testing.T) {
name
:
"test when ServerList is not specified"
,
name
:
"test when ServerList is not specified"
,
testOptions
:
&
EtcdOptions
{
testOptions
:
&
EtcdOptions
{
StorageConfig
:
storagebackend
.
Config
{
StorageConfig
:
storagebackend
.
Config
{
Type
:
"etcd3"
,
Type
:
"etcd3"
,
ServerList
:
nil
,
Prefix
:
"/registry"
,
Prefix
:
"/registry"
,
Transport
:
storagebackend
.
TransportConfig
{
KeyFile
:
"/var/run/kubernetes/etcd.key"
,
ServerList
:
nil
,
CAFile
:
"/var/run/kubernetes/etcdca.crt"
,
KeyFile
:
"/var/run/kubernetes/etcd.key"
,
CertFile
:
"/var/run/kubernetes/etcdce.crt"
,
CAFile
:
"/var/run/kubernetes/etcdca.crt"
,
CertFile
:
"/var/run/kubernetes/etcdce.crt"
,
},
CompactionInterval
:
storagebackend
.
DefaultCompactInterval
,
CompactionInterval
:
storagebackend
.
DefaultCompactInterval
,
CountMetricPollPeriod
:
time
.
Minute
,
CountMetricPollPeriod
:
time
.
Minute
,
},
},
...
@@ -58,12 +60,14 @@ func TestEtcdOptionsValidate(t *testing.T) {
...
@@ -58,12 +60,14 @@ func TestEtcdOptionsValidate(t *testing.T) {
name
:
"test when storage-backend is invalid"
,
name
:
"test when storage-backend is invalid"
,
testOptions
:
&
EtcdOptions
{
testOptions
:
&
EtcdOptions
{
StorageConfig
:
storagebackend
.
Config
{
StorageConfig
:
storagebackend
.
Config
{
Type
:
"etcd4"
,
Type
:
"etcd4"
,
ServerList
:
[]
string
{
"http://127.0.0.1"
},
Prefix
:
"/registry"
,
Prefix
:
"/registry"
,
Transport
:
storagebackend
.
TransportConfig
{
KeyFile
:
"/var/run/kubernetes/etcd.key"
,
ServerList
:
[]
string
{
"http://127.0.0.1"
},
CAFile
:
"/var/run/kubernetes/etcdca.crt"
,
KeyFile
:
"/var/run/kubernetes/etcd.key"
,
CertFile
:
"/var/run/kubernetes/etcdce.crt"
,
CAFile
:
"/var/run/kubernetes/etcdca.crt"
,
CertFile
:
"/var/run/kubernetes/etcdce.crt"
,
},
CompactionInterval
:
storagebackend
.
DefaultCompactInterval
,
CompactionInterval
:
storagebackend
.
DefaultCompactInterval
,
CountMetricPollPeriod
:
time
.
Minute
,
CountMetricPollPeriod
:
time
.
Minute
,
},
},
...
@@ -80,12 +84,14 @@ func TestEtcdOptionsValidate(t *testing.T) {
...
@@ -80,12 +84,14 @@ func TestEtcdOptionsValidate(t *testing.T) {
name
:
"test when etcd-servers-overrides is invalid"
,
name
:
"test when etcd-servers-overrides is invalid"
,
testOptions
:
&
EtcdOptions
{
testOptions
:
&
EtcdOptions
{
StorageConfig
:
storagebackend
.
Config
{
StorageConfig
:
storagebackend
.
Config
{
Type
:
"etcd3"
,
Type
:
"etcd3"
,
ServerList
:
[]
string
{
"http://127.0.0.1"
},
Transport
:
storagebackend
.
TransportConfig
{
ServerList
:
[]
string
{
"http://127.0.0.1"
},
KeyFile
:
"/var/run/kubernetes/etcd.key"
,
CAFile
:
"/var/run/kubernetes/etcdca.crt"
,
CertFile
:
"/var/run/kubernetes/etcdce.crt"
,
},
Prefix
:
"/registry"
,
Prefix
:
"/registry"
,
KeyFile
:
"/var/run/kubernetes/etcd.key"
,
CAFile
:
"/var/run/kubernetes/etcdca.crt"
,
CertFile
:
"/var/run/kubernetes/etcdce.crt"
,
CompactionInterval
:
storagebackend
.
DefaultCompactInterval
,
CompactionInterval
:
storagebackend
.
DefaultCompactInterval
,
CountMetricPollPeriod
:
time
.
Minute
,
CountMetricPollPeriod
:
time
.
Minute
,
},
},
...
@@ -102,12 +108,14 @@ func TestEtcdOptionsValidate(t *testing.T) {
...
@@ -102,12 +108,14 @@ func TestEtcdOptionsValidate(t *testing.T) {
name
:
"test when EtcdOptions is valid"
,
name
:
"test when EtcdOptions is valid"
,
testOptions
:
&
EtcdOptions
{
testOptions
:
&
EtcdOptions
{
StorageConfig
:
storagebackend
.
Config
{
StorageConfig
:
storagebackend
.
Config
{
Type
:
"etcd3"
,
Type
:
"etcd3"
,
ServerList
:
[]
string
{
"http://127.0.0.1"
},
Prefix
:
"/registry"
,
Prefix
:
"/registry"
,
Transport
:
storagebackend
.
TransportConfig
{
KeyFile
:
"/var/run/kubernetes/etcd.key"
,
ServerList
:
[]
string
{
"http://127.0.0.1"
},
CAFile
:
"/var/run/kubernetes/etcdca.crt"
,
KeyFile
:
"/var/run/kubernetes/etcd.key"
,
CertFile
:
"/var/run/kubernetes/etcdce.crt"
,
CAFile
:
"/var/run/kubernetes/etcdca.crt"
,
CertFile
:
"/var/run/kubernetes/etcdce.crt"
,
},
CompactionInterval
:
storagebackend
.
DefaultCompactInterval
,
CompactionInterval
:
storagebackend
.
DefaultCompactInterval
,
CountMetricPollPeriod
:
time
.
Minute
,
CountMetricPollPeriod
:
time
.
Minute
,
},
},
...
...
staging/src/k8s.io/apiserver/pkg/server/storage/storage_factory.go
View file @
7b242533
...
@@ -121,7 +121,7 @@ type groupResourceOverrides struct {
...
@@ -121,7 +121,7 @@ type groupResourceOverrides struct {
// Apply overrides the provided config and options if the override has a value in that position
// Apply overrides the provided config and options if the override has a value in that position
func
(
o
groupResourceOverrides
)
Apply
(
config
*
storagebackend
.
Config
,
options
*
StorageCodecConfig
)
{
func
(
o
groupResourceOverrides
)
Apply
(
config
*
storagebackend
.
Config
,
options
*
StorageCodecConfig
)
{
if
len
(
o
.
etcdLocation
)
>
0
{
if
len
(
o
.
etcdLocation
)
>
0
{
config
.
ServerList
=
o
.
etcdLocation
config
.
Transport
.
ServerList
=
o
.
etcdLocation
}
}
if
len
(
o
.
etcdPrefix
)
>
0
{
if
len
(
o
.
etcdPrefix
)
>
0
{
config
.
Prefix
=
o
.
etcdPrefix
config
.
Prefix
=
o
.
etcdPrefix
...
@@ -290,7 +290,7 @@ func (s *DefaultStorageFactory) NewConfig(groupResource schema.GroupResource) (*
...
@@ -290,7 +290,7 @@ func (s *DefaultStorageFactory) NewConfig(groupResource schema.GroupResource) (*
// Backends returns all backends for all registered storage destinations.
// Backends returns all backends for all registered storage destinations.
// Used for getting all instances for health validations.
// Used for getting all instances for health validations.
func
(
s
*
DefaultStorageFactory
)
Backends
()
[]
Backend
{
func
(
s
*
DefaultStorageFactory
)
Backends
()
[]
Backend
{
servers
:=
sets
.
NewString
(
s
.
StorageConfig
.
ServerList
...
)
servers
:=
sets
.
NewString
(
s
.
StorageConfig
.
Transport
.
ServerList
...
)
for
_
,
overrides
:=
range
s
.
Overrides
{
for
_
,
overrides
:=
range
s
.
Overrides
{
servers
.
Insert
(
overrides
.
etcdLocation
...
)
servers
.
Insert
(
overrides
.
etcdLocation
...
)
...
@@ -299,16 +299,16 @@ func (s *DefaultStorageFactory) Backends() []Backend {
...
@@ -299,16 +299,16 @@ func (s *DefaultStorageFactory) Backends() []Backend {
tlsConfig
:=
&
tls
.
Config
{
tlsConfig
:=
&
tls
.
Config
{
InsecureSkipVerify
:
true
,
InsecureSkipVerify
:
true
,
}
}
if
len
(
s
.
StorageConfig
.
CertFile
)
>
0
&&
len
(
s
.
StorageConfig
.
KeyFile
)
>
0
{
if
len
(
s
.
StorageConfig
.
Transport
.
CertFile
)
>
0
&&
len
(
s
.
StorageConfig
.
Transport
.
KeyFile
)
>
0
{
cert
,
err
:=
tls
.
LoadX509KeyPair
(
s
.
StorageConfig
.
CertFile
,
s
.
StorageConfig
.
KeyFile
)
cert
,
err
:=
tls
.
LoadX509KeyPair
(
s
.
StorageConfig
.
Transport
.
CertFile
,
s
.
StorageConfig
.
Transport
.
KeyFile
)
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Errorf
(
"failed to load key pair while getting backends: %s"
,
err
)
klog
.
Errorf
(
"failed to load key pair while getting backends: %s"
,
err
)
}
else
{
}
else
{
tlsConfig
.
Certificates
=
[]
tls
.
Certificate
{
cert
}
tlsConfig
.
Certificates
=
[]
tls
.
Certificate
{
cert
}
}
}
}
}
if
len
(
s
.
StorageConfig
.
CAFile
)
>
0
{
if
len
(
s
.
StorageConfig
.
Transport
.
CAFile
)
>
0
{
if
caCert
,
err
:=
ioutil
.
ReadFile
(
s
.
StorageConfig
.
CAFile
);
err
!=
nil
{
if
caCert
,
err
:=
ioutil
.
ReadFile
(
s
.
StorageConfig
.
Transport
.
CAFile
);
err
!=
nil
{
klog
.
Errorf
(
"failed to read ca file while getting backends: %s"
,
err
)
klog
.
Errorf
(
"failed to read ca file while getting backends: %s"
,
err
)
}
else
{
}
else
{
caPool
:=
x509
.
NewCertPool
()
caPool
:=
x509
.
NewCertPool
()
...
...
staging/src/k8s.io/apiserver/pkg/server/storage/storage_factory_test.go
View file @
7b242533
...
@@ -104,7 +104,7 @@ func TestConfigurableStorageFactory(t *testing.T) {
...
@@ -104,7 +104,7 @@ func TestConfigurableStorageFactory(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
if
config
.
Prefix
!=
"/prefix_for_test"
||
!
reflect
.
DeepEqual
(
config
.
ServerList
,
[]
string
{
"/server2"
})
{
if
config
.
Prefix
!=
"/prefix_for_test"
||
!
reflect
.
DeepEqual
(
config
.
Transport
.
ServerList
,
[]
string
{
"/server2"
})
{
t
.
Errorf
(
"unexpected config %#v"
,
config
)
t
.
Errorf
(
"unexpected config %#v"
,
config
)
}
}
if
!
called
{
if
!
called
{
...
@@ -136,8 +136,10 @@ func TestUpdateEtcdOverrides(t *testing.T) {
...
@@ -136,8 +136,10 @@ func TestUpdateEtcdOverrides(t *testing.T) {
defaultEtcdLocation
:=
[]
string
{
"http://127.0.0.1"
}
defaultEtcdLocation
:=
[]
string
{
"http://127.0.0.1"
}
for
i
,
test
:=
range
testCases
{
for
i
,
test
:=
range
testCases
{
defaultConfig
:=
storagebackend
.
Config
{
defaultConfig
:=
storagebackend
.
Config
{
Prefix
:
"/registry"
,
Prefix
:
"/registry"
,
ServerList
:
defaultEtcdLocation
,
Transport
:
storagebackend
.
TransportConfig
{
ServerList
:
defaultEtcdLocation
,
},
}
}
storageFactory
:=
NewDefaultStorageFactory
(
defaultConfig
,
""
,
codecs
,
NewDefaultResourceEncodingConfig
(
scheme
),
NewResourceConfig
(),
nil
)
storageFactory
:=
NewDefaultStorageFactory
(
defaultConfig
,
""
,
codecs
,
NewDefaultResourceEncodingConfig
(
scheme
),
NewResourceConfig
(),
nil
)
storageFactory
.
SetEtcdLocation
(
test
.
resource
,
test
.
servers
)
storageFactory
.
SetEtcdLocation
(
test
.
resource
,
test
.
servers
)
...
@@ -148,8 +150,8 @@ func TestUpdateEtcdOverrides(t *testing.T) {
...
@@ -148,8 +150,8 @@ func TestUpdateEtcdOverrides(t *testing.T) {
t
.
Errorf
(
"%d: unexpected error %v"
,
i
,
err
)
t
.
Errorf
(
"%d: unexpected error %v"
,
i
,
err
)
continue
continue
}
}
if
!
reflect
.
DeepEqual
(
config
.
ServerList
,
test
.
servers
)
{
if
!
reflect
.
DeepEqual
(
config
.
Transport
.
ServerList
,
test
.
servers
)
{
t
.
Errorf
(
"%d: expected %v, got %v"
,
i
,
test
.
servers
,
config
.
ServerList
)
t
.
Errorf
(
"%d: expected %v, got %v"
,
i
,
test
.
servers
,
config
.
Transport
.
ServerList
)
continue
continue
}
}
...
@@ -158,8 +160,8 @@ func TestUpdateEtcdOverrides(t *testing.T) {
...
@@ -158,8 +160,8 @@ func TestUpdateEtcdOverrides(t *testing.T) {
t
.
Errorf
(
"%d: unexpected error %v"
,
i
,
err
)
t
.
Errorf
(
"%d: unexpected error %v"
,
i
,
err
)
continue
continue
}
}
if
!
reflect
.
DeepEqual
(
config
.
ServerList
,
defaultEtcdLocation
)
{
if
!
reflect
.
DeepEqual
(
config
.
Transport
.
ServerList
,
defaultEtcdLocation
)
{
t
.
Errorf
(
"%d: expected %v, got %v"
,
i
,
defaultEtcdLocation
,
config
.
ServerList
)
t
.
Errorf
(
"%d: expected %v, got %v"
,
i
,
defaultEtcdLocation
,
config
.
Transport
.
ServerList
)
continue
continue
}
}
...
...
staging/src/k8s.io/apiserver/pkg/storage/etcd/testing/utils.go
View file @
7b242533
...
@@ -293,10 +293,12 @@ func NewUnsecuredEtcd3TestClientServer(t *testing.T) (*EtcdTestServer, *storageb
...
@@ -293,10 +293,12 @@ func NewUnsecuredEtcd3TestClientServer(t *testing.T) (*EtcdTestServer, *storageb
}
}
server
.
V3Client
=
server
.
v3Cluster
.
RandClient
()
server
.
V3Client
=
server
.
v3Cluster
.
RandClient
()
config
:=
&
storagebackend
.
Config
{
config
:=
&
storagebackend
.
Config
{
Type
:
"etcd3"
,
Type
:
"etcd3"
,
Prefix
:
etcdtest
.
PathPrefix
(),
Prefix
:
etcdtest
.
PathPrefix
(),
ServerList
:
server
.
V3Client
.
Endpoints
(),
Transport
:
storagebackend
.
TransportConfig
{
Paging
:
true
,
ServerList
:
server
.
V3Client
.
Endpoints
(),
},
Paging
:
true
,
}
}
return
server
,
config
return
server
,
config
}
}
staging/src/k8s.io/apiserver/pkg/storage/storagebackend/config.go
View file @
7b242533
...
@@ -30,18 +30,26 @@ const (
...
@@ -30,18 +30,26 @@ const (
DefaultCompactInterval
=
5
*
time
.
Minute
DefaultCompactInterval
=
5
*
time
.
Minute
)
)
// Config is configuration for creating a storage backend.
// TransportConfig holds all connection related info, i.e. equal TransportConfig means equal servers we talk to.
type
Config
struct
{
type
TransportConfig
struct
{
// Type defines the type of storage backend. Default ("") is "etcd3".
Type
string
// Prefix is the prefix to all keys passed to storage.Interface methods.
Prefix
string
// ServerList is the list of storage servers to connect with.
// ServerList is the list of storage servers to connect with.
ServerList
[]
string
ServerList
[]
string
// TLS credentials
// TLS credentials
KeyFile
string
KeyFile
string
CertFile
string
CertFile
string
CAFile
string
CAFile
string
}
// Config is configuration for creating a storage backend.
type
Config
struct
{
// Type defines the type of storage backend. Default ("") is "etcd3".
Type
string
// Prefix is the prefix to all keys passed to storage.Interface methods.
Prefix
string
// Transport holds all connection related info, i.e. equal TransportConfig means equal servers we talk to.
Transport
TransportConfig
// Quorum indicates that whether read operations should be quorum-level consistent.
Quorum
bool
// Paging indicates whether the server implementation should allow paging (if it is
// Paging indicates whether the server implementation should allow paging (if it is
// supported). This is generally configured by feature gating, or by a specific
// supported). This is generally configured by feature gating, or by a specific
// resource type not wishing to allow paging, and is not intended for end users to
// resource type not wishing to allow paging, and is not intended for end users to
...
@@ -55,7 +63,6 @@ type Config struct {
...
@@ -55,7 +63,6 @@ type Config struct {
// CompactionInterval is an interval of requesting compaction from apiserver.
// CompactionInterval is an interval of requesting compaction from apiserver.
// If the value is 0, no compaction will be issued.
// If the value is 0, no compaction will be issued.
CompactionInterval
time
.
Duration
CompactionInterval
time
.
Duration
// CountMetricPollPeriod specifies how often should count metric be updated
// CountMetricPollPeriod specifies how often should count metric be updated
CountMetricPollPeriod
time
.
Duration
CountMetricPollPeriod
time
.
Duration
}
}
...
...
staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go
View file @
7b242533
...
@@ -54,7 +54,7 @@ func newETCD3HealthCheck(c storagebackend.Config) (func() error, error) {
...
@@ -54,7 +54,7 @@ func newETCD3HealthCheck(c storagebackend.Config) (func() error, error) {
clientErrMsg
.
Store
(
"etcd client connection not yet established"
)
clientErrMsg
.
Store
(
"etcd client connection not yet established"
)
go
wait
.
PollUntil
(
time
.
Second
,
func
()
(
bool
,
error
)
{
go
wait
.
PollUntil
(
time
.
Second
,
func
()
(
bool
,
error
)
{
client
,
err
:=
newETCD3Client
(
c
)
client
,
err
:=
newETCD3Client
(
c
.
Transport
)
if
err
!=
nil
{
if
err
!=
nil
{
clientErrMsg
.
Store
(
err
.
Error
())
clientErrMsg
.
Store
(
err
.
Error
())
return
false
,
nil
return
false
,
nil
...
@@ -78,7 +78,7 @@ func newETCD3HealthCheck(c storagebackend.Config) (func() error, error) {
...
@@ -78,7 +78,7 @@ func newETCD3HealthCheck(c storagebackend.Config) (func() error, error) {
},
nil
},
nil
}
}
func
newETCD3Client
(
c
storagebackend
.
Config
)
(
*
clientv3
.
Client
,
error
)
{
func
newETCD3Client
(
c
storagebackend
.
Transport
Config
)
(
*
clientv3
.
Client
,
error
)
{
tlsInfo
:=
transport
.
TLSInfo
{
tlsInfo
:=
transport
.
TLSInfo
{
CertFile
:
c
.
CertFile
,
CertFile
:
c
.
CertFile
,
KeyFile
:
c
.
KeyFile
,
KeyFile
:
c
.
KeyFile
,
...
@@ -109,7 +109,7 @@ func newETCD3Client(c storagebackend.Config) (*clientv3.Client, error) {
...
@@ -109,7 +109,7 @@ func newETCD3Client(c storagebackend.Config) (*clientv3.Client, error) {
}
}
func
newETCD3Storage
(
c
storagebackend
.
Config
)
(
storage
.
Interface
,
DestroyFunc
,
error
)
{
func
newETCD3Storage
(
c
storagebackend
.
Config
)
(
storage
.
Interface
,
DestroyFunc
,
error
)
{
client
,
err
:=
newETCD3Client
(
c
)
client
,
err
:=
newETCD3Client
(
c
.
Transport
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
...
...
staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/tls_test.go
View file @
7b242533
...
@@ -66,12 +66,14 @@ func TestTLSConnection(t *testing.T) {
...
@@ -66,12 +66,14 @@ func TestTLSConnection(t *testing.T) {
defer
cluster
.
Terminate
(
t
)
defer
cluster
.
Terminate
(
t
)
cfg
:=
storagebackend
.
Config
{
cfg
:=
storagebackend
.
Config
{
Type
:
storagebackend
.
StorageTypeETCD3
,
Type
:
storagebackend
.
StorageTypeETCD3
,
ServerList
:
[]
string
{
cluster
.
Members
[
0
]
.
GRPCAddr
()},
Transport
:
storagebackend
.
TransportConfig
{
CertFile
:
certFile
,
ServerList
:
[]
string
{
cluster
.
Members
[
0
]
.
GRPCAddr
()},
KeyFile
:
keyFile
,
CertFile
:
certFile
,
CAFile
:
caFile
,
KeyFile
:
keyFile
,
Codec
:
codec
,
CAFile
:
caFile
,
},
Codec
:
codec
,
}
}
storage
,
destroyFunc
,
err
:=
newETCD3Storage
(
cfg
)
storage
,
destroyFunc
,
err
:=
newETCD3Storage
(
cfg
)
defer
destroyFunc
()
defer
destroyFunc
()
...
...
test/integration/examples/apiserver_test.go
View file @
7b242533
...
@@ -98,7 +98,7 @@ func TestAggregatedAPIServer(t *testing.T) {
...
@@ -98,7 +98,7 @@ func TestAggregatedAPIServer(t *testing.T) {
kubeAPIServerOptions
.
SecureServing
.
BindAddress
=
net
.
ParseIP
(
"127.0.0.1"
)
kubeAPIServerOptions
.
SecureServing
.
BindAddress
=
net
.
ParseIP
(
"127.0.0.1"
)
kubeAPIServerOptions
.
SecureServing
.
ServerCert
.
CertDirectory
=
certDir
kubeAPIServerOptions
.
SecureServing
.
ServerCert
.
CertDirectory
=
certDir
kubeAPIServerOptions
.
InsecureServing
.
BindPort
=
0
kubeAPIServerOptions
.
InsecureServing
.
BindPort
=
0
kubeAPIServerOptions
.
Etcd
.
StorageConfig
.
ServerList
=
[]
string
{
framework
.
GetEtcdURL
()}
kubeAPIServerOptions
.
Etcd
.
StorageConfig
.
Transport
.
ServerList
=
[]
string
{
framework
.
GetEtcdURL
()}
kubeAPIServerOptions
.
ServiceClusterIPRange
=
*
defaultServiceClusterIPRange
kubeAPIServerOptions
.
ServiceClusterIPRange
=
*
defaultServiceClusterIPRange
kubeAPIServerOptions
.
Authentication
.
RequestHeader
.
UsernameHeaders
=
[]
string
{
"X-Remote-User"
}
kubeAPIServerOptions
.
Authentication
.
RequestHeader
.
UsernameHeaders
=
[]
string
{
"X-Remote-User"
}
kubeAPIServerOptions
.
Authentication
.
RequestHeader
.
GroupHeaders
=
[]
string
{
"X-Remote-Group"
}
kubeAPIServerOptions
.
Authentication
.
RequestHeader
.
GroupHeaders
=
[]
string
{
"X-Remote-Group"
}
...
...
test/integration/examples/setup_test.go
View file @
7b242533
...
@@ -89,7 +89,7 @@ func startTestServer(t *testing.T, stopCh <-chan struct{}, setup TestServerSetup
...
@@ -89,7 +89,7 @@ func startTestServer(t *testing.T, stopCh <-chan struct{}, setup TestServerSetup
kubeAPIServerOptions
.
SecureServing
.
ServerCert
.
CertDirectory
=
certDir
kubeAPIServerOptions
.
SecureServing
.
ServerCert
.
CertDirectory
=
certDir
kubeAPIServerOptions
.
InsecureServing
.
BindPort
=
0
kubeAPIServerOptions
.
InsecureServing
.
BindPort
=
0
kubeAPIServerOptions
.
Etcd
.
StorageConfig
.
Prefix
=
path
.
Join
(
"/"
,
uuid
.
New
(),
"registry"
)
kubeAPIServerOptions
.
Etcd
.
StorageConfig
.
Prefix
=
path
.
Join
(
"/"
,
uuid
.
New
(),
"registry"
)
kubeAPIServerOptions
.
Etcd
.
StorageConfig
.
ServerList
=
[]
string
{
framework
.
GetEtcdURL
()}
kubeAPIServerOptions
.
Etcd
.
StorageConfig
.
Transport
.
ServerList
=
[]
string
{
framework
.
GetEtcdURL
()}
kubeAPIServerOptions
.
ServiceClusterIPRange
=
*
defaultServiceClusterIPRange
kubeAPIServerOptions
.
ServiceClusterIPRange
=
*
defaultServiceClusterIPRange
kubeAPIServerOptions
.
Authentication
.
RequestHeader
.
UsernameHeaders
=
[]
string
{
"X-Remote-User"
}
kubeAPIServerOptions
.
Authentication
.
RequestHeader
.
UsernameHeaders
=
[]
string
{
"X-Remote-User"
}
kubeAPIServerOptions
.
Authentication
.
RequestHeader
.
GroupHeaders
=
[]
string
{
"X-Remote-Group"
}
kubeAPIServerOptions
.
Authentication
.
RequestHeader
.
GroupHeaders
=
[]
string
{
"X-Remote-Group"
}
...
...
test/integration/framework/master_utils.go
View file @
7b242533
...
@@ -242,7 +242,7 @@ func NewMasterConfig() *master.Config {
...
@@ -242,7 +242,7 @@ func NewMasterConfig() *master.Config {
// prefix code, so please don't change without ensuring
// prefix code, so please don't change without ensuring
// sufficient coverage in other ways.
// sufficient coverage in other ways.
etcdOptions
:=
options
.
NewEtcdOptions
(
storagebackend
.
NewDefaultConfig
(
uuid
.
New
(),
nil
))
etcdOptions
:=
options
.
NewEtcdOptions
(
storagebackend
.
NewDefaultConfig
(
uuid
.
New
(),
nil
))
etcdOptions
.
StorageConfig
.
ServerList
=
[]
string
{
GetEtcdURL
()}
etcdOptions
.
StorageConfig
.
Transport
.
ServerList
=
[]
string
{
GetEtcdURL
()}
info
,
_
:=
runtime
.
SerializerInfoForMediaType
(
legacyscheme
.
Codecs
.
SupportedMediaTypes
(),
runtime
.
ContentTypeJSON
)
info
,
_
:=
runtime
.
SerializerInfoForMediaType
(
legacyscheme
.
Codecs
.
SupportedMediaTypes
(),
runtime
.
ContentTypeJSON
)
ns
:=
NewSingleContentTypeSerializer
(
legacyscheme
.
Scheme
,
info
)
ns
:=
NewSingleContentTypeSerializer
(
legacyscheme
.
Scheme
,
info
)
...
@@ -341,7 +341,7 @@ func RunAMasterUsingServer(masterConfig *master.Config, s *httptest.Server, mast
...
@@ -341,7 +341,7 @@ func RunAMasterUsingServer(masterConfig *master.Config, s *httptest.Server, mast
// SharedEtcd creates a storage config for a shared etcd instance, with a unique prefix.
// SharedEtcd creates a storage config for a shared etcd instance, with a unique prefix.
func
SharedEtcd
()
*
storagebackend
.
Config
{
func
SharedEtcd
()
*
storagebackend
.
Config
{
cfg
:=
storagebackend
.
NewDefaultConfig
(
path
.
Join
(
uuid
.
New
(),
"registry"
),
nil
)
cfg
:=
storagebackend
.
NewDefaultConfig
(
path
.
Join
(
uuid
.
New
(),
"registry"
),
nil
)
cfg
.
ServerList
=
[]
string
{
GetEtcdURL
()}
cfg
.
Transport
.
ServerList
=
[]
string
{
GetEtcdURL
()}
return
cfg
return
cfg
}
}
...
...
test/integration/master/transformation_testcase.go
View file @
7b242533
...
@@ -228,7 +228,7 @@ func (e *transformTest) createSecret(name, namespace string) (*corev1.Secret, er
...
@@ -228,7 +228,7 @@ func (e *transformTest) createSecret(name, namespace string) (*corev1.Secret, er
}
}
func
(
e
*
transformTest
)
readRawRecordFromETCD
(
path
string
)
(
*
clientv3
.
GetResponse
,
error
)
{
func
(
e
*
transformTest
)
readRawRecordFromETCD
(
path
string
)
(
*
clientv3
.
GetResponse
,
error
)
{
_
,
etcdClient
,
err
:=
integration
.
GetEtcdClients
(
e
.
kubeAPIServer
.
ServerOpts
.
Etcd
.
StorageConfig
)
_
,
etcdClient
,
err
:=
integration
.
GetEtcdClients
(
e
.
kubeAPIServer
.
ServerOpts
.
Etcd
.
StorageConfig
.
Transport
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to create etcd client: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"failed to create etcd client: %v"
,
err
)
}
}
...
...
test/integration/utils.go
View file @
7b242533
...
@@ -67,7 +67,7 @@ func WaitForPodToDisappear(podClient coreclient.PodInterface, podName string, in
...
@@ -67,7 +67,7 @@ func WaitForPodToDisappear(podClient coreclient.PodInterface, podName string, in
})
})
}
}
func
GetEtcdClients
(
config
storagebackend
.
Config
)
(
*
clientv3
.
Client
,
clientv3
.
KV
,
error
)
{
func
GetEtcdClients
(
config
storagebackend
.
Transport
Config
)
(
*
clientv3
.
Client
,
clientv3
.
KV
,
error
)
{
tlsInfo
:=
transport
.
TLSInfo
{
tlsInfo
:=
transport
.
TLSInfo
{
CertFile
:
config
.
CertFile
,
CertFile
:
config
.
CertFile
,
KeyFile
:
config
.
KeyFile
,
KeyFile
:
config
.
KeyFile
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment