Skip to content

Commit

Permalink
Fixes for 1.32
Browse files Browse the repository at this point in the history
Signed-off-by: galal-hussein <[email protected]>
  • Loading branch information
galal-hussein committed Dec 18, 2024
1 parent 634eaad commit 2e9888a
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 35 deletions.
3 changes: 3 additions & 0 deletions manifests/rolebindings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ rules:
- nodes
verbs:
- get
- list
- watch
- update
- apiGroups:
- ""
resources:
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/flannel/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func Run(ctx context.Context, nodeConfig *config.Node, nodes typedcorev1.NodeInt
return errors.Wrap(err, "failed to check netMode for flannel")
}
go func() {
err := flannel(ctx, nodeConfig.FlannelIface, nodeConfig.FlannelConfFile, nodeConfig.AgentConfig.KubeConfigKubelet, nodeConfig.FlannelIPv6Masq, netMode)
err := flannel(ctx, nodeConfig.FlannelIface, nodeConfig.FlannelConfFile, nodeConfig.AgentConfig.KubeConfigK3sController, nodeConfig.FlannelIPv6Masq, netMode)
if err != nil && !errors.Is(err, context.Canceled) {
logrus.Errorf("flannel exited: %v", err)
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func run(ctx context.Context, cfg cmds.Agent, proxy proxy.Proxy) error {
return errors.Wrap(err, "failed to wait for apiserver ready")
}

coreClient, err := util.GetClientSet(nodeConfig.AgentConfig.KubeConfigKubelet)
coreClient, err := util.GetClientSet(nodeConfig.AgentConfig.KubeConfigK3sController)
if err != nil {
return err
}
Expand Down
18 changes: 5 additions & 13 deletions pkg/cloudprovider/servicelb.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package cloudprovider

import (
"context"
"encoding/json"
"fmt"
"sort"
"strconv"
"strings"
"time"
"encoding/json"

"sigs.k8s.io/yaml"

"github.com/k3s-io/k3s/pkg/util"
Expand All @@ -27,11 +28,9 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/client-go/util/retry"
"k8s.io/cloud-provider/names"
servicehelper "k8s.io/cloud-provider/service/helpers"
"k8s.io/kubernetes/pkg/features"
utilsnet "k8s.io/utils/net"
utilsptr "k8s.io/utils/ptr"
)
Expand Down Expand Up @@ -563,7 +562,7 @@ func (k *k3s) newDaemonSet(svc *core.Service) (*apps.DaemonSet, error) {
Name: "DEST_IPS",
ValueFrom: &core.EnvVarSource{
FieldRef: &core.ObjectFieldSelector{
FieldPath: getHostIPsFieldPath(),
FieldPath: "status.hostIPs",
},
},
},
Expand Down Expand Up @@ -710,8 +709,8 @@ func (k *k3s) getPriorityClassName(svc *core.Service) string {
return k.LBDefaultPriorityClassName
}

// getTolerations retrieves the tolerations from a service's annotations.
// It parses the tolerations from a JSON or YAML string stored in the annotations.
// getTolerations retrieves the tolerations from a service's annotations.
// It parses the tolerations from a JSON or YAML string stored in the annotations.
func (k *k3s) getTolerations(svc *core.Service) ([]core.Toleration, error) {
tolerationsStr, ok := svc.Annotations[tolerationsAnnotation]
if !ok {
Expand Down Expand Up @@ -778,10 +777,3 @@ func ingressToString(ingresses []core.LoadBalancerIngress) []string {
}
return parts
}

func getHostIPsFieldPath() string {
if utilfeature.DefaultFeatureGate.Enabled(features.PodHostIPs) {
return "status.hostIPs"
}
return "status.hostIP"
}
2 changes: 0 additions & 2 deletions pkg/daemons/agent/agent_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ func kubeletArgs(cfg *config.Agent) map[string]string {
argsMap["node-ip"] = cfg.NodeIP
}
} else {
// Cluster is using the embedded CCM, we know that the feature-gate will be enabled there as well.
argsMap["feature-gates"] = util.AddFeatureGate(argsMap["feature-gates"], "CloudDualStackNodeIPs=true")
if nodeIPs := util.JoinIPs(cfg.NodeIPs); nodeIPs != "" {
argsMap["node-ip"] = util.JoinIPs(cfg.NodeIPs)
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/daemons/agent/agent_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ func kubeletArgs(cfg *config.Agent) map[string]string {
argsMap["node-ip"] = cfg.NodeIP
}
} else {
// Cluster is using the embedded CCM, we know that the feature-gate will be enabled there as well.
argsMap["feature-gates"] = util.AddFeatureGate(argsMap["feature-gates"], "CloudDualStackNodeIPs=true")
if nodeIPs := util.JoinIPs(cfg.NodeIPs); nodeIPs != "" {
argsMap["node-ip"] = util.JoinIPs(cfg.NodeIPs)
}
Expand Down
22 changes: 11 additions & 11 deletions pkg/daemons/control/deps/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apiserver/pkg/apis/apiserver"
apiserverconfigv1 "k8s.io/apiserver/pkg/apis/apiserver/v1"
apiserverv1beta1 "k8s.io/apiserver/pkg/apis/apiserver/v1beta1"
"k8s.io/apiserver/pkg/authentication/user"
"k8s.io/client-go/util/keyutil"
)
Expand Down Expand Up @@ -785,19 +785,19 @@ func genEncryptionConfigAndState(controlConfig *config.Control) error {
}

func genEgressSelectorConfig(controlConfig *config.Control) error {
var clusterConn apiserver.Connection
var clusterConn apiserverv1beta1.Connection

if controlConfig.EgressSelectorMode == config.EgressSelectorModeDisabled {
clusterConn = apiserver.Connection{
ProxyProtocol: apiserver.ProtocolDirect,
clusterConn = apiserverv1beta1.Connection{
ProxyProtocol: apiserverv1beta1.ProtocolDirect,
}
} else {
clusterConn = apiserver.Connection{
ProxyProtocol: apiserver.ProtocolHTTPConnect,
Transport: &apiserver.Transport{
TCP: &apiserver.TCPTransport{
clusterConn = apiserverv1beta1.Connection{
ProxyProtocol: apiserverv1beta1.ProtocolHTTPConnect,
Transport: &apiserverv1beta1.Transport{
TCP: &apiserverv1beta1.TCPTransport{
URL: fmt.Sprintf("https://%s:%d", controlConfig.BindAddressOrLoopback(false, true), controlConfig.SupervisorPort),
TLSConfig: &apiserver.TLSConfig{
TLSConfig: &apiserverv1beta1.TLSConfig{
CABundle: controlConfig.Runtime.ServerCA,
ClientKey: controlConfig.Runtime.ClientKubeAPIKey,
ClientCert: controlConfig.Runtime.ClientKubeAPICert,
Expand All @@ -807,12 +807,12 @@ func genEgressSelectorConfig(controlConfig *config.Control) error {
}
}

egressConfig := apiserver.EgressSelectorConfiguration{
egressConfig := apiserverv1beta1.EgressSelectorConfiguration{
TypeMeta: metav1.TypeMeta{
Kind: "EgressSelectorConfiguration",
APIVersion: "apiserver.k8s.io/v1beta1",
},
EgressSelections: []apiserver.EgressSelection{
EgressSelections: []apiserverv1beta1.EgressSelection{
{
Name: "cluster",
Connection: clusterConn,
Expand Down
1 change: 0 additions & 1 deletion pkg/daemons/control/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ func cloudControllerManager(ctx context.Context, cfg *config.Control) error {
"authentication-kubeconfig": runtime.KubeConfigCloudController,
"node-status-update-frequency": "1m0s",
"bind-address": cfg.Loopback(false),
"feature-gates": "CloudDualStackNodeIPs=true",
}
if cfg.NoLeaderElect {
argsMap["leader-elect"] = "false"
Expand Down
4 changes: 2 additions & 2 deletions pkg/daemons/executor/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (*Embedded) APIServer(ctx context.Context, etcdReady <-chan struct{}, args
}

func (e *Embedded) Scheduler(ctx context.Context, apiReady <-chan struct{}, args []string) error {
command := sapp.NewSchedulerCommand()
command := sapp.NewSchedulerCommand(ctx.Done())
command.SetArgs(args)

go func() {
Expand All @@ -165,7 +165,7 @@ func (e *Embedded) Scheduler(ctx context.Context, apiReady <-chan struct{}, args
// node (usually, the local node) before starting the scheduler to ensure that it
// finds a node that is ready to run pods during its initial scheduling loop.
if !e.nodeConfig.AgentConfig.DisableCCM {
if err := waitForUntaintedNode(ctx, e.nodeConfig.AgentConfig.KubeConfigKubelet); err != nil {
if err := waitForUntaintedNode(ctx, e.nodeConfig.AgentConfig.KubeConfigK3sController); err != nil {
logrus.Fatalf("failed to wait for untained node: %v", err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/zz_generated_bindata.go

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

2 changes: 1 addition & 1 deletion tests/integration/kubeflags/kubeflags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ var _ = Describe("create a new cluster with kube-* flags", Ordered, func() {
"--authorization-kubeconfig=/var/lib/rancher/k3s/server/cred/cloud-controller.kubeconfig --bind-address=127.0.0.1 "+
"--cloud-config=/var/lib/rancher/k3s/server/etc/cloud-config.yaml --cloud-provider=k3s --cluster-cidr=10.42.0.0/16 "+
"--configure-cloud-routes=false --controllers=*,-route,-cloud-node,-cloud-node-lifecycle "+
"--feature-gates=CloudDualStackNodeIPs=true --kubeconfig=/var/lib/rancher/k3s/server/cred/cloud-controller.kubeconfig "+
"--kubeconfig=/var/lib/rancher/k3s/server/cred/cloud-controller.kubeconfig "+
"--leader-elect-resource-name=k3s-cloud-controller-manager --node-status-update-frequency=1m0s --profiling=false --secure-port=0")
if err != nil {
return err
Expand Down

0 comments on commit 2e9888a

Please sign in to comment.