Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for hostPath #15648

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/core/300-resources/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,10 @@ spec:
description: This is accessible behind a feature flag - kubernetes.podspec-emptydir
type: object
x-kubernetes-preserve-unknown-fields: true
hostPath:
description: This is accessible behind a feature flag - kubernetes.podspec-hostpath
type: object
x-kubernetes-preserve-unknown-fields: true
name:
description: |-
name of the volume.
Expand Down
2,904 changes: 1,522 additions & 1,382 deletions config/core/300-resources/revision.yaml

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion config/core/300-resources/service.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 The Knative Authors

Check failure on line 1 in config/core/300-resources/service.yaml

View workflow job for this annotation

GitHub Actions / verify / Verify Deps and Codegen

Please run ./hack/update-codegen.sh. diff --git a/config/core/300-resources/service.yaml b/config/core/300-resources/service.yaml index 6f45a63..b4d8b0b 100644 --- a/config/core/300-resources/service.yaml +++ b/config/core/300-resources/service.yaml @@ -1732,4 +1732,4 @@ spec: description: |- URL holds the url that will distribute traffic over the provided traffic targets. It generally has the form http[s]://{route-name}.{route-namespace}.{cluster-level-suffix} - type: string \ No newline at end of file + type: string
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -1233,6 +1233,10 @@
description: This is accessible behind a feature flag - kubernetes.podspec-emptydir
type: object
x-kubernetes-preserve-unknown-fields: true
hostPath:
description: This is accessible behind a feature flag - kubernetes.podspec-hostpath
type: object
x-kubernetes-preserve-unknown-fields: true
name:
description: |-
name of the volume.
Expand Down Expand Up @@ -1728,4 +1732,4 @@
description: |-
URL holds the url that will distribute traffic over the provided traffic targets.
It generally has the form http[s]://{route-name}.{route-namespace}.{cluster-level-suffix}
type: string
type: string

Check failure on line 1735 in config/core/300-resources/service.yaml

View workflow job for this annotation

GitHub Actions / style / Golang / Lint

[EOF Newline] reported by reviewdog 🐶 Missing newline Raw Output: config/core/300-resources/service.yaml:1735: Missing newline
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A new line is missing.

12 changes: 10 additions & 2 deletions config/core/configmaps/features.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 The Knative Authors

Check failure on line 1 in config/core/configmaps/features.yaml

View workflow job for this annotation

GitHub Actions / verify / Verify Deps and Codegen

Please run ./hack/update-codegen.sh. diff --git a/config/core/configmaps/features.yaml b/config/core/configmaps/features.yaml index b01f0ec..51830a8 100644 --- a/config/core/configmaps/features.yaml +++ b/config/core/configmaps/features.yaml @@ -241,4 +241,4 @@ data: queueproxy.mount-podinfo: "disabled" # Default queue proxy resource requests and limits to good values for most cases if set. - queueproxy.resource-defaults: "disabled" \ No newline at end of file + queueproxy.resource-defaults: "disabled"
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,7 @@
app.kubernetes.io/component: controller
app.kubernetes.io/version: devel
annotations:
knative.dev/example-checksum: "9ff569ad"
knative.dev/example-checksum: "63a13754"
data:
_example: |-
################################
Expand Down Expand Up @@ -200,6 +200,14 @@
# 2. Disabled: disabling EmptyDir volume support
kubernetes.podspec-volumes-emptydir: "enabled"

# Controls whether volume support for HostPath is enabled or not.
# WARNING: Cannot safely be disabled once enabled.
# WARNING: If you can avoid using a hostPath volume, you should.
# Please read https://kubernetes.io/docs/concepts/storage/volumes/#hostpath before enabling this feature.
# 1. Enabled: enabling HostPath volume support
# 2. Disabled: disabling HostPath volume support
kubernetes.podspec-volumes-hostpath: "disabled"

# Controls whether init containers support is enabled or not.
# 1. Enabled: enabling init containers support
# 2. Disabled: disabling init containers support
Expand Down Expand Up @@ -233,4 +241,4 @@
queueproxy.mount-podinfo: "disabled"

# Default queue proxy resource requests and limits to good values for most cases if set.
queueproxy.resource-defaults: "disabled"
queueproxy.resource-defaults: "disabled"

