# cni **Repository Path**: haply/cni ## Basic Information - **Project Name**: cni - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-07-27 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [](https://goreportcard.com/report/github.com/istio/cni) [](https://golangci.com/r/github.com/istio/cni) # Deprecation Notice This repo has been merged into [istio.io/istio/cni](https://github.com/istio/istio/blob/master/cni/). Please go to that repo to make any changes to CNI. The only exception is bug backports to branches <= 1.6, which should be submitted here. The text below is preserved for reference but is no longer maintained at this location. # Istio CNI plugin For application pods in the Istio service mesh, all traffic to/from the pods needs to go through the sidecar proxies (istio-proxy containers). This `istio-cni` Container Network Interface (CNI) plugin will set up the pods' networking to fulfill this requirement in place of the current Istio injected pod `initContainers` `istio-init` approach. This is currently accomplished (for IPv4) via configuring the iptables rules in the netns for the pods. The CNI handling the netns setup replaces the current Istio approach using a `NET_ADMIN` privileged `initContainers` container, `istio-init`, injected in the pods along with `istio-proxy` sidecars. This removes the need for a privileged, `NET_ADMIN` container in the Istio users' application pods. ## Usage A complete set of instructions on how to use and install the Istio CNI is available on the Istio documentation site under [Install Istio with the Istio CNI plugin](https://preliminary.istio.io/docs/setup/kubernetes/install/cni/). Only a summary is provided here. The steps are: 1. Install Kubernetes and `kubelet` in a manner that can support the CNI 1. Install Kubernetes with the [ServiceAccount admission controller](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#serviceaccount) enabled 1. Install the Istio CNI components. A specific example assuming locally built CNI images would be: ```console $ CNI_HUB=docker.io/my_userid $ CNI_TAG=mytag # run from the ${GOPATH}/src/istio.io/cni dir (repo where istio/cni was cloned) $ helm template --name=istio-cni --namespace=kube-system --set "excludeNamespaces={}" --set hub=${CNI_HUB} --set tag=${CNI_TAG} --set pullPolicy=IfNotPresent --set logLevel=debug deployments/kubernetes/install/helm/istio-cni > istio-cni_install.yaml $ kubectl apply -f istio-cni_install.yaml ``` 1. Create and apply Istio manifests with the Istio CNI plugin enabled using the `--set istio_cni.enabled=true` Helm variable For most Kubernetes environments the `istio-cni` [helm parameters' defaults](deployments/kubernetes/install/helm/istio-cni/values.yaml) will configure the Istio CNI plugin in a manner compatible with the Kubernetes installation. Refer to the [Hosted Kubernetes Usage](#hosted-kubernetes-usage) section for Kubernetes environment specific procedures. Helm chart parameters: | Option | Values | Default | Description | |--------|--------|---------|-------------| | hub | | | The container registry to pull the `install-cni` image. | | tag | | | The container tag to use to pull the `install-cni` image. | | logLevel | `panic`, `fatal`, `error`, `warn`, `info`, `debug` | `warn` | Logging level for CNI binary | | excludeNamespaces | `[]string` | `[ istio-system ]` | List of namespaces to exclude from Istio pod check | | cniBinDir | | `/opt/cni/bin` | Must be the same as the environment's `--cni-bin-dir` setting (`kubelet` param) | | cniConfDir | | `/etc/cni/net.d` | Must be the same as the environment's `--cni-conf-dir` setting (`kubelet` param) | | cniConfFileName | | None | Leave unset to auto-find the first file in the `cni-conf-dir` (as `kubelet` does). Primarily used for testing `install-cni` plugin config. If set, `install-cni` will inject the plugin config into this file in the `cni-conf-dir` | | psp_cluster_role | | | A `ClusterRole` that sets the according use of [PodSecurityPolicy](https://kubernetes.io/docs/concepts/policy/pod-security-policy) for the `ServiceAccount`| | chained | `true` or `false` | `true` | Whether to deploy the config file as a plugin chain or as a standalone file in the conf dir. Some k8s flavors (e.g. OpenShift) do not support the chain approach, set to false if this is the case. | ### Hosted Kubernetes Usage Not all hosted Kubernetes clusters are created with the `kubelet` configured to use the CNI plugin so compatibility with this `istio-cni` solution is not ubiquitous. The `istio-cni` plugin is expected to work with any hosted kubernetes leveraging CNI plugins. The below table indicates the known CNI status of hosted Kubernetes environments and whether `istio-cni` has been trialed in the cluster type. | Hosted Cluster Type | Uses CNI | istio-cni tested? | |---------------------|----------|-------------------| | GKE 1.9.7-gke.6 default | N | N | | GKE 1.9.7-gke.6 w/ [network-policy](https://cloud.google.com/kubernetes-engine/docs/how-to/network-policy) | Y | Y | | IKS (IBM cloud) | Y | Y (on k8s 1.10) | | EKS (AWS) | Y | N | | AKS (Azure) | Y | N | | Red Hat OpenShift 3.10| Y | Y | #### GKE Setup 1. Enable [network-policy](https://cloud.google.com/kubernetes-engine/docs/how-to/network-policy) in your cluster. NOTE: for existing clusters this redeploys the nodes. 1. Make sure your kubectl user (service-account) has a ClusterRoleBinding to the `cluster-admin` role. This is also a typical pre-requisite for installing Istio on GKE. 1. `kubectl create clusterrolebinding cni-cluster-admin-binding --clusterrole=cluster-admin --user=istio-user@gmail.com` 1. User `istio-user@gmail.com` is an admin user associated with the gcloud GKE cluster 1. Create the Istio CNI manifests with this Helm chart option `--set cniBinDir=/home/kubernetes/bin` #### IKS Setup No special set up is required for IKS, as it currently uses the default `cni-conf-dir` and `cni-bin-dir`. #### Red Hat OpenShift Setup Add the following section into [istio-cni.yaml](deployments/kubernetes/install/helm/istio-cni/templates/istio-cni.yaml#L109) to run the `install-cni` DaemonSet container as privileged so that it has proper write permission in the host filesystem: ```yaml securityContext: privileged: true ``` 1. Grant privileged permission to `istio-cni` service account: ```console $ oc adm policy add-scc-to-user privileged -z istio-cni -n kube-system ``` ## Build First, clone this repository under `$GOPATH/src/istio.io/`. For linux targets: ```console $ GOOS=linux make build ``` You can also build the project from a non-standard location like so: ```console $ ISTIO_CNI_RELPATH=github.com/some/cni GOOS=linux make build ``` To push the Docker image: ```console $ export HUB=docker.io/myuser $ export TAG=dev $ GOOS=linux make docker.push ``` **NOTE:** Set HUB and TAG per your docker registry. ### Helm The Helm package tarfile can be created via ```console $ helm package $GOPATH/src/istio.io/cni/deployments/kubernetes/install/helm/istio-cni ``` #### Serve Helm Repo An example for hosting a test repo for the Helm istio-cni package: 1. Create package tarfile with `helm package $GOPATH/src/istio.io/cni/deployments/kubernetes/install/helm/istio-cni` 1. Copy tarfile to dir to serve the repo from 1. Run `helm serve --repo-path