Commit a8d96112 authored by Darren Shepherd's avatar Darren Shepherd Committed by Erik Wilson

Updates for k8s v1.18 support

parent 53ed13bf
...@@ -80,7 +80,7 @@ func Run(ctx context.Context, cfg *config.Node) error { ...@@ -80,7 +80,7 @@ func Run(ctx context.Context, cfg *config.Node) error {
continue 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 { if err != nil {
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
continue continue
......
...@@ -81,7 +81,7 @@ func Run(ctx context.Context, nodeConfig *config.Node, nodes v1.NodeInterface) e ...@@ -81,7 +81,7 @@ func Run(ctx context.Context, nodeConfig *config.Node, nodes v1.NodeInterface) e
nodeName := nodeConfig.AgentConfig.NodeName nodeName := nodeConfig.AgentConfig.NodeName
for { for {
node, err := nodes.Get(nodeName, metav1.GetOptions{}) node, err := nodes.Get(ctx, nodeName, metav1.GetOptions{})
if err == nil && node.Spec.PodCIDR != "" { if err == nil && node.Spec.PodCIDR != "" {
break break
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
package netpol package netpol
import ( import (
"context"
"crypto/sha256" "crypto/sha256"
"encoding/base32" "encoding/base32"
"errors" "errors"
...@@ -1700,7 +1701,7 @@ func NewNetworkPolicyController( ...@@ -1700,7 +1701,7 @@ func NewNetworkPolicyController(
npc.v1NetworkPolicy = false 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 { if err != nil {
return nil, err return nil, err
} }
......
...@@ -158,7 +158,7 @@ func validate() error { ...@@ -158,7 +158,7 @@ func validate() error {
func configureNode(ctx context.Context, agentConfig *daemonconfig.Agent, nodes v1.NodeInterface) error { func configureNode(ctx context.Context, agentConfig *daemonconfig.Agent, nodes v1.NodeInterface) error {
for { for {
node, err := nodes.Get(agentConfig.NodeName, metav1.GetOptions{}) node, err := nodes.Get(ctx, agentConfig.NodeName, metav1.GetOptions{})
if err != nil { if err != nil {
logrus.Infof("Waiting for kubelet to be ready on node %s: %v", agentConfig.NodeName, err) logrus.Infof("Waiting for kubelet to be ready on node %s: %v", agentConfig.NodeName, err)
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
...@@ -182,7 +182,7 @@ func configureNode(ctx context.Context, agentConfig *daemonconfig.Agent, nodes v ...@@ -182,7 +182,7 @@ func configureNode(ctx context.Context, agentConfig *daemonconfig.Agent, nodes v
updateNode = true updateNode = true
} }
if updateNode { 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) logrus.Infof("Failed to update node %s: %v", agentConfig.NodeName, err)
select { select {
case <-ctx.Done(): case <-ctx.Done():
......
...@@ -73,7 +73,7 @@ func Setup(ctx context.Context, config *config.Node, onChange func([]string)) er ...@@ -73,7 +73,7 @@ func Setup(ctx context.Context, config *config.Node, onChange func([]string)) er
addresses := []string{config.ServerAddress} 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 { if endpoint != nil {
addresses = getAddresses(endpoint) addresses = getAddresses(endpoint)
if onChange != nil { if onChange != nil {
...@@ -94,7 +94,7 @@ func Setup(ctx context.Context, config *config.Node, onChange func([]string)) er ...@@ -94,7 +94,7 @@ func Setup(ctx context.Context, config *config.Node, onChange func([]string)) er
connect: connect:
for { for {
time.Sleep(5 * time.Second) 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(), FieldSelector: fields.Set{"metadata.name": "kubernetes"}.String(),
ResourceVersion: "0", ResourceVersion: "0",
}) })
......
...@@ -187,7 +187,7 @@ func (h *handler) updateService(svc *core.Service) (runtime.Object, error) { ...@@ -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) 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 { func serviceIPs(svc *core.Service) []string {
...@@ -391,7 +391,7 @@ func (h *handler) newDaemonSet(svc *core.Service) (*apps.DaemonSet, error) { ...@@ -391,7 +391,7 @@ func (h *handler) newDaemonSet(svc *core.Service) (*apps.DaemonSet, error) {
} }
func (h *handler) updateDaemonSets() 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", LabelSelector: nodeSelectorLabel + "=false",
}) })
if err != nil { if err != nil {
...@@ -403,7 +403,7 @@ func (h *handler) updateDaemonSets() error { ...@@ -403,7 +403,7 @@ func (h *handler) updateDaemonSets() error {
daemonsetNodeLabel: "true", daemonsetNodeLabel: "true",
} }
ds.Labels[nodeSelectorLabel] = "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 return err
} }
...@@ -420,5 +420,5 @@ func (h *handler) deleteOldDeployments(svc *core.Service) error { ...@@ -420,5 +420,5 @@ func (h *handler) deleteOldDeployments(svc *core.Service) error {
} }
return err return err
} }
return h.deployments.Deployments(svc.Namespace).Delete(name, &meta.DeleteOptions{}) return h.deployments.Deployments(svc.Namespace).Delete(context.TODO(), name, meta.DeleteOptions{})
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment