diff --git a/.github/workflows/build-go.yml b/.github/workflows/build-go.yml index cb1eedc..b7a2e10 100644 --- a/.github/workflows/build-go.yml +++ b/.github/workflows/build-go.yml @@ -27,4 +27,4 @@ jobs: run: bash scripts/check-fmt.sh - name: Build - run: make build + run: go build ./... diff --git a/Makefile b/Makefile index 759a84b..b7badc5 100644 --- a/Makefile +++ b/Makefile @@ -20,74 +20,56 @@ export GOARCH=$(TARGETARCH) DOCKER_DEPLOY_BUCKET=uhub.service.ucloud.cn/uk8s DOCKER_TEST_BUCKET=uhub.service.ucloud.cn/wxyz -DOCKER_LABEL:=$(if $(DEPLOY),$(CNI_VERSION),build-$(COMMIT_ID_SHORT)) +DOCKER_LABEL:=$(if $(DEPLOY),$(CNI_VERSION),dev-$(COMMIT_ID_SHORT)) DOCKER_BUCKET:=$(if $(DEPLOY),$(DOCKER_DEPLOY_BUCKET),$(DOCKER_TEST_BUCKET)) IPAMD_IMAGE:=$(DOCKER_BUCKET)/cni-vpc-ipamd:$(DOCKER_LABEL) VIP_CONTROLLER_IMAGE:=$(DOCKER_BUCKET)/vip-controller:$(DOCKER_LABEL) CNI_VPC_BUILD_IMAGE:=$(DOCKER_BUCKET)/cni-vpc-build:$(DOCKER_LABEL) -DOCKER_CMD:=$(if $(DOCKER_CMD),$(DOCKER_CMD),docker) +DOCKER_CMD:=$(shell if docker ps 2> /dev/null; then echo "docker"; else echo "sudo docker"; fi) +CWD:=$(shell pwd) -DOCKER_BASE_IMAGE:=$(if $(DOCKER_BASE_IMAGE),$(DOCKER_BASE_IMAGE),uhub.service.ucloud.cn/wxyz/cni-vpc-base:1.19.4) +DOCKER_BASE_IMAGE:=$(if $(DOCKER_BASE_IMAGE),$(DOCKER_BASE_IMAGE),uhub.service.ucloud.cn/wxyz/cni-vpc-base:1.19.6) -.PHONY: docker-build docker-deploy docker-build-cni docker-base-image deploy-docker-base-image \ - check-fmt fmt install-check check version clean generate-grpc \ - build build-cni build-ipamd build-ipamctl build-vip-controller \ - install-grpc generate-k8s generate-grpc - -all: build - -build: build-cni build-ipamd build-ipamctl build-vip-controller +all: build-cni build-ipamd build-cnictl build-vip-controller +.PHONY: build-cni build-cni: go build ${LDFLAGS} -o ./bin/cnivpc ./cmd/cnivpc +.PHONY: build-ipamd build-ipamd: go build ${LDFLAGS} -o ./bin/cnivpc-ipamd ./cmd/cnivpc-ipamd -build-ipamctl: - go build ${LDFLAGS} -o ./bin/ipamctl ./cmd/ipamctl +.PHONY: build-cnictl +build-cnictl: + go build ${LDFLAGS} -o ./bin/cnictl ./cmd/cnictl +.PHONY: build-vip-controller build-vip-controller: go build ${LDFLAGS} -o ./bin/vip-controller ./cmd/vip-controller +.PHONY: docker-build docker-build: - ${DOCKER_CMD} build -t ${IPAMD_IMAGE} -f dockerfiles/ipamd/Dockerfile . - ${DOCKER_CMD} build -t ${VIP_CONTROLLER_IMAGE} -f dockerfiles/vip-controller/Dockerfile . - @echo "Successfully built image: ${IPAMD_IMAGE}" - @echo "Successfully built image: ${VIP_CONTROLLER_IMAGE}" + $(DOCKER_CMD) run -v $(CWD):/src -w="/src" -it $(DOCKER_BASE_IMAGE) make -docker-deploy: docker-build - ${DOCKER_CMD} push ${IPAMD_IMAGE} - ${DOCKER_CMD} push ${VIP_CONTROLLER_IMAGE} - @echo "Successfully pushed image: ${IPAMD_IMAGE}" - @echo "Successfully pushed image: ${VIP_CONTROLLER_IMAGE}" - -# Build cnivpc binary in image, so that the glibc can match the production -# environment. -# If you build cnivpc binary in the latest Linux distribution (Such as Arch), -# the binary might not be able to run in UK8S machine because the glibc version -# in UK8S machine is very old. -# we should use the image "uhub.service.ucloud.cn/wxyz/cni-vpc-base", it is based -# on centos 7 (same as production), and glibc version is properly. -docker-build-cni: - ${DOCKER_CMD} build -t ${CNI_VPC_BUILD_IMAGE} -f dockerfiles/cnivpc-build/Dockerfile . - @mkdir -p bin - @bash ./scripts/copy-from-docker-image.sh "${DOCKER_CMD}" "${CNI_VPC_BUILD_IMAGE}" /cnivpc ./bin/cnivpc - @bash ./scripts/copy-from-docker-image.sh "${DOCKER_CMD}" "${CNI_VPC_BUILD_IMAGE}" /ipamctl ./bin/ipamctl -ifdef NODE_IP - scp bin/docker/cnivpc root@${NODE_IP}:/opt/cni/bin/cnivpc -endif - -docker-build-base-image: - ${DOCKER_CMD} build -t ${DOCKER_BASE_IMAGE} -f dockerfiles/base/Dockerfile . +.PHONY: docker-base +docker-base: + $(DOCKER_CMD) build -t $(DOCKER_BASE_IMAGE) -f dockerfiles/base/Dockerfile . @echo "Successfully built ${DOCKER_BASE_IMAGE}" -docker-deploy-base-image: docker-base-image - ${DOCKER_CMD} push ${DOCKER_BASE_IMAGE} - @echo "Successfully pushed ${DOCKER_BASE_IMAGE}" +.PHONY: docker-ipamd +docker-ipamd: + $(DOCKER_CMD) build -t $(IPAMD_IMAGE) -f dockerfiles/ipamd/Dockerfile . + @echo "Successfully built image: ${IPAMD_IMAGE}" + +.PHONY: docker-vip-controller +docker-vip-controller: + $(DOCKER_CMD) build -t $(VIP_CONTROLLER_IMAGE) -f dockerfiles/vip-controller/Dockerfile . + @echo "Successfully built image: ${VIP_CONTROLLER_IMAGE}" +.PHONY: fmt fmt: @command -v goimports >/dev/null || { echo "ERROR: goimports not installed"; exit 1; } @exit $(shell find ./* \ @@ -95,15 +77,18 @@ fmt: -name '*.go' \ -print0 | sort -z | xargs -0 -- goimports $(or $(FORMAT_FLAGS),-w) | wc -l | bc) +.PHONY: check-fmt check-fmt: @./scripts/check-fmt.sh +.PHONY: install-check install-check: @go install github.com/fzipp/gocyclo/cmd/gocyclo@latest @go install github.com/client9/misspell/cmd/misspell@latest @go install github.com/gordonklaus/ineffassign@latest @go install golang.org/x/tools/cmd/goimports@latest +.PHONY: check check: @echo "==> check ineffassign" @ineffassign ./... @@ -114,19 +99,24 @@ check: @echo "==> go vet" @go vet ./... +.PHONY: version version: @echo ${CNI_VERSION} +.PHONY: clean clean: @rm -rf ./bin +.PHONY: install-grpc install-grpc: @go install github.com/golang/protobuf/protoc-gen-go@latest +.PHONY: generate-grpc generate-grpc: @command -v protoc >/dev/null || { echo "ERROR: protoc not installed"; exit 1; } @command -v protoc-gen-go >/dev/null || { echo "ERROR: protoc-gen-go not installed"; exit 1; } @protoc --go_out=plugins=grpc:./rpc ./rpc/ipamd.proto +.PHONY: generate-k8s generate-k8s: @bash hack/update-codegen.sh diff --git a/cmd/cnictl/common/ip.go b/cmd/cnictl/common/ip.go new file mode 100644 index 0000000..10dabe7 --- /dev/null +++ b/cmd/cnictl/common/ip.go @@ -0,0 +1,105 @@ +package common + +import ( + "context" + "fmt" + "sort" + "sync" + + "github.com/ucloud/uk8s-cni-vpc/rpc" +) + +type IPSummary struct { + Allocated []string `json:"-"` + Pods []*PodSecondaryIP `json:"pods,omitempty"` + PodIPCount int `json:"-"` + Pool []string `json:"pool,omitempty"` + Unused []string `json:"unused,omitempty"` +} + +func SummarizeIP() (*IPSummary, error) { + var wg sync.WaitGroup + wg.Add(3) + errChan := make(chan error, 3) + + var allocated []*SecondaryIP + var allocatedIPs []string + go func() { + defer wg.Done() + var err error + allocated, err = ListSecondaryIP() + if err != nil { + errChan <- err + } + allocatedIPs = make([]string, len(allocated)) + for i, ip := range allocated { + allocatedIPs[i] = ip.IP + } + }() + + var pods []*PodSecondaryIP + go func() { + defer wg.Done() + var err error + pods, err = ListPodSecondaryIPs() + if err != nil { + errChan <- err + } + }() + + node := Node() + var pool []string + go func() { + defer wg.Done() + if node.IpamdEnable { + ipamdClient, err := IpamdClient() + if err != nil { + errChan <- fmt.Errorf("failed to init ipamd client: %v", err) + return + } + resp, err := ipamdClient.Status(context.Background(), &rpc.StatusRequest{}) + if err != nil { + errChan <- fmt.Errorf("failed to request ipamd status: %v", err) + return + } + pool = resp.Pool + } + }() + + wg.Wait() + close(errChan) + + err := <-errChan + if err != nil { + return nil, err + } + + unused := make(map[string]struct{}, len(allocatedIPs)) + var podIPCount int + for _, ip := range allocatedIPs { + unused[ip] = struct{}{} + } + for _, pod := range pods { + podIPCount += len(pod.SecondaryIPs) + for _, ip := range pod.SecondaryIPs { + delete(unused, ip) + } + } + for _, ip := range pool { + delete(unused, ip) + } + + unusedIPs := make([]string, 0, len(unused)) + for ip := range unused { + unusedIPs = append(unusedIPs, ip) + } + sort.Strings(unusedIPs) + + return &IPSummary{ + Allocated: allocatedIPs, + Pods: pods, + PodIPCount: podIPCount, + Pool: pool, + Unused: unusedIPs, + }, nil +} diff --git a/cmd/cnictl/common/ipamd.go b/cmd/cnictl/common/ipamd.go new file mode 100644 index 0000000..b8acb2f --- /dev/null +++ b/cmd/cnictl/common/ipamd.go @@ -0,0 +1,36 @@ +package common + +import ( + "context" + "fmt" + "os" + + "github.com/ucloud/uk8s-cni-vpc/pkg/ipamd" + "github.com/ucloud/uk8s-cni-vpc/rpc" + "google.golang.org/grpc" +) + +func IpamdEnable() bool { + _, err := os.Stat(ipamd.SocketPath) + if err != nil { + if os.IsNotExist(err) { + return false + } + OnError(fmt.Errorf("stat ipamd socket: %v", err)) + } + + return true +} + +func IpamdClient() (rpc.CNIIpamClient, error) { + conn, err := grpc.Dial(ipamd.SocketTarget, grpc.WithInsecure()) + if err != nil { + return nil, err + } + c := rpc.NewCNIIpamClient(conn) + _, err = c.Ping(context.Background(), &rpc.PingRequest{}) + if err != nil { + return nil, fmt.Errorf("failed to ping ipamd: %v", err) + } + return c, nil +} diff --git a/cmd/cnictl/common/node.go b/cmd/cnictl/common/node.go new file mode 100644 index 0000000..1ec60be --- /dev/null +++ b/cmd/cnictl/common/node.go @@ -0,0 +1,263 @@ +package common + +import ( + "fmt" + "io" + "io/ioutil" + "net" + "os" + "path/filepath" + "strings" + "sync" + + "github.com/fatih/color" + "github.com/ucloud/uk8s-cni-vpc/pkg/uapi" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/tools/clientcmd" +) + +func OnError(err error) { + fmt.Printf("%s: %v\n", color.RedString("error"), err) + os.Exit(1) +} + +var ( + client *kubernetes.Clientset + + initKubeOnce sync.Once +) + +const ( + etcConfigPath = "/etc/kubernetes/kubelet.kubeconfig" + etcEnvPath = "/etc/kubernetes/ucloud" + nodeInterfaceName = "eth0" +) + +func KubeClient() *kubernetes.Clientset { + var err error + initKubeOnce.Do(func() { + err = initKubeConfig() + }) + if err != nil { + OnError(err) + } + + return client +} + +func initKubeConfig() error { + homePath, err := os.UserHomeDir() + if err != nil { + return fmt.Errorf("failed to get home dir: %v", err) + } + + kubeConfigDir := filepath.Join(homePath, ".kube") + stat, err := os.Stat(kubeConfigDir) + switch { + case err == nil: + if !stat.IsDir() { + return fmt.Errorf("%s is not a directory", kubeConfigDir) + } + + case os.IsNotExist(err): + err = os.MkdirAll(kubeConfigDir, os.ModePerm) + if err != nil { + return fmt.Errorf("failed to ensure config dir: %v", err) + } + + default: + return err + } + + kubeConfigPath := filepath.Join(kubeConfigDir, "config") + _, err = os.Stat(kubeConfigPath) + if err != nil { + if !os.IsNotExist(err) { + return err + } + _, err = os.Stat(etcConfigPath) + if err != nil { + return fmt.Errorf("failed to read etc kubeconfig: %v", err) + } + + err = copyFile(kubeConfigPath, etcConfigPath) + if err != nil { + return fmt.Errorf("failed to copy etc kubeconfig: %v", err) + } + } + + cfg, err := clientcmd.BuildConfigFromFlags("", kubeConfigPath) + if err != nil { + return fmt.Errorf("failed to read kubeconfig: %v", err) + } + + client, err = kubernetes.NewForConfig(cfg) + if err != nil { + return fmt.Errorf("failed to init kube client: %v", err) + } + + return nil +} + +func copyFile(dstPath, srcPath string) error { + dst, err := os.OpenFile(dstPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644) + if err != nil { + return err + } + defer dst.Close() + + src, err := os.Open(srcPath) + if err != nil { + return err + } + defer src.Close() + + _, err = io.Copy(dst, src) + return err +} + +type NodeInfo struct { + Name string `json:"name"` + MAC string `json:"mac"` + Region string `json:"region"` + APIEndpoint string `json:"api_endpoint"` + ProjectID string `json:"project_id"` + VPCID string `json:"vpc_id"` + SubnetID string `json:"subnet_id"` + IpamdEnable bool `json:"ipamd_enable"` +} + +var ( + nodeInfo *NodeInfo + initNodeInfoOnce sync.Once +) + +func Node() *NodeInfo { + var err error + initNodeInfoOnce.Do(func() { + nodeInfo, err = buildInfo() + }) + if err != nil { + OnError(err) + } + return nodeInfo +} + +func buildInfo() (*NodeInfo, error) { + name, mac, err := getNodeName() + if err != nil { + return nil, fmt.Errorf("failed to get node name: %v", err) + } + + err = parseEnvFile(etcEnvPath) + if err != nil { + return nil, fmt.Errorf("faield to parse env file: %v", err) + } + + region, err := getLocalEnv("UCLOUD_REGION_ID") + if err != nil { + return nil, err + } + + apiEndpoint, err := getLocalEnv("UCLOUD_API_ENDPOINT") + if err != nil { + return nil, err + } + + projectID, err := getLocalEnv("UCLOUD_PROJECT_ID") + if err != nil { + return nil, err + } + + vpcID, err := getLocalEnv("UCLOUD_VPC_ID") + if err != nil { + return nil, err + } + + subnetID, err := getLocalEnv("UCLOUD_SUBNET_ID") + if err != nil { + return nil, err + } + + return &NodeInfo{ + Name: name, + MAC: mac, + Region: region, + APIEndpoint: apiEndpoint, + ProjectID: projectID, + VPCID: vpcID, + SubnetID: subnetID, + IpamdEnable: IpamdEnable(), + }, nil +} + +func getNodeName() (string, string, error) { + ifaces, err := net.Interfaces() + if err != nil { + return "", "", fmt.Errorf("failed to get net interfaces: %v", err) + } + for _, iface := range ifaces { + if iface.Name == nodeInterfaceName { + addrs, err := iface.Addrs() + if err != nil { + return "", "", fmt.Errorf("failed to get addrs for iface: %v", err) + } + if len(addrs) != 1 { + return "", "", fmt.Errorf("invalid iface addr count, expect 1, found %d", len(addrs)) + } + ip, _, err := net.ParseCIDR(addrs[0].String()) + if err != nil { + return "", "", fmt.Errorf("failed to parse CIDR: %v", err) + } + return ip.String(), iface.HardwareAddr.String(), nil + } + } + return "", "", fmt.Errorf("cannot find network interface %s", nodeInterfaceName) +} + +func parseEnvFile(path string) error { + data, err := ioutil.ReadFile(path) + if err != nil { + return err + } + lines := strings.Split(string(data), "\n") + for _, line := range lines { + line = strings.TrimSpace(line) + tmp := strings.Split(line, "=") + if len(tmp) == 2 { + key := tmp[0] + val := tmp[1] + err = os.Setenv(key, val) + if err != nil { + return fmt.Errorf("failed to setenv: %v", err) + } + } + } + + return nil +} + +func getLocalEnv(key string) (string, error) { + val := os.Getenv(key) + if val == "" { + return "", fmt.Errorf("cannot get env %q", key) + } + return val, nil +} + +var ( + apiClient *uapi.ApiClient + initAPIOnce sync.Once +) + +func UAPI() *uapi.ApiClient { + _ = Node() + var err error + initAPIOnce.Do(func() { + apiClient, err = uapi.NewClient() + }) + if err != nil { + OnError(err) + } + return apiClient +} diff --git a/cmd/cnictl/common/pod.go b/cmd/cnictl/common/pod.go new file mode 100644 index 0000000..d0fa1e0 --- /dev/null +++ b/cmd/cnictl/common/pod.go @@ -0,0 +1,61 @@ +package common + +import ( + "context" + "fmt" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/fields" +) + +type PodSecondaryIP struct { + Name string `json:"name"` + Namespace string `json:"namespace"` + SecondaryIPs []string `json:"secondary_ips"` +} + +func ListPodSecondaryIPs() ([]*PodSecondaryIP, error) { + podList, err := ListPods() + if err != nil { + return nil, err + } + + nodeIP := Node().Name + + ips := make([]*PodSecondaryIP, 0, len(podList.Items)) + for _, pod := range podList.Items { + if pod.Spec.HostNetwork { + continue + } + podIPs := pod.Status.PodIPs + item := &PodSecondaryIP{ + Name: pod.Name, + Namespace: pod.Namespace, + SecondaryIPs: make([]string, 0, len(podIPs)), + } + for _, podIP := range podIPs { + if podIP.IP == nodeIP { + continue + } + item.SecondaryIPs = append(item.SecondaryIPs, podIP.IP) + } + ips = append(ips, item) + } + + return ips, nil +} + +func ListPods() (*corev1.PodList, error) { + opts := metav1.ListOptions{ + FieldSelector: fields.OneTermEqualSelector("spec.nodeName", Node().Name).String(), + ResourceVersion: "0", + } + + pods, err := KubeClient().CoreV1().Pods(corev1.NamespaceAll).List(context.Background(), opts) + if err != nil { + return nil, fmt.Errorf("failed to list pods: %v", err) + } + + return pods, nil +} diff --git a/cmd/cnictl/common/utils.go b/cmd/cnictl/common/utils.go new file mode 100644 index 0000000..95bd796 --- /dev/null +++ b/cmd/cnictl/common/utils.go @@ -0,0 +1,14 @@ +package common + +import ( + "encoding/json" + "fmt" +) + +func ShowObject(v any) { + data, err := json.MarshalIndent(v, "", " ") + if err != nil { + OnError(err) + } + fmt.Println(string(data)) +} diff --git a/cmd/cnictl/common/vpc.go b/cmd/cnictl/common/vpc.go new file mode 100644 index 0000000..b9419f4 --- /dev/null +++ b/cmd/cnictl/common/vpc.go @@ -0,0 +1,41 @@ +package common + +import ( + "github.com/ucloud/ucloud-sdk-go/ucloud" +) + +type SecondaryIP struct { + IP string + Mask string + Gateway string +} + +func ListSecondaryIP() ([]*SecondaryIP, error) { + node := Node() + + vpcClient, err := UAPI().VPCClient() + if err != nil { + return nil, err + } + req := vpcClient.NewDescribeSecondaryIpRequest() + req.Region = ucloud.String(node.Region) + req.SubnetId = ucloud.String(node.SubnetID) + req.VPCId = ucloud.String(node.VPCID) + req.Mac = ucloud.String(node.MAC) + + resp, err := vpcClient.DescribeSecondaryIp(req) + if err != nil { + return nil, err + } + + ips := make([]*SecondaryIP, len(resp.DataSet)) + for i, data := range resp.DataSet { + ips[i] = &SecondaryIP{ + IP: data.Ip, + Mask: data.Mask, + Gateway: data.Gateway, + } + } + + return ips, nil +} diff --git a/cmd/cnictl/main.go b/cmd/cnictl/main.go new file mode 100644 index 0000000..a6dc66d --- /dev/null +++ b/cmd/cnictl/main.go @@ -0,0 +1,28 @@ +package main + +import ( + "github.com/spf13/cobra" + "github.com/ucloud/uk8s-cni-vpc/cmd/cnictl/common" + "github.com/ucloud/uk8s-cni-vpc/cmd/cnictl/status" +) + +var cmd = &cobra.Command{ + Use: "cnictl", + Short: "CNI CLI tools", + + SilenceErrors: true, + SilenceUsage: true, + + CompletionOptions: cobra.CompletionOptions{ + HiddenDefaultCmd: true, + }, +} + +func main() { + cmd.AddCommand(status.Command) + + err := cmd.Execute() + if err != nil { + common.OnError(err) + } +} diff --git a/cmd/cnictl/status/ip.go b/cmd/cnictl/status/ip.go new file mode 100644 index 0000000..bccdb67 --- /dev/null +++ b/cmd/cnictl/status/ip.go @@ -0,0 +1,36 @@ +package status + +import ( + "fmt" + + "github.com/spf13/cobra" + "github.com/ucloud/uk8s-cni-vpc/cmd/cnictl/common" +) + +func init() { + Command.AddCommand(ip) +} + +var ip = &cobra.Command{ + Use: "ip [-a]", + Short: "Show ip status", + + RunE: func(_ *cobra.Command, _ []string) error { + sum, err := common.SummarizeIP() + if err != nil { + return err + } + + if all { + common.ShowObject(sum) + return nil + } + + fmt.Printf("Allocated: %d\n", len(sum.Allocated)) + fmt.Printf("Pods: %d\n", sum.PodIPCount) + fmt.Printf("Pool: %d\n", len(sum.Pool)) + fmt.Printf("Unused: %d\n", len(sum.Unused)) + + return nil + }, +} diff --git a/cmd/cnictl/status/status.go b/cmd/cnictl/status/status.go new file mode 100644 index 0000000..fe50866 --- /dev/null +++ b/cmd/cnictl/status/status.go @@ -0,0 +1,34 @@ +package status + +import ( + "encoding/json" + "fmt" + + "github.com/spf13/cobra" + "github.com/ucloud/uk8s-cni-vpc/cmd/cnictl/common" +) + +var ( + all bool +) + +var Command = &cobra.Command{ + Use: "status", + Short: "Show status for current node", + + RunE: func(_ *cobra.Command, _ []string) error { + node := common.Node() + + data, err := json.MarshalIndent(node, "", " ") + if err != nil { + return err + } + fmt.Println(string(data)) + + return nil + }, +} + +func init() { + Command.PersistentFlags().BoolVarP(&all, "all", "a", false, "Show all details") +} diff --git a/cmd/cnivpc/rpc.go b/cmd/cnivpc/rpc.go index 8e703d3..63b96ef 100644 --- a/cmd/cnivpc/rpc.go +++ b/cmd/cnivpc/rpc.go @@ -20,10 +20,10 @@ import ( "strings" "time" + "github.com/ucloud/uk8s-cni-vpc/pkg/ipamd" "github.com/ucloud/uk8s-cni-vpc/pkg/uapi" "github.com/ucloud/ucloud-sdk-go/ucloud" - "github.com/ucloud/uk8s-cni-vpc/pkg/ipamd" "github.com/ucloud/uk8s-cni-vpc/pkg/storage" "github.com/ucloud/uk8s-cni-vpc/rpc" @@ -33,9 +33,8 @@ import ( ) const ( - IpamdServiceSocket = "unix:" + ipamd.IpamdServiceSocket - CNIVpcDbName = "cni-vpc-network" - storageFile = "/opt/cni/networkbolt.db" + CNIVpcDbName = "cni-vpc-network" + storageFile = "/opt/cni/networkbolt.db" instanceTypeCube = "Cube" instanceTypeUHost = "UHost" @@ -70,7 +69,7 @@ func accessToPodNetworkDB(dbName, storageFile string) (storage.Storage[rpc.PodNe // If there is ipamd daemon service, use ipamd to allocate Pod Ip; // if not, do this on myself. func assignPodIp(podName, podNS, netNS, sandboxId string) (*rpc.PodNetwork, bool, error) { - conn, err := grpc.Dial(IpamdServiceSocket, grpc.WithInsecure()) + conn, err := grpc.Dial(ipamd.SocketTarget, grpc.WithInsecure()) if err == nil { // There are two prerequisites for using ipamd: // 1. The connection is successfully established, that is, Dial ok. @@ -96,7 +95,7 @@ func assignPodIp(podName, podNS, netNS, sandboxId string) (*rpc.PodNetwork, bool // If there is ipamd daemon service, use ipamd to release Pod Ip; // if not, do this on myself. func releasePodIp(podName, podNS, netNS, sandboxId string, pNet *rpc.PodNetwork) error { - conn, err := grpc.Dial(IpamdServiceSocket, grpc.WithInsecure()) + conn, err := grpc.Dial(ipamd.SocketTarget, grpc.WithInsecure()) if err != nil { // Cannot establish gRPC unix domain connection to ipamd // If pod has dedicated uni, leave this to ipamd when it is reinstalled @@ -355,7 +354,7 @@ func deallocateSecondaryIPFromIpamd(c rpc.CNIIpamClient, podName, podNS, netNS, // If there is ipamd daemon service, use ipamd to add PodNetworkRecord; // if not, do this on myself. func addPodNetworkRecord(podName, podNS, sandBoxID, netNS string, pNet *rpc.PodNetwork) error { - conn, err := grpc.Dial(IpamdServiceSocket, grpc.WithInsecure()) + conn, err := grpc.Dial(ipamd.SocketTarget, grpc.WithInsecure()) if err != nil { return addPodNetworkRecordLocal(podName, podNS, sandBoxID, netNS, pNet) } @@ -401,7 +400,7 @@ func addPodNetworkRecordFromIpamd(c rpc.CNIIpamClient, podName, podNS, sandBoxID // If there is ipamd daemon service, use ipamd to delete NetworkRecord; // if not, do this on myself. func delPodNetworkRecord(podName, podNS, sandBoxID string, pNet *rpc.PodNetwork) error { - conn, err := grpc.Dial(IpamdServiceSocket, grpc.WithInsecure()) + conn, err := grpc.Dial(ipamd.SocketTarget, grpc.WithInsecure()) if err != nil { return delPodNetworkRecordLocal(podName, podNS, sandBoxID, pNet) } @@ -451,7 +450,7 @@ func delPodNetworkRecordFromIpamd(c rpc.CNIIpamClient, podName, podNS, sandBoxID // If there is ipamd daemon service, use ipamd to get PodNetworkRecord; // if not, do this on myself. func getPodNetworkRecord(podName, podNS, sandBoxID string) (*rpc.PodNetwork, error) { - conn, err := grpc.Dial(IpamdServiceSocket, grpc.WithInsecure()) + conn, err := grpc.Dial(ipamd.SocketTarget, grpc.WithInsecure()) if err != nil { return getPodNetworkRecordLocal(podName, podNS, sandBoxID) } diff --git a/cmd/ipamctl/main.go b/cmd/ipamctl/main.go deleted file mode 100644 index cccc68e..0000000 --- a/cmd/ipamctl/main.go +++ /dev/null @@ -1,64 +0,0 @@ -package main - -import ( - "fmt" - "os" - "path/filepath" - - "github.com/fatih/color" - "github.com/spf13/cobra" - crdclientset "github.com/ucloud/uk8s-cni-vpc/kubernetes/generated/clientset/versioned" - "k8s.io/client-go/tools/clientcmd" -) - -var ( - configPath string - - crdClient *crdclientset.Clientset -) - -var Root = &cobra.Command{ - Use: "ipamctl [--kube-config config-path]", - Short: "Ipam CLI tool", - - SilenceErrors: true, - SilenceUsage: true, - - PersistentPreRunE: func(_ *cobra.Command, _ []string) error { - if configPath == "" { - homePath, err := os.UserHomeDir() - if err != nil { - return err - } - configPath = filepath.Join(homePath, ".kube", "config") - } - - cfg, err := clientcmd.BuildConfigFromFlags("", configPath) - if err != nil { - return fmt.Errorf("failed to read kube-config: %v", err) - } - - crdClient, err = crdclientset.NewForConfig(cfg) - if err != nil { - return fmt.Errorf("failed to init client: %v", err) - } - - return nil - }, - - CompletionOptions: cobra.CompletionOptions{ - HiddenDefaultCmd: true, - }, -} - -func main() { - Root.Flags().StringVarP(&configPath, "kube-config", "", "", "kubeconfig path") - - Root.AddCommand(Status) - - err := Root.Execute() - if err != nil { - fmt.Printf("%s %v\n", color.RedString("error:"), err) - os.Exit(1) - } -} diff --git a/cmd/ipamctl/status.go b/cmd/ipamctl/status.go deleted file mode 100644 index 38375f5..0000000 --- a/cmd/ipamctl/status.go +++ /dev/null @@ -1,57 +0,0 @@ -package main - -import ( - "context" - "fmt" - - "github.com/fatih/color" - "github.com/ryanuber/columnize" - "github.com/spf13/cobra" - ipamdv1beta1 "github.com/ucloud/uk8s-cni-vpc/kubernetes/apis/ipamd/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -var Status = &cobra.Command{ - Use: "status", - Short: "Show ipamd status", - - RunE: func(_ *cobra.Command, _ []string) error { - ctx := context.Background() - ipamdList, err := crdClient.IpamdV1beta1().Ipamds("kube-system").List(ctx, metav1.ListOptions{}) - if err != nil { - return fmt.Errorf("failed to list resources: %v", err) - } - - if len(ipamdList.Items) == 0 { - fmt.Println("no resources") - return nil - } - - lines := []string{"NAME | SUBNET | SIZE | STATUS"} - for _, ipamd := range ipamdList.Items { - var attr color.Attribute - switch ipamd.Status.Status { - case ipamdv1beta1.StatusNormal: - attr = color.FgGreen - - case ipamdv1beta1.StatusDry: - attr = color.FgRed - - case ipamdv1beta1.StatusHungry: - attr = color.FgYellow - - case ipamdv1beta1.StatusOverflow: - attr = color.FgMagenta - } - - c := color.New(attr) - line := fmt.Sprintf("%s | %s | %d | %s", ipamd.Name, - ipamd.Spec.Subnet, ipamd.Status.Current, - c.Sprint(ipamd.Status.Status)) - lines = append(lines, line) - } - - fmt.Println(columnize.SimpleFormat(lines)) - return nil - }, -} diff --git a/dockerfiles/base/Dockerfile b/dockerfiles/base/Dockerfile index 78ea892..b94f297 100644 --- a/dockerfiles/base/Dockerfile +++ b/dockerfiles/base/Dockerfile @@ -21,8 +21,8 @@ RUN yum -y install devtoolset-7-gcc* SHELL [ "/usr/bin/scl", "enable", "devtoolset-7"] RUN gcc --version -RUN wget https://dl.google.com/go/go1.19.4.linux-amd64.tar.gz -RUN tar -C /usr/local -xzf go1.19.4.linux-amd64.tar.gz +RUN wget https://dl.google.com/go/go1.19.6.linux-amd64.tar.gz +RUN tar -C /usr/local -xzf go1.19.6.linux-amd64.tar.gz ENV PATH $PATH:/usr/local/go/bin # Configure build with Go modules diff --git a/dockerfiles/cnivpc-build/Dockerfile b/dockerfiles/cnivpc-build/Dockerfile deleted file mode 100644 index cac261b..0000000 --- a/dockerfiles/cnivpc-build/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM uhub.service.ucloud.cn/wxyz/cni-vpc-base:1.19.4 AS builder - -WORKDIR /go/src/cni-vpc-uk8s - -# Configure build with Go modules -ENV GO111MODULE=on -ENV GOPROXY=direct - -COPY . ./ -RUN make build-cni -RUN make build-ipamctl - -FROM scratch AS export -COPY --from=builder /go/src/cni-vpc-uk8s/bin/cnivpc / -COPY --from=builder /go/src/cni-vpc-uk8s/bin/ipamctl / -ENTRYPOINT [ "bash" ] diff --git a/dockerfiles/cnivpc/Dockerfile b/dockerfiles/cnivpc/Dockerfile index 2f76896..4602c42 100644 --- a/dockerfiles/cnivpc/Dockerfile +++ b/dockerfiles/cnivpc/Dockerfile @@ -1,4 +1,4 @@ -FROM uhub.service.ucloud.cn/wxyz/cni-vpc-base:1.19.4 AS builder +FROM uhub.service.ucloud.cn/wxyz/cni-vpc-base:1.19.6 AS builder WORKDIR /go/src/cni-vpc-uk8s diff --git a/dockerfiles/ipamd/Dockerfile b/dockerfiles/ipamd/Dockerfile index b7276cf..9aefbcb 100644 --- a/dockerfiles/ipamd/Dockerfile +++ b/dockerfiles/ipamd/Dockerfile @@ -1,4 +1,4 @@ -FROM uhub.service.ucloud.cn/wxyz/cni-vpc-base:1.19.4 AS builder +FROM uhub.service.ucloud.cn/wxyz/cni-vpc-base:1.19.6 AS builder WORKDIR /go/src/cni-vpc-uk8s diff --git a/dockerfiles/vip-controller/Dockerfile b/dockerfiles/vip-controller/Dockerfile index 46ca026..ec3e7b0 100644 --- a/dockerfiles/vip-controller/Dockerfile +++ b/dockerfiles/vip-controller/Dockerfile @@ -1,4 +1,4 @@ -FROM uhub.service.ucloud.cn/wxyz/cni-vpc-base:1.19.4 AS builder +FROM uhub.service.ucloud.cn/wxyz/cni-vpc-base:1.19.6 AS builder WORKDIR /go/src/cni-vpc-uk8s diff --git a/pkg/ipamd/rpc.go b/pkg/ipamd/rpc.go index 6b7882d..1f307f9 100644 --- a/pkg/ipamd/rpc.go +++ b/pkg/ipamd/rpc.go @@ -214,3 +214,26 @@ func (s *ipamServer) BorrowIP(ctx context.Context, req *rpc.BorrowIPRequest) (*r IP: ip, }, nil } + +func (s *ipamServer) Status(ctx context.Context, req *rpc.StatusRequest) (*rpc.StatusResponse, error) { + items, err := s.pool.List() + if err != nil { + return &rpc.StatusResponse{ + Code: rpc.CNIErrorCode_CNIReadDBError, + }, status.Error(codes.Internal, fmt.Sprintf("failed to read db: %v", err)) + } + + ips := make([]string, len(items)) + for i, item := range items { + ips[i] = item.VPCIP + } + + return &rpc.StatusResponse{ + Code: rpc.CNIErrorCode_CNISuccess, + Pool: ips, + }, nil +} + +func (s *ipamServer) Clean(ctx context.Context, req *rpc.CleanRequest) (*rpc.CleanResponse, error) { + return &rpc.CleanResponse{}, nil +} diff --git a/pkg/ipamd/svc.go b/pkg/ipamd/svc.go index f160247..d2b4a61 100644 --- a/pkg/ipamd/svc.go +++ b/pkg/ipamd/svc.go @@ -35,7 +35,8 @@ import ( ) const ( - IpamdServiceSocket = "/run/cni-vpc-ipamd.sock" + SocketPath = "/run/cni-vpc-ipamd.sock" + SocketTarget = "unix:" + SocketPath UHostMasterInterface = "eth0" UPHostMasterInterface = "net1" CNIVpcDbName = "cni-vpc-network" @@ -109,8 +110,8 @@ func Start() error { go cleanUpOnTermination(server, ipd) - if pathExist(IpamdServiceSocket) { - os.Remove(IpamdServiceSocket) + if pathExist(SocketPath) { + os.Remove(SocketPath) } go ipd.ipPoolWatermarkManager() @@ -127,7 +128,7 @@ func Start() error { }() } - socketListenr, err := net.Listen("unix", IpamdServiceSocket) + socketListenr, err := net.Listen("unix", SocketPath) klog.Flush() if err != nil { klog.Fatalf("listen socket: %v", err) @@ -140,7 +141,7 @@ func Start() error { errChan := make(chan error) go func() { - klog.Infof("Start to serve socket: %s", IpamdServiceSocket) + klog.Infof("Start to serve socket: %s", SocketPath) err = server.Serve(socketListenr) errChan <- err }() diff --git a/rpc/ipamd.pb.go b/rpc/ipamd.pb.go index 5fb4239..05661a7 100644 --- a/rpc/ipamd.pb.go +++ b/rpc/ipamd.pb.go @@ -1016,6 +1016,184 @@ func (x *BorrowIPResponse) GetIP() *PodNetwork { return nil } +type StatusRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *StatusRequest) Reset() { + *x = StatusRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_ipamd_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StatusRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StatusRequest) ProtoMessage() {} + +func (x *StatusRequest) ProtoReflect() protoreflect.Message { + mi := &file_rpc_ipamd_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StatusRequest.ProtoReflect.Descriptor instead. +func (*StatusRequest) Descriptor() ([]byte, []int) { + return file_rpc_ipamd_proto_rawDescGZIP(), []int{15} +} + +type StatusResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code CNIErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=rpc.CNIErrorCode" json:"Code,omitempty"` + Pool []string `protobuf:"bytes,2,rep,name=pool,proto3" json:"pool,omitempty"` +} + +func (x *StatusResponse) Reset() { + *x = StatusResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_ipamd_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StatusResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StatusResponse) ProtoMessage() {} + +func (x *StatusResponse) ProtoReflect() protoreflect.Message { + mi := &file_rpc_ipamd_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StatusResponse.ProtoReflect.Descriptor instead. +func (*StatusResponse) Descriptor() ([]byte, []int) { + return file_rpc_ipamd_proto_rawDescGZIP(), []int{16} +} + +func (x *StatusResponse) GetCode() CNIErrorCode { + if x != nil { + return x.Code + } + return CNIErrorCode_CNISuccess +} + +func (x *StatusResponse) GetPool() []string { + if x != nil { + return x.Pool + } + return nil +} + +type CleanRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *CleanRequest) Reset() { + *x = CleanRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_ipamd_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CleanRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CleanRequest) ProtoMessage() {} + +func (x *CleanRequest) ProtoReflect() protoreflect.Message { + mi := &file_rpc_ipamd_proto_msgTypes[17] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CleanRequest.ProtoReflect.Descriptor instead. +func (*CleanRequest) Descriptor() ([]byte, []int) { + return file_rpc_ipamd_proto_rawDescGZIP(), []int{17} +} + +type CleanResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Count int32 `protobuf:"varint,1,opt,name=Count,proto3" json:"Count,omitempty"` +} + +func (x *CleanResponse) Reset() { + *x = CleanResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_ipamd_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CleanResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CleanResponse) ProtoMessage() {} + +func (x *CleanResponse) ProtoReflect() protoreflect.Message { + mi := &file_rpc_ipamd_proto_msgTypes[18] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CleanResponse.ProtoReflect.Descriptor instead. +func (*CleanResponse) Descriptor() ([]byte, []int) { + return file_rpc_ipamd_proto_rawDescGZIP(), []int{18} +} + +func (x *CleanResponse) GetCount() int32 { + if x != nil { + return x.Count + } + return 0 +} + var File_rpc_ipamd_proto protoreflect.FileDescriptor var file_rpc_ipamd_proto_rawDesc = []byte{ @@ -1121,68 +1299,84 @@ var file_rpc_ipamd_proto_rawDesc = []byte{ 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1f, 0x0a, 0x02, 0x49, 0x50, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x02, 0x49, 0x50, - 0x2a, 0xad, 0x03, 0x0a, 0x0c, 0x43, 0x4e, 0x49, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, - 0x65, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x4e, 0x49, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, - 0x00, 0x12, 0x19, 0x0a, 0x14, 0x43, 0x4e, 0x49, 0x4d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x50, - 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x10, 0xe9, 0x07, 0x12, 0x22, 0x0a, 0x1d, - 0x43, 0x4e, 0x49, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x53, 0x65, 0x63, 0x6f, 0x6e, - 0x64, 0x61, 0x72, 0x79, 0x49, 0x50, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, 0xea, 0x07, - 0x12, 0x21, 0x0a, 0x1c, 0x43, 0x4e, 0x49, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x53, 0x65, - 0x63, 0x6f, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x49, 0x50, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, - 0x10, 0xeb, 0x07, 0x12, 0x1a, 0x0a, 0x15, 0x43, 0x4e, 0x49, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, - 0x74, 0x65, 0x45, 0x49, 0x50, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, 0xec, 0x07, 0x12, - 0x19, 0x0a, 0x14, 0x43, 0x4e, 0x49, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x45, 0x49, 0x50, - 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, 0xed, 0x07, 0x12, 0x16, 0x0a, 0x11, 0x43, 0x4e, - 0x49, 0x42, 0x69, 0x6e, 0x64, 0x45, 0x49, 0x50, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, - 0xee, 0x07, 0x12, 0x18, 0x0a, 0x13, 0x43, 0x4e, 0x49, 0x55, 0x6e, 0x62, 0x69, 0x6e, 0x64, 0x45, - 0x49, 0x50, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, 0xef, 0x07, 0x12, 0x1a, 0x0a, 0x15, - 0x43, 0x4e, 0x49, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x55, 0x4e, 0x49, 0x46, 0x61, - 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, 0xf0, 0x07, 0x12, 0x19, 0x0a, 0x14, 0x43, 0x4e, 0x49, 0x52, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x55, 0x4e, 0x49, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, - 0x10, 0xf1, 0x07, 0x12, 0x18, 0x0a, 0x13, 0x43, 0x4e, 0x49, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, - 0x55, 0x4e, 0x49, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, 0xf2, 0x07, 0x12, 0x18, 0x0a, - 0x13, 0x43, 0x4e, 0x49, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x55, 0x4e, 0x49, 0x46, 0x61, 0x69, - 0x6c, 0x75, 0x72, 0x65, 0x10, 0xf3, 0x07, 0x12, 0x13, 0x0a, 0x0e, 0x43, 0x4e, 0x49, 0x4b, 0x38, - 0x53, 0x41, 0x50, 0x49, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0xf4, 0x07, 0x12, 0x14, 0x0a, 0x0f, - 0x43, 0x4e, 0x49, 0x57, 0x72, 0x69, 0x74, 0x65, 0x44, 0x42, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, - 0xf5, 0x07, 0x12, 0x13, 0x0a, 0x0e, 0x43, 0x4e, 0x49, 0x52, 0x65, 0x61, 0x64, 0x44, 0x42, 0x45, - 0x72, 0x72, 0x6f, 0x72, 0x10, 0xf6, 0x07, 0x12, 0x17, 0x0a, 0x12, 0x43, 0x4e, 0x49, 0x42, 0x6f, - 0x72, 0x72, 0x6f, 0x77, 0x49, 0x50, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, 0xf7, 0x07, - 0x32, 0x9b, 0x04, 0x0a, 0x07, 0x43, 0x4e, 0x49, 0x49, 0x70, 0x61, 0x6d, 0x12, 0x2d, 0x0a, 0x04, - 0x50, 0x69, 0x6e, 0x67, 0x12, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x50, 0x69, 0x6e, - 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x0d, 0x41, - 0x64, 0x64, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x19, 0x2e, 0x72, + 0x22, 0x0f, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x22, 0x4b, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x11, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x4e, 0x49, 0x45, 0x72, 0x72, 0x6f, 0x72, + 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, + 0x6f, 0x6c, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x70, 0x6f, 0x6f, 0x6c, 0x22, 0x0e, + 0x0a, 0x0c, 0x43, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x25, + 0x0a, 0x0d, 0x43, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x14, 0x0a, 0x05, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, + 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x2a, 0xad, 0x03, 0x0a, 0x0c, 0x43, 0x4e, 0x49, 0x45, 0x72, 0x72, + 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x4e, 0x49, 0x53, 0x75, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x14, 0x43, 0x4e, 0x49, 0x4d, 0x69, 0x73, + 0x73, 0x69, 0x6e, 0x67, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x10, 0xe9, + 0x07, 0x12, 0x22, 0x0a, 0x1d, 0x43, 0x4e, 0x49, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, + 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x49, 0x50, 0x46, 0x61, 0x69, 0x6c, 0x75, + 0x72, 0x65, 0x10, 0xea, 0x07, 0x12, 0x21, 0x0a, 0x1c, 0x43, 0x4e, 0x49, 0x52, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x49, 0x50, 0x46, 0x61, + 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, 0xeb, 0x07, 0x12, 0x1a, 0x0a, 0x15, 0x43, 0x4e, 0x49, 0x41, + 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x45, 0x49, 0x50, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, + 0x65, 0x10, 0xec, 0x07, 0x12, 0x19, 0x0a, 0x14, 0x43, 0x4e, 0x49, 0x52, 0x65, 0x6c, 0x65, 0x61, + 0x73, 0x65, 0x45, 0x49, 0x50, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, 0xed, 0x07, 0x12, + 0x16, 0x0a, 0x11, 0x43, 0x4e, 0x49, 0x42, 0x69, 0x6e, 0x64, 0x45, 0x49, 0x50, 0x46, 0x61, 0x69, + 0x6c, 0x75, 0x72, 0x65, 0x10, 0xee, 0x07, 0x12, 0x18, 0x0a, 0x13, 0x43, 0x4e, 0x49, 0x55, 0x6e, + 0x62, 0x69, 0x6e, 0x64, 0x45, 0x49, 0x50, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, 0xef, + 0x07, 0x12, 0x1a, 0x0a, 0x15, 0x43, 0x4e, 0x49, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, + 0x55, 0x4e, 0x49, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, 0xf0, 0x07, 0x12, 0x19, 0x0a, + 0x14, 0x43, 0x4e, 0x49, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x55, 0x4e, 0x49, 0x46, 0x61, + 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, 0xf1, 0x07, 0x12, 0x18, 0x0a, 0x13, 0x43, 0x4e, 0x49, 0x41, + 0x74, 0x74, 0x61, 0x63, 0x68, 0x55, 0x4e, 0x49, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, + 0xf2, 0x07, 0x12, 0x18, 0x0a, 0x13, 0x43, 0x4e, 0x49, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x55, + 0x4e, 0x49, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x10, 0xf3, 0x07, 0x12, 0x13, 0x0a, 0x0e, + 0x43, 0x4e, 0x49, 0x4b, 0x38, 0x53, 0x41, 0x50, 0x49, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0xf4, + 0x07, 0x12, 0x14, 0x0a, 0x0f, 0x43, 0x4e, 0x49, 0x57, 0x72, 0x69, 0x74, 0x65, 0x44, 0x42, 0x45, + 0x72, 0x72, 0x6f, 0x72, 0x10, 0xf5, 0x07, 0x12, 0x13, 0x0a, 0x0e, 0x43, 0x4e, 0x49, 0x52, 0x65, + 0x61, 0x64, 0x44, 0x42, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0xf6, 0x07, 0x12, 0x17, 0x0a, 0x12, + 0x43, 0x4e, 0x49, 0x42, 0x6f, 0x72, 0x72, 0x6f, 0x77, 0x49, 0x50, 0x46, 0x61, 0x69, 0x6c, 0x75, + 0x72, 0x65, 0x10, 0xf7, 0x07, 0x32, 0x82, 0x05, 0x0a, 0x07, 0x43, 0x4e, 0x49, 0x49, 0x70, 0x61, + 0x6d, 0x12, 0x2d, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, + 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x72, 0x70, + 0x63, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x48, 0x0a, 0x0d, 0x41, 0x64, 0x64, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, + 0x6b, 0x12, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x6f, 0x64, 0x4e, 0x65, + 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x64, - 0x64, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x50, 0x6f, 0x64, 0x4e, - 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, - 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x50, 0x6f, 0x64, 0x4e, 0x65, - 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x5a, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x1f, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x64, 0x64, - 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x64, - 0x64, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, - 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5a, 0x0a, 0x13, 0x44, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x0d, 0x44, 0x65, + 0x6c, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x19, 0x2e, 0x72, 0x70, + 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, + 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x5a, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x50, 0x6f, 0x64, 0x4e, 0x65, + 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x1f, 0x2e, 0x72, 0x70, + 0x63, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, + 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x72, + 0x70, 0x63, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, + 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x5a, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, + 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x1f, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, + 0x6c, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, + 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x63, 0x6f, - 0x72, 0x64, 0x12, 0x1f, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x50, 0x6f, 0x64, 0x4e, - 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x50, 0x6f, 0x64, - 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5a, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x50, 0x6f, - 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x1f, - 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, - 0x72, 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x20, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, - 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x12, 0x39, 0x0a, 0x08, 0x42, 0x6f, 0x72, 0x72, 0x6f, 0x77, 0x49, 0x50, 0x12, - 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x42, 0x6f, 0x72, 0x72, 0x6f, 0x77, 0x49, 0x50, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x42, 0x6f, 0x72, 0x72, - 0x6f, 0x77, 0x49, 0x50, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x08, - 0x5a, 0x06, 0x2e, 0x2f, 0x3b, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5a, 0x0a, 0x13, + 0x47, 0x65, 0x74, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x63, + 0x6f, 0x72, 0x64, 0x12, 0x1f, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x64, + 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6f, + 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x39, 0x0a, 0x08, 0x42, 0x6f, 0x72, 0x72, + 0x6f, 0x77, 0x49, 0x50, 0x12, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x42, 0x6f, 0x72, 0x72, 0x6f, + 0x77, 0x49, 0x50, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x72, 0x70, 0x63, + 0x2e, 0x42, 0x6f, 0x72, 0x72, 0x6f, 0x77, 0x49, 0x50, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x33, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x2e, + 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x30, 0x0a, 0x05, 0x43, 0x6c, 0x65, 0x61, + 0x6e, 0x12, 0x11, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6c, 0x65, 0x61, 0x6e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2f, + 0x3b, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1198,7 +1392,7 @@ func file_rpc_ipamd_proto_rawDescGZIP() []byte { } var file_rpc_ipamd_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_rpc_ipamd_proto_msgTypes = make([]protoimpl.MessageInfo, 15) +var file_rpc_ipamd_proto_msgTypes = make([]protoimpl.MessageInfo, 19) var file_rpc_ipamd_proto_goTypes = []interface{}{ (CNIErrorCode)(0), // 0: rpc.CNIErrorCode (*PingRequest)(nil), // 1: rpc.PingRequest @@ -1216,6 +1410,10 @@ var file_rpc_ipamd_proto_goTypes = []interface{}{ (*PodNetwork)(nil), // 13: rpc.PodNetwork (*BorrowIPRequest)(nil), // 14: rpc.BorrowIPRequest (*BorrowIPResponse)(nil), // 15: rpc.BorrowIPResponse + (*StatusRequest)(nil), // 16: rpc.StatusRequest + (*StatusResponse)(nil), // 17: rpc.StatusResponse + (*CleanRequest)(nil), // 18: rpc.CleanRequest + (*CleanResponse)(nil), // 19: rpc.CleanResponse } var file_rpc_ipamd_proto_depIdxs = []int32{ 0, // 0: rpc.AddPodNetworkResponse.Code:type_name -> rpc.CNIErrorCode @@ -1229,25 +1427,30 @@ var file_rpc_ipamd_proto_depIdxs = []int32{ 13, // 8: rpc.GetPodNetworkRecordResponse.PodNetwork:type_name -> rpc.PodNetwork 0, // 9: rpc.BorrowIPResponse.Code:type_name -> rpc.CNIErrorCode 13, // 10: rpc.BorrowIPResponse.IP:type_name -> rpc.PodNetwork - 1, // 11: rpc.CNIIpam.Ping:input_type -> rpc.PingRequest - 3, // 12: rpc.CNIIpam.AddPodNetwork:input_type -> rpc.AddPodNetworkRequest - 5, // 13: rpc.CNIIpam.DelPodNetwork:input_type -> rpc.DelPodNetworkRequest - 7, // 14: rpc.CNIIpam.AddPodNetworkRecord:input_type -> rpc.AddPodNetworkRecordRequest - 9, // 15: rpc.CNIIpam.DelPodNetworkRecord:input_type -> rpc.DelPodNetworkRecordRequest - 11, // 16: rpc.CNIIpam.GetPodNetworkRecord:input_type -> rpc.GetPodNetworkRecordRequest - 14, // 17: rpc.CNIIpam.BorrowIP:input_type -> rpc.BorrowIPRequest - 2, // 18: rpc.CNIIpam.Ping:output_type -> rpc.PingResponse - 4, // 19: rpc.CNIIpam.AddPodNetwork:output_type -> rpc.AddPodNetworkResponse - 6, // 20: rpc.CNIIpam.DelPodNetwork:output_type -> rpc.DelPodNetworkResponse - 8, // 21: rpc.CNIIpam.AddPodNetworkRecord:output_type -> rpc.AddPodNetworkRecordResponse - 10, // 22: rpc.CNIIpam.DelPodNetworkRecord:output_type -> rpc.DelPodNetworkRecordResponse - 12, // 23: rpc.CNIIpam.GetPodNetworkRecord:output_type -> rpc.GetPodNetworkRecordResponse - 15, // 24: rpc.CNIIpam.BorrowIP:output_type -> rpc.BorrowIPResponse - 18, // [18:25] is the sub-list for method output_type - 11, // [11:18] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name + 0, // 11: rpc.StatusResponse.Code:type_name -> rpc.CNIErrorCode + 1, // 12: rpc.CNIIpam.Ping:input_type -> rpc.PingRequest + 3, // 13: rpc.CNIIpam.AddPodNetwork:input_type -> rpc.AddPodNetworkRequest + 5, // 14: rpc.CNIIpam.DelPodNetwork:input_type -> rpc.DelPodNetworkRequest + 7, // 15: rpc.CNIIpam.AddPodNetworkRecord:input_type -> rpc.AddPodNetworkRecordRequest + 9, // 16: rpc.CNIIpam.DelPodNetworkRecord:input_type -> rpc.DelPodNetworkRecordRequest + 11, // 17: rpc.CNIIpam.GetPodNetworkRecord:input_type -> rpc.GetPodNetworkRecordRequest + 14, // 18: rpc.CNIIpam.BorrowIP:input_type -> rpc.BorrowIPRequest + 16, // 19: rpc.CNIIpam.Status:input_type -> rpc.StatusRequest + 18, // 20: rpc.CNIIpam.Clean:input_type -> rpc.CleanRequest + 2, // 21: rpc.CNIIpam.Ping:output_type -> rpc.PingResponse + 4, // 22: rpc.CNIIpam.AddPodNetwork:output_type -> rpc.AddPodNetworkResponse + 6, // 23: rpc.CNIIpam.DelPodNetwork:output_type -> rpc.DelPodNetworkResponse + 8, // 24: rpc.CNIIpam.AddPodNetworkRecord:output_type -> rpc.AddPodNetworkRecordResponse + 10, // 25: rpc.CNIIpam.DelPodNetworkRecord:output_type -> rpc.DelPodNetworkRecordResponse + 12, // 26: rpc.CNIIpam.GetPodNetworkRecord:output_type -> rpc.GetPodNetworkRecordResponse + 15, // 27: rpc.CNIIpam.BorrowIP:output_type -> rpc.BorrowIPResponse + 17, // 28: rpc.CNIIpam.Status:output_type -> rpc.StatusResponse + 19, // 29: rpc.CNIIpam.Clean:output_type -> rpc.CleanResponse + 21, // [21:30] is the sub-list for method output_type + 12, // [12:21] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name } func init() { file_rpc_ipamd_proto_init() } @@ -1436,6 +1639,54 @@ func file_rpc_ipamd_proto_init() { return nil } } + file_rpc_ipamd_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StatusRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_ipamd_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StatusResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_ipamd_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CleanRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_ipamd_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CleanResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -1443,7 +1694,7 @@ func file_rpc_ipamd_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_rpc_ipamd_proto_rawDesc, NumEnums: 1, - NumMessages: 15, + NumMessages: 19, NumExtensions: 0, NumServices: 1, }, @@ -1477,6 +1728,8 @@ type CNIIpamClient interface { DelPodNetworkRecord(ctx context.Context, in *DelPodNetworkRecordRequest, opts ...grpc.CallOption) (*DelPodNetworkRecordResponse, error) GetPodNetworkRecord(ctx context.Context, in *GetPodNetworkRecordRequest, opts ...grpc.CallOption) (*GetPodNetworkRecordResponse, error) BorrowIP(ctx context.Context, in *BorrowIPRequest, opts ...grpc.CallOption) (*BorrowIPResponse, error) + Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) + Clean(ctx context.Context, in *CleanRequest, opts ...grpc.CallOption) (*CleanResponse, error) } type cNIIpamClient struct { @@ -1550,6 +1803,24 @@ func (c *cNIIpamClient) BorrowIP(ctx context.Context, in *BorrowIPRequest, opts return out, nil } +func (c *cNIIpamClient) Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) { + out := new(StatusResponse) + err := c.cc.Invoke(ctx, "/rpc.CNIIpam/Status", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *cNIIpamClient) Clean(ctx context.Context, in *CleanRequest, opts ...grpc.CallOption) (*CleanResponse, error) { + out := new(CleanResponse) + err := c.cc.Invoke(ctx, "/rpc.CNIIpam/Clean", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // CNIIpamServer is the server API for CNIIpam service. type CNIIpamServer interface { Ping(context.Context, *PingRequest) (*PingResponse, error) @@ -1559,6 +1830,8 @@ type CNIIpamServer interface { DelPodNetworkRecord(context.Context, *DelPodNetworkRecordRequest) (*DelPodNetworkRecordResponse, error) GetPodNetworkRecord(context.Context, *GetPodNetworkRecordRequest) (*GetPodNetworkRecordResponse, error) BorrowIP(context.Context, *BorrowIPRequest) (*BorrowIPResponse, error) + Status(context.Context, *StatusRequest) (*StatusResponse, error) + Clean(context.Context, *CleanRequest) (*CleanResponse, error) } // UnimplementedCNIIpamServer can be embedded to have forward compatible implementations. @@ -1586,6 +1859,12 @@ func (*UnimplementedCNIIpamServer) GetPodNetworkRecord(context.Context, *GetPodN func (*UnimplementedCNIIpamServer) BorrowIP(context.Context, *BorrowIPRequest) (*BorrowIPResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method BorrowIP not implemented") } +func (*UnimplementedCNIIpamServer) Status(context.Context, *StatusRequest) (*StatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Status not implemented") +} +func (*UnimplementedCNIIpamServer) Clean(context.Context, *CleanRequest) (*CleanResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Clean not implemented") +} func RegisterCNIIpamServer(s *grpc.Server, srv CNIIpamServer) { s.RegisterService(&_CNIIpam_serviceDesc, srv) @@ -1717,6 +1996,42 @@ func _CNIIpam_BorrowIP_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _CNIIpam_Status_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StatusRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CNIIpamServer).Status(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/rpc.CNIIpam/Status", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CNIIpamServer).Status(ctx, req.(*StatusRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _CNIIpam_Clean_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CleanRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CNIIpamServer).Clean(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/rpc.CNIIpam/Clean", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CNIIpamServer).Clean(ctx, req.(*CleanRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _CNIIpam_serviceDesc = grpc.ServiceDesc{ ServiceName: "rpc.CNIIpam", HandlerType: (*CNIIpamServer)(nil), @@ -1749,6 +2064,14 @@ var _CNIIpam_serviceDesc = grpc.ServiceDesc{ MethodName: "BorrowIP", Handler: _CNIIpam_BorrowIP_Handler, }, + { + MethodName: "Status", + Handler: _CNIIpam_Status_Handler, + }, + { + MethodName: "Clean", + Handler: _CNIIpam_Clean_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "rpc/ipamd.proto", diff --git a/rpc/ipamd.proto b/rpc/ipamd.proto index a4e92ca..62cd73c 100644 --- a/rpc/ipamd.proto +++ b/rpc/ipamd.proto @@ -12,6 +12,9 @@ service CNIIpam { rpc GetPodNetworkRecord (GetPodNetworkRecordRequest) returns (GetPodNetworkRecordResponse) {} rpc BorrowIP(BorrowIPRequest) returns (BorrowIPResponse) {} + + rpc Status(StatusRequest) returns (StatusResponse) {} + rpc Clean(CleanRequest) returns (CleanResponse) {} } message PingRequest {} @@ -98,6 +101,19 @@ message BorrowIPResponse { PodNetwork IP = 2; } +message StatusRequest {} + +message StatusResponse { + CNIErrorCode Code = 1; + repeated string pool = 2; +} + +message CleanRequest {} + +message CleanResponse { + int32 Count = 1; +} + enum CNIErrorCode { CNISuccess = 0;