2019年4月12日金曜日

kubernetes (1.14.1) for Raspberryのアップデートについて

1.8.14以降のアップデートは安定性がない。

以下を実施すると、基本的に失敗に終わる。
原因は、kubeletっぽい。
ということで、この辺が修正されたら正式なアップデートを行いたい!!


kubeadm init --pod-network-cidr=10.244.0.0/16

kubernetes fori Raspberry piのインストール方法について

現状、以下の構成が安定しているようだ。
基本的に、apt-get update&apt-get upgradeは実施していない。
(カーネルアップデートも実施しないことにしている。)

◻️OS
2018-06-27-raspbian-stretch-lite.img

◻️kubernetes
kubelet=1.8.14-00 kubeadm=1.8.14-00 kubectl=1.8.14-00 kubernetes-cni=0.5.1-00

◻️docker
docker-ce=18.06.3~ce~3-0~raspbian


<導入メモ>

◻️swapは、稼働させない設定など
sudo dphys-swapfile swapoff
sudo dphys-swapfile uninstall
sudo update-rc.d dphys-swapfile remove


◻️その他、必要なものを導入。
sudo apt install -y curl
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common


◻️dockerのインストール&レポジトリ追加
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
echo "deb [arch=armhf] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
     $(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list

sudo apt-get -y update

curl -sSL https://get.docker.com | sh
apt-get purge -y docker-ce
apt-get autoremove -y
apt-get install -y --no-install-recommends docker-ce=18.06.3~ce~3-0~raspbian


◻️kubernetesのインストール&レポジトリ追加
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg|sudo apt-key add -
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kube.list

apt-get install -y kubelet=1.8.14-00 kubeadm=1.8.14-00 kubectl=1.8.14-00 kubernetes-cni=0.5.1-00


[メモ]
1)kubectl get nodeの動きが遅い。

2)kubectl コマンドは、nodeでは実施できない。
◻️実施結果
root@rasp-node1:~# kubectl get node
=======================================
The connection to the server localhost:8080 was refused - did you specify the right host or port?
========================================

3)カーネルアップデート、apt-get upgradeを行ってからtopコマンドを行うと
常にcpuの使用率が100%越えが多い。
とにかく、全体の動作が重い。

kunernetes(再起後の動きについて) for Raspberry pi

1)"master"/"node1"/"node2"全ての機器を再起動を行う。

2)再起動後に、以下のコマンドを実施すると、拒否されるメッセージが出て困った。
root@rasp-master:~# kubectl get node
The connection to the server 192.168.13.2:6443 was refused - did you specify the right host or port?


3)しばらく、すると以下のように正常に表示されたので、raspberryの処理が追いつかなかったのが
原因かと思われる。

root@rasp-master:~# kubectl get node
===================================================
NAME          STATUS    ROLES     AGE       VERSION
rasp-master   Ready     master    1h        v1.8.14
rasp-node1    Ready     <none>    1h        v1.8.14
rasp-node2    Ready     <none>    45m       v1.8.14
====================================================



Raspberry pi for Centosの設定方法

Raspberry pi for Centosの設定方法についてのメモ
イメージの取得方法については割愛。

◻️以下で、ログインを行う
ID:root
Pass:centos

◻️パーテションサイズの拡張を行う
/usr/local/bin/rootfs-expand

◻️kernelアップデートを除外して、アップデートを行う。
yum --disablerepo=centos-kernel update


◻️レポジトリの編集について
vi /etc/yum.repos.d/kernel.repo
==============================================-
[kernel]
name=kernel repo for RaspberryPi 2 and 3
#baseurl=https://mirror.centos.org/altarch/7/kernel/$basearch/kernel-$kvariant/
baseurl=http://mirror.centos.org/altarch/7/kernel/$basearch/kernel-rpi2
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
       file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-AltArch-Arm32
=============================================


vi /etc/yum.repos.d/CentOS-armhfp-kernel.repo
=====================================
[centos-kernel]
name=CentOS Kernels for armhfp
#baseurl=https://mirror.centos.org/altarch/7/kernel/$basearch/kernel-$kvariant
baseurl=http://mirror.centos.org/altarch/7/kernel/$basearch/kernel-rpi2/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
       file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-AltArch-Arm32
