Deploying Antrea on a GKE cluster
Install the Google Cloud SDK (gcloud). Refer to
Make sure you are authenticated to use the Google Cloud API
gcloud auth login
Create a project or use an existing one
export GKE_PROJECT=gke-clusters
gcloud projects create $GKE_PROJECT
You can use any method to create a GKE cluster (gcloud SDK, gcloud Console, etc). The example given here is using the Google Cloud SDK.
Note: Antrea is supported on Ubuntu Nodes only for GKE cluster. When creating the cluster, you must use the default network provider and must not enable “Dataplane V2”.
-
export GKE_ZONE="us-west1"
gcloud container --project $GKE_PROJECT clusters create cluster1 --image-type $GKE_HOST \
--zone $GKE_ZONE --enable-ip-alias
Access your cluster
Create a cluster-admin ClusterRoleBinding
kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user user@email.com
Note: To create clusterRoleBinding, the user must have
container.clusterRoleBindings.create
permission. Use this command to enable it, if the previous command fails due to permission error. Only cluster Admin can assign this permission.
Prepare the Cluster Nodes
Deploy
antrea-node-init
DaemonSet to enablekubelet
to operate in CNI mode.kubectl apply -f https://raw.githubusercontent.com/antrea-io/antrea/main/build/yamls/antrea-gke-node-init.yml
-
To deploy a released version of Antrea, pick a deployment manifest from the list of releases. Note that GKE support was added in release 0.5.0, which means you cannot pick a release older than 0.5.0. For any given release
<TAG>
(e.g.v0.5.0
), you can deploy Antrea as follows:To deploy the latest version of Antrea (built from the main branch), use the checked-in :
kubectl apply -f https://raw.githubusercontent.com/antrea-io/antrea/main/build/yamls/antrea-gke.yml
The command will deploy a single replica of Antrea controller to the GKE cluster and deploy Antrea agent to every Node. After a successful deployment you should be able to see these Pods running in your cluster:
$ kubectl get pods --namespace kube-system -l app=antrea -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
antrea-controller-5f9985c59-5crt6 1/1 Running 0 46s 10.138.15.209 gke-cluster1-default-pool-93d7da1c-rkbm <none> <none>
Restart remaining Pods
Once Antrea is up and running, restart all Pods in all Namespaces (kube-system, etc) so they can be managed by Antrea.
$ kubectl delete pods -n kube-system $(kubectl get pods -n kube-system -o custom-columns=NAME:.metadata.name,HOSTNETWORK:.spec.hostNetwork --no-headers=true | grep '<none>' | awk '{ print $1 }')
pod "event-exporter-gke-755c4b4d97-wqlcg" deleted
pod "konnectivity-agent-5cb8ff9b9-2cv5j" deleted
pod "konnectivity-agent-5cb8ff9b9-5jpvp" deleted
pod "konnectivity-agent-autoscaler-7dc78c8c9-kqn9f" deleted
pod "kube-dns-5b5dfcd97b-79m4c" deleted
pod "kube-dns-5b5dfcd97b-q49qj" deleted
pod "kube-dns-autoscaler-5f56f8997c-kqrgx" deleted