openstack-cni is a CNI plugin that provides the ability to dynamically configure Openstack Neutron Ports and attach them to Pod containers.
Configuration is achieved by created NetworkAttachmentDefinitions and referencing them with Pod Annotations.
Such configuration allows the implementer to configure a port for any OpenStack network and attach it to any Pod.
These sequence diagrams show the workflow and relationship between kubelet, multus, openstack-cni and openstack-cni-daemon.
- Ensure that multus-cni is installed
- Add the required secret.
For example:
---
apiVersion: v1
kind: Secret
metadata:
name: openstack-cni-secret
namespace: mynamespace
type: Opaque
stringData:
OS_PASSWORD: SECRETPASSWORD
- Create a helm values file (example)
- Run helm (
helm upgrade openstack-cni helm/ --install) - Create a pod with the proper annotations.
For example:
apiVersion: v1
kind: Pod
metadata:
annotations:
k8s.v1.cni.cncf.io/networks: '[{"name": "mycloud-network1", "interface": "ens37"},{"name": "mycloud-network2", "interface": "ens42"}]'
name: dummypod
namespace: mynamespace
...
The spec.config portion of the NetworkAttachmentDefinition should contain the following configuration:
cniVersionis requiredtypeis required and must beopenstack-cninetworkis requiredproject_nameis optional, but required ifsubnet_nameis specifiedsubnet_nameis optionalsecurity_groupsis optional
spec:
config: '{
"cniVersion": "0.3.1",
"type": "openstack-cni",
"name": "service-ingress",
"network": "my-openstack-network",
"project_name": "my-openstack-project-name",
"subnet_name": "my-openstack-subnet",
"security_groups": ["project_default", "default"],
}'
In order to run the full test suite valid OpenStack credentials must be present in the environment.
testing.conf will be sourced if present.
The following enviroment variables an be used to control the tests.
OS_TESTS="1" ## 0 = skip openstack tests 1 = execute openstack tests
CNI_CONFIG_FILE="../../config.conf" # path to the main config file
OS_VM_NAME="mytestvm"
OS_NETWORK_NAME="myproject-network"
OS_PORT_NAME="mytestport"
OS_PROJECT_NAME="myproject"
OS_SUBNET_NAME="myproject-subnet"
OS_SECURITY_GROUPS="default;project_default"
GET /health- returns the health of the server including whether OpenStack authentication is workingGET /ping- returns "PONG"POST /cni- handlesADD/DEL/CHECKCNI commands
-
OS_PROJECT_NAME- required -
CNI_API_URL- urlopenstack-cniwill used to contactopenstack-cni-daemon. Also overridesopenstack-cni-daemon's listen address (http://127.0.0.1:4242) -
CNI_CACHE_TTL- cache ttl (300s) -
CNI_CONFIG_FILE- configuration fileopenstack-cnireads (/etc/cni/net.d/openstack-cni.conf) -
CNI_MIN_PORT_AGE- minimum age of ports to be cleaned up (300s) -
CNI_READ_TIMEOUT- http server read timeout (10s) -
CNI_REAP_INTERVAL- the port cleanup interval (300s) -
CNI_REQUEST_TIMEOUT-openstack-cni's request timeout in seconds (60) -
CNI_WRITE_TIMEOUT- http server write timeout (10s) -
OS_REGION_NAME- OpenStack region (RegionOne)
The following vars control the test that interact directly with the OpenStack APIs
OS_TESTS-0= skip OpenStack tests1= perform OpenStack testsOS_PROJECT_NAME- required whenOS_TESTS=1OS_NETWORK_NAME- required whenOS_TESTS=1OS_SECURITY_GROUPS- required whenOS_TESTS=1OS_SUBNET_NAME- required whenOS_TESTS=1OS_PORT_NAME- optionally override the port nameOS_VM_NAME- optionally tell the OpenStack tests to use a hostname other thanos.Hostname()
For local testing, configuration and secrets can be loaded from config.conf or secrets.conf.