Skip to content

ChenXie-sci/k8s-cni

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#k8s-cni-test

IPIP mode test method

  1. It is best to have a clean k8s environment without any network plug-ins installed.

// Create a new file ending with .conf in the /etc/cni/net.d/ directory and enter the following configuration items
{
  "cniVersion": "0.3.0",
  "name": "testcni",
  "type": "testcni",
  "mode": "ipip",
  "subnet": "10.244.0.0/16"
}
# Execute in the project root directory
make build_main
  1. A main will be generated at this time

  2. Go to https://github.com/projectcalico/bird clone project

  3. Execution

# Compile calico's bird
# After compilation, there will be a bird binary in the dist directory
ARCH=<your computer architecture> ./build.sh
  1. Create the /opt/testcni directory and copy the bird binary above to here

  2. Copy the main binary generated in the third step to /opt/cni/bin/testcni

mv main /opt/cni/bin/testcni





vxlan mode test method

  1. It is best to have a clean k8s environment without any network plug-ins installed.

// Create a new file ending with .conf in the /etc/cni/net.d/ directory and enter the following configuration items
{
  "cniVersion": "0.3.0",
  "name": "testcni",
  "type": "testcni",
  "mode": "vxlan",
  "subnet": "10.244.0.0"
}
# Execute in the project root directory
make build
  1. A binary file named testcni will be generated. Three ebpf files will be generated at the same time. These three ebpf files will be automatically copied to the “/opt/testcni/” directory. If this directory does not exist, you can create it manually.

  2. Copy the testcni generated in the previous step to the "/opt/cni/bin" directory






IPVlan & MACVlan mode test method

  1. It is best to have a clean k8s environment without any network plug-ins installed.

//Create a new file ending with .conf in the /etc/cni/net.d/ directory of each node and enter the following configuration items
// Note that the range in "subnet" and "ipam" needs to be manually changed to your own environment. In addition, each node of the range should be configured to a different range.
{
  "cniVersion": "0.3.0",
  "name": "testcni",
  "type": "testcni",
  "mode": "ipvlan",
  "subnet": "192.168.64.0/24",
  "ipam": {
    "rangeStart": "192.168.64.90",
    "rangeEnd": "192.168.64.100"
  }
}

2. 
```bash
# Execute in the project root directory
make build_main
  1. At this time, a main binary will be generated, and the binary will be copied to /opt/cni/bin/testcni
mv main /opt/cni/bin/testcni





host-gw mode test method

// Create a new file ending with .conf in the /etc/cni/net.d/ directory and enter the following configuration items
{
  "cniVersion": "0.3.0",
  "name": "testcni",
  "type": "testcni",
  "bridge": "testcni0",
  "subnet": "10.244.0.0/16"
}
  1. Change the IP address used to initialize the etcd client under /etcd/client.go to the etcd address of your own cluster.
  2. go build main.go
  3. mv main /opt/cni/bin/testcni
  4. Repeat the above three steps on each host.
  5. kubectl apply -f test-busybox.yaml
  6. Check cluster pod status



Test without k8s cluster

  1. Testing can be done through main_test.go in the /test directory
  2. Before testing, create a command space using ip netns add test.net.1
  3. Then go test ./test/main_test.go -v
  4. Then perform the same steps on other nodes.
  5. ip netns exec test.net.1 ping the network card ip under ns on another node



Use the cnitool test provided by the k8s cni repo

  1. Switch to the test/cni-test branch
  2. Enter the ./cnitool directory
  3. go build cnitool.go
  4. ip netns add test.net.1 creates a net ns
  5. Create the same configuration as above in the /etc/cni/net.d/ directory
  6. ./cnitool add testcni /run/netns/test.net.1



Problems and troubleshooting

Troubleshooting methods when encountering problems

  1. View kubelet logs through journalctl -xeu kubelet -f command
  2. Modify the log output address in the ./utils/write_log.go file. Key error messages will be automatically sent to this address.

Problems you may encounter:

  1. If the compiled main.go has been copied to /opt/cni/bin/testcni but kubelet still reports an error like "not found", try adding "export CNI_PATH=/ to the environment variable opt/cni/bin"
  2. If the kubelet log shows something like "the configuration file contains illegal characters", check whether any logs are output directly to the standard output using fmt in all codes. cni reads the configuration through the standard output, so if there is any illegal Configuration related information is output, it will definitely be gg



About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages