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
da33d8ab
Unverified
Commit
da33d8ab
authored
Nov 13, 2018
by
k8s-ci-robot
Committed by
GitHub
Nov 13, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #70893 from fabriziopandini/fix-stacked-etcd
fix kubeadm upgrade regression
parents
89bdc42f
7f1b2a62
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
14 deletions
+42
-14
etcd.go
cmd/kubeadm/app/util/etcd/etcd.go
+42
-14
No files found.
cmd/kubeadm/app/util/etcd/etcd.go
View file @
da33d8ab
...
@@ -113,27 +113,55 @@ func New(endpoints []string, ca, cert, key string) (*Client, error) {
...
@@ -113,27 +113,55 @@ func New(endpoints []string, ca, cert, key string) (*Client, error) {
return
&
client
,
nil
return
&
client
,
nil
}
}
// NewFromStaticPod creates a GenericClient from the given endpoints, manifestDir, and certificatesDir
// NewFromCluster creates an etcd client for the the etcd endpoints defined in the ClusterStatus value stored in
func
NewFromStaticPod
(
endpoints
[]
string
,
manifestDir
string
,
certificatesDir
string
)
(
*
Client
,
error
)
{
// the kubeadm-config ConfigMap in kube-system namespace.
hasTLS
,
err
:=
PodManifestsHaveTLS
(
manifestDir
)
// Once created, the client synchronizes client's endpoints with the known endpoints from the etcd membership API (reality check).
func
NewFromCluster
(
client
clientset
.
Interface
,
certificatesDir
string
)
(
*
Client
,
error
)
{
// Kubeadm v1.13 should manage v1.12 clusters and v1.13 clusters
// v1.12 clusters can be have etcd listening on localhost only (if the cluster was created with kubeadm v1.12)
// or etcd listening on localhost and API server advertise address (if the cluster was created with kubeadm v1.13).
// The first case should be dropped in v1.14 when support for v1.12 clusters can be removed from the codebase.
// Detect which type of etcd we are dealing with
oldManifest
:=
false
klog
.
V
(
1
)
.
Infoln
(
"checking etcd manifest"
)
etcdManifestFile
:=
constants
.
GetStaticPodFilepath
(
constants
.
Etcd
,
constants
.
GetStaticPodDirectory
())
etcdPod
,
err
:=
staticpod
.
ReadStaticPodFromDisk
(
etcdManifestFile
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"could not read manifests from: %s, error"
,
manifestDir
)
return
nil
,
errors
.
Wrap
(
err
,
"error reading etcd manifest file"
)
}
etcdContainer
:=
etcdPod
.
Spec
.
Containers
[
0
]
for
_
,
arg
:=
range
etcdContainer
.
Command
{
if
arg
==
"--listen-client-urls=https://127.0.0.1:2379"
{
klog
.
V
(
1
)
.
Infoln
(
"etcd manifest created by kubeadm v1.12"
)
oldManifest
=
true
}
}
}
if
hasTLS
{
return
New
(
// if etcd is listening on localhost only
if
oldManifest
==
true
{
// etcd cluster has a single member "by design"
endpoints
:=
[]
string
{
fmt
.
Sprintf
(
"localhost:%d"
,
constants
.
EtcdListenClientPort
)}
etcdClient
,
err
:=
New
(
endpoints
,
endpoints
,
filepath
.
Join
(
certificatesDir
,
constants
.
EtcdCACertName
),
filepath
.
Join
(
certificatesDir
,
constants
.
EtcdCACertName
),
filepath
.
Join
(
certificatesDir
,
constants
.
EtcdHealthcheckClientCertName
),
filepath
.
Join
(
certificatesDir
,
constants
.
EtcdHealthcheckClientCertName
),
filepath
.
Join
(
certificatesDir
,
constants
.
EtcdHealthcheckClientKeyName
),
filepath
.
Join
(
certificatesDir
,
constants
.
EtcdHealthcheckClientKeyName
),
)
)
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"error creating etcd client for %v endpoint"
,
endpoints
)
}
return
etcdClient
,
nil
}
}
return
New
(
endpoints
,
""
,
""
,
""
)
}
// NewFromCluster creates an etcd client for the the etcd endpoints defined in the ClusterStatus value stored in
// etcd is listening on localhost and API server advertise address, and
// the kubeadm-config ConfigMap in kube-system namespace.
// the etcd cluster can have more than one etcd members, so it is necessary to get the
// Once created, the client synchronizes client's endpoints with the known endpoints from the etcd membership API (reality check).
// list of endpoints from kubeadm cluster status before connecting
func
NewFromCluster
(
client
clientset
.
Interface
,
certificatesDir
string
)
(
*
Client
,
error
)
{
// Gets the cluster status
// Gets the cluster status
clusterStatus
,
err
:=
config
.
GetClusterStatus
(
client
)
clusterStatus
,
err
:=
config
.
GetClusterStatus
(
client
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -155,13 +183,13 @@ func NewFromCluster(client clientset.Interface, certificatesDir string) (*Client
...
@@ -155,13 +183,13 @@ func NewFromCluster(client clientset.Interface, certificatesDir string) (*Client
filepath
.
Join
(
certificatesDir
,
constants
.
EtcdHealthcheckClientKeyName
),
filepath
.
Join
(
certificatesDir
,
constants
.
EtcdHealthcheckClientKeyName
),
)
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
ors
.
Wrapf
(
err
,
"error creating etcd client for %v endpoints"
,
endpoints
)
}
}
// synchronizes client's endpoints with the known endpoints from the etcd membership.
// synchronizes client's endpoints with the known endpoints from the etcd membership.
err
=
etcdClient
.
Sync
()
err
=
etcdClient
.
Sync
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
ors
.
Wrap
(
err
,
"error syncing endpoints with etc"
)
}
}
return
etcdClient
,
nil
return
etcdClient
,
nil
...
...
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