Skip to content

Commit e19cf5b

Browse files
authored
Bump K8s to 1.24 (#531)
Depend on k8s 1.24 Support additional Pod configuration elements Add RBAC configuration for finalizers in Coherence resource Require Go 1.17
1 parent 587c9d8 commit e19cf5b

22 files changed

+884
-163
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
- name: Set up Go
8080
uses: actions/setup-go@v2
8181
with:
82-
go-version: 1.16.x
82+
go-version: 1.17.x
8383

8484
- name: Edit DNS Resolve
8585
shell: bash

.github/workflows/coherence-matrix.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ jobs:
110110
- name: Set up Go
111111
uses: actions/setup-go@v2
112112
with:
113-
go-version: 1.16.x
113+
go-version: 1.17.x
114114

115115
- name: Edit DNS Resolve
116116
shell: bash

.github/workflows/compatibility-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
- name: Set up Go
108108
uses: actions/setup-go@v2
109109
with:
110-
go-version: 1.16.x
110+
go-version: 1.17.x
111111

112112
- name: Edit DNS Resolve
113113
shell: bash

.github/workflows/istio-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
- name: Set up Go
8787
uses: actions/setup-go@v2
8888
with:
89-
go-version: 1.16.x
89+
go-version: 1.17.x
9090

9191
- name: Edit DNS Resolve
9292
shell: bash

.github/workflows/k8s-matrix.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
- name: Set up Go
9494
uses: actions/setup-go@v2
9595
with:
96-
go-version: 1.16.x
96+
go-version: 1.17.x
9797

9898
- name: Edit DNS Resolve
9999
shell: bash

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Set up Go
4444
uses: actions/setup-go@v2
4545
with:
46-
go-version: 1.16.x
46+
go-version: 1.17.x
4747

4848
- name: Start KinD Cluster
4949
shell: bash

api/v1/coherence_types.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2021 Oracle and/or its affiliates.
2+
* Copyright (c) 2022, Oracle and/or its affiliates.
33
* Licensed under the Universal Permissive License v 1.0 as shown at
44
* http://oss.oracle.com/licenses/upl.
55
*/
@@ -1953,7 +1953,7 @@ type ScalingSpec struct {
19531953
// Enabled to false then no check will take place and a deployment will be assumed to be safe).
19541954
// +k8s:openapi-gen=true
19551955
type Probe struct {
1956-
corev1.Handler `json:",inline"`
1956+
corev1.ProbeHandler `json:",inline"`
19571957
// Number of seconds after which the handler times out (only applies to http and tcp handlers).
19581958
// Defaults to 1 second. Minimum value is 1.
19591959
// +optional
@@ -2102,6 +2102,17 @@ type NetworkSpec struct {
21022102
// Specifies the hostname of the Pod If not specified, the pod's hostname will be set to a system-defined value.
21032103
// +optional
21042104
Hostname *string `json:"hostname,omitempty"`
2105+
// SetHostnameAsFQDN if true the pod's hostname will be configured as the pod's FQDN, rather than the leaf name (the default).
2106+
// In Linux containers, this means setting the FQDN in the hostname field of the kernel (the nodename field of struct utsname).
2107+
// In Windows containers, this means setting the registry value of hostname for the registry key HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters to FQDN.
2108+
// If a pod does not have FQDN, this has no effect.
2109+
// Default to false.
2110+
// +optional
2111+
SetHostnameAsFQDN *bool `json:"setHostnameAsFQDN,omitempty"`
2112+
// Subdomain, if specified, the fully qualified Pod hostname will be "<hostname>.<subdomain>.<pod namespace>.svc.<cluster domain>".
2113+
// If not specified, the pod will not have a domain name at all.
2114+
// +optional
2115+
Subdomain *string `json:"subdomain,omitempty"`
21052116
}
21062117

21072118
// UpdateStatefulSet updates the specified StatefulSet's network settings.
@@ -2119,6 +2130,8 @@ func (in *NetworkSpec) UpdateStatefulSet(sts *appsv1.StatefulSet) {
21192130
sts.Spec.Template.Spec.HostAliases = in.HostAliases
21202131
sts.Spec.Template.Spec.HostNetwork = notNilBool(in.HostNetwork)
21212132
sts.Spec.Template.Spec.Hostname = notNilString(in.Hostname)
2133+
sts.Spec.Template.Spec.SetHostnameAsFQDN = in.SetHostnameAsFQDN
2134+
sts.Spec.Template.Spec.Subdomain = notNilString(in.Subdomain)
21222135
}
21232136

21242137
// ----- PodDNSConfig -------------------------------------------------------

api/v1/coherenceresourcespec_types.go

Lines changed: 88 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2021 Oracle and/or its affiliates.
2+
* Copyright (c) 2022, Oracle and/or its affiliates.
33
* Licensed under the Universal Permissive License v 1.0 as shown at
44
* http://oss.oracle.com/licenses/upl.
55
*/
@@ -301,6 +301,72 @@ type CoherenceResourceSpec struct {
301301
// Actions to execute once all of the Pods are ready after an initial deployment
302302
// +optional
303303
Actions []Action `json:"actions,omitempty"`
304+
// ActiveDeadlineSeconds is the optional duration in seconds the pod may be active on the node relative to
305+
// StartTime before the system will actively try to mark it failed and kill associated containers.
306+
// Value must be a positive integer.
307+
// +optional
308+
ActiveDeadlineSeconds *int64 `json:"activeDeadlineSeconds,omitempty"`
309+
// EnableServiceLinks indicates whether information about services should be injected into pod's
310+
// environment variables, matching the syntax of Docker links.
311+
// Optional: Defaults to true.
312+
// +optional
313+
EnableServiceLinks *bool `json:"enableServiceLinks,omitempty"`
314+
// Overhead represents the resource overhead associated with running a pod for a given RuntimeClass.
315+
// This field will be autopopulated at admission time by the RuntimeClass admission controller. If
316+
// the RuntimeClass admission controller is enabled, overhead must not be set in Pod create requests.
317+
// The RuntimeClass admission controller will reject Pod create requests which have the overhead already
318+
// set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value
319+
// defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero.
320+
// More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md
321+
// +optional
322+
Overhead corev1.ResourceList `json:"overhead,omitempty" protobuf:"bytes,32,opt,name=overhead"`
323+
// PreemptionPolicy is the Policy for preempting pods with lower priority.
324+
// One of Never, PreemptLowerPriority.
325+
// Defaults to PreemptLowerPriority if unset.
326+
// +optional
327+
PreemptionPolicy *corev1.PreemptionPolicy `json:"preemptionPolicy,omitempty"`
328+
// Priority is the priority value. Various system components use this field to find the
329+
// priority of the pod. When Priority Admission Controller is enabled, it
330+
// prevents users from setting this field. The admission controller populates
331+
// this field from PriorityClassName.
332+
// The higher the value, the higher the priority.
333+
// +optional
334+
Priority *int32 `json:"priority,omitempty"`
335+
// PriorityClassName, if specified, indicates the pod's priority. "system-node-critical" and
336+
// "system-cluster-critical" are two special keywords which indicate the
337+
// highest priorities with the former being the highest priority. Any other
338+
// name must be defined by creating a PriorityClass object with that name.
339+
// If not specified, the pod priority will be default or zero if there is no
340+
// default.
341+
// +optional
342+
PriorityClassName *string `json:"priorityClassName,omitempty"`
343+
// Restart policy for all containers within the pod.
344+
// One of Always, OnFailure, Never.
345+
// Default to Always.
346+
// More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy
347+
// +optional
348+
RestartPolicy *corev1.RestartPolicy `json:"restartPolicy,omitempty"`
349+
// RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used
350+
// to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run.
351+
// If unset or empty, the "legacy" RuntimeClass will be used, which is an implicit class with an
352+
// empty definition that uses the default runtime handler.
353+
// More info: https://git.k8s.io/enhancements/keps/sig-node/585-runtime-class
354+
// +optional
355+
RuntimeClassName *string `json:"runtimeClassName,omitempty"`
356+
// If specified, the pod will be dispatched by specified scheduler.
357+
// If not specified, the pod will be dispatched by default scheduler.
358+
// +optional
359+
SchedulerName *string `json:"schedulerName,omitempty" protobuf:"bytes,19,opt,name=schedulerName"`
360+
// TopologySpreadConstraints describes how a group of pods ought to spread across topology
361+
// domains. Scheduler will schedule pods in a way which abides by the constraints.
362+
// All topologySpreadConstraints are ANDed.
363+
// +optional
364+
// +patchMergeKey=topologyKey
365+
// +patchStrategy=merge
366+
// +listType=map
367+
// +listMapKey=topologyKey
368+
// +listMapKey=whenUnsatisfiable
369+
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty" patchStrategy:"merge" patchMergeKey:"topologyKey"`
304370
}
305371

306372
// Action is an action to execute when the StatefulSet becomes ready.
@@ -445,7 +511,7 @@ func (in *CoherenceResourceSpec) GetDefaultScalingProbe() *Probe {
445511

446512
probe := Probe{
447513
TimeoutSeconds: &timeout,
448-
Handler: corev1.Handler{
514+
ProbeHandler: corev1.ProbeHandler{
449515
HTTPGet: &corev1.HTTPGetAction{
450516
Path: "/ha",
451517
Port: intstr.FromString(PortNameHealth),
@@ -476,7 +542,7 @@ func (in *CoherenceResourceSpec) GetDefaultSuspendProbe() *Probe {
476542

477543
probe := Probe{
478544
TimeoutSeconds: timeout,
479-
Handler: corev1.Handler{
545+
ProbeHandler: corev1.ProbeHandler{
480546
HTTPGet: &corev1.HTTPGetAction{
481547
Path: "/suspend",
482548
Port: intstr.FromString(PortNameHealth),
@@ -722,16 +788,25 @@ func (in *CoherenceResourceSpec) CreateStatefulSet(deployment *Coherence) Resour
722788
Annotations: in.Annotations,
723789
},
724790
Spec: corev1.PodSpec{
725-
ImagePullSecrets: in.GetImagePullSecrets(),
726-
ServiceAccountName: in.GetServiceAccountName(),
791+
Affinity: in.EnsurePodAffinity(deployment),
792+
ActiveDeadlineSeconds: in.ActiveDeadlineSeconds,
727793
AutomountServiceAccountToken: in.AutomountServiceAccountToken,
728-
SecurityContext: in.SecurityContext,
729-
ShareProcessNamespace: in.ShareProcessNamespace,
794+
EnableServiceLinks: in.EnableServiceLinks,
730795
HostIPC: notNilBool(in.HostIPC),
731-
Tolerations: in.Tolerations,
732-
Affinity: in.EnsurePodAffinity(deployment),
796+
ImagePullSecrets: in.GetImagePullSecrets(),
797+
Overhead: in.Overhead,
798+
PreemptionPolicy: in.PreemptionPolicy,
799+
Priority: in.Priority,
800+
PriorityClassName: notNilString(in.PriorityClassName),
733801
NodeSelector: in.NodeSelector,
734802
ReadinessGates: in.ReadinessGates,
803+
RuntimeClassName: in.RuntimeClassName,
804+
SchedulerName: notNilString(in.SchedulerName),
805+
SecurityContext: in.SecurityContext,
806+
ServiceAccountName: in.GetServiceAccountName(),
807+
ShareProcessNamespace: in.ShareProcessNamespace,
808+
Tolerations: in.Tolerations,
809+
TopologySpreadConstraints: in.TopologySpreadConstraints,
735810
InitContainers: []corev1.Container{
736811
in.CreateUtilsContainer(deployment),
737812
},
@@ -743,6 +818,10 @@ func (in *CoherenceResourceSpec) CreateStatefulSet(deployment *Coherence) Resour
743818
},
744819
}
745820

821+
if in.RestartPolicy != nil {
822+
sts.Spec.Template.Spec.RestartPolicy = *in.RestartPolicy
823+
}
824+
746825
// Add any network settings
747826
in.Network.UpdateStatefulSet(&sts)
748827
// Add any JVM settings

api/v1/create_statefulset_networkspec_test.go

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2022, Oracle and/or its affiliates.
33
* Licensed under the Universal Permissive License v 1.0 as shown at
44
* http://oss.oracle.com/licenses/upl.
55
*/
@@ -261,3 +261,57 @@ func TestCreateStatefulSetWithNetworkSpecWithHostname(t *testing.T) {
261261
// assert that the StatefulSet is as expected
262262
assertStatefulSetCreation(t, deployment, stsExpected)
263263
}
264+
265+
func TestCreateStatefulSetWithNetworkSpecWithSetHostnameAsFQDNTrue(t *testing.T) {
266+
267+
spec := coh.CoherenceResourceSpec{
268+
Network: &coh.NetworkSpec{
269+
SetHostnameAsFQDN: boolPtr(true),
270+
},
271+
}
272+
273+
// Create the test deployment
274+
deployment := createTestDeployment(spec)
275+
// Create expected StatefulSet
276+
stsExpected := createMinimalExpectedStatefulSet(deployment)
277+
stsExpected.Spec.Template.Spec.SetHostnameAsFQDN = boolPtr(true)
278+
279+
// assert that the StatefulSet is as expected
280+
assertStatefulSetCreation(t, deployment, stsExpected)
281+
}
282+
283+
func TestCreateStatefulSetWithNetworkSpecWithSetHostnameAsFQDNFalse(t *testing.T) {
284+
285+
spec := coh.CoherenceResourceSpec{
286+
Network: &coh.NetworkSpec{
287+
SetHostnameAsFQDN: boolPtr(false),
288+
},
289+
}
290+
291+
// Create the test deployment
292+
deployment := createTestDeployment(spec)
293+
// Create expected StatefulSet
294+
stsExpected := createMinimalExpectedStatefulSet(deployment)
295+
stsExpected.Spec.Template.Spec.SetHostnameAsFQDN = boolPtr(false)
296+
297+
// assert that the StatefulSet is as expected
298+
assertStatefulSetCreation(t, deployment, stsExpected)
299+
}
300+
301+
func TestCreateStatefulSetWithNetworkSpecWithSubdomain(t *testing.T) {
302+
303+
spec := coh.CoherenceResourceSpec{
304+
Network: &coh.NetworkSpec{
305+
Subdomain: stringPtr("foo"),
306+
},
307+
}
308+
309+
// Create the test deployment
310+
deployment := createTestDeployment(spec)
311+
// Create expected StatefulSet
312+
stsExpected := createMinimalExpectedStatefulSet(deployment)
313+
stsExpected.Spec.Template.Spec.Subdomain = "foo"
314+
315+
// assert that the StatefulSet is as expected
316+
assertStatefulSetCreation(t, deployment, stsExpected)
317+
}

0 commit comments

Comments
 (0)