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
f2d0c540
Commit
f2d0c540
authored
Aug 15, 2023
by
Derek Nola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add check for support on cp nodes
Signed-off-by:
Derek Nola
<
derek.nola@suse.com
>
parent
51f1a5a0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
secrets-encrypt.go
pkg/server/secrets-encrypt.go
+21
-0
No files found.
pkg/server/secrets-encrypt.go
View file @
f2d0c540
...
@@ -19,6 +19,7 @@ import (
...
@@ -19,6 +19,7 @@ import (
"github.com/k3s-io/k3s/pkg/util"
"github.com/k3s-io/k3s/pkg/util"
"github.com/rancher/wrangler/pkg/generated/controllers/core"
"github.com/rancher/wrangler/pkg/generated/controllers/core"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
"golang.org/x/mod/semver"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/labels"
apiserverconfigv1
"k8s.io/apiserver/pkg/apis/config/v1"
apiserverconfigv1
"k8s.io/apiserver/pkg/apis/config/v1"
...
@@ -313,6 +314,10 @@ func encryptionRotateKeys(ctx context.Context, server *config.Control) error {
...
@@ -313,6 +314,10 @@ func encryptionRotateKeys(ctx context.Context, server *config.Control) error {
return
err
return
err
}
}
if
err
:=
verifyRotateKeysSupport
(
server
.
Runtime
.
Core
.
Core
());
err
!=
nil
{
return
err
}
if
err
:=
addAndRotateKeys
(
server
);
err
!=
nil
{
if
err
:=
addAndRotateKeys
(
server
);
err
!=
nil
{
return
err
return
err
}
}
...
@@ -377,6 +382,22 @@ func getEncryptionHashAnnotation(core core.Interface) (string, string, error) {
...
@@ -377,6 +382,22 @@ func getEncryptionHashAnnotation(core core.Interface) (string, string, error) {
return
""
,
""
,
fmt
.
Errorf
(
"missing annotation on node %s"
,
nodeName
)
return
""
,
""
,
fmt
.
Errorf
(
"missing annotation on node %s"
,
nodeName
)
}
}
// verifyRotateKeysSupport checks that the k3s version is at least v1.28.0 on all control-plane nodes
func
verifyRotateKeysSupport
(
core
core
.
Interface
)
error
{
labelSelector
:=
labels
.
Set
{
util
.
ControlPlaneRoleLabelKey
:
"true"
}
.
String
()
nodes
,
err
:=
core
.
V1
()
.
Node
()
.
List
(
metav1
.
ListOptions
{
LabelSelector
:
labelSelector
})
if
err
!=
nil
{
return
err
}
for
_
,
node
:=
range
nodes
.
Items
{
kubver
:=
node
.
Status
.
NodeInfo
.
KubeletVersion
if
semver
.
Compare
(
kubver
,
"v1.28.0"
)
<
0
{
return
fmt
.
Errorf
(
"node %s is running k3s version %s that does not support rotate-keys"
,
node
.
ObjectMeta
.
Name
,
kubver
)
}
}
return
nil
}
// verifyEncryptionHashAnnotation checks that all nodes are on the same stage,
// verifyEncryptionHashAnnotation checks that all nodes are on the same stage,
// and that a request for new stage is valid
// and that a request for new stage is valid
func
verifyEncryptionHashAnnotation
(
runtime
*
config
.
ControlRuntime
,
core
core
.
Interface
,
prevStage
string
)
error
{
func
verifyEncryptionHashAnnotation
(
runtime
*
config
.
ControlRuntime
,
core
core
.
Interface
,
prevStage
string
)
error
{
...
...
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