Skip to content

Commit

Permalink
Merge pull request kubernetes#140 from krunalhinguu/v1.30-june-2024-p…
Browse files Browse the repository at this point in the history
…atches

[release v1.30] k8s v1.30.2
  • Loading branch information
kinarashah authored Jun 20, 2024
2 parents ccee972 + b560a19 commit a0fa657
Show file tree
Hide file tree
Showing 82 changed files with 2,298 additions and 641 deletions.
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.22.2
1.22.4
200 changes: 155 additions & 45 deletions CHANGELOG/CHANGELOG-1.30.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/build-image/cross/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.30.0-go1.22.2-bullseye.0
v1.30.0-go1.22.4-bullseye.0
6 changes: 3 additions & 3 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ readonly KUBE_RSYNC_PORT="${KUBE_RSYNC_PORT:-}"
readonly KUBE_CONTAINER_RSYNC_PORT=8730

# These are the default versions (image tags) for their respective base images.
readonly __default_distroless_iptables_version=v0.5.3
readonly __default_go_runner_version=v2.3.1-go1.22.2-bookworm.0
readonly __default_setcap_version=bookworm-v1.0.2
readonly __default_distroless_iptables_version=v0.5.5
readonly __default_go_runner_version=v2.3.1-go1.22.4-bookworm.0
readonly __default_setcap_version=bookworm-v1.0.3

# These are the base images for the Docker-wrapped binaries.
readonly KUBE_GORUNNER_IMAGE="${KUBE_GORUNNER_IMAGE:-$KUBE_BASE_IMAGE_REGISTRY/go-runner:$__default_go_runner_version}"
Expand Down
12 changes: 6 additions & 6 deletions build/dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ dependencies:

# Golang
- name: "golang: upstream version"
version: 1.22.2
version: 1.22.4
refPaths:
- path: .go-version
- path: build/build-image/cross/VERSION
Expand All @@ -138,13 +138,13 @@ dependencies:
match: minimum_go_version=go([0-9]+\.[0-9]+)

- name: "registry.k8s.io/kube-cross: dependents"
version: v1.30.0-go1.22.2-bullseye.0
version: v1.30.0-go1.22.4-bullseye.0
refPaths:
- path: build/build-image/cross/VERSION