Check failure on line 244 in config/core/configmaps/features.yaml

View workflow job for this annotation

GitHub Actions / style / Golang / Lint

[EOF Newline] reported by reviewdog 🐶 Missing newline Raw Output: config/core/configmaps/features.yaml:244: Missing newline
95 changes: 51 additions & 44 deletions hack/schemapatch-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# Following are behind feature flags
- EmptyDir
- PersistentVolumeClaim
- HostPath
k8s.io/api/core/v1.PersistentVolumeClaimVolumeSource:
description: "This is accessible behind a feature flag - kubernetes.podspec-persistent-volume-claim"
additionalMarkers:
Expand All @@ -24,6 +25,12 @@
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
k8s.io/api/core/v1.HostPathVolumeSource:
description: "This is accessible behind a feature flag - kubernetes.podspec-hostpath"
additionalMarkers:
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
k8s.io/api/core/v1.VolumeProjection:
fieldMask:
- Secret
Expand Down Expand Up @@ -79,17 +86,17 @@
Affinity:
description: "This is accessible behind a feature flag - kubernetes.podspec-affinity"
additionalMarkers:
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
DNSPolicy:
description: "This is accessible behind a feature flag - kubernetes.podspec-dnspolicy"
DNSConfig:
description: "This is accessible behind a feature flag - kubernetes.podspec-dnsconfig"
additionalMarkers:
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
EnableServiceLinks:
description: 'EnableServiceLinks indicates whether information about services should be injected into pod''s environment variables, matching the syntax of Docker links. Optional: Knative defaults this to false.'
HostAliases:
Expand All @@ -99,9 +106,9 @@
itemOverride:
description: "This is accessible behind a feature flag - kubernetes.podspec-hostaliases"
additionalMarkers:
# # Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
# # Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
Containers:
additionalMarkers:
- kubebuilder:validation:DropListMapMarkers
Expand All @@ -111,33 +118,33 @@
itemOverride:
description: "This is accessible behind a feature flag - kubernetes.podspec-init-containers"
additionalMarkers:
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
NodeSelector:
description: "This is accessible behind a feature flag - kubernetes.podspec-nodeselector"
additionalMarkers:
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
PriorityClassName:
description: "This is accessible behind a feature flag - kubernetes.podspec-priorityclassname"
additionalMarkers:
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
RuntimeClassName:
description: "This is accessible behind a feature flag - kubernetes.podspec-runtimeclassname"
additionalMarkers:
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
SchedulerName:
description: "This is accessible behind a feature flag - kubernetes.podspec-schedulername"
additionalMarkers:
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
SecurityContext:
description: "This is accessible behind a feature flag - kubernetes.podspec-securitycontext"
additionalMarkers:
Expand All @@ -153,9 +160,9 @@
HostIPC:
description: "This is accessible behind a feature flag - kubernetes.podspec-hostipc"
additionalMarkers:
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
HostPID:
description: "This is accessible behind a feature flag - kubernetes.podspec-hostpid"
additionalMarkers:
Expand All @@ -173,19 +180,19 @@
itemOverride:
description: "This is accessible behind a feature flag - kubernetes.podspec-tolerations"
additionalMarkers:
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
TopologySpreadConstraints:
description: "This is accessible behind a feature flag - kubernetes.podspec-topologyspreadconstraints"
additionalMarkers:
- kubebuilder:validation:DropListMapMarkers
itemOverride:
description: "This is accessible behind a feature flag - kubernetes.podspec-topologyspreadconstraints"
additionalMarkers:
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
k8s.io/api/core/v1.Container:
fieldMask:
- Name
Expand All @@ -208,10 +215,10 @@
fieldOverrides:
Name:
additionalMarkers:
- optional
- optional
Ports:
additionalMarkers:
- optional
- optional
k8s.io/api/core/v1.VolumeMount:
fieldMask:
- Name
Expand Down Expand Up @@ -252,15 +259,15 @@
fieldOverrides:
Port:
additionalMarkers:
- optional
- optional
k8s.io/api/core/v1.TCPSocketAction:
fieldMask:
- Host
- Port
fieldOverrides:
Port:
additionalMarkers:
- optional
- optional
k8s.io/api/core/v1.ContainerPort:
fieldMask:
- ContainerPort
Expand All @@ -281,15 +288,15 @@
FieldRef:
description: "This is accessible behind a feature flag - kubernetes.podspec-fieldref"
additionalMarkers:
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
ResourceFieldRef:
description: "This is accessible behind a feature flag - kubernetes.podspec-fieldref"
additionalMarkers:
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
# Part of a feature flag - so we want to omit the schema and preserve unknown fields
- kubebuilder:validation:DropProperties
- kubebuilder:pruning:PreserveUnknownFields
k8s.io/api/core/v1.LocalObjectReference:
fieldMask:
- Name
Expand Down Expand Up @@ -340,4 +347,4 @@
fieldMask:
- APIVersion
- Kind
- Name
- Name

