Browse Source

Updates for k8s v1.18 support

pull/1569/head
Darren Shepherd 5 years ago committed by Erik Wilson
parent
commit
a8d96112d9
  1. 2
      pkg/agent/containerd/containerd.go
  2. 2
      pkg/agent/flannel/setup.go
  3. 3
      pkg/agent/netpol/network_policy_controller.go
  4. 4
      pkg/agent/run.go
  5. 4
      pkg/agent/tunnel/tunnel.go
  6. 8
      pkg/servicelb/controller.go

2
pkg/agent/containerd/containerd.go

@ -80,7 +80,7 @@ func Run(ctx context.Context, cfg *config.Node) error {
continue
}
conn, err := grpc.Dial(addr, grpc.WithInsecure(), grpc.WithTimeout(3*time.Second), grpc.WithDialer(dialer), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)))
conn, err := grpc.Dial(addr, grpc.WithInsecure(), grpc.WithTimeout(3*time.Second), grpc.WithContextDialer(dialer), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)))
if err != nil {
time.Sleep(1 * time.Second)
continue

2
pkg/agent/flannel/setup.go

@ -81,7 +81,7 @@ func Run(ctx context.Context, nodeConfig *config.Node, nodes v1.NodeInterface) e
nodeName := nodeConfig.AgentConfig.NodeName
for {
node, err := nodes.Get(nodeName, metav1.GetOptions{})
node, err := nodes.Get(ctx, nodeName, metav1.GetOptions{})
if err == nil && node.Spec.PodCIDR != "" {
break
}

3
pkg/agent/netpol/network_policy_controller.go

@ -6,6 +6,7 @@
package netpol
import (
"context"
"crypto/sha256"
"encoding/base32"
"errors"
@ -1700,7 +1701,7 @@ func NewNetworkPolicyController(
npc.v1NetworkPolicy = false
}
node, err := clientset.CoreV1().Nodes().Get(hostnameOverride, metav1.GetOptions{})
node, err := clientset.CoreV1().Nodes().Get(context.TODO(), hostnameOverride, metav1.GetOptions{})
if err != nil {
return nil, err
}

4
pkg/agent/run.go

@ -158,7 +158,7 @@ func validate() error {
func configureNode(ctx context.Context, agentConfig *daemonconfig.Agent, nodes v1.NodeInterface) error {
for {
node, err := nodes.Get(agentConfig.NodeName, metav1.GetOptions{})
node, err := nodes.Get(ctx, agentConfig.NodeName, metav1.GetOptions{})
if err != nil {
logrus.Infof("Waiting for kubelet to be ready on node %s: %v", agentConfig.NodeName, err)
time.Sleep(1 * time.Second)
@ -182,7 +182,7 @@ func configureNode(ctx context.Context, agentConfig *daemonconfig.Agent, nodes v
updateNode = true
}
if updateNode {
if _, err := nodes.Update(node); err != nil {
if _, err := nodes.Update(ctx, node, metav1.UpdateOptions{}); err != nil {
logrus.Infof("Failed to update node %s: %v", agentConfig.NodeName, err)
select {
case <-ctx.Done():

4
pkg/agent/tunnel/tunnel.go

@ -73,7 +73,7 @@ func Setup(ctx context.Context, config *config.Node, onChange func([]string)) er
addresses := []string{config.ServerAddress}
endpoint, _ := client.CoreV1().Endpoints("default").Get("kubernetes", metav1.GetOptions{})
endpoint, _ := client.CoreV1().Endpoints("default").Get(ctx, "kubernetes", metav1.GetOptions{})
if endpoint != nil {
addresses = getAddresses(endpoint)
if onChange != nil {
@ -94,7 +94,7 @@ func Setup(ctx context.Context, config *config.Node, onChange func([]string)) er
connect:
for {
time.Sleep(5 * time.Second)
watch, err := client.CoreV1().Endpoints("default").Watch(metav1.ListOptions{
watch, err := client.CoreV1().Endpoints("default").Watch(ctx, metav1.ListOptions{
FieldSelector: fields.Set{"metadata.name": "kubernetes"}.String(),
ResourceVersion: "0",
})

8
pkg/servicelb/controller.go

@ -187,7 +187,7 @@ func (h *handler) updateService(svc *core.Service) (runtime.Object, error) {
}
logrus.Debugf("Setting service loadbalancer %s/%s to IPs %v", svc.Namespace, svc.Name, expectedIPs)
return h.services.Services(svc.Namespace).UpdateStatus(svc)
return h.services.Services(svc.Namespace).UpdateStatus(context.TODO(), svc, meta.UpdateOptions{})
}
func serviceIPs(svc *core.Service) []string {
@ -391,7 +391,7 @@ func (h *handler) newDaemonSet(svc *core.Service) (*apps.DaemonSet, error) {
}
func (h *handler) updateDaemonSets() error {
daemonsets, err := h.daemonsets.DaemonSets("").List(meta.ListOptions{
daemonsets, err := h.daemonsets.DaemonSets("").List(context.TODO(), meta.ListOptions{
LabelSelector: nodeSelectorLabel + "=false",
})
if err != nil {
@ -403,7 +403,7 @@ func (h *handler) updateDaemonSets() error {
daemonsetNodeLabel: "true",
}
ds.Labels[nodeSelectorLabel] = "true"
if _, err := h.daemonsets.DaemonSets(ds.Namespace).Update(&ds); err != nil {
if _, err := h.daemonsets.DaemonSets(ds.Namespace).Update(context.TODO(), &ds, meta.UpdateOptions{}); err != nil {
return err
}
@ -420,5 +420,5 @@ func (h *handler) deleteOldDeployments(svc *core.Service) error {
}
return err
}
return h.deployments.Deployments(svc.Namespace).Delete(name, &meta.DeleteOptions{})
return h.deployments.Deployments(svc.Namespace).Delete(context.TODO(), name, meta.DeleteOptions{})
}

Loading…
Cancel
Save