Skip to content

Commit

Permalink
Merge pull request #156 from chiukapoor/rancher-v1.30.4
Browse files Browse the repository at this point in the history
[release v1.30] k8s v1.30.4
  • Loading branch information
kinarashah authored Aug 22, 2024
2 parents a31af7e + f24d721 commit 713ffce
Show file tree
Hide file tree
Showing 4,626 changed files with 1,203,755 additions and 1,473 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
251 changes: 198 additions & 53 deletions CHANGELOG/CHANGELOG-1.30.md

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions api/openapi-spec/swagger.json

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

Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,9 @@
"description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds"
}
},
"required": [
"items"
],
"type": "object",
"x-kubernetes-group-version-kind": [
{
Expand Down Expand Up @@ -699,6 +702,9 @@
"description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds"
}
},
"required": [
"items"
],
"type": "object",
"x-kubernetes-group-version-kind": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@
"description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds"
}
},
"required": [
"items"
],
"type": "object",
"x-kubernetes-group-version-kind": [
{
Expand Down Expand Up @@ -427,6 +430,9 @@
"description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds"
}
},
"required": [
"items"
],
"type": "object",
"x-kubernetes-group-version-kind": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@
"description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds"
}
},
"required": [
"items"
],
"type": "object",
"x-kubernetes-group-version-kind": [
{
Expand Down Expand Up @@ -428,6 +431,9 @@
"description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds"
}
},
"required": [
"items"
],
"type": "object",
"x-kubernetes-group-version-kind": [
{
Expand Down
3 changes: 2 additions & 1 deletion cmd/kubeadm/app/apis/kubeadm/fuzzer/fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

bootstraptokenv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/bootstraptoken/v1"
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
)

// Funcs returns the fuzzer functions for the kubeadm apis.
Expand Down Expand Up @@ -132,7 +133,7 @@ func fuzzJoinConfiguration(obj *kubeadm.JoinConfiguration, c fuzz.Continue) {
obj.Discovery = kubeadm.Discovery{
BootstrapToken: &kubeadm.BootstrapTokenDiscovery{Token: "baz"},
TLSBootstrapToken: "qux",
Timeout: &metav1.Duration{},
Timeout: &metav1.Duration{Duration: constants.DiscoveryTimeout},
}
obj.SkipPhases = nil
obj.NodeRegistration.ImagePullPolicy = corev1.PullIfNotPresent
Expand Down
4 changes: 4 additions & 0 deletions cmd/kubeadm/app/apis/kubeadm/v1beta3/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ func Convert_v1beta3_InitConfiguration_To_kubeadm_InitConfiguration(in *InitConf

// Convert_kubeadm_JoinConfiguration_To_v1beta3_JoinConfiguration converts a private JoinConfiguration to public JoinConfiguration.
func Convert_kubeadm_JoinConfiguration_To_v1beta3_JoinConfiguration(in *kubeadm.JoinConfiguration, out *JoinConfiguration, s conversion.Scope) error {
// Migrate the discovery timeout.
out.Discovery.Timeout = in.Timeouts.Discovery.DeepCopy()
return autoConvert_kubeadm_JoinConfiguration_To_v1beta3_JoinConfiguration(in, out, s)
}

// Convert_v1beta3_JoinConfiguration_To_kubeadm_JoinConfiguration converts a public JoinConfiguration to a private JoinConfiguration.
func Convert_v1beta3_JoinConfiguration_To_kubeadm_JoinConfiguration(in *JoinConfiguration, out *kubeadm.JoinConfiguration, s conversion.Scope) error {
kubeadm.SetDefaultTimeouts(&out.Timeouts)
// Migrate the discovery timeout.
out.Timeouts.Discovery = in.Discovery.Timeout.DeepCopy()
return autoConvert_v1beta3_JoinConfiguration_To_kubeadm_JoinConfiguration(in, out, s)
}

Expand Down
1 change: 1 addition & 0 deletions cmd/kubeadm/app/apis/kubeadm/v1beta4/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func Convert_v1beta4_ClusterConfiguration_To_kubeadm_ClusterConfiguration(in *Cl
// Convert_v1beta4_JoinConfiguration_To_kubeadm_JoinConfiguration converts a public JoinConfiguration to a private JoinConfiguration.
func Convert_v1beta4_JoinConfiguration_To_kubeadm_JoinConfiguration(in *JoinConfiguration, out *kubeadm.JoinConfiguration, s conversion.Scope) error {
err := autoConvert_v1beta4_JoinConfiguration_To_kubeadm_JoinConfiguration(in, out, s)
out.Discovery.Timeout = in.Timeouts.Discovery.DeepCopy()
return err
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/kubeadm/app/apis/kubeadm/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ func isAllowedFlag(flagName string) bool {
kubeadmcmdoptions.NodeName,
kubeadmcmdoptions.KubeconfigDir,
kubeadmcmdoptions.UploadCerts,
"print-join-command", "rootfs", "v", "log-file")
"print-join-command", "rootfs", "v", "log-file", "yes")
if allowedFlags.Has(flagName) {
return true
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/kubeadm/app/apis/kubeadm/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,11 @@ func TestValidateMixedArguments(t *testing.T) {
// Expected to succeed, --config is mixed with skip-* flags only or no other flags
{[]string{"--config=hello", "--skip-token-print=true"}, true},
{[]string{"--config=hello", "--ignore-preflight-errors=baz", "--skip-token-print"}, true},
{[]string{"--config=hello", "--yes=true"}, true},
// Expected to fail, --config is mixed with the --foo flag
{[]string{"--config=hello", "--ignore-preflight-errors=baz", "--foo=bar"}, false},
{[]string{"--config=hello", "--foo=bar"}, false},
{[]string{"--config=hello", "--yes=true", "--foo=bar"}, false},
// Expected to fail, --config is mixed with the upgrade related flag
{[]string{"--config=hello", "--allow-experimental-upgrades"}, false},
}
Expand All @@ -765,6 +767,7 @@ func TestValidateMixedArguments(t *testing.T) {
f.StringSliceVar(&ignorePreflightErrors, "ignore-preflight-errors", ignorePreflightErrors, "flag not bound to config object")
f.Bool("allow-experimental-upgrades", true, "upgrade flags for plan and apply command")
f.Bool("skip-token-print", false, "flag not bound to config object")
f.Bool("yes", false, "flag not bound to config object")
f.StringVar(&cfgPath, "config", cfgPath, "Path to kubeadm config file")
if err := f.Parse(rt.args); err != nil {
t.Fatal(err)
Expand Down
8 changes: 8 additions & 0 deletions cmd/kubeadm/app/cmd/phases/join/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,14 @@ func runKubeletStartJoinPhase(c workflow.RunData) (returnErr error) {
fmt.Println("[kubelet-start] Starting the kubelet")
kubeletphase.TryStartKubelet()

// Apply patches to the in-memory kubelet configuration so that any configuration changes like kubelet healthz
// address and port options are respected during the wait below. WriteConfigToDisk already applied patches to
// the kubelet.yaml written to disk. This should be done after WriteConfigToDisk because both use the same config
// in memory and we don't want patches to be applied two times to the config that is written to disk.
if err := kubeletphase.ApplyPatchesToConfig(&initCfg.ClusterConfiguration, data.PatchesDir()); err != nil {
return errors.Wrap(err, "could not apply patches to the in-memory kubelet configuration")
}

// Now the kubelet will perform the TLS Bootstrap, transforming /etc/kubernetes/bootstrap-kubelet.conf to /etc/kubernetes/kubelet.conf
// Wait for the kubelet to create the /etc/kubernetes/kubelet.conf kubeconfig file. If this process
// times out, display a somewhat user-friendly message.
Expand Down
41 changes: 40 additions & 1 deletion cmd/kubeadm/app/phases/kubelet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ import (
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
"k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs"
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
"k8s.io/kubernetes/cmd/kubeadm/app/util/apiclient"
"k8s.io/kubernetes/cmd/kubeadm/app/util/patches"
)

var applyKubeletConfigPatchesFunc = applyKubeletConfigPatches

// WriteConfigToDisk writes the kubelet config object down to a file
// Used at "kubeadm init" and "kubeadm upgrade" time
func WriteConfigToDisk(cfg *kubeadmapi.ClusterConfiguration, kubeletDir, patchesDir string, output io.Writer) error {
Expand All @@ -57,7 +60,7 @@ func WriteConfigToDisk(cfg *kubeadmapi.ClusterConfiguration, kubeletDir, patches

// Apply patches to the KubeletConfiguration
if len(patchesDir) != 0 {
kubeletBytes, err = applyKubeletConfigPatches(kubeletBytes, patchesDir, output)
kubeletBytes, err = applyKubeletConfigPatchesFunc(kubeletBytes, patchesDir, output)
if err != nil {
return errors.Wrap(err, "could not apply patches to the KubeletConfiguration")
}
Expand All @@ -66,6 +69,42 @@ func WriteConfigToDisk(cfg *kubeadmapi.ClusterConfiguration, kubeletDir, patches
return writeConfigBytesToDisk(kubeletBytes, kubeletDir)
}

// ApplyPatchesToConfig applies the patches located in patchesDir to the KubeletConfiguration stored
// in the ClusterConfiguration.ComponentConfigs map.
func ApplyPatchesToConfig(cfg *kubeadmapi.ClusterConfiguration, patchesDir string) error {
kubeletCfg, ok := cfg.ComponentConfigs[componentconfigs.KubeletGroup]
if !ok {
return errors.New("no kubelet component config found")
}

if err := kubeletCfg.Mutate(); err != nil {
return err
}

kubeletBytes, err := kubeletCfg.Marshal()
if err != nil {
return err
}

// Apply patches to the KubeletConfiguration. Output is discarded.
if len(patchesDir) != 0 {
kubeletBytes, err = applyKubeletConfigPatchesFunc(kubeletBytes, patchesDir, io.Discard)
if err != nil {
return errors.Wrap(err, "could not apply patches to the KubeletConfiguration")
}
}

gvkmap, err := kubeadmutil.SplitYAMLDocuments(kubeletBytes)
if err != nil {
return err
}
if err := kubeletCfg.Unmarshal(gvkmap); err != nil {
return err
}

return nil
}

// CreateConfigMap creates a ConfigMap with the generic kubelet configuration.
// Used at "kubeadm init" and "kubeadm upgrade" time
func CreateConfigMap(cfg *kubeadmapi.ClusterConfiguration, client clientset.Interface) error {
Expand Down
51 changes: 51 additions & 0 deletions cmd/kubeadm/app/phases/kubelet/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package kubelet

import (
"bytes"
"fmt"
"io"
"os"
"path/filepath"
Expand All @@ -28,7 +29,11 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/fake"
core "k8s.io/client-go/testing"
kubeletconfig "k8s.io/kubelet/config/v1beta1"
"k8s.io/utils/ptr"

kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
"k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs"
configutil "k8s.io/kubernetes/cmd/kubeadm/app/util/config"
)

Expand Down Expand Up @@ -103,3 +108,49 @@ func TestApplyKubeletConfigPatches(t *testing.T) {
t.Fatalf("expected output:\n%s\ngot\n%s\n", expectedOutput, output)
}
}

func TestApplyPatchesToConfig(t *testing.T) {
const (
expectedAddress = "barfoo"
expectedPort = 4321
)

kc := &kubeletconfig.KubeletConfiguration{
HealthzBindAddress: "foobar",
HealthzPort: ptr.To[int32](1234),
}

cfg := &kubeadmapi.ClusterConfiguration{}
cfg.ComponentConfigs = kubeadmapi.ComponentConfigMap{}

localAPIEndpoint := &kubeadmapi.APIEndpoint{}
nodeRegOps := &kubeadmapi.NodeRegistrationOptions{}
componentconfigs.Default(cfg, localAPIEndpoint, nodeRegOps)
cfg.ComponentConfigs[componentconfigs.KubeletGroup].Set(kc)

// Change to a fake function that does patching with string replace.
applyKubeletConfigPatchesFunc = func(b []byte, _ string, _ io.Writer) ([]byte, error) {
b = bytes.ReplaceAll(b, []byte("foobar"), []byte(expectedAddress))
b = bytes.ReplaceAll(b, []byte("1234"), []byte(fmt.Sprintf("%d", expectedPort)))
return b, nil
}
defer func() {
applyKubeletConfigPatchesFunc = applyKubeletConfigPatches
}()

if err := ApplyPatchesToConfig(cfg, "fakedir"); err != nil {
t.Fatalf("unexpected error: %v", err)
}

new := cfg.ComponentConfigs[componentconfigs.KubeletGroup].Get()
newTyped, ok := new.(*kubeletconfig.KubeletConfiguration)
if !ok {
t.Fatal("could not cast kubelet config")
}
if newTyped.HealthzBindAddress != expectedAddress {
t.Fatalf("expected address: %s, got: %s", expectedAddress, newTyped.HealthzBindAddress)
}
if *newTyped.HealthzPort != expectedPort {
t.Fatalf("expected port: %d, got: %d", expectedPort, *newTyped.HealthzPort)
}
}
7 changes: 6 additions & 1 deletion cmd/kubeadm/app/util/apiclient/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,12 @@ func (w *KubeWaiter) WaitForKubelet(healthzAddress string, healthzPort int32) er
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)
if healthzPort == 0 {
fmt.Println("[kubelet-check] Skipping the kubelet health check because the healthz port is set to 0")
return nil
}
fmt.Printf("[kubelet-check] Waiting for a healthy kubelet at %s. This can take up to %v\n",
healthzEndpoint, w.timeout)

formatError := func(cause string) error {
return errors.Errorf("The HTTP call equal to 'curl -sSL %s' returned %s\n",
Expand Down
21 changes: 11 additions & 10 deletions pkg/controller/statefulset/stateful_pod_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (spc *StatefulPodControl) ClaimsMatchRetentionPolicy(ctx context.Context, s
case err != nil:
return false, fmt.Errorf("Could not retrieve claim %s for %s when checking PVC deletion policy", claimName, pod.Name)
default:
if !claimOwnerMatchesSetAndPod(logger, claim, set, pod) {
if !isClaimOwnerUpToDate(logger, claim, set, pod) {
return false, nil
}
}
Expand All @@ -242,14 +242,16 @@ func (spc *StatefulPodControl) UpdatePodClaimForRetentionPolicy(ctx context.Cont
case err != nil:
return fmt.Errorf("Could not retrieve claim %s not found for %s when checking PVC deletion policy: %w", claimName, pod.Name, err)
default:
if !claimOwnerMatchesSetAndPod(logger, claim, set, pod) {
if hasUnexpectedController(claim, set, pod) {
// Add an event so the user knows they're in a strange configuration. The claim will be cleaned up below.
msg := fmt.Sprintf("PersistentVolumeClaim %s has a conflicting OwnerReference that acts as a manging controller, the retention policy is ignored for this claim", claimName)
spc.recorder.Event(set, v1.EventTypeWarning, "ConflictingController", msg)
}
if !isClaimOwnerUpToDate(logger, claim, set, pod) {
claim = claim.DeepCopy() // Make a copy so we don't mutate the shared cache.
needsUpdate := updateClaimOwnerRefForSetAndPod(logger, claim, set, pod)
if needsUpdate {
err := spc.objectMgr.UpdateClaim(claim)
if err != nil {
return fmt.Errorf("Could not update claim %s for delete policy ownerRefs: %w", claimName, err)
}
updateClaimOwnerRefForSetAndPod(logger, claim, set, pod)
if err := spc.objectMgr.UpdateClaim(claim); err != nil {
return fmt.Errorf("could not update claim %s for delete policy ownerRefs: %w", claimName, err)
}
}
}
Expand All @@ -275,8 +277,7 @@ func (spc *StatefulPodControl) PodClaimIsStale(set *apps.StatefulSet, pod *v1.Po
case err != nil:
return false, err
case err == nil:
// A claim is stale if it doesn't match the pod's UID, including if the pod has no UID.
if hasStaleOwnerRef(pvc, pod) {
if hasStaleOwnerRef(pvc, pod, podKind) {
return true, nil
}
}
Expand Down
Loading

0 comments on commit 713ffce

Please sign in to comment.