Help us understand the problem. What is going on with this article?

CRI-Oを用いてKubernetesをインストールする(途中)

KubernetesのコンテナランタイムとしてDockerの代わりにCRI-Oを用いてみる

前提

OS: Ubuntu 18.04

インストール

コンテナランタイム CRI-Oのインストール

基本的に下記のkubernetes.ioの記事通りに進められる

https://kubernetes.io/docs/setup/production-environment/container-runtimes/#cri-o

root@controller-0:~# systemctl start crio
Job for crio.service failed because the control process exited with error code.
See "systemctl status crio.service" and "journalctl -xe" for details.
root@controller-0:~# journalctl -xe 
中略
Apr 25 03:08:45 controller-0 crio[3319]: time="2020-04-25 03:08:45.559628306Z" level=fatal msg="runtime config: runtime validation: \"runc\" not found in $PATH: exec: \"runc\": executable file not found in $PATH"

kubeadmのインストール

下記ページを基にサクサク進める
https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/

kernel parameter少し変更

cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system

スワップ切っておく

swapoff -a

kubeadm等のインストール

sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

kubernetes clusterの構築
出力欄に出てくるコマンドをそれぞれ実行する

クラスタの構築

kubeadm init

略
Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 10.240.0.10:6443 --token 43e76r.pe3ilo6i6908r2og \
    --discovery-token-ca-cert-hash sha256:ae956c8edb77cbc9659823b89d7426d4eceb8d4b8cc85b3bf5656f9d1989175d 

kubectlを使うための認証情報をユーザのホームに移動する

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

何かしらのCNIを導入する ここではCalicoを選択

kubectl apply -f https://docs.projectcalico.org/v3.11/manifests/calico.yaml

クラスタへのノードの追加

最初のノードと同様にコンテナランタイムとkubeadmのインストールを済ませる

新たに追加するノードに下記を追記する(これを行わないと、vagrantで作成されたeth0のIPが使われてしまい、calicoによるVXLAN構成が失敗する)

vi /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
Environment="KUBELET_EXTRA_ARGS=--node-ip=追加するマシンのIP"

最初のノードの出力にあったkubeadm joinコマンドを実行する

kubeadm join 10.240.0.10:6443 --token rrqz8z.xjln30peilb0efqf     --discovery-token-ca-cert-hash sha256:89424e23e88150c521dc7dec53ef95d1afc130c4d4cf0465a12181320c65cf06 

joinに成功すると、下記のコマンドにてノードが増えていることを確認できる

root@controller-0:~# kubectl get node
NAME           STATUS   ROLES    AGE   VERSION
controller-0   Ready    master   34m   v1.18.2
controller-1   Ready    <none>   33m   v1.18.2

ただ、calicoで何かエラーが出ている
追加したノード上のcalico-node podが起動できていないようである
これに伴い、corednsやcalico-kube-controllersも影響を受けていそう。

root@controller-0:~# kubectl get po -owide
NAME                                       READY   STATUS              RESTARTS   AGE    IP               NODE           NOMINATED NODE   READINESS GATES
calico-kube-controllers-75d56dfc47-8cg2m   0/1     ContainerCreating   0          31m    <none>           controller-1   <none>           <none>
calico-node-8jjql                          1/1     Running             0          31m    10.240.0.10      controller-0   <none>           <none>
calico-node-rs9dq                          0/1     CrashLoopBackOff    5          8m4s   10.240.0.20      controller-1   <none>           <none>
coredns-66bff467f8-96bb5                   0/1     ContainerCreating   0          34m    <none>           controller-1   <none>           <none>
coredns-66bff467f8-j2g8v                   1/1     Running             0          34m    192.168.192.65   controller-0   <none>           <none>
etcd-controller-0                          1/1     Running             0          34m    10.240.0.10      controller-0   <none>           <none>
kube-apiserver-controller-0                1/1     Running             0          34m    10.240.0.10      controller-0   <none>           <none>
kube-controller-manager-controller-0       1/1     Running             0          34m    10.240.0.10      controller-0   <none>           <none>
kube-proxy-5njt2                           1/1     Running             0          34m    10.240.0.20      controller-1   <none>           <none>
kube-proxy-9s5lv                           1/1     Running             0          34m    10.240.0.10      controller-0   <none>           <none>
kube-scheduler-controller-0                1/1     Running             0          34m    10.240.0.10      controller-0   <none>           <none>
iaoiui
SIerでDocker, Kubernetes使って遊んでる人
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした