Skip to content

Commit

Permalink
Merge pull request #1246 from josefkarasek/rebase-1.21.11
Browse files Browse the repository at this point in the history
Bug 2077004: Rebase 1.21.11
  • Loading branch information
openshift-merge-robot committed May 4, 2022
2 parents ed4d8fd + 7cc5d6d commit 6b3cbdd
Show file tree
Hide file tree
Showing 120 changed files with 2,366 additions and 676 deletions.
522 changes: 410 additions & 112 deletions CHANGELOG/CHANGELOG-1.21.md

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions api/openapi-spec/swagger.json

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

2 changes: 1 addition & 1 deletion build/build-image/cross/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.21.0-go1.16.12-buster.0
v1.21.0-go1.16.15-buster.0
2 changes: 1 addition & 1 deletion build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ readonly KUBE_CONTAINER_RSYNC_PORT=8730

# These are the default versions (image tags) for their respective base images.
readonly __default_debian_iptables_version=buster-v1.6.7
readonly __default_go_runner_version=v2.3.1-go1.16.12-buster.0
readonly __default_go_runner_version=v2.3.1-go1.16.15-buster.0
readonly __default_setcap_version=buster-v2.0.4

# These are the base images for the Docker-wrapped binaries.
Expand Down
6 changes: 3 additions & 3 deletions build/dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ dependencies:

# Golang
- name: "golang: upstream version"
version: 1.16.12
version: 1.16.15
refPaths:
- path: build/build-image/cross/VERSION
- path: cluster/addons/fluentd-elasticsearch/es-image/Dockerfile
Expand All @@ -124,7 +124,7 @@ dependencies:
match: minimum_go_version=go([0-9]+\.[0-9]+)

- name: "k8s.gcr.io/kube-cross: dependents"
version: v1.21.0-go1.16.12-buster.0
version: v1.21.0-go1.16.15-buster.0
refPaths:
- path: build/build-image/cross/VERSION
- path: test/images/sample-apiserver/Makefile
Expand Down Expand Up @@ -154,7 +154,7 @@ dependencies:
match: configs\[DebianIptables\] = Config{buildImageRegistry, "debian-iptables", "[a-zA-Z]+\-v((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)"}

