Skip to content

Commit 5998f40

Browse files
authored
Add Node hostname to the Coherence Pod anti-affinity rules (#556)
1 parent db6738f commit 5998f40

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

api/v1/coherenceresourcespec_types.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ type CoherenceResourceSpec struct {
264264
// Use the host's ipc namespace. Optional: Default to false.
265265
// +optional
266266
HostIPC *bool `json:"hostIPC,omitempty"`
267-
// Configure various networks and DNS settings for Pods in this rolw.
267+
// Configure various networks and DNS settings for Pods in this role.
268268
// +optional
269269
Network *NetworkSpec `json:"network,omitempty"`
270270
// The configuration for the Coherence operator image name
@@ -771,7 +771,7 @@ func (in *CoherenceResourceSpec) CreateStatefulSet(deployment *Coherence) appsv1
771771
UpdateStrategy: appsv1.StatefulSetUpdateStrategy{
772772
Type: appsv1.RollingUpdateStatefulSetStrategyType,
773773
},
774-
RevisionHistoryLimit: pointer.Int32Ptr(5),
774+
RevisionHistoryLimit: pointer.Int32(5),
775775
ServiceName: deployment.GetHeadlessServiceName(),
776776
Selector: &metav1.LabelSelector{
777777
MatchLabels: in.CreatePodSelectorLabels(deployment),
@@ -973,6 +973,8 @@ func (in *CoherenceResourceSpec) AddEnvVarIfAbsent(envVar corev1.EnvVar) {
973973
}
974974

975975
// AddEnvVarIfAbsent adds the specified EnvVar to the destination slice if one with the same name does not already exist.
976+
//
977+
//goland:noinspection ALL
976978
func AddEnvVarIfAbsent(dest []corev1.EnvVar, envVar corev1.EnvVar) []corev1.EnvVar {
977979
for _, e := range dest {
978980
if e.Name == envVar.Name {
@@ -1005,7 +1007,7 @@ func (in *CoherenceResourceSpec) CreateDefaultEnv(deployment *Coherence) []corev
10051007
SecretKeyRef: &corev1.SecretKeySelector{
10061008
LocalObjectReference: corev1.LocalObjectReference{Name: OperatorConfigName},
10071009
Key: OperatorConfigKeyHost,
1008-
Optional: pointer.BoolPtr(true),
1010+
Optional: pointer.Bool(true),
10091011
},
10101012
},
10111013
},
@@ -1151,12 +1153,19 @@ func (in *CoherenceResourceSpec) CreateDefaultPodAffinity(deployment *Coherence)
11511153
},
11521154
},
11531155
{
1154-
Weight: 1,
1156+
Weight: 10,
11551157
PodAffinityTerm: corev1.PodAffinityTerm{
11561158
TopologyKey: operator.LabelOciNodeFaultDomain,
11571159
LabelSelector: &selector,
11581160
},
11591161
},
1162+
{
1163+
Weight: 1,
1164+
PodAffinityTerm: corev1.PodAffinityTerm{
1165+
TopologyKey: operator.LabelHostName,
1166+
LabelSelector: &selector,
1167+
},
1168+
},
11601169
},
11611170
},
11621171
}

pkg/operator/operator.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* http://oss.oracle.com/licenses/upl.
55
*/
66

7-
// The operator package contains types and functions used directly by the Operator main
7+
// Package operator package contains types and functions used directly by the Operator main
88
package operator
99

1010
import (
@@ -28,7 +28,7 @@ const (
2828
DefaultRestHost = "0.0.0.0"
2929
DefaultRestPort int32 = 8000
3030

31-
// DefaultCertValidity makes new certificates default to a 1 year expiration
31+
// DefaultCertValidity makes new certificates default to a one-year expiration
3232
DefaultCertValidity = 365 * 24 * time.Hour
3333
// DefaultRotateBefore defines how long before expiration a certificate
3434
// should be re-issued
@@ -75,8 +75,11 @@ const (
7575

7676
// OCI Node Labels
7777

78-
// LabelOciNodeFaultDomain is the OCI Node label fo the fault domain.
78+
// LabelOciNodeFaultDomain is the OCI Node label for the fault domain.
7979
LabelOciNodeFaultDomain = "oci.oraclecloud.com/fault-domain"
80+
81+
// LabelHostName is the Node label for the Node's hostname.
82+
LabelHostName = "kubernetes.io/hostname"
8083
)
8184

8285
var setupLog = ctrl.Log.WithName("setup")

0 commit comments

Comments
 (0)