Skip to content

Commit

Permalink
Add per-component option hostNetwork (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
koct9i authored Jun 20, 2024
1 parent 48e2b11 commit 4860a55
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 @@ -543,12 +546,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 @@ -3109,6 +3113,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 @@ -5470,6 +5478,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 @@ -7824,6 +7836,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 @@ -9767,6 +9783,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 @@ -10381,6 +10398,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 @@ -12788,6 +12809,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 @@ -15185,6 +15210,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 @@ -17535,6 +17564,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 @@ -19875,6 +19908,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 @@ -22222,6 +22259,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 @@ -24605,6 +24646,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 @@ -26960,6 +27005,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 @@ -29379,6 +29428,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 @@ -31746,6 +31799,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 @@ -34315,6 +34372,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 4860a55

Please sign in to comment.