diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 20115bf21..3aec7f7b1 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -10,13 +10,6 @@ RUN zypper -n install ca-certificates awk lsb-release rsync docker containerd ## install golangci RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$(go env GOPATH)/bin" v1.55.2; -## install k8s.io and generate openapi spec -RUN mkdir -p /go/src/github.com/kubernetes && \ - cd /go/src/github.com/kubernetes && \ - git clone https://github.com/kubernetes/kubernetes && \ - cd kubernetes && \ - git checkout v1.27.11 - # -- for dapper ENV DAPPER_RUN_ARGS --privileged --network host -v /run/containerd/containerd.sock:/run/containerd/containerd.sock ENV GO111MODULE off diff --git a/docs/development.md b/docs/development.md index b8e1b1522..b527b569a 100644 --- a/docs/development.md +++ b/docs/development.md @@ -40,6 +40,17 @@ func FillObjectMetaSystemFields(meta metav1.Object) { } ``` +* k8s.io/apiserver/pkg/registry/rest/meta.go +```go +// WipeObjectMetaSystemFields erases fields that are managed by the system on ObjectMeta. +func WipeObjectMetaSystemFields(meta metav1.Object) { + //meta.SetCreationTimestamp(metav1.Time{}) + meta.SetUID("") + meta.SetDeletionTimestamp(nil) + meta.SetDeletionGracePeriodSeconds(nil) + meta.SetSelfLink("") +} +``` ## virtual kubelet log support The `support-bundle-kit simulator` runs a minimal virtual-kubelet to support log streaming from the support bundle. The simulator listens on localhost, to ensure kubectl and other cli tooling works natively, diff --git a/go.mod b/go.mod index 69fc9df16..79324a99c 100644 --- a/go.mod +++ b/go.mod @@ -50,7 +50,6 @@ replace ( k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.27.11 k8s.io/kubectl => k8s.io/kubectl v0.27.11 k8s.io/kubelet => k8s.io/kubelet v0.27.11 - k8s.io/kubernetes => ../../kubernetes/kubernetes k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.27.11 k8s.io/metrics => k8s.io/metrics v0.27.11 k8s.io/mount-utils => k8s.io/mount-utils v0.27.11 diff --git a/go.sum b/go.sum index 6dd1b1039..86c9e0b41 100644 --- a/go.sum +++ b/go.sum @@ -1299,6 +1299,8 @@ k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f h1:2kWPakN3i/k81b0gvD5C5F k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f/go.mod h1:byini6yhqGC14c3ebc/QwanvYwhuMWF6yz2F8uwW8eg= k8s.io/kubelet v0.27.11 h1:o6XGh8QdGjXEYCHpdTOSY8GhrxhO80HIX7jWyL3ySvg= k8s.io/kubelet v0.27.11/go.mod h1:h0ycSyyeSeQfTqJNxBUXF6hwAyETtwTb2oS0GKfaxP4= +k8s.io/kubernetes v1.27.11 h1:Qrd9IwWfkP0BO+LpH0rNttC3ZieMGgZW2mIvb8q9Ynw= +k8s.io/kubernetes v1.27.11/go.mod h1:cRLM3g95AsipdxwaEkPgIFiF+qda0y3UKHyDHVSj6ok= k8s.io/legacy-cloud-providers v0.27.11 h1:WBjKf1s3+3sAVz8fnYuQmSCKWEXT8e1MYmIhe+Upbpk= k8s.io/legacy-cloud-providers v0.27.11/go.mod h1:WOEmrIKkbVzw1aQyZ3zwtZSBmc9GnWXHSc9CXmL4Tkg= k8s.io/metrics v0.27.11 h1:f9BQgW0uQ36y9dujRNCk+dTealrDH92NZQLomKRqh/A= diff --git a/vendor/k8s.io/apimachinery/pkg/api/validation/objectmeta.go b/vendor/k8s.io/apimachinery/pkg/api/validation/objectmeta.go index 593d7ba8c..f53c840c5 100644 --- a/vendor/k8s.io/apimachinery/pkg/api/validation/objectmeta.go +++ b/vendor/k8s.io/apimachinery/pkg/api/validation/objectmeta.go @@ -252,7 +252,8 @@ func ValidateObjectMetaAccessorUpdate(newMeta, oldMeta metav1.Object, fldPath *f allErrs = append(allErrs, ValidateImmutableField(newMeta.GetName(), oldMeta.GetName(), fldPath.Child("name"))...) allErrs = append(allErrs, ValidateImmutableField(newMeta.GetNamespace(), oldMeta.GetNamespace(), fldPath.Child("namespace"))...) allErrs = append(allErrs, ValidateImmutableField(newMeta.GetUID(), oldMeta.GetUID(), fldPath.Child("uid"))...) - allErrs = append(allErrs, ValidateImmutableField(newMeta.GetCreationTimestamp(), oldMeta.GetCreationTimestamp(), fldPath.Child("creationTimestamp"))...) + //Disabled to ensure the objectMeta from support bundle is honored while importing the object + //allErrs = append(allErrs, ValidateImmutableField(newMeta.GetCreationTimestamp(), oldMeta.GetCreationTimestamp(), fldPath.Child("creationTimestamp"))...) allErrs = append(allErrs, ValidateImmutableField(newMeta.GetDeletionTimestamp(), oldMeta.GetDeletionTimestamp(), fldPath.Child("deletionTimestamp"))...) allErrs = append(allErrs, ValidateImmutableField(newMeta.GetDeletionGracePeriodSeconds(), oldMeta.GetDeletionGracePeriodSeconds(), fldPath.Child("deletionGracePeriodSeconds"))...) diff --git a/vendor/k8s.io/apiserver/pkg/registry/rest/meta.go b/vendor/k8s.io/apiserver/pkg/registry/rest/meta.go index 12c1e5f98..4df624eca 100644 --- a/vendor/k8s.io/apiserver/pkg/registry/rest/meta.go +++ b/vendor/k8s.io/apiserver/pkg/registry/rest/meta.go @@ -25,7 +25,7 @@ import ( // WipeObjectMetaSystemFields erases fields that are managed by the system on ObjectMeta. func WipeObjectMetaSystemFields(meta metav1.Object) { - meta.SetCreationTimestamp(metav1.Time{}) + //meta.SetCreationTimestamp(metav1.Time{}) meta.SetUID("") meta.SetDeletionTimestamp(nil) meta.SetDeletionGracePeriodSeconds(nil) @@ -34,7 +34,9 @@ func WipeObjectMetaSystemFields(meta metav1.Object) { // FillObjectMetaSystemFields populates fields that are managed by the system on ObjectMeta. func FillObjectMetaSystemFields(meta metav1.Object) { - meta.SetCreationTimestamp(metav1.Now()) + if meta.GetCreationTimestamp().String() == "" { + meta.SetCreationTimestamp(metav1.Now()) + } meta.SetUID(uuid.NewUUID()) } diff --git a/vendor/k8s.io/kubernetes/pkg/registry/core/pod/strategy.go b/vendor/k8s.io/kubernetes/pkg/registry/core/pod/strategy.go index 7c235a647..acc62ee9c 100644 --- a/vendor/k8s.io/kubernetes/pkg/registry/core/pod/strategy.go +++ b/vendor/k8s.io/kubernetes/pkg/registry/core/pod/strategy.go @@ -438,6 +438,8 @@ func LogLocation( if err != nil { return nil, nil, err } + //patch to allow the node to point to localhost to ensure virtual kubelet can return logs + nodeInfo.Hostname = "localhost" params := url.Values{} if opts.Follow { params.Add("follow", "true") diff --git a/vendor/modules.txt b/vendor/modules.txt index c94d74032..69da5f86a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1802,7 +1802,7 @@ k8s.io/kube-openapi/pkg/validation/validate # k8s.io/kubelet v0.0.0 => k8s.io/kubelet v0.27.11 ## explicit; go 1.20 k8s.io/kubelet/pkg/apis -# k8s.io/kubernetes v1.27.11 => ../../kubernetes/kubernetes +# k8s.io/kubernetes v1.27.11 ## explicit; go 1.20 k8s.io/kubernetes/cmd/kube-apiserver/app k8s.io/kubernetes/cmd/kube-apiserver/app/options @@ -2367,7 +2367,6 @@ sigs.k8s.io/yaml # k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.27.11 # k8s.io/kubectl => k8s.io/kubectl v0.27.11 # k8s.io/kubelet => k8s.io/kubelet v0.27.11 -# k8s.io/kubernetes => ../../kubernetes/kubernetes # k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.27.11 # k8s.io/metrics => k8s.io/metrics v0.27.11 # k8s.io/mount-utils => k8s.io/mount-utils v0.27.11