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
2b00d362
Commit
2b00d362
authored
Nov 21, 2017
by
xiangpengzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address review comments.
parent
b37d6641
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
postupgrade.go
cmd/kubeadm/app/phases/upgrade/postupgrade.go
+2
-1
postupgrade_v18_19.go
cmd/kubeadm/app/phases/upgrade/postupgrade_v18_19.go
+10
-4
No files found.
cmd/kubeadm/app/phases/upgrade/postupgrade.go
View file @
2b00d362
...
...
@@ -68,8 +68,9 @@ func PerformPostUpgradeTasks(client clientset.Interface, cfg *kubeadmapi.MasterC
errs
=
append
(
errs
,
err
)
}
shouldBackup
,
err
:=
shouldBackupAPIServerCertAndKey
(
newK8sVer
)
// Don't fail the upgrade phase if failing to determine to backup kube-apiserver cert and key.
if
shouldBackup
,
err
:=
shouldBackupAPIServerCertAndKey
(
newK8sVer
);
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"[postupgrade] WARNING: failed to determine to backup kube-apiserver cert and key: %v"
,
err
)
}
else
if
shouldBackup
{
// Don't fail the upgrade phase if failing to backup kube-apiserver cert and key.
...
...
cmd/kubeadm/app/phases/upgrade/postupgrade_v18_19.go
View file @
2b00d362
...
...
@@ -64,29 +64,35 @@ func rollbackFiles(files map[string]string, originalErr error) error {
errs
=
append
(
errs
,
err
)
}
}
return
fmt
.
Errorf
(
"couldn't
roll back kube-apiserver cert and key! Got errors: %v"
,
errors
.
NewAggregate
(
errs
))
return
fmt
.
Errorf
(
"couldn't
move these files: %v. Got errors: %v"
,
files
,
errors
.
NewAggregate
(
errs
))
}
// shouldBackupAPIServerCertAndKey check if the new k8s version is at least 1.9.0
// and kube-apiserver will be expired in 60 days.
func
shouldBackupAPIServerCertAndKey
(
newK8sVer
*
version
.
Version
)
(
bool
,
error
)
{
if
!
newK8sVer
.
AtLeast
(
v190
)
{
if
!
newK8sVer
.
LessThan
(
v190
)
{
return
false
,
nil
}
data
,
err
:=
ioutil
.
ReadFile
(
filepath
.
Join
(
kubeadmapiext
.
DefaultCertificatesDir
,
constants
.
APIServerCertName
))
apiServerCert
:=
filepath
.
Join
(
kubeadmapiext
.
DefaultCertificatesDir
,
constants
.
APIServerCertName
)
data
,
err
:=
ioutil
.
ReadFile
(
apiServerCert
)
if
err
!=
nil
{
return
false
,
fmt
.
Errorf
(
"failed to read kube-apiserver certificate from disk: %v"
,
err
)
}
block
,
_
:=
pem
.
Decode
(
data
)
if
block
==
nil
{
return
false
,
fmt
.
Errorf
(
"expected the kube-apiserver certificate to be PEM encoded"
)
}
certs
,
err
:=
x509
.
ParseCertificates
(
block
.
Bytes
)
if
err
!=
nil
{
return
false
,
fmt
.
Errorf
(
"unable to parse certificate data: %v"
,
err
)
}
if
len
(
certs
)
==
0
{
return
false
,
fmt
.
Errorf
(
"no certificate data found"
)
}
if
certs
[
0
]
.
NotAfter
.
Sub
(
time
.
Now
())
<
60
*
24
*
time
.
Hour
{
return
true
,
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