mirror of
https://github.com/k8snetworkplumbingwg/multus-cni.git
synced 2025-08-16 15:25:15 +00:00
Update kubernetes.cni.cncf.io -> k8s.cni.cncf.io
This commit is contained in:
parent
6e440b4fa8
commit
a4567df76a
28
README.md
28
README.md
@ -90,9 +90,9 @@ Multus is compatible to work with both CRD and TPR(deprecated in K8s 1.7).
|
|||||||
apiVersion: apiextensions.k8s.io/v1beta1
|
apiVersion: apiextensions.k8s.io/v1beta1
|
||||||
kind: CustomResourceDefinition
|
kind: CustomResourceDefinition
|
||||||
metadata:
|
metadata:
|
||||||
name: network-attachment-definitions.kubernetes.cni.cncf.io
|
name: network-attachment-definitions.k8s.cni.cncf.io
|
||||||
spec:
|
spec:
|
||||||
group: kubernetes.cni.cncf.io
|
group: k8s.cni.cncf.io
|
||||||
version: v1
|
version: v1
|
||||||
scope: Namespaced
|
scope: Namespaced
|
||||||
names:
|
names:
|
||||||
@ -112,19 +112,19 @@ spec:
|
|||||||
2. Run kubectl create command for the Custom Resource Definition
|
2. Run kubectl create command for the Custom Resource Definition
|
||||||
```
|
```
|
||||||
# kubectl create -f ./crdnetwork.yaml
|
# kubectl create -f ./crdnetwork.yaml
|
||||||
customresourcedefinition "networks.kubernetes.cni.cncf.io" created
|
customresourcedefinition "network-attachment-definitions.k8s.cni.cncf.io" created
|
||||||
```
|
```
|
||||||
3. Run kubectl get command to check the Network CRD creation
|
3. Run kubectl get command to check the Network CRD creation
|
||||||
```
|
```
|
||||||
# kubectl get CustomResourceDefinition
|
# kubectl get CustomResourceDefinition
|
||||||
NAME KIND
|
NAME KIND
|
||||||
networks.kubernetes.cni.cncf.io CustomResourceDefinition.v1beta1.apiextensions.k8s.io
|
network-attachment-definitions.k8s.cni.cncf.io CustomResourceDefinition.v1beta1.apiextensions.k8s.io
|
||||||
```
|
```
|
||||||
For Kubernetes v1.7 and above use CRD to create network object. For version older than 1.7 use TPR based objects as shown below:
|
For Kubernetes v1.7 and above use CRD to create network object. For version older than 1.7 use TPR based objects as shown below:
|
||||||
|
|
||||||
Note: Both TPR and CRD will have same selfLink :
|
Note: Both TPR and CRD will have same selfLink :
|
||||||
|
|
||||||
*/apis/kubernetes.cni.cncf.io/v1/namespaces/default/networks/*
|
*/apis/k8s.cni.cncf.io/v1/namespaces/default/network-attachment-definitions/*
|
||||||
|
|
||||||
|
|
||||||
#### TPR based Network objects
|
#### TPR based Network objects
|
||||||
@ -135,7 +135,7 @@ Note: Both TPR and CRD will have same selfLink :
|
|||||||
apiVersion: extensions/v1beta1
|
apiVersion: extensions/v1beta1
|
||||||
kind: ThirdPartyResource
|
kind: ThirdPartyResource
|
||||||
metadata:
|
metadata:
|
||||||
name: network.kubernetes.cni.cncf.io
|
name: network-attachment-definition.k8s.cni.cncf.io
|
||||||
description: "A specification of a Network obj in the kubernetes"
|
description: "A specification of a Network obj in the kubernetes"
|
||||||
versions:
|
versions:
|
||||||
- name: v1
|
- name: v1
|
||||||
@ -145,13 +145,13 @@ versions:
|
|||||||
|
|
||||||
```
|
```
|
||||||
# kubectl create -f ./tprnetwork.yaml
|
# kubectl create -f ./tprnetwork.yaml
|
||||||
thirdpartyresource "network.kubernetes.cni.cncf.io" created
|
thirdpartyresource "network-attachment-definition.k8s.cni.cncf.io" created
|
||||||
```
|
```
|
||||||
3. Run kubectl get command to check the Network TPR creation
|
3. Run kubectl get command to check the Network TPR creation
|
||||||
```
|
```
|
||||||
# kubectl get thirdpartyresource
|
# kubectl get thirdpartyresource
|
||||||
NAME DESCRIPTION VERSION(S)
|
NAME DESCRIPTION VERSION(S)
|
||||||
network.kubernetes.cni.cncf.io A specification of a Network obj in the kubernetes v1
|
network-attachment-definition.k8s.cni.cncf.io A specification of a Network obj in the kubernetes v1
|
||||||
```
|
```
|
||||||
### Creating network resources in Kubernetes
|
### Creating network resources in Kubernetes
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ network.kubernetes.cni.cncf.io A specification of a Network obj in the kuberne
|
|||||||
2. Save the following YAML to flannel-network.yaml
|
2. Save the following YAML to flannel-network.yaml
|
||||||
|
|
||||||
```
|
```
|
||||||
apiVersion: "kubernetes.cni.cncf.io/v1"
|
apiVersion: "k8s.cni.cncf.io/v1"
|
||||||
kind: NetworkAttachmentDefinition
|
kind: NetworkAttachmentDefinition
|
||||||
metadata:
|
metadata:
|
||||||
name: flannel-networkobj
|
name: flannel-networkobj
|
||||||
@ -187,7 +187,7 @@ flannel-networkobj 26s
|
|||||||
```
|
```
|
||||||
4. Get the custom network object details
|
4. Get the custom network object details
|
||||||
```
|
```
|
||||||
apiVersion: kubernetes.cni.cncf.io/v1
|
apiVersion: k8s.cni.cncf.io/v1
|
||||||
kind: NetworkAttachmentDefinition
|
kind: NetworkAttachmentDefinition
|
||||||
metadata:
|
metadata:
|
||||||
clusterName: ""
|
clusterName: ""
|
||||||
@ -198,7 +198,7 @@ metadata:
|
|||||||
name: flannel-networkobj
|
name: flannel-networkobj
|
||||||
namespace: default
|
namespace: default
|
||||||
resourceVersion: "21176114"
|
resourceVersion: "21176114"
|
||||||
selfLink: /apis/kubernetes.cni.cncf.io/v1/namespaces/default/networks/flannel-networkobj
|
selfLink: /apis/k8s.cni.cncf.io/v1/namespaces/default/networks/flannel-networkobj
|
||||||
uid: 8ac8f873-59b2-11e8-8308-a4bf01024e6f
|
uid: 8ac8f873-59b2-11e8-8308-a4bf01024e6f
|
||||||
spec:
|
spec:
|
||||||
config: '{ "cniVersion": "0.3.0", "type": "flannel", "delegate": { "isDefaultGateway":
|
config: '{ "cniVersion": "0.3.0", "type": "flannel", "delegate": { "isDefaultGateway":
|
||||||
@ -206,7 +206,7 @@ spec:
|
|||||||
```
|
```
|
||||||
5. Save the following YAML to sriov-network.yaml to creating sriov network object. ( Refer to [Intel - SR-IOV CNI](https://github.com/Intel-Corp/sriov-cni) or contact @kural in [Intel-Corp Slack](https://intel-corp.herokuapp.com/) for running the DPDK based workloads in Kubernetes)
|
5. Save the following YAML to sriov-network.yaml to creating sriov network object. ( Refer to [Intel - SR-IOV CNI](https://github.com/Intel-Corp/sriov-cni) or contact @kural in [Intel-Corp Slack](https://intel-corp.herokuapp.com/) for running the DPDK based workloads in Kubernetes)
|
||||||
```
|
```
|
||||||
apiVersion: "kubernetes.cni.cncf.io/v1"
|
apiVersion: "k8s.cni.cncf.io/v1"
|
||||||
kind: NetworkAttachmentDefinition
|
kind: NetworkAttachmentDefinition
|
||||||
metadata:
|
metadata:
|
||||||
name: sriov-conf
|
name: sriov-conf
|
||||||
@ -229,7 +229,7 @@ spec:
|
|||||||
6. Likewise save the following YAML to sriov-vlanid-l2enable-network.yaml to create another sriov based network object:
|
6. Likewise save the following YAML to sriov-vlanid-l2enable-network.yaml to create another sriov based network object:
|
||||||
|
|
||||||
```
|
```
|
||||||
apiVersion: "kubernetes.cni.cncf.io/v1"
|
apiVersion: "k8s.cni.cncf.io/v1"
|
||||||
kind: NetworkAttachmentDefinition
|
kind: NetworkAttachmentDefinition
|
||||||
metadata:
|
metadata:
|
||||||
name: sriov-vlanid-l2enable-conf
|
name: sriov-vlanid-l2enable-conf
|
||||||
@ -296,7 +296,7 @@ kind: Pod
|
|||||||
metadata:
|
metadata:
|
||||||
name: multus-multi-net-poc
|
name: multus-multi-net-poc
|
||||||
annotations:
|
annotations:
|
||||||
kubernetes.v1.cni.cncf.io/networks: '[
|
k8s.v1.cni.cncf.io/networks: '[
|
||||||
{ "name": "flannel-conf" },
|
{ "name": "flannel-conf" },
|
||||||
{ "name": "sriov-conf" },
|
{ "name": "sriov-conf" },
|
||||||
{ "name": "sriov-vlanid-l2enable-conf",
|
{ "name": "sriov-vlanid-l2enable-conf",
|
||||||
|
@ -12,7 +12,7 @@ More specifically, these examples show:
|
|||||||
|
|
||||||
* Multus configured, using CNI a `.conf` file, with CRD support, specifying that we will use a "default network".
|
* Multus configured, using CNI a `.conf` file, with CRD support, specifying that we will use a "default network".
|
||||||
* A resource definition with a daemonset that places the `.conf` on each node in the cluster.
|
* A resource definition with a daemonset that places the `.conf` on each node in the cluster.
|
||||||
* A CRD definining the "networks" @ `networks.kubernetes.cni.cncf.io`
|
* A CRD definining the "networks" @ `network-attachment-definitions.k8s.cni.cncf.io`
|
||||||
* CRD objects containing the configuration for both Flannel & macvlan.
|
* CRD objects containing the configuration for both Flannel & macvlan.
|
||||||
|
|
||||||
## Quick-start instructions
|
## Quick-start instructions
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
apiVersion: apiextensions.k8s.io/v1beta1
|
apiVersion: apiextensions.k8s.io/v1beta1
|
||||||
kind: CustomResourceDefinition
|
kind: CustomResourceDefinition
|
||||||
metadata:
|
metadata:
|
||||||
name: network-attachment-definitions.kubernetes.cni.cncf.io
|
name: network-attachment-definitions.k8s.cni.cncf.io
|
||||||
spec:
|
spec:
|
||||||
group: kubernetes.cni.cncf.io
|
group: k8s.cni.cncf.io
|
||||||
version: v1
|
version: v1
|
||||||
scope: Namespaced
|
scope: Namespaced
|
||||||
names:
|
names:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
apiVersion: "kubernetes.cni.cncf.io/v1"
|
apiVersion: "k8s.cni.cncf.io/v1"
|
||||||
kind: NetworkAttachmentDefinition
|
kind: NetworkAttachmentDefinition
|
||||||
metadata:
|
metadata:
|
||||||
name: flannel-conf
|
name: flannel-conf
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
apiVersion: "kubernetes.cni.cncf.io/v1"
|
apiVersion: "k8s.cni.cncf.io/v1"
|
||||||
kind: NetworkAttachmentDefinition
|
kind: NetworkAttachmentDefinition
|
||||||
metadata:
|
metadata:
|
||||||
name: macvlan-conf
|
name: macvlan-conf
|
||||||
|
@ -77,7 +77,7 @@ func getPodNetworkAnnotation(client KubeClient, k8sArgs types.K8sArgs) (string,
|
|||||||
return "", "", fmt.Errorf("getPodNetworkAnnotation: failed to query the pod %v in out of cluster comm: %v", string(k8sArgs.K8S_POD_NAME), err)
|
return "", "", fmt.Errorf("getPodNetworkAnnotation: failed to query the pod %v in out of cluster comm: %v", string(k8sArgs.K8S_POD_NAME), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return pod.Annotations["kubernetes.v1.cni.cncf.io/networks"], pod.ObjectMeta.Namespace, nil
|
return pod.Annotations["k8s.v1.cni.cncf.io/networks"], pod.ObjectMeta.Namespace, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parsePodNetworkObjectName(podnetwork string) (string, string, string, error) {
|
func parsePodNetworkObjectName(podnetwork string) (string, string, string, error) {
|
||||||
@ -247,7 +247,7 @@ func cniConfigFromNetworkResource(customResource *types.NetworkAttachmentDefinit
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getKubernetesDelegate(client KubeClient, net *types.NetworkSelectionElement, confdir string) (*types.DelegateNetConf, error) {
|
func getKubernetesDelegate(client KubeClient, net *types.NetworkSelectionElement, confdir string) (*types.DelegateNetConf, error) {
|
||||||
rawPath := fmt.Sprintf("/apis/kubernetes.cni.cncf.io/v1/namespaces/%s/network-attachment-definitions/%s", net.Namespace, net.Name)
|
rawPath := fmt.Sprintf("/apis/k8s.cni.cncf.io/v1/namespaces/%s/network-attachment-definitions/%s", net.Namespace, net.Name)
|
||||||
netData, err := client.GetRawWithPath(rawPath)
|
netData, err := client.GetRawWithPath(rawPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("getKubernetesDelegate: failed to get network resource, refer Multus README.md for the usage guide: %v", err)
|
return nil, fmt.Errorf("getKubernetesDelegate: failed to get network resource, refer Multus README.md for the usage guide: %v", err)
|
||||||
|
@ -52,7 +52,7 @@ func (f *FakeKubeClient) GetRawWithPath(path string) ([]byte, error) {
|
|||||||
|
|
||||||
func (f *FakeKubeClient) AddNetConfig(namespace, name, data string) {
|
func (f *FakeKubeClient) AddNetConfig(namespace, name, data string) {
|
||||||
cr := fmt.Sprintf(`{
|
cr := fmt.Sprintf(`{
|
||||||
"apiVersion": "kubernetes.cni.cncf.io/v1",
|
"apiVersion": "k8s.cni.cncf.io/v1",
|
||||||
"kind": "Network",
|
"kind": "Network",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"namespace": "%s",
|
"namespace": "%s",
|
||||||
@ -64,19 +64,19 @@ func (f *FakeKubeClient) AddNetConfig(namespace, name, data string) {
|
|||||||
}`, namespace, name, strings.Replace(data, "\"", "\\\"", -1))
|
}`, namespace, name, strings.Replace(data, "\"", "\\\"", -1))
|
||||||
cr = strings.Replace(cr, "\n", "", -1)
|
cr = strings.Replace(cr, "\n", "", -1)
|
||||||
cr = strings.Replace(cr, "\t", "", -1)
|
cr = strings.Replace(cr, "\t", "", -1)
|
||||||
f.nets[fmt.Sprintf("/apis/kubernetes.cni.cncf.io/v1/namespaces/%s/network-attachment-definitions/%s", namespace, name)] = cr
|
f.nets[fmt.Sprintf("/apis/k8s.cni.cncf.io/v1/namespaces/%s/network-attachment-definitions/%s", namespace, name)] = cr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakeKubeClient) AddNetFile(namespace, name, filePath, fileData string) {
|
func (f *FakeKubeClient) AddNetFile(namespace, name, filePath, fileData string) {
|
||||||
cr := fmt.Sprintf(`{
|
cr := fmt.Sprintf(`{
|
||||||
"apiVersion": "kubernetes.cni.cncf.io/v1",
|
"apiVersion": "k8s.cni.cncf.io/v1",
|
||||||
"kind": "Network",
|
"kind": "Network",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"namespace": "%s",
|
"namespace": "%s",
|
||||||
"name": "%s"
|
"name": "%s"
|
||||||
}
|
}
|
||||||
}`, namespace, name)
|
}`, namespace, name)
|
||||||
f.nets[fmt.Sprintf("/apis/kubernetes.cni.cncf.io/v1/namespaces/%s/network-attachment-definitions/%s", namespace, name)] = cr
|
f.nets[fmt.Sprintf("/apis/k8s.cni.cncf.io/v1/namespaces/%s/network-attachment-definitions/%s", namespace, name)] = cr
|
||||||
|
|
||||||
err := ioutil.WriteFile(filePath, []byte(fileData), 0600)
|
err := ioutil.WriteFile(filePath, []byte(fileData), 0600)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
@ -113,7 +113,7 @@ func NewFakePod(name string, netAnnotation string) *v1.Pod {
|
|||||||
netAnnotation = strings.Replace(netAnnotation, "\n", "", -1)
|
netAnnotation = strings.Replace(netAnnotation, "\n", "", -1)
|
||||||
netAnnotation = strings.Replace(netAnnotation, "\t", "", -1)
|
netAnnotation = strings.Replace(netAnnotation, "\t", "", -1)
|
||||||
pod.ObjectMeta.Annotations = map[string]string{
|
pod.ObjectMeta.Annotations = map[string]string{
|
||||||
"kubernetes.v1.cni.cncf.io/networks": netAnnotation,
|
"k8s.v1.cni.cncf.io/networks": netAnnotation,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pod
|
return pod
|
||||||
|
Loading…
Reference in New Issue
Block a user