# Base images
- name: "registry.k8s.io/debian-base: dependents"
version: bookworm-v1.0.2
version: bookworm-v1.0.3
refPaths:
- path: cluster/images/etcd/Makefile
match: BASEIMAGE\?\=registry\.k8s\.io\/build-image\/debian-base:[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-]+)*))?)
Expand Down Expand Up @@ -176,15 +176,15 @@ dependencies:
match: registry\.k8s\.io\/build-image\/debian-base:[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: "registry.k8s.io/distroless-iptables: dependents"
version: v0.5.3
version: v0.5.5
refPaths:
- path: build/common.sh
match: __default_distroless_iptables_version=
- path: test/utils/image/manifest.go
match: configs\[DistrolessIptables\] = Config{list\.BuildImageRegistry, "distroless-iptables", "v([0-9]+)\.([0-9]+)\.([0-9]+)"}

- name: "registry.k8s.io/go-runner: dependents"
version: v2.3.1-go1.22.2-bookworm.0
version: v2.3.1-go1.22.4-bookworm.0
refPaths:
- path: build/common.sh
match: __default_go_runner_version=
Expand Down Expand Up @@ -252,7 +252,7 @@ dependencies:
match: configs\[Pause\] = Config{list\.GcRegistry, "pause", "\d+\.\d+(.\d+)?"}

- name: "registry.k8s.io/build-image/setcap: dependents"
version: bookworm-v1.0.2
version: bookworm-v1.0.3
refPaths:
- path: build/common.sh
match: __default_setcap_version=
Expand Down
2 changes: 1 addition & 1 deletion cluster/gce/gci/configure-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3173,7 +3173,7 @@ spec:
- name: vol
containers:
- name: pv-recycler
image: registry.k8s.io/build-image/debian-base:bookworm-v1.0.2
image: registry.k8s.io/build-image/debian-base:bookworm-v1.0.3
command:
- /bin/sh
args:
Expand Down
2 changes: 1 addition & 1 deletion cluster/gce/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ function construct-linux-kubelet-flags {
# Keep in sync with the mkdir command in configure-helper.sh (until the TODO is resolved)
flags+=" --cert-dir=/var/lib/kubelet/pki/"

# If ENABLE_AUTH_PROVIDER_GCP is set to true, kubelet is enabled to use out-of-tree auth
# If ENABLE_AUTH_PROVIDER_GCP is set to true, kubelet is enabled to use out-of-tree auth
# credential provider instead of in-tree auth credential provider.
# https://kubernetes.io/docs/tasks/kubelet-credential-provider/kubelet-credential-provider
if [[ "${ENABLE_AUTH_PROVIDER_GCP:-true}" == "true" ]]; then
Expand Down
10 changes: 5 additions & 5 deletions cluster/images/etcd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ DOCKERFILE.windows = Dockerfile.windows
DOCKERFILE := ${DOCKERFILE.${OS}}

ifeq ($(ARCH),amd64)
BASEIMAGE?=registry.k8s.io/build-image/debian-base:bookworm-v1.0.2
BASEIMAGE?=registry.k8s.io/build-image/debian-base:bookworm-v1.0.3
endif
ifeq ($(ARCH),arm)
BASEIMAGE?=registry.k8s.io/build-image/debian-base-arm:bookworm-v1.0.2
BASEIMAGE?=registry.k8s.io/build-image/debian-base-arm:bookworm-v1.0.3
endif
ifeq ($(ARCH),arm64)
BASEIMAGE?=registry.k8s.io/build-image/debian-base-arm64:bookworm-v1.0.2
BASEIMAGE?=registry.k8s.io/build-image/debian-base-arm64:bookworm-v1.0.3
endif
ifeq ($(ARCH),ppc64le)
BASEIMAGE?=registry.k8s.io/build-image/debian-base-ppc64le:bookworm-v1.0.2
BASEIMAGE?=registry.k8s.io/build-image/debian-base-ppc64le:bookworm-v1.0.3
endif
ifeq ($(ARCH),s390x)
BASEIMAGE?=registry.k8s.io/build-image/debian-base-s390x:bookworm-v1.0.2
BASEIMAGE?=registry.k8s.io/build-image/debian-base-s390x:bookworm-v1.0.3
endif

BASE.windows = mcr.microsoft.com/windows/nanoserver
Expand Down
11 changes: 9 additions & 2 deletions cmd/kubeadm/app/cmd/phases/init/waitcontrolplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ import (
"github.com/pkg/errors"

clientset "k8s.io/client-go/kubernetes"
kubeletconfig "k8s.io/kubelet/config/v1beta1"

"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
"k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs"
"k8s.io/kubernetes/cmd/kubeadm/app/features"
"k8s.io/kubernetes/cmd/kubeadm/app/util/apiclient"
dryrunutil "k8s.io/kubernetes/cmd/kubeadm/app/util/dryrun"
Expand Down Expand Up @@ -107,11 +109,16 @@ func runWaitControlPlanePhase(c workflow.RunData) error {
}

kubeletFailTempl.Execute(data.OutputWriter(), context)
return errors.New("couldn't initialize a Kubernetes cluster")
return errors.New("could not initialize a Kubernetes cluster")
}

waiter.SetTimeout(data.Cfg().Timeouts.KubeletHealthCheck.Duration)
if err := waiter.WaitForKubelet(); err != nil {
kubeletConfig := data.Cfg().ClusterConfiguration.ComponentConfigs[componentconfigs.KubeletGroup].Get()
kubeletConfigTyped, ok := kubeletConfig.(*kubeletconfig.KubeletConfiguration)
if !ok {
return errors.New("could not convert the KubeletConfiguration to a typed object")
}
if err := waiter.WaitForKubelet(kubeletConfigTyped.HealthzBindAddress, *kubeletConfigTyped.HealthzPort); err != nil {
return handleError(err)
}

Expand Down
9 changes: 8 additions & 1 deletion cmd/kubeadm/app/cmd/phases/join/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ import (
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
certutil "k8s.io/client-go/util/cert"
"k8s.io/klog/v2"
kubeletconfig "k8s.io/kubelet/config/v1beta1"

kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
"k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs"
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
kubeletphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubelet"
patchnodephase "k8s.io/kubernetes/cmd/kubeadm/app/phases/patchnode"
Expand Down Expand Up @@ -208,7 +210,12 @@ func runKubeletStartJoinPhase(c workflow.RunData) (returnErr error) {
// times out, display a somewhat user-friendly message.
waiter := apiclient.NewKubeWaiter(nil, 0, os.Stdout)
waiter.SetTimeout(cfg.Timeouts.KubeletHealthCheck.Duration)
if err := waiter.WaitForKubelet(); err != nil {
kubeletConfig := initCfg.ClusterConfiguration.ComponentConfigs[componentconfigs.KubeletGroup].Get()
kubeletConfigTyped, ok := kubeletConfig.(*kubeletconfig.KubeletConfiguration)
if !ok {
return errors.New("could not convert the KubeletConfiguration to a typed object")
}
if err := waiter.WaitForKubelet(kubeletConfigTyped.HealthzBindAddress, *kubeletConfigTyped.HealthzPort); err != nil {
fmt.Printf(kubeadmJoinFailMsg, err)
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubeadm/app/componentconfigs/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (kc *kubeletConfig) Default(cfg *kubeadmapi.ClusterConfiguration, _ *kubead
warnDefaultComponentConfigValue(kind, "authentication.webhook.enabled", kubeletAuthenticationWebhookEnabled, *kc.config.Authentication.Webhook.Enabled)
}

// Serve a /healthz webserver on localhost:10248 that kubeadm can talk to
// Serve a /healthz webserver on 127.0.0.1:10248 that kubeadm can talk to
if kc.config.HealthzBindAddress == "" {
kc.config.HealthzBindAddress = kubeletHealthzBindAddress
} else if kc.config.HealthzBindAddress != kubeletHealthzBindAddress {
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubeadm/app/phases/upgrade/staticpods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (w *fakeWaiter) WaitForStaticPodHashChange(_, _, _ string) error {
}

// WaitForHKubelet returns a dummy nil just to implement the interface
func (w *fakeWaiter) WaitForKubelet() error {
func (w *fakeWaiter) WaitForKubelet(_ string, _ int32) error {
return nil
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/kubeadm/app/util/apiclient/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type Waiter interface {
// WaitForStaticPodControlPlaneHashes fetches sha256 hashes for the control plane static pods
WaitForStaticPodControlPlaneHashes(nodeName string) (map[string]string, error)
// WaitForKubelet blocks until the kubelet /healthz endpoint returns 'ok'
WaitForKubelet() error
WaitForKubelet(healthzAddress string, healthzPort int32) error
// SetTimeout adjusts the timeout to the specified duration
SetTimeout(timeout time.Duration)
}
Expand Down Expand Up @@ -243,11 +243,11 @@ func (w *KubeWaiter) WaitForPodToDisappear(podName string) error {
}

// WaitForKubelet blocks until the kubelet /healthz endpoint returns 'ok'.
func (w *KubeWaiter) WaitForKubelet() error {
func (w *KubeWaiter) WaitForKubelet(healthzAddress string, healthzPort int32) error {
var (
lastError error
start = time.Now()
healthzEndpoint = fmt.Sprintf("http://localhost:%d/healthz", constants.KubeletHealthzPort)
healthzEndpoint = fmt.Sprintf("http://%s:%d/healthz", healthzAddress, healthzPort)
)

fmt.Printf("[kubelet-check] Waiting for a healthy kubelet. This can take up to %v\n", w.timeout)
Expand Down
4 changes: 2 additions & 2 deletions cmd/kubeadm/app/util/dryrun/dryrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ func (w *Waiter) WaitForPodToDisappear(podName string) error {
}

// WaitForKubelet blocks until the kubelet /healthz endpoint returns 'ok'
func (w *Waiter) WaitForKubelet() error {
fmt.Println("[dryrun] Would make sure the kubelet's /healthz endpoint is healthy")
func (w *Waiter) WaitForKubelet(healthzAddress string, healthzPort int32) error {
fmt.Printf("[dryrun] Would make sure the kubelet returns 'ok' at http://%s:%d/healthz\n", healthzAddress, healthzPort)
return nil
}

Expand Down
43 changes: 34 additions & 9 deletions pkg/apis/admissionregistration/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import (
"k8s.io/apiserver/pkg/admission/plugin/webhook/matchconditions"
"k8s.io/apiserver/pkg/cel"
"k8s.io/apiserver/pkg/cel/environment"
"k8s.io/apiserver/pkg/features"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/apiserver/pkg/util/webhook"
"k8s.io/client-go/util/jsonpath"

Expand Down Expand Up @@ -221,6 +223,7 @@ func ValidateValidatingWebhookConfiguration(e *admissionregistration.ValidatingW
requireRecognizedAdmissionReviewVersion: true,
requireUniqueWebhookNames: true,
allowInvalidLabelValueInSelector: false,
strictCostEnforcement: utilfeature.DefaultFeatureGate.Enabled(features.StrictCostEnforcementForWebhooks),
})
}

Expand Down Expand Up @@ -250,6 +253,7 @@ func ValidateMutatingWebhookConfiguration(e *admissionregistration.MutatingWebho
requireRecognizedAdmissionReviewVersion: true,
requireUniqueWebhookNames: true,
allowInvalidLabelValueInSelector: false,
strictCostEnforcement: utilfeature.DefaultFeatureGate.Enabled(features.StrictCostEnforcementForWebhooks),
})
}

Expand All @@ -261,6 +265,7 @@ type validationOptions struct {
requireUniqueWebhookNames bool
allowInvalidLabelValueInSelector bool
preexistingExpressions preexistingExpressions
strictCostEnforcement bool
}

type preexistingExpressions struct {
Expand Down Expand Up @@ -687,6 +692,7 @@ func ValidateValidatingWebhookConfigurationUpdate(newC, oldC *admissionregistrat
requireUniqueWebhookNames: validatingHasUniqueWebhookNames(oldC.Webhooks),
allowInvalidLabelValueInSelector: validatingWebhookHasInvalidLabelValueInSelector(oldC.Webhooks),
preexistingExpressions: findValidatingPreexistingExpressions(oldC),
strictCostEnforcement: utilfeature.DefaultFeatureGate.Enabled(features.StrictCostEnforcementForWebhooks),
})
}

Expand All @@ -700,6 +706,7 @@ func ValidateMutatingWebhookConfigurationUpdate(newC, oldC *admissionregistratio
requireUniqueWebhookNames: mutatingHasUniqueWebhookNames(oldC.Webhooks),
allowInvalidLabelValueInSelector: mutatingWebhookHasInvalidLabelValueInSelector(oldC.Webhooks),
preexistingExpressions: findMutatingPreexistingExpressions(oldC),
strictCostEnforcement: utilfeature.DefaultFeatureGate.Enabled(features.StrictCostEnforcementForWebhooks),
})
}

Expand All @@ -713,7 +720,7 @@ const (

// ValidateValidatingAdmissionPolicy validates a ValidatingAdmissionPolicy before creation.
func ValidateValidatingAdmissionPolicy(p *admissionregistration.ValidatingAdmissionPolicy) field.ErrorList {
return validateValidatingAdmissionPolicy(p, validationOptions{ignoreMatchConditions: false})
return validateValidatingAdmissionPolicy(p, validationOptions{ignoreMatchConditions: false, strictCostEnforcement: utilfeature.DefaultFeatureGate.Enabled(features.StrictCostEnforcementForVAP)})
}

func validateValidatingAdmissionPolicy(p *admissionregistration.ValidatingAdmissionPolicy, opts validationOptions) field.ErrorList {
Expand All @@ -728,7 +735,7 @@ func validateValidatingAdmissionPolicySpec(meta metav1.ObjectMeta, spec *admissi
getCompiler := func() plugincel.Compiler {
if compiler == nil {
needsComposition := len(spec.Variables) > 0
compiler = createCompiler(needsComposition)
compiler = createCompiler(needsComposition, opts.strictCostEnforcement)
}
return compiler
}
Expand Down Expand Up @@ -973,6 +980,7 @@ func validateVariable(compiler plugincel.Compiler, v *admissionregistration.Vari
result := compiler.CompileAndStoreVariable(variable, plugincel.OptionalVariableDeclarations{
HasParams: paramKind != nil,
HasAuthorizer: true,
StrictCost: opts.strictCostEnforcement,
}, envType)
if result.Error != nil {
allErrors = append(allErrors, convertCELErrorToValidationError(fldPath.Child("expression"), variable, result.Error))
Expand Down Expand Up @@ -1047,6 +1055,7 @@ func validateValidationExpression(compiler plugincel.Compiler, expression string
}, plugincel.OptionalVariableDeclarations{
HasParams: hasParams,
HasAuthorizer: true,
StrictCost: opts.strictCostEnforcement,
}, envType, fldPath)
}

Expand All @@ -1055,11 +1064,18 @@ func validateMatchConditionsExpression(expression string, opts validationOptions
if opts.preexistingExpressions.matchConditionExpressions.Has(expression) {
envType = environment.StoredExpressions
}
return validateCELCondition(statelessCELCompiler, &matchconditions.MatchCondition{
var compiler plugincel.Compiler
if opts.strictCostEnforcement {
compiler = strictStatelessCELCompiler
} else {
compiler = nonStrictStatelessCELCompiler
}
return validateCELCondition(compiler, &matchconditions.MatchCondition{
Expression: expression,
}, plugincel.OptionalVariableDeclarations{
HasParams: opts.allowParamsInMatchConditions,
HasAuthorizer: true,
StrictCost: opts.strictCostEnforcement,
}, envType, fldPath)
}

Expand All @@ -1073,6 +1089,7 @@ func validateMessageExpression(compiler plugincel.Compiler, expression string, o
}, plugincel.OptionalVariableDeclarations{
HasParams: opts.allowParamsInMatchConditions,
HasAuthorizer: false,
StrictCost: opts.strictCostEnforcement,
}, envType, fldPath)
}

Expand All @@ -1097,7 +1114,7 @@ func validateAuditAnnotation(compiler plugincel.Compiler, meta metav1.ObjectMeta
}
result := compiler.CompileCELExpression(&validatingadmissionpolicy.AuditAnnotationCondition{
ValueExpression: trimmedValueExpression,
}, plugincel.OptionalVariableDeclarations{HasParams: paramKind != nil, HasAuthorizer: true}, envType)
}, plugincel.OptionalVariableDeclarations{HasParams: paramKind != nil, HasAuthorizer: true, StrictCost: opts.strictCostEnforcement}, envType)
if result.Error != nil {
switch result.Error.Type {
case cel.ErrorTypeRequired:
Expand Down Expand Up @@ -1191,6 +1208,7 @@ func ValidateValidatingAdmissionPolicyUpdate(newC, oldC *admissionregistration.V
return validateValidatingAdmissionPolicy(newC, validationOptions{
ignoreMatchConditions: ignoreValidatingAdmissionPolicyMatchConditions(newC, oldC),
preexistingExpressions: findValidatingPolicyPreexistingExpressions(oldC),
strictCostEnforcement: utilfeature.DefaultFeatureGate.Enabled(features.StrictCostEnforcementForVAP),
})
}

Expand Down Expand Up @@ -1250,17 +1268,24 @@ func validateFieldRef(fieldRef string, fldPath *field.Path) field.ErrorList {

// statelessCELCompiler does not support variable composition (and thus is stateless). It should be used when
// variable composition is not allowed, for example, when validating MatchConditions.
var statelessCELCompiler = plugincel.NewCompiler(environment.MustBaseEnvSet(environment.DefaultCompatibilityVersion()))
// strictStatelessCELCompiler is a cel Compiler that enforces strict cost enforcement.
// nonStrictStatelessCELCompiler is a cel Compiler that does not enforce strict cost enforcement.
var strictStatelessCELCompiler = plugincel.NewCompiler(environment.MustBaseEnvSet(environment.DefaultCompatibilityVersion(), true))
var nonStrictStatelessCELCompiler = plugincel.NewCompiler(environment.MustBaseEnvSet(environment.DefaultCompatibilityVersion(), false))

func createCompiler(allowComposition bool) plugincel.Compiler {
func createCompiler(allowComposition, strictCost bool) plugincel.Compiler {
if !allowComposition {
return statelessCELCompiler
if strictCost {
return strictStatelessCELCompiler
} else {
return nonStrictStatelessCELCompiler
}
}
compiler, err := plugincel.NewCompositedCompiler(environment.MustBaseEnvSet(environment.DefaultCompatibilityVersion()))
compiler, err := plugincel.NewCompositedCompiler(environment.MustBaseEnvSet(environment.DefaultCompatibilityVersion(), strictCost))
if err != nil {
// should never happen, but cannot panic either.
utilruntime.HandleError(err)
return plugincel.NewCompiler(environment.MustBaseEnvSet(environment.DefaultCompatibilityVersion()))
return plugincel.NewCompiler(environment.MustBaseEnvSet(environment.DefaultCompatibilityVersion(), strictCost))
}
return compiler
}
Expand Down
Loading

0 comments on commit a0fa657

Please sign in to comment.