...
The common installation steps for both Kubernetes master and slave node are given as Linux shell scripts:
Code Block |
---|
|
$ sudo bash
$ apt-get update && apt-get install -y apt-transport-https curl
$ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
$ cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
$ deb https://apt.kubernetes.io/ kubernetes-xenial main
$ EOF
$ apt-get update
$ apt-get install -y kubelet=1.13.0-00 kubeadm=1.13.0-00 kubectl=1.13.0-00
$ apt-mark hold kubelet kubeadm kubectl
$ sysctl net.bridge.bridge-nf-call-iptables=1 |
For host setup as Kubernetes master:
Code Block |
---|
|
$ sudo kubeadm config images pull
$ sudo kubeadm init --pod-network-cidr=192.168.0.0/16 --apiserver-advertise-address=$MGMT_IP \
--service-cidr=172.16.1.0/24 |
To start using your cluster, you need to run (as a regular user)::
Code Block |
---|
|
$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config |
or ::
...
$ export KUBECONFIG=/etc/kubernetes/admin.conf |
if you are the ``root`` user.
For hosts setup as Kubernetes slave:
Code Block |
---|
|
$ kubeadm join --token <token> <master-ip>:6443 --discovery-token-ca-cert-hash sha256:<hash> |
...
which will skip ca-cert verification.
After the `slave` joining the Kubernetes cluster, in the master node, you could check the cluster
node with the command::
Code Block |
---|
|
$ kubectl get nodes |
Install the Calico CNI Plugin to Kubernetes Cluster
...
Install the Etcd Database
::
Please use the following command to install etcd database.
Code Block |
---|
|
$ kubectl apply -f https://raw.githubusercontent.com/Jingzhao123/arm64TemporaryCalico/temporay_arm64/
v3.3/getting-started/kubernetes/installation/hosted/etcd-arm64.yaml |
...
Install the RBAC Roles required for Calico
...
Code Block |
---|
|
$ kubectl apply -f https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/rbac.yaml |
Install Calico to system
Firstly, we should get the configuration file from web site and modify the corresponding image from amd64 to arm64 version. Then, by using kubectl, the calico pod will be created.
...
Code Block |
---|
|
$ wget https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/hosted/calico.yaml |
...
Since the "quay.io/calico" image repo does not support does not multi-arch, we have to replace the “quay.io/calico” image path to "calico" which supports multi-arch.
...
Code Block |
---|
|
$ sed -i "s/quay.io\/calico/calico/" calico.yaml |
Deploy the Calico using following command:
Code Block |
---|
|
$ kubectl apply -f calico.yaml |
...
...
In calico.yaml file, there is an option "IP_AUTODETECTION_METHOD" about choosing
network interface. The default value is "first-found" which means the first valid
IP address (except local interface, docker bridge). So if the number of network-interface
is more than 1 on your server, you should configure it depends on your networking
environments. If it does not configure it properly, there are some error about
calico-node pod: "BGP not established with X.X.X.X". |
...
Remove the taints on master node
...
Code Block |
---|
|
$ kubectl taint nodes --all node-role.kubernetes.io/master- |
...
Verification for the Work of Kubernetes
Now we can verify the work of Kubernetes and Calico with Kubernets pod and service creation and accessing based on Nginx which is a widely used web server.
Firstly, create a file named nginx-app.yaml to describe a Pod and service by:
...
Code Block |
---|
|
$ cat <<EOF >~/nginx-app.yaml
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
app: nginx
spec:
type: NodePort
ports:
- port: 80
protocol: TCP
name: http
selector:
app: nginx
---
apiVersion: v1
kind: ReplicationController
metadata:
name: nginx
spec:
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
EOF |
...
then test the Kubernetes working status with the script:
Code Block |
---|
|
set -ex
kubectl create -f ~/nginx-app.yaml
kubectl get nodes
kubectl get services
kubectl get pods
kubectl get rc
r="0"
while [ $r -ne "2" ]
do
r=$(kubectl get pods | grep Running | wc -l)
sleep 60
done
svcip=$(kubectl get services nginx -o json | grep clusterIP | cut -f4 -d'"')
sleep 10
wget http://$svcip
kubectl delete -f ./examples/nginx-app.yaml
kubectl delete -f ./nginx-app.yaml
kubectl get rc
kubectl get pods
kubectl get services |
...
Helm Install on Arm64
Helm is a tool for managing Kubernetes charts. Charts are packages of pre-configured Kubernetes resources. The installation of Helm on arm64 is as followes:follows:
...
...
$ wget https://storage.googleapis.com/kubernetes-helm/helm-v2.12.3-linux-arm64.tar.gz
$ xvf helm-v2.12.3-linux-arm64.tar.gz
$ sudo cp linux-arm64/helm /usr/bin
$ sudo cp linux-arm64/tiller /usr/bin |
...
Further Information
We would like to provide a walk through shell script to automate the installation of Kubernetes and Calico in the future. But this README is still useful for IEC developers and users.
...