==========================

2019年4月9日火曜日

raspberry pi バックアップの取得方法およびパーテーションサイズの縮小について

◻️以下、手順raspberry pi のバックアップとパーテーションの縮小についてのメモになる。



root@raspberrypi:~# sudo e2fsck -p -f /dev/sda2
rootfs: 126993/916864 files (0.3% non-contiguous), 1117366/3784704 blocks

◻️ファイルシステムの検証を行う。


root@raspberrypi:~# sudo resize2fs -P /dev/sda2
resize2fs 1.43.4 (31-Jan-2017)
Estimated minimum size of the filesystem: 1571716

◻️縮小後のファイルシステムのサイズ見積もりを行う。


root@raspberrypi:~# sudo resize2fs -p /dev/sda2 1572740

(ポイント)filesystem: 1571716 + 1024(ブロックサイズ) 1572740になる。


◻️パーテーションのリサイズを行う。(5G)

resize2fs 1.43.4 (31-Jan-2017)
Resizing the filesystem on /dev/sda2 to 1572740 (4k) blocks.
Begin pass 2 (max = 350941)
Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 116)
Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 4 (max = 14310)
Updating inode references     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/sda2 is now 1572740 (4k) blocks long.



root@raspberrypi:~# sudo fdisk /dev/sda

◻️fdiskコマンドを投入する。

Welcome to fdisk (util-linux 2.29.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.



Command (m for help): p

◻️パーテーションを表示する。

Disk /dev/sda: 14.5 GiB, 15552479232 bytes, 30375936 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x2dfd6ab3

Device     Boot Start      End  Sectors  Size Id Type
/dev/sda1        8192    96663    88472 43.2M  c W95 FAT32 (LBA)
/dev/sda2       98304 30375935 30277632 14.4G 83 Linux

Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

◻️削除を実施する。


Command (m for help): p

◻️プライマリーを選択する。

Disk /dev/sda: 14.5 GiB, 15552479232 bytes, 30375936 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x2dfd6ab3

Device     Boot Start   End Sectors  Size Id Type
/dev/sda1        8192 96663   88472 43.2M  c W95 FAT32 (LBA)

◻️削除されたのがわかる。


Command (m for help): n

◻️新しいパーテーションを作成する。

Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-30375935, default 2048): 98304
Last sector, +sectors or +size{K,M,G,T,P} (98304-30375935, default 30375935): +5G

Created a new partition 2 of type 'Linux' and of size 5 GiB.
Partition #2 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: N


Command (m for help): w

◻️書き込みを実施する。

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.


root@raspberrypi:~# sudo fdisk -l /dev/sda

◻️書き込みが出来たか確認してみる。

Disk /dev/sda: 14.5 GiB, 15552479232 bytes, 30375936 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x2dfd6ab3

Device     Boot Start      End  Sectors  Size Id Type
/dev/sda1        8192    96663    88472 43.2M  c W95 FAT32 (LBA)
/dev/sda2       98304 10584063 10485760    5G 83 Linux




<Macで実施する>


iMac:~ hidenari$ diskutil list

◻️パーテーションの確認を行う

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *121.3 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                 Apple_APFS Container disk2         121.1 GB   disk0s2

/dev/disk1 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk1
   1:                        EFI EFI                     209.7 MB   disk1s1
   2:                 Apple_APFS Container disk2         1000.0 GB  disk1s2

/dev/disk2 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +1.1 TB     disk2
                                 Physical Stores disk0s2, disk1s2
   1:                APFS Volume Macintosh HD            430.4 GB   disk2s1
   2:                APFS Volume Preboot                 45.5 MB    disk2s2
   3:                APFS Volume Recovery                517.0 MB   disk2s3
   4:                APFS Volume VM                      3.2 GB     disk2s4

/dev/disk5 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *15.6 GB    disk5
   1:             Windows_FAT_32 boot                    46.0 MB    disk5s1
   2:                      Linux                         5.4 GB     disk5s2



