mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-02-23 08:20:15 -05:00
operator: move control plane label to constants
This commit is contained in:
parent
ebee6b3398
commit
3ddd6389e3
@ -81,6 +81,7 @@ go_test(
|
|||||||
"//3rdparty/node-maintenance-operator/api/v1beta1",
|
"//3rdparty/node-maintenance-operator/api/v1beta1",
|
||||||
"//internal/constants",
|
"//internal/constants",
|
||||||
"//operators/constellation-node-operator/api/v1alpha1",
|
"//operators/constellation-node-operator/api/v1alpha1",
|
||||||
|
"//operators/constellation-node-operator/internal/constants",
|
||||||
"@com_github_onsi_ginkgo_v2//:ginkgo",
|
"@com_github_onsi_ginkgo_v2//:ginkgo",
|
||||||
"@com_github_onsi_gomega//:gomega",
|
"@com_github_onsi_gomega//:gomega",
|
||||||
"@com_github_stretchr_testify//assert",
|
"@com_github_stretchr_testify//assert",
|
||||||
|
@ -19,4 +19,6 @@ const (
|
|||||||
PlaceholderControlPlaneScalingGroupName = "control-planes-id"
|
PlaceholderControlPlaneScalingGroupName = "control-planes-id"
|
||||||
// PlaceholderWorkerScalingGroupName name of the worker scaling group used if upgrades are not yet supported.
|
// PlaceholderWorkerScalingGroupName name of the worker scaling group used if upgrades are not yet supported.
|
||||||
PlaceholderWorkerScalingGroupName = "workers-id"
|
PlaceholderWorkerScalingGroupName = "workers-id"
|
||||||
|
// ControlPlaneRoleLabel label used to identify control plane nodes.
|
||||||
|
ControlPlaneRoleLabel = "node-role.kubernetes.io/control-plane"
|
||||||
)
|
)
|
||||||
|
@ -18,6 +18,7 @@ go_test(
|
|||||||
srcs = ["controlplane_test.go"],
|
srcs = ["controlplane_test.go"],
|
||||||
embed = [":controlplane"],
|
embed = [":controlplane"],
|
||||||
deps = [
|
deps = [
|
||||||
|
"//operators/constellation-node-operator/internal/constants",
|
||||||
"@com_github_stretchr_testify//assert",
|
"@com_github_stretchr_testify//assert",
|
||||||
"@com_github_stretchr_testify//require",
|
"@com_github_stretchr_testify//require",
|
||||||
"@io_k8s_api//core/v1:core",
|
"@io_k8s_api//core/v1:core",
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/internal/constants"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
@ -29,7 +30,7 @@ func TestListControlPlaneIPs(t *testing.T) {
|
|||||||
nodes: []corev1.Node{
|
nodes: []corev1.Node{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Labels: map[string]string{"node-role.kubernetes.io/control-plane": ""},
|
Labels: map[string]string{constants.ControlPlaneRoleLabel: ""},
|
||||||
},
|
},
|
||||||
Status: corev1.NodeStatus{Addresses: []corev1.NodeAddress{{
|
Status: corev1.NodeStatus{Addresses: []corev1.NodeAddress{{
|
||||||
Type: corev1.NodeInternalIP,
|
Type: corev1.NodeInternalIP,
|
||||||
|
@ -19,6 +19,7 @@ go_test(
|
|||||||
srcs = ["etcd_test.go"],
|
srcs = ["etcd_test.go"],
|
||||||
embed = [":etcd"],
|
embed = [":etcd"],
|
||||||
deps = [
|
deps = [
|
||||||
|
"//operators/constellation-node-operator/internal/constants",
|
||||||
"@com_github_stretchr_testify//assert",
|
"@com_github_stretchr_testify//assert",
|
||||||
"@com_github_stretchr_testify//require",
|
"@com_github_stretchr_testify//require",
|
||||||
"@io_etcd_go_etcd_api_v3//etcdserverpb",
|
"@io_etcd_go_etcd_api_v3//etcdserverpb",
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/internal/constants"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
|
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
|
||||||
@ -124,7 +125,7 @@ func TestGetInitialEndpoints(t *testing.T) {
|
|||||||
nodes: []corev1.Node{
|
nodes: []corev1.Node{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Labels: map[string]string{"node-role.kubernetes.io/control-plane": ""},
|
Labels: map[string]string{constants.ControlPlaneRoleLabel: ""},
|
||||||
},
|
},
|
||||||
Status: corev1.NodeStatus{Addresses: []corev1.NodeAddress{{
|
Status: corev1.NodeStatus{Addresses: []corev1.NodeAddress{{
|
||||||
Type: corev1.NodeInternalIP,
|
Type: corev1.NodeInternalIP,
|
||||||
|
@ -8,6 +8,7 @@ go_library(
|
|||||||
visibility = ["//operators/constellation-node-operator:__subpackages__"],
|
visibility = ["//operators/constellation-node-operator:__subpackages__"],
|
||||||
deps = [
|
deps = [
|
||||||
"//operators/constellation-node-operator/api/v1alpha1",
|
"//operators/constellation-node-operator/api/v1alpha1",
|
||||||
|
"//operators/constellation-node-operator/internal/constants",
|
||||||
"@io_k8s_api//core/v1:core",
|
"@io_k8s_api//core/v1:core",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -18,6 +19,7 @@ go_test(
|
|||||||
embed = [":node"],
|
embed = [":node"],
|
||||||
deps = [
|
deps = [
|
||||||
"//operators/constellation-node-operator/api/v1alpha1",
|
"//operators/constellation-node-operator/api/v1alpha1",
|
||||||
|
"//operators/constellation-node-operator/internal/constants",
|
||||||
"@com_github_stretchr_testify//assert",
|
"@com_github_stretchr_testify//assert",
|
||||||
"@com_github_stretchr_testify//require",
|
"@com_github_stretchr_testify//require",
|
||||||
"@io_k8s_api//core/v1:core",
|
"@io_k8s_api//core/v1:core",
|
||||||
|
@ -11,11 +11,10 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
updatev1alpha1 "github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/api/v1alpha1"
|
updatev1alpha1 "github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/api/v1alpha1"
|
||||||
|
"github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/internal/constants"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
const controlPlaneRoleLabel = "node-role.kubernetes.io/control-plane"
|
|
||||||
|
|
||||||
var reservedHostRegex = regexp.MustCompile(`^(.+\.|)(kubernetes|k8s)\.io(/.*)?$`)
|
var reservedHostRegex = regexp.MustCompile(`^(.+\.|)(kubernetes|k8s)\.io(/.*)?$`)
|
||||||
|
|
||||||
// Ready checks if a kubernetes node has the `NodeReady` condition set to true.
|
// Ready checks if a kubernetes node has the `NodeReady` condition set to true.
|
||||||
@ -40,7 +39,7 @@ func VPCIP(node *corev1.Node) (string, error) {
|
|||||||
|
|
||||||
// IsControlPlaneNode returns true if the node is a control plane node.
|
// IsControlPlaneNode returns true if the node is a control plane node.
|
||||||
func IsControlPlaneNode(node *corev1.Node) bool {
|
func IsControlPlaneNode(node *corev1.Node) bool {
|
||||||
_, ok := node.Labels[controlPlaneRoleLabel]
|
_, ok := node.Labels[constants.ControlPlaneRoleLabel]
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
updatev1alpha1 "github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/api/v1alpha1"
|
updatev1alpha1 "github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/api/v1alpha1"
|
||||||
|
"github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/internal/constants"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
@ -69,7 +70,7 @@ func TestIsControlPlaneNode(t *testing.T) {
|
|||||||
"node with control-plane role label": {
|
"node with control-plane role label": {
|
||||||
node: corev1.Node{
|
node: corev1.Node{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Labels: map[string]string{controlPlaneRoleLabel: ""},
|
Labels: map[string]string{constants.ControlPlaneRoleLabel: ""},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantControlPlane: true,
|
wantControlPlane: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user