Skip to content

Commit

Permalink
Add per-component option hostNetwork
Browse files Browse the repository at this point in the history
  • Loading branch information
koct9i committed Jun 19, 2024
1 parent b3cca0a commit ecf325f
Show file tree
Hide file tree
Showing 12 changed files with 168 additions and 8 deletions.
9 changes: 7 additions & 2 deletions api/v1/ytsaurus_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ type InstanceSpec struct {
RuntimeClassName *string `json:"runtimeClassName,omitempty"`
// Deprecated: use Affinity.PodAntiAffinity instead.
EnableAntiAffinity *bool `json:"enableAntiAffinity,omitempty"`
// Use the host's network namespace, this overrides global option.
//+optional
HostNetwork *bool `json:"hostNetwork,omitempty"`
//+optional
MonitoringPort *int32 `json:"monitoringPort,omitempty"`
Loggers []TextLoggerSpec `json:"loggers,omitempty"`
Expand Down Expand Up @@ -541,12 +544,14 @@ type CommonSpec struct {
//+kubebuilder:default:=true
//+optional
UseShortNames bool `json:"useShortNames"`
// Use the host's network namespace for all components.
//+kubebuilder:default:=false
//+optional
UsePorto bool `json:"usePorto"`
HostNetwork bool `json:"hostNetwork"`

//+kubebuilder:default:=false
//+optional
HostNetwork bool `json:"hostNetwork"`
UsePorto bool `json:"usePorto"`

ExtraPodAnnotations map[string]string `json:"extraPodAnnotations,omitempty"`

Expand Down
3 changes: 2 additions & 1 deletion api/v1/ytsaurus_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/apimachinery/pkg/util/yaml"
ptr "k8s.io/utils/pointer"
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
Expand Down Expand Up @@ -127,7 +128,7 @@ func (r *Ytsaurus) validateHostAddresses(masterSpec MastersSpec, fieldPath *fiel
var allErrors field.ErrorList

hostAddressesFieldPath := fieldPath.Child("hostAddresses")
if !r.Spec.HostNetwork && len(masterSpec.HostAddresses) != 0 {
if !ptr.BoolDeref(masterSpec.HostNetwork, r.Spec.HostNetwork) && len(masterSpec.HostAddresses) != 0 {
allErrors = append(
allErrors,
field.Required(
Expand Down
5 changes: 5 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ spec:
type: object
hostNetwork:
default: false
description: Use the host's network namespace for all components.
type: boolean
image:
description: Overrides coreImage for component.
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/cluster.ytsaurus.tech_remoteytsaurus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,10 @@ spec:
items:
type: string
type: array
hostNetwork:
description: Use the host's network namespace, this overrides global
option.
type: boolean
image:
description: Overrides coreImage for component.
type: string
Expand Down
61 changes: 61 additions & 0 deletions config/crd/bases/cluster.ytsaurus.tech_ytsaurus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,10 @@ spec:
items:
type: string
type: array
hostNetwork:
description: Use the host's network namespace, this overrides
global option.
type: boolean
image:
description: Overrides coreImage for component.
type: string
Expand Down Expand Up @@ -3101,6 +3105,10 @@ spec:
items:
type: string
type: array
hostNetwork:
description: Use the host's network namespace, this overrides
global option.
type: boolean
image:
description: Overrides coreImage for component.
type: string
Expand Down Expand Up @@ -5454,6 +5462,10 @@ spec:
items:
type: string
type: array
hostNetwork:
description: Use the host's network namespace, this overrides
global option.
type: boolean
image:
description: Overrides coreImage for component.
type: string
Expand Down Expand Up @@ -7800,6 +7812,10 @@ spec:
items:
type: string
type: array
hostNetwork:
description: Use the host's network namespace, this overrides
global option.
type: boolean
image:
description: Overrides coreImage for component.
type: string
Expand Down Expand Up @@ -9735,6 +9751,7 @@ spec:
type: object
hostNetwork:
default: false
description: Use the host's network namespace for all components.
type: boolean
httpProxies:
items:
Expand Down Expand Up @@ -10349,6 +10366,10 @@ spec:
items:
type: string
type: array
hostNetwork:
description: Use the host's network namespace, this overrides
global option.
type: boolean
httpNodePort:
format: int32
type: integer
Expand Down Expand Up @@ -12748,6 +12769,10 @@ spec:
items:
type: string
type: array
hostNetwork:
description: Use the host's network namespace, this overrides
global option.
type: boolean
image:
description: Overrides coreImage for component.
type: string
Expand Down Expand Up @@ -15137,6 +15162,10 @@ spec:
items:
type: string
type: array
hostNetwork:
description: Use the host's network namespace, this overrides
global option.
type: boolean
image:
description: Overrides coreImage for component.
type: string
Expand Down Expand Up @@ -17479,6 +17508,10 @@ spec:
items:
type: string
type: array
hostNetwork:
description: Use the host's network namespace, this overrides
global option.
type: boolean
image:
description: Overrides coreImage for component.
type: string
Expand Down Expand Up @@ -19811,6 +19844,10 @@ spec:
items:
type: string
type: array
hostNetwork:
description: Use the host's network namespace, this overrides
global option.
type: boolean
image:
description: Overrides coreImage for component.
type: string
Expand Down Expand Up @@ -22150,6 +22187,10 @@ spec:
items:
type: string
type: array
hostNetwork:
description: Use the host's network namespace, this overrides
global option.
type: boolean
image:
description: Overrides coreImage for component.
type: string
Expand Down Expand Up @@ -24525,6 +24566,10 @@ spec:
items:
type: string
type: array
hostNetwork:
description: Use the host's network namespace, this overrides
global option.
type: boolean
image:
description: Overrides coreImage for component.
type: string
Expand Down Expand Up @@ -26872,6 +26917,10 @@ spec:
items:
type: string
type: array
hostNetwork:
description: Use the host's network namespace, this overrides
global option.
type: boolean
image:
description: Overrides coreImage for component.
type: string
Expand Down Expand Up @@ -29283,6 +29332,10 @@ spec:
items:
type: string
type: array
hostNetwork:
description: Use the host's network namespace, this overrides
global option.
type: boolean
image:
description: Overrides coreImage for component.
type: string
Expand Down Expand Up @@ -31642,6 +31695,10 @@ spec:
items:
type: string
type: array
hostNetwork:
description: Use the host's network namespace, this overrides
global option.
type: boolean
image:
description: Overrides coreImage for component.
type: string
Expand Down Expand Up @@ -34203,6 +34260,10 @@ spec:
items:
type: string
type: array
hostNetwork:
description: Use the host's network namespace, this overrides
global option.
type: boolean
image:
description: Overrides coreImage for component.
type: string
Expand Down
Loading

0 comments on commit ecf325f

Please sign in to comment.