mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Merge pull request #81956 from apelisse/server-side-apply-beta
Server side apply beta
This commit is contained in:
commit
991d71e9fe
393
api/openapi-spec/swagger.json
generated
393
api/openapi-spec/swagger.json
generated
File diff suppressed because it is too large
Load Diff
@ -579,7 +579,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
|
||||
genericfeatures.APIResponseCompression: {Default: true, PreRelease: featuregate.Beta},
|
||||
genericfeatures.APIListChunking: {Default: true, PreRelease: featuregate.Beta},
|
||||
genericfeatures.DryRun: {Default: true, PreRelease: featuregate.Beta},
|
||||
genericfeatures.ServerSideApply: {Default: false, PreRelease: featuregate.Alpha},
|
||||
genericfeatures.ServerSideApply: {Default: true, PreRelease: featuregate.Beta},
|
||||
genericfeatures.RequestManagement: {Default: false, PreRelease: featuregate.Alpha},
|
||||
|
||||
// inherited features from apiextensions-apiserver, relisted here to get a conflict if it is changed
|
||||
|
@ -95,6 +95,7 @@ const (
|
||||
|
||||
// owner: @apelisse, @lavalamp
|
||||
// alpha: v1.14
|
||||
// beta: v1.16
|
||||
//
|
||||
// Server-side apply. Merging happens on the server.
|
||||
ServerSideApply featuregate.Feature = "ServerSideApply"
|
||||
@ -156,7 +157,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
|
||||
APIListChunking: {Default: true, PreRelease: featuregate.Beta},
|
||||
DryRun: {Default: true, PreRelease: featuregate.Beta},
|
||||
RemainingItemCount: {Default: true, PreRelease: featuregate.Beta},
|
||||
ServerSideApply: {Default: false, PreRelease: featuregate.Alpha},
|
||||
ServerSideApply: {Default: true, PreRelease: featuregate.Beta},
|
||||
StorageVersionHash: {Default: true, PreRelease: featuregate.Beta},
|
||||
WinOverlay: {Default: false, PreRelease: featuregate.Alpha},
|
||||
WinDSR: {Default: false, PreRelease: featuregate.Alpha},
|
||||
|
@ -204,11 +204,11 @@ func (o *ApplyOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
|
||||
o.DryRun = cmdutil.GetDryRunFlag(cmd)
|
||||
|
||||
if o.ForceConflicts && !o.ServerSideApply {
|
||||
return fmt.Errorf("--experimental-force-conflicts only works with --experimental-server-side")
|
||||
return fmt.Errorf("--force-conflicts only works with --server-side")
|
||||
}
|
||||
|
||||
if o.DryRun && o.ServerSideApply {
|
||||
return fmt.Errorf("--dry-run doesn't work with --experimental-server-side (did you mean --server-dry-run instead?)")
|
||||
return fmt.Errorf("--dry-run doesn't work with --server-side (did you mean --server-dry-run instead?)")
|
||||
}
|
||||
|
||||
if o.DryRun && o.ServerDryRun {
|
||||
|
@ -402,7 +402,7 @@ func (o *DiffOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
|
||||
o.ServerSideApply = cmdutil.GetServerSideApplyFlag(cmd)
|
||||
o.ForceConflicts = cmdutil.GetForceConflictsFlag(cmd)
|
||||
if o.ForceConflicts && !o.ServerSideApply {
|
||||
return fmt.Errorf("--experimental-force-conflicts only works with --experimental-server-side")
|
||||
return fmt.Errorf("--force-conflicts only works with --server-side")
|
||||
}
|
||||
|
||||
if !o.ServerSideApply {
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/evanphx/json-patch"
|
||||
jsonpatch "github.com/evanphx/json-patch"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
@ -409,9 +409,9 @@ func AddDryRunFlag(cmd *cobra.Command) {
|
||||
}
|
||||
|
||||
func AddServerSideApplyFlags(cmd *cobra.Command) {
|
||||
cmd.Flags().Bool("experimental-server-side", false, "If true, apply runs in the server instead of the client. This is an alpha feature and flag.")
|
||||
cmd.Flags().Bool("experimental-force-conflicts", false, "If true, server-side apply will force the changes against conflicts. This is an alpha feature and flag.")
|
||||
cmd.Flags().String("experimental-field-manager", "kubectl", "Name of the manager used to track field ownership. This is an alpha feature and flag.")
|
||||
cmd.Flags().Bool("server-side", false, "If true, apply runs in the server instead of the client.")
|
||||
cmd.Flags().Bool("force-conflicts", false, "If true, server-side apply will force the changes against conflicts.")
|
||||
cmd.Flags().String("field-manager", "kubectl", "Name of the manager used to track field ownership.")
|
||||
}
|
||||
|
||||
func AddIncludeUninitializedFlag(cmd *cobra.Command) {
|
||||
@ -488,15 +488,15 @@ func DumpReaderToFile(reader io.Reader, filename string) error {
|
||||
}
|
||||
|
||||
func GetServerSideApplyFlag(cmd *cobra.Command) bool {
|
||||
return GetFlagBool(cmd, "experimental-server-side")
|
||||
return GetFlagBool(cmd, "server-side")
|
||||
}
|
||||
|
||||
func GetForceConflictsFlag(cmd *cobra.Command) bool {
|
||||
return GetFlagBool(cmd, "experimental-force-conflicts")
|
||||
return GetFlagBool(cmd, "force-conflicts")
|
||||
}
|
||||
|
||||
func GetFieldManagerFlag(cmd *cobra.Command) string {
|
||||
return GetFlagString(cmd, "experimental-field-manager")
|
||||
return GetFlagString(cmd, "field-manager")
|
||||
}
|
||||
|
||||
func GetDryRunFlag(cmd *cobra.Command) bool {
|
||||
|
@ -249,12 +249,12 @@ run_kubectl_apply_tests() {
|
||||
set -o errexit
|
||||
|
||||
create_and_use_new_namespace
|
||||
kube::log::status "Testing kubectl apply --experimental-server-side"
|
||||
kube::log::status "Testing kubectl apply --server-side"
|
||||
## kubectl apply should create the resource that doesn't exist yet
|
||||
# Pre-Condition: no POD exists
|
||||
kube::test::get_object_assert pods "{{range.items}}{{${id_field:?}}}:{{end}}" ''
|
||||
# Command: apply a pod "test-pod" (doesn't exist) should create this pod
|
||||
kubectl apply --experimental-server-side -f hack/testdata/pod.yaml "${kube_flags[@]:?}"
|
||||
kubectl apply --server-side -f hack/testdata/pod.yaml "${kube_flags[@]:?}"
|
||||
# Post-Condition: pod "test-pod" is created
|
||||
kube::test::get_object_assert 'pods test-pod' "{{${labels_field:?}.name}}" 'test-pod-label'
|
||||
# Clean up
|
||||
@ -265,13 +265,13 @@ run_kubectl_apply_tests() {
|
||||
kube::test::get_object_assert pods "{{range.items}}{{${id_field:?}}}:{{end}}" ''
|
||||
|
||||
# apply dry-run
|
||||
kubectl apply --experimental-server-side --server-dry-run -f hack/testdata/pod.yaml "${kube_flags[@]:?}"
|
||||
kubectl apply --server-side --server-dry-run -f hack/testdata/pod.yaml "${kube_flags[@]:?}"
|
||||
# No pod exists
|
||||
kube::test::get_object_assert pods "{{range.items}}{{${id_field:?}}}:{{end}}" ''
|
||||
# apply non dry-run creates the pod
|
||||
kubectl apply --experimental-server-side -f hack/testdata/pod.yaml "${kube_flags[@]:?}"
|
||||
kubectl apply --server-side -f hack/testdata/pod.yaml "${kube_flags[@]:?}"
|
||||
# apply changes
|
||||
kubectl apply --experimental-server-side --server-dry-run -f hack/testdata/pod-apply.yaml "${kube_flags[@]:?}"
|
||||
kubectl apply --server-side --server-dry-run -f hack/testdata/pod-apply.yaml "${kube_flags[@]:?}"
|
||||
# Post-Condition: label still has initial value
|
||||
kube::test::get_object_assert 'pods test-pod' "{{${labels_field:?}.name}}" 'test-pod-label'
|
||||
|
||||
@ -302,7 +302,7 @@ run_kubectl_apply_tests() {
|
||||
__EOF__
|
||||
|
||||
# Dry-run create the CR
|
||||
kubectl "${kube_flags[@]:?}" apply --experimental-server-side --server-dry-run -f hack/testdata/CRD/resource.yaml "${kube_flags[@]:?}"
|
||||
kubectl "${kube_flags[@]:?}" apply --server-side --server-dry-run -f hack/testdata/CRD/resource.yaml "${kube_flags[@]:?}"
|
||||
# Make sure that the CR doesn't exist
|
||||
! kubectl "${kube_flags[@]:?}" get resource/myobj
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user