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
2302c660
Commit
2302c660
authored
Feb 02, 2016
by
AdoHe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix apiserver tls overwrite bug
parent
dae5ac48
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
4 deletions
+29
-4
genericapiserver.go
pkg/genericapiserver/genericapiserver.go
+29
-4
No files found.
pkg/genericapiserver/genericapiserver.go
View file @
2302c660
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"net"
"net"
"net/http"
"net/http"
"net/http/pprof"
"net/http/pprof"
"os"
"path"
"path"
"regexp"
"regexp"
"sort"
"sort"
...
@@ -700,10 +701,12 @@ func (s *GenericAPIServer) Run(options *ServerRunOptions) {
...
@@ -700,10 +701,12 @@ func (s *GenericAPIServer) Run(options *ServerRunOptions) {
alternateDNS
:=
[]
string
{
"kubernetes.default.svc"
,
"kubernetes.default"
,
"kubernetes"
}
alternateDNS
:=
[]
string
{
"kubernetes.default.svc"
,
"kubernetes.default"
,
"kubernetes"
}
// It would be nice to set a fqdn subject alt name, but only the kubelets know, the apiserver is clueless
// It would be nice to set a fqdn subject alt name, but only the kubelets know, the apiserver is clueless
// alternateDNS = append(alternateDNS, "kubernetes.default.svc.CLUSTER.DNS.NAME")
// alternateDNS = append(alternateDNS, "kubernetes.default.svc.CLUSTER.DNS.NAME")
if
err
:=
crypto
.
GenerateSelfSignedCert
(
s
.
ClusterIP
.
String
(),
options
.
TLSCertFile
,
options
.
TLSPrivateKeyFile
,
alternateIPs
,
alternateDNS
);
err
!=
nil
{
if
shouldGenSelfSignedCerts
(
options
.
TLSCertFile
,
options
.
TLSPrivateKeyFile
)
{
glog
.
Errorf
(
"Unable to generate self signed cert: %v"
,
err
)
if
err
:=
crypto
.
GenerateSelfSignedCert
(
s
.
ClusterIP
.
String
(),
options
.
TLSCertFile
,
options
.
TLSPrivateKeyFile
,
alternateIPs
,
alternateDNS
);
err
!=
nil
{
}
else
{
glog
.
Errorf
(
"Unable to generate self signed cert: %v"
,
err
)
glog
.
Infof
(
"Using self-signed cert (%v, %v)"
,
options
.
TLSCertFile
,
options
.
TLSPrivateKeyFile
)
}
else
{
glog
.
Infof
(
"Using self-signed cert (%options, %options)"
,
options
.
TLSCertFile
,
options
.
TLSPrivateKeyFile
)
}
}
}
}
}
...
@@ -737,6 +740,28 @@ func (s *GenericAPIServer) Run(options *ServerRunOptions) {
...
@@ -737,6 +740,28 @@ func (s *GenericAPIServer) Run(options *ServerRunOptions) {
glog
.
Fatal
(
http
.
ListenAndServe
())
glog
.
Fatal
(
http
.
ListenAndServe
())
}
}
// If the file represented by path exists and
// readable, return true otherwise return false.
func
canReadFile
(
path
string
)
bool
{
f
,
err
:=
os
.
Open
(
path
)
if
err
!=
nil
{
return
false
}
defer
f
.
Close
()
return
true
}
func
shouldGenSelfSignedCerts
(
certPath
,
keyPath
string
)
bool
{
if
canReadFile
(
certPath
)
||
canReadFile
(
keyPath
)
{
glog
.
Infof
(
"using existing apiserver.crt and apiserver.key files"
)
return
false
}
return
true
}
func
(
s
*
GenericAPIServer
)
installAPIGroup
(
apiGroupInfo
*
APIGroupInfo
)
error
{
func
(
s
*
GenericAPIServer
)
installAPIGroup
(
apiGroupInfo
*
APIGroupInfo
)
error
{
apiPrefix
:=
s
.
APIGroupPrefix
apiPrefix
:=
s
.
APIGroupPrefix
if
apiGroupInfo
.
IsLegacyGroup
{
if
apiGroupInfo
.
IsLegacyGroup
{
...
...
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