iMac:~ hidenari$ sudo fdisk /dev/disk5

◻️対象のSDカードのパーテーションを確認する。

Disk: /dev/disk5 geometry: 1890/255/63 [30375936 sectors]
Signature: 0xAA55
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: 0C    0 130   3 -    6  26  18 [      8192 -      89854] Win95 FAT32L
 2: 83   48   0   1 -   47  63  32 [     98304 -   10485760] Linux files*
 3: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
 4: 00    0   0   0 -    0   0   0 [         0 -          0] unused      

(ポイント) 10485760 / 2048 = 5120

iMac:~ hidenari$ sudo dd if=/dev/rdisk5 of=~/rpi.img count=5120 bs=1m


◻️raspi-configを実行する。
7 Advanced Options の設定   

  A1 Expand Filesys


上記を行わないと、ディスクフルの状態になるので注意!!

2019年4月8日月曜日

K3S for raspberry pi


◻️master&node側でk3sのインストールを行う。

wget https://github.com/rancher/k3s/releases/download/v0.3.0/k3s-armhf && \
chmod +x k3s-armhf && \
sudo mv k3s-armhf /usr/local/bin/k3s


◻️master側で実施

root@rasp01:~# sudo cat /var/lib/rancher/k3s/server/node-token
K10f6b6658c57b3746e62e66cf97d5d44357f9a552da862204e1c7d22fb75f6ee12::node:8fa426db4b28657934d8be98eb023345


◻️node側で実施

export NODE_TOKEN="K10f6b6658c57b3746e62e66cf97d5d44357f9a552da862204e1c7d22fb75f6ee12::node:8fa426db4b28657934d8be98eb023345"
$ export SERVER_IP="https://192.168.13.2:6443"
$ sudo -E k3s agent -s ${SERVER_IP} -t ${NODE_TOKEN}

<master側のIP>
https://192.168.13.2:6443



◻️master側で以下のコマンドを実施してみると、node側と同期できていることが分かる。

root@rasp01:~# sudo k3s kubectl get node -o wide
======================================
NAME     STATUS   ROLES    AGE     VERSION         INTERNAL-IP    EXTERNAL-IP   OS-IMAGE                         KERNEL-VERSION   CONTAINER-RUNTIME
rasp01   Ready    <none>   5h16m   v1.13.5-k3s.1   192.168.13.2   <none>        Raspbian GNU/Linux 9 (stretch)   4.14.98-v7+      containerd://1.2.4+unknown
rasp02   Ready    <none>   6m46s   v1.13.5-k3s.1   192.168.13.3   <none>        Raspbian GNU/Linux 9 (stretch)   4.14.98-v7+      containerd://1.2.4+unknown
======================================

2019年4月6日土曜日

fluentd for kubernets(raspberry pi)

1)gti経由で、yamlファイルを落とす。
git clone https://github.com/fluent/fluentd-kubernetes-daemonset


2)以下、自己のIPに変更する。
vi fluentd-daemonset-elasticsearch.yaml
==============fluentd-daemonset-elasticsearch.yaml=======================
    spec:
      tolerations:
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
      containers:
      - name: fluentd
        image: fluent/fluentd-kubernetes-daemonset:elasticsearch
        env:
          - name:  FLUENT_ELASTICSEARCH_HOST
            value: "192.168.13.2"
          - name:  FLUENT_ELASTICSEARCH_PORT
            value: "9200"
          - name: FLUENT_ELASTICSEARCH_SCHEME
            value: "http"
          # Option to configure elasticsearch plugin with self signed certs
=================================================================================


3) fluentdの各ノードを確認する。

kubectl get daemonsets --namespace=kube-system

root@rasp-master:/home/pi/fluntd/fluentd-kubernetes-daemonset# kubectl get daemonsets --namespace=kube-system
===========================================================================================================
NAME              DESIRED   CURRENT   READY     UP-TO-DATE   AVAILABLE   NODE SELECTOR                 AGE
fluentd           3         3         0         3            0           <none>                        7m
kube-flannel-ds   3         3         3         3            3           beta.kubernetes.io/arch=arm   2d
kube-proxy        3         3         3         3            3           <none>                        3d
==========================================================================================================