- name: "k8s.gcr.io/go-runner: dependents"
version: v2.3.1-go1.16.12-buster.0
version: v2.3.1-go1.16.15-buster.0
refPaths:
- path: build/common.sh
match: __default_go_runner_version=
Expand Down
2 changes: 1 addition & 1 deletion cluster/addons/fluentd-elasticsearch/es-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.16.12 AS builder
FROM golang:1.16.15 AS builder
COPY elasticsearch_logging_discovery.go go.mod go.sum /
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -ldflags "-w" -o /elasticsearch_logging_discovery /elasticsearch_logging_discovery.go

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
nodeSelector:
kubernetes.io/os: linux
containers:
- image: k8s.gcr.io/kas-network-proxy/proxy-agent:v0.0.22
- image: k8s.gcr.io/kas-network-proxy/proxy-agent:v0.0.30
name: konnectivity-agent
command: ["/proxy-agent"]
args: [
Expand Down
2 changes: 1 addition & 1 deletion cluster/gce/manifests/konnectivity-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
hostNetwork: true
containers:
- name: konnectivity-server-container
image: k8s.gcr.io/kas-network-proxy/proxy-server:v0.0.22
image: k8s.gcr.io/kas-network-proxy/proxy-server:v0.0.30
resources:
requests:
cpu: 25m
Expand Down
2 changes: 2 additions & 0 deletions cmd/kube-proxy/app/server_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ func newProxyServer(config *proxyconfigapi.KubeProxyConfiguration, cleanupAndExi
if err != nil {
return nil, fmt.Errorf("unable to create proxier: %v", err)
}

winkernel.RegisterMetrics()
} else {
klog.V(0).Info("Using userspace Proxier.")
execer := exec.New()
Expand Down
16 changes: 16 additions & 0 deletions cmd/kubeadm/app/cmd/phases/init/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package phases

import (
"fmt"
"path/filepath"
"strings"

"github.com/pkg/errors"
Expand All @@ -27,6 +28,7 @@ import (
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases"
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
Expand Down Expand Up @@ -232,7 +234,21 @@ func runCAPhase(ca *certsphase.KubeadmCert) func(c workflow.RunData) error {
if cert, err := pkiutil.TryLoadCertFromDisk(data.CertificateDir(), ca.BaseName); err == nil {
certsphase.CheckCertificatePeriodValidity(ca.BaseName, cert)

// If CA Cert existed while dryrun, copy CA Cert to dryrun dir for later use
if data.DryRun() {
err := phases.CopyFile(filepath.Join(data.CertificateDir(), kubeadmconstants.CACertName), filepath.Join(data.CertificateWriteDir(), kubeadmconstants.CACertName))
if err != nil {
return errors.Wrapf(err, "could not copy %s to dry run directory %s", kubeadmconstants.CACertName, data.CertificateWriteDir())
}
}
if _, err := pkiutil.TryLoadKeyFromDisk(data.CertificateDir(), ca.BaseName); err == nil {
// If CA Key existed while dryrun, copy CA Key to dryrun dir for later use
if data.DryRun() {
err := phases.CopyFile(filepath.Join(data.CertificateDir(), kubeadmconstants.CAKeyName), filepath.Join(data.CertificateWriteDir(), kubeadmconstants.CAKeyName))
if err != nil {
return errors.Wrapf(err, "could not copy %s to dry run directory %s", kubeadmconstants.CAKeyName, data.CertificateWriteDir())
}
}
fmt.Printf("[certs] Using existing %s certificate authority\n", ca.BaseName)
return nil
}
Expand Down
9 changes: 9 additions & 0 deletions cmd/kubeadm/app/cmd/phases/init/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ package phases

import (
"fmt"
"path/filepath"

"github.com/pkg/errors"
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases"
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
Expand Down Expand Up @@ -132,6 +134,13 @@ func runKubeConfigFile(kubeConfigFileName string) func(workflow.RunData) error {
// if external CA mode, skip certificate authority generation
if data.ExternalCA() {
fmt.Printf("[kubeconfig] External CA mode: Using user provided %s\n", kubeConfigFileName)
// If using an external CA while dryrun, copy kubeconfig files to dryrun dir for later use
if data.DryRun() {
err := phases.CopyFile(filepath.Join(kubeadmconstants.KubernetesDir, kubeConfigFileName), filepath.Join(data.KubeConfigDir(), kubeConfigFileName))
if err != nil {
return errors.Wrapf(err, "could not copy %s to dry run directory %s", kubeConfigFileName, data.KubeConfigDir())
}
}
return nil
}

Expand Down
14 changes: 14 additions & 0 deletions cmd/kubeadm/app/cmd/phases/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ limitations under the License.
package phases

import (
"os"

"k8s.io/component-base/version"

kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
)

Expand All @@ -30,3 +33,14 @@ func SetKubernetesVersion(cfg *kubeadmapiv1beta2.ClusterConfiguration) {
}
cfg.KubernetesVersion = version.Get().String()
}

// CopyFile copy file from src to dest.
func CopyFile(src, dest string) error {
fileInfo, _ := os.Stat(src)
contents, err := os.ReadFile(src)
if err != nil {
return err
}
err = os.WriteFile(dest, contents, fileInfo.Mode())
return err
}
12 changes: 5 additions & 7 deletions cmd/kubeadm/app/phases/certs/renewal/readwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ func (rw *pkiCertificateReadWriter) Read() (*x509.Certificate, error) {
return nil, errors.Wrapf(err, "failed to load existing certificate %s", rw.baseName)
}

if len(certs) != 1 {
return nil, errors.Errorf("wanted exactly one certificate, got %d", len(certs))
}

// Safely pick the first one because the sender's certificate must come first in the list.
// For details, see: https://www.rfc-editor.org/rfc/rfc4346#section-7.4.2
return certs[0], nil
}

Expand Down Expand Up @@ -145,9 +143,9 @@ func (rw *kubeConfigReadWriter) Read() (*x509.Certificate, error) {
if err != nil {
return nil, errors.Wrapf(err, "failed to load existing certificate %s", rw.baseName)
}
if len(caCerts) != 1 {
return nil, errors.Errorf("wanted exactly one certificate, got %d", len(caCerts))
}

// Safely pick the first one because the sender's certificate must come first in the list.
// For details, see: https://www.rfc-editor.org/rfc/rfc4346#section-7.4.2
rw.caCert = caCerts[0]

// get current context
Expand Down
19 changes: 18 additions & 1 deletion cmd/kubeadm/app/util/apiclient/dryrunclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ import (
"strings"

"github.com/pkg/errors"

v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
clientset "k8s.io/client-go/kubernetes"
fakeclientset "k8s.io/client-go/kubernetes/fake"
core "k8s.io/client-go/testing"
bootstrapapi "k8s.io/cluster-bootstrap/token/api"

kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
)

Expand Down Expand Up @@ -160,7 +165,19 @@ func NewDryRunClientWithOpts(opts DryRunClientOptions) clientset.Interface {
&core.SimpleReactor{
Verb: "create",
Resource: "*",
Reaction: successfulModificationReactorFunc,
Reaction: func(action core.Action) (bool, runtime.Object, error) {
objAction, ok := action.(actionWithObject)
if obj := objAction.GetObject(); ok && obj != nil {
if secret, ok := obj.(*v1.Secret); ok {
if secret.Namespace == metav1.NamespaceSystem && strings.HasPrefix(secret.Name, bootstrapapi.BootstrapTokenSecretPrefix) {
// bypass bootstrap token secret create event so that it can be persisted to the backing data store
// this secret should be readable during the uploadcerts init phase if it has already been created
return false, nil, nil
}
}
}
return successfulModificationReactorFunc(action)
},
},
&core.SimpleReactor{
Verb: "update",
Expand Down
14 changes: 0 additions & 14 deletions cmd/kubeadm/app/util/apiclient/init_dryrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package apiclient

import (
"net"
"strings"

"github.com/pkg/errors"

Expand All @@ -36,7 +35,6 @@ import (
// Need to handle these routes in a special manner:
// - GET /default/services/kubernetes -- must return a valid Service
// - GET /clusterrolebindings/system:nodes -- can safely return a NotFound error
// - GET /kube-system/secrets/bootstrap-token-* -- can safely return a NotFound error
// - GET /nodes/<node-name> -- must return a valid Node
// - ...all other, unknown GETs/LISTs will be logged
type InitDryRunGetter struct {
Expand All @@ -61,7 +59,6 @@ func (idr *InitDryRunGetter) HandleGetAction(action core.GetAction) (bool, runti
idr.handleKubernetesService,
idr.handleGetNode,
idr.handleSystemNodesClusterRoleBinding,
idr.handleGetBootstrapToken,
}
for _, f := range funcs {
handled, obj, err := f(action)
Expand Down Expand Up @@ -148,14 +145,3 @@ func (idr *InitDryRunGetter) handleSystemNodesClusterRoleBinding(action core.Get
// This can only happen on an upgrade; and in that case the ClientBackedDryRunGetter impl will be used
return true, nil, apierrors.NewNotFound(action.GetResource().GroupResource(), "clusterrolebinding not found")
}

// handleGetBootstrapToken handles the case where kubeadm init creates the default token; and the token code GETs the
// bootstrap token secret first in order to check if it already exists
func (idr *InitDryRunGetter) handleGetBootstrapToken(action core.GetAction) (bool, runtime.Object, error) {
if !strings.HasPrefix(action.GetName(), "bootstrap-token-") || action.GetNamespace() != metav1.NamespaceSystem || action.GetResource().Resource != "secrets" {
// We can't handle this event
return false, nil, nil
}
// We can safely return a NotFound error here as the code will just proceed normally and create the Bootstrap Token
return true, nil, apierrors.NewNotFound(action.GetResource().GroupResource(), "secret not found")
}
14 changes: 0 additions & 14 deletions cmd/kubeadm/app/util/apiclient/init_dryrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ func TestHandleGetAction(t *testing.T) {
expectedObjectJSON: []byte(``),
expectedErr: true, // we expect a NotFound error here
},
{
name: "get kube-system secret bootstrap-token-abcdef",
action: core.NewGetAction(schema.GroupVersionResource{Version: "v1", Resource: "secrets"}, "kube-system", "bootstrap-token-abcdef"),
expectedHandled: true,
expectedObjectJSON: []byte(``),
expectedErr: true, // we expect a NotFound error here
},
{ // an ask for a kubernetes service in the _kube-system_ ns should not be answered
name: "get kube-system services",
action: core.NewGetAction(schema.GroupVersionResource{Version: "v1", Resource: "services"}, "kube-system", "kubernetes"),
Expand All @@ -87,13 +80,6 @@ func TestHandleGetAction(t *testing.T) {
expectedObjectJSON: []byte(``),
expectedErr: false,
},
{ // an ask for a secret in any other ns than kube-system should not be answered
name: "get default secret bootstrap-token-abcdef",
action: core.NewGetAction(schema.GroupVersionResource{Version: "v1", Resource: "secrets"}, "default", "bootstrap-token-abcdef"),
expectedHandled: false,
expectedObjectJSON: []byte(``),
expectedErr: false,
},
}
for _, rt := range tests {
t.Run(rt.name, func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions cmd/kubeadm/app/util/config/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ func getNodeNameFromKubeletConfig(kubeconfigDir string) (string, error) {
return "", errors.Errorf("invalid kubeconfig file %s. x509 certificate expected", fileName)
}

// We are only putting one certificate in the certificate pem file, so it's safe to just pick the first one
// TODO: Support multiple certs here in order to be able to rotate certs
// Safely pick the first one because the sender's certificate must come first in the list.
// For details, see: https://www.rfc-editor.org/rfc/rfc4346#section-7.4.2
cert := certs[0]

// gets the node name from the certificate common name
Expand Down
4 changes: 2 additions & 2 deletions cmd/kubeadm/app/util/pkiutil/pki_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ func TryLoadCertFromDisk(pkiPath, name string) (*x509.Certificate, error) {
return nil, errors.Wrapf(err, "couldn't load the certificate file %s", certificatePath)
}

// We are only putting one certificate in the certificate pem file, so it's safe to just pick the first one
// TODO: Support multiple certs here in order to be able to rotate certs
// Safely pick the first one because the sender's certificate must come first in the list.
// For details, see: https://www.rfc-editor.org/rfc/rfc4346#section-7.4.2
cert := certs[0]

return cert, nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubelet/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ HTTP server: The kubelet can also listen for HTTP and respond to a simple API
config.StaticPodURLHeader[k] = []string{"<masked>"}
}
// log the kubelet's config for inspection
klog.V(5).InfoS("KubeletConfiguration", "configuration", kubeletServer.KubeletConfiguration)
klog.V(5).InfoS("KubeletConfiguration", "configuration", config)

// run the kubelet
if err := Run(ctx, kubeletServer, kubeletDeps, utilfeature.DefaultFeatureGate); err != nil {
Expand Down
11 changes: 6 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ require (
github.com/golang/protobuf v1.5.0
github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e // indirect
github.com/google/btree v1.0.0
github.com/google/cadvisor v0.39.0
github.com/google/cadvisor v0.39.3
github.com/google/go-cmp v0.5.5
github.com/google/gofuzz v1.1.0
github.com/google/uuid v1.1.2
Expand Down Expand Up @@ -134,8 +134,8 @@ require (
k8s.io/sample-apiserver v0.0.0
k8s.io/system-validators v1.4.0
k8s.io/utils v0.0.0-20211116205334-6203023598ed
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.22 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.2
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.30 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1
sigs.k8s.io/yaml v1.2.0
)

Expand Down Expand Up @@ -463,6 +463,7 @@ replace (
go.opencensus.io => go.opencensus.io v0.22.3
go.starlark.net => go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5
go.uber.org/atomic => go.uber.org/atomic v1.4.0
go.uber.org/goleak => go.uber.org/goleak v1.1.10
go.uber.org/multierr => go.uber.org/multierr v1.1.0
go.uber.org/zap => go.uber.org/zap v1.10.0
golang.org/x/crypto => golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
Expand Down Expand Up @@ -548,14 +549,14 @@ replace (
modernc.org/strutil => modernc.org/strutil v1.0.0
modernc.org/xc => modernc.org/xc v1.0.0
rsc.io/pdf => rsc.io/pdf v0.1.1
sigs.k8s.io/apiserver-network-proxy/konnectivity-client => sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.22
sigs.k8s.io/apiserver-network-proxy/konnectivity-client => sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.30
sigs.k8s.io/controller-tools => sigs.k8s.io/controller-tools v0.2.8
sigs.k8s.io/kube-storage-version-migrator => sigs.k8s.io/kube-storage-version-migrator v0.0.3
sigs.k8s.io/kustomize/api => sigs.k8s.io/kustomize/api v0.8.8
sigs.k8s.io/kustomize/cmd/config => sigs.k8s.io/kustomize/cmd/config v0.9.10
sigs.k8s.io/kustomize/kustomize/v4 => sigs.k8s.io/kustomize/kustomize/v4 v4.1.2
sigs.k8s.io/kustomize/kyaml => sigs.k8s.io/kustomize/kyaml v0.10.17
sigs.k8s.io/structured-merge-diff/v4 => sigs.k8s.io/structured-merge-diff/v4 v4.1.2
sigs.k8s.io/structured-merge-diff/v4 => sigs.k8s.io/structured-merge-diff/v4 v4.2.1
sigs.k8s.io/yaml => sigs.k8s.io/yaml v1.2.0
vbom.ml/util => vbom.ml/util v0.0.0-20180919145318-efcd4e0f9787
)
Loading

0 comments on commit 6b3cbdd

Please sign in to comment.