Check failure on line 350 in hack/schemapatch-config.yaml

View workflow job for this annotation

GitHub Actions / style / Golang / Lint

[EOF Newline] reported by reviewdog 🐶 Missing newline Raw Output: hack/schemapatch-config.yaml:350: Missing newline
3 changes: 3 additions & 0 deletions pkg/apis/config/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func defaultFeaturesConfig() *Features {
ContainerSpecAddCapabilities: Disabled,
PodSpecTolerations: Disabled,
PodSpecVolumesEmptyDir: Enabled,
PodSpecVolumesHostPath: Disabled,
PodSpecPersistentVolumeClaim: Disabled,
PodSpecPersistentVolumeWrite: Disabled,
QueueProxyMountPodInfo: Disabled,
Expand Down Expand Up @@ -107,6 +108,7 @@ func NewFeaturesConfigFromMap(data map[string]string) (*Features, error) {
asFlag("kubernetes.containerspec-addcapabilities", &nc.ContainerSpecAddCapabilities),
asFlag("kubernetes.podspec-tolerations", &nc.PodSpecTolerations),
asFlag("kubernetes.podspec-volumes-emptydir", &nc.PodSpecVolumesEmptyDir),
asFlag("kubernetes.podspec-volumes-hostpath", &nc.PodSpecVolumesHostPath),
asFlag("kubernetes.podspec-hostipc", &nc.PodSpecHostIPC),
asFlag("kubernetes.podspec-hostpid", &nc.PodSpecHostPID),
asFlag("kubernetes.podspec-hostnetwork", &nc.PodSpecHostNetwork),
Expand Down Expand Up @@ -151,6 +153,7 @@ type Features struct {
ContainerSpecAddCapabilities Flag
PodSpecTolerations Flag
PodSpecVolumesEmptyDir Flag
PodSpecVolumesHostPath Flag
PodSpecInitContainers Flag
PodSpecPersistentVolumeClaim Flag
PodSpecPersistentVolumeWrite Flag
Expand Down
18 changes: 18 additions & 0 deletions pkg/apis/config/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,24 @@ func TestFeaturesConfiguration(t *testing.T) {
data: map[string]string{
"kubernetes.podspec-volumes-emptydir": "Enabled",
},
}, {
name: "kubernetes.podspec-volumes-hostpath Disabled",
wantErr: false,
wantFeatures: defaultWith(&Features{
PodSpecVolumesHostPath: Disabled,
}),
data: map[string]string{
"kubernetes.podspec-volumes-hostpath": "Disabled",
},
}, {
name: "kubernetes.podspec-volumes-hostpath Enabled",
wantErr: false,
wantFeatures: defaultWith(&Features{
PodSpecVolumesHostPath: Enabled,
}),
data: map[string]string{
"kubernetes.podspec-volumes-hostpath": "Enabled",
},
}, {
name: "kubernetes.podspec-persistent-volume-claim Disabled",
wantErr: false,
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/serving/fieldmask.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ func VolumeSourceMask(ctx context.Context, in *corev1.VolumeSource) *corev1.Volu
out.PersistentVolumeClaim = in.PersistentVolumeClaim
}

if cfg.Features.PodSpecVolumesHostPath != config.Disabled {
out.HostPath = in.HostPath
}

// Too many disallowed fields to list

return out
Expand Down
Loading
Loading