◻️参照先
http://level69.net/archives/25391

2019年4月2日火曜日

dockerのダウングレード方法について

1)導入済みのdokcerの削除を行う
apt remove -y docker-ce docker-ce-cli
rm -rf /var/lib/docker
sudo apt autoremove


2)導入したいdockerを以下のコマンドで投入する。
apt-get install docker-ce=18.06.1~ce~3-0~raspbian


<メモ>
以下のコマンドを投入することで、dokcerのライブラリーが表示される。

apt-cache madison docker-ce
=====================================
 docker-ce | 5:18.09.0~3-0~raspbian-stretch | https://download.docker.com/linux/raspbian stretch/stable armhf Packages
 docker-ce | 18.06.3~ce~3-0~raspbian | https://download.docker.com/linux/raspbian stretch/stable armhf Packages
 docker-ce | 18.06.2~ce~3-0~raspbian | https://download.docker.com/linux/raspbian stretch/stable armhf Packages
 docker-ce | 18.06.1~ce~3-0~raspbian | https://download.docker.com/linux/raspbian stretch/stable armhf Packages
 docker-ce | 18.06.0~ce~3-0~raspbian | https://download.docker.com/linux/raspbian stretch/stable armhf Packages
 docker-ce | 18.03.1~ce-0~raspbian | https://download.docker.com/linux/raspbian stretch/stable armhf Packages
 docker-ce | 18.03.0~ce-0~raspbian | https://download.docker.com/linux/raspbian stretch/stable armhf Packages
 docker-ce | 17.12.1~ce-0~raspbian | https://download.docker.com/linux/raspbian stretch/stable armhf Packages
 docker-ce | 17.12.0~ce-0~raspbian | https://download.docker.com/linux/raspbian stretch/stable armhf Packages
 docker-ce | 17.09.1~ce-0~raspbian | https://download.docker.com/linux/raspbian stretch/stable armhf Packages
 docker-ce | 17.09.0~ce-0~raspbian | https://download.docker.com/linux/raspbian stretch/stable armhf Packages
====================================

◻️表示されている中から導入対象のdockerを選択してインストールを行う。
(例)apt-get install docker-ce=[リストに表示されているdockerを選択]



3)以下のような結果が出ていること。

root@rasp-node1:/home/pi# docker version
================================================
Client:
 Version:           18.06.1-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        e68fc7a
 Built:             Tue Aug 21 17:30:52 2018
 OS/Arch:           linux/arm
 Experimental:      false

Server:
 Engine:
  Version:          18.06.1-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       e68fc7a
  Built:            Tue Aug 21 17:26:37 2018
  OS/Arch:          linux/arm

  Experimental:     false
==============================================

2019年4月1日月曜日

kubeadm init 失敗の対策について

◻️kubeadm init を実施すると、コネクション拒否のエラーが出て失敗に終わる。


root@rasp-master:~# kubeadm init --pod-network-cidr=10.0.0.0/16
==========================================
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get http://localhost:10248/healthz: dial tcp [::1]:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get http://localhost:10248/healthz: dial tcp [::1]:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get http://localhost:10248/healthz: dial tcp [::1]:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get http://localhost:10248/healthz: dial tcp [::1]:10248: connect: connection refused
===========================================


◻️対策とは、言えないが以下のコマンドを投入して回避することしか出来ていない。
リブートをしないと回避できないのは微妙ではあるが。。

swapoff -a
kubeadm reset

reboot

Calico(kubernetesのプラグイン)

◻️Calicoの導入
コンテナのネットワークおよびセキュリティ(Firewall機能)の役割を果たすプラグインになる。

ローカルLLMでコーディングさせるポイント

 簡単な指示で、依頼するとコンテキストオーバーで記憶喪失になって コードの内容が一致しないことが起こるので、work.mdみたいな作業メモを取らせたるのがよい 途中から、別スレッドに再実施する場合でも、work.mdが引き継ぎとして 参照して実施してくれるのがポイント