Use Multi-arch etcd yaml to support Calico 96/1096/1
authortrevor tao <trevor.tao@arm.com>
Sun, 30 Jun 2019 14:25:44 +0000 (22:25 +0800)
committertrevor tao <trevor.tao@arm.com>
Sun, 30 Jun 2019 14:25:44 +0000 (22:25 +0800)
Change the separate etcd-arm64.yaml and etcd-amd64.yaml to a single
multi-arch supported etcd.yaml to simply the Calico install.

Change-Id: I2750213235043f9ad7411e8211beb58214487386
Signed-off-by: trevor tao <trevor.tao@arm.com>
src/foundation/scripts/cni/calico/etcd-amd64.yaml [deleted file]
src/foundation/scripts/cni/calico/etcd.yaml [moved from src/foundation/scripts/cni/calico/etcd-arm64.yaml with 53% similarity]
src/foundation/scripts/setup-cni.sh

diff --git a/src/foundation/scripts/cni/calico/etcd-amd64.yaml b/src/foundation/scripts/cni/calico/etcd-amd64.yaml
deleted file mode 100644 (file)
index e3d0aa3..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-# This manifest installs the Calico etcd on the kubeadm master.  This uses a DaemonSet
-# to force it to run on the master even when the master isn't schedulable, and uses
-# nodeSelector to ensure it only runs on the master.
-apiVersion: extensions/v1beta1
-kind: DaemonSet
-metadata:
-  name: calico-etcd
-  namespace: kube-system
-  labels:
-    k8s-app: calico-etcd
-spec:
-  template:
-    metadata:
-      labels:
-        k8s-app: calico-etcd
-      annotations:
-        # Mark this pod as a critical add-on; when enabled, the critical add-on scheduler
-        # reserves resources for critical add-on pods so that they can be rescheduled after
-        # a failure.  This annotation works in tandem with the toleration below.
-        scheduler.alpha.kubernetes.io/critical-pod: ''
-    spec:
-      tolerations:
-        # This taint is set by all kubelets running `--cloud-provider=external`
-        # so we should tolerate it to schedule the Calico pods
-        - key: node.cloudprovider.kubernetes.io/uninitialized
-          value: "true"
-          effect: NoSchedule
-        # Allow this pod to run on the master.
-        - key: node-role.kubernetes.io/master
-          effect: NoSchedule
-        # Allow this pod to be rescheduled while the node is in "critical add-ons only" mode.
-        # This, along with the annotation above marks this pod as a critical add-on.
-        - key: CriticalAddonsOnly
-          operator: Exists
-      # Only run this pod on the master.
-      nodeSelector:
-        node-role.kubernetes.io/master: ""
-      hostNetwork: true
-      containers:
-        - name: calico-etcd
-          image: quay.io/coreos/etcd:v3.3.9
-          env:
-            - name: CALICO_ETCD_IP
-              valueFrom:
-                fieldRef:
-                  fieldPath: status.podIP
-          command:
-            - /usr/local/bin/etcd
-          args:
-            - --name=calico
-            - --data-dir=/var/etcd/calico-data
-            - --advertise-client-urls=http://$(CALICO_ETCD_IP):6666
-            - --listen-client-urls=http://0.0.0.0:6666
-            - --listen-peer-urls=http://0.0.0.0:6667
-            - --auto-compaction-retention=1
-          volumeMounts:
-            - name: var-etcd
-              mountPath: /var/etcd
-      volumes:
-        - name: var-etcd
-          hostPath:
-            path: /var/etcd
-
----
-
-# This manifest installs the Service which gets traffic to the Calico
-# etcd.
-apiVersion: v1
-kind: Service
-metadata:
-  labels:
-    k8s-app: calico-etcd
-  name: calico-etcd
-  namespace: kube-system
-spec:
-  # Select the calico-etcd pod running on the master.
-  selector:
-    k8s-app: calico-etcd
-  # This ClusterIP needs to be known in advance, since we cannot rely
-  # on DNS to get access to etcd.
-  clusterIP: 10.96.232.136
-  ports:
-    - port: 6666
@@ -1,10 +1,11 @@
+---
 # This manifest installs the Calico etcd on the kubeadm master.  This uses a DaemonSet
 # to force it to run on the master even when the master isn't schedulable, and uses
 # nodeSelector to ensure it only runs on the master.
 apiVersion: extensions/v1beta1
 kind: DaemonSet
 metadata:
-  name: calico-etcd
+  name: calico-etcd-arm64
   namespace: kube-system
   labels:
     k8s-app: calico-etcd
@@ -35,6 +36,7 @@ spec:
       # Only run this pod on the master.
       nodeSelector:
         node-role.kubernetes.io/master: ""
+        beta.kubernetes.io/arch: arm64
       hostNetwork: true
       containers:
         - name: calico-etcd
@@ -63,6 +65,71 @@ spec:
           hostPath:
             path: /var/etcd
 
+---
+# This manifest installs the Calico etcd on the kubeadm master.  This uses a DaemonSet
+# to force it to run on the master even when the master isn't schedulable, and uses
+# nodeSelector to ensure it only runs on the master.
+apiVersion: extensions/v1beta1
+kind: DaemonSet
+metadata:
+  name: calico-etcd-amd64
+  namespace: kube-system
+  labels:
+    k8s-app: calico-etcd
+spec:
+  template:
+    metadata:
+      labels:
+        k8s-app: calico-etcd
+      annotations:
+        # Mark this pod as a critical add-on; when enabled, the critical add-on scheduler
+        # reserves resources for critical add-on pods so that they can be rescheduled after
+        # a failure.  This annotation works in tandem with the toleration below.
+        scheduler.alpha.kubernetes.io/critical-pod: ''
+    spec:
+      tolerations:
+        # This taint is set by all kubelets running `--cloud-provider=external`
+        # so we should tolerate it to schedule the Calico pods
+        - key: node.cloudprovider.kubernetes.io/uninitialized
+          value: "true"
+          effect: NoSchedule
+        # Allow this pod to run on the master.
+        - key: node-role.kubernetes.io/master
+          effect: NoSchedule
+        # Allow this pod to be rescheduled while the node is in "critical add-ons only" mode.
+        # This, along with the annotation above marks this pod as a critical add-on.
+        - key: CriticalAddonsOnly
+          operator: Exists
+      # Only run this pod on the master.
+      nodeSelector:
+        node-role.kubernetes.io/master: ""
+        beta.kubernetes.io/arch: amd64
+      hostNetwork: true
+      containers:
+        - name: calico-etcd
+          image: quay.io/coreos/etcd:v3.3.9
+          env:
+            - name: CALICO_ETCD_IP
+              valueFrom:
+                fieldRef:
+                  fieldPath: status.podIP
+          command:
+            - /usr/local/bin/etcd
+          args:
+            - --name=calico
+            - --data-dir=/var/etcd/calico-data
+            - --advertise-client-urls=http://$(CALICO_ETCD_IP):6666
+            - --listen-client-urls=http://0.0.0.0:6666
+            - --listen-peer-urls=http://0.0.0.0:6667
+            - --auto-compaction-retention=1
+          volumeMounts:
+            - name: var-etcd
+              mountPath: /var/etcd
+      volumes:
+        - name: var-etcd
+          hostPath:
+            path: /var/etcd
+
 ---
 
 # This manifest installs the Service which gets traffic to the Calico
index 30bc841..55953a2 100755 (executable)
@@ -16,11 +16,7 @@ SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}")
 
 install_calico(){
   # Install the Etcd Database
-  if [ "$(uname -m)" == 'aarch64' ]; then
-    ETCD_YAML=etcd-arm64.yaml
-  else
-    ETCD_YAML=etcd-amd64.yaml
-  fi
+  ETCD_YAML=etcd.yaml
 
   sed -i "s/10.96.232.136/${CLUSTER_IP}/" "${SCRIPTS_DIR}/cni/calico/${ETCD_YAML}"
   kubectl apply -f "${SCRIPTS_DIR}/cni/calico/${ETCD_YAML}"