LoginSignup
0
0

More than 1 year has passed since last update.

[03] オンプレ環境で VM 2台を使って 1マスタ・1ノードの kubernetes を構築してみる (マスタへの flannel の導入)

Last updated at Posted at 2021-08-29

概要

下表の構成で、オンプレ上に k8s を構築したときの記録である.
本記事では「k8sマスタへの flannel 導入手順」を記す.

No 用途 ノード名 形態 公開IP 内部IP OS 備考
1 k8sマスタ master01 VM 192.168.1.91 172.24.20.11 Ubuntu18.04
2 k8sノード node01 VM 192.168.1.92 172.24.20.12 Ubuntu18.04

参考にしたサイトおよび書籍

URL 備考
実践 Vagrant
15Stepで習得 Dockerから入るKubernetes K8s だけでなく、Ansible, Vagrant, GlusterFS のことなども学べる.
https://github.com/takara9/vagrant-k8s 『15Stepで習得 Dockerから入るKubernetes』の著者が公開されている GitHub.
Vagrant や Ansible コードを公開してくださっている.
https://github.com/takara9/vagrant-kubernetes 同上
https://github.com/takara9/codes_for_lessons 同上
https://nextpublishing.jp/book/12197.html 『解体kubeadm フェーズから読み解くKubernetesクラスタ構築ツールの全貌』を参考にして 1マスタ・1ノードを構築した.

環境

物理PC および 仮想PC の OS

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.4 LTS"

物理PC

下記ソフトを導入済みであること.

  • Vagrant
  • VirtualBox

手順

1. flannel デプロイ用のマニフェストを入手する

kubctl のバージョンに対応した flannel バージョンを導入しないと、後段の処理でエラーになる.

vagrant@master01:~$ git clone https://github.com/flannel-io/flannel/blob/master/Documentation/kube-flannel.yml

2. flannel を導入する

vagrant@master01:~$ kubectl apply -f /home/vagrant/kube-flannel.yml
Warning: policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+
podsecuritypolicy.policy/psp.flannel.unprivileged created
clusterrole.rbac.authorization.k8s.io/flannel created
clusterrolebinding.rbac.authorization.k8s.io/flannel created
serviceaccount/flannel created
configmap/kube-flannel-cfg created
daemonset.apps/kube-flannel-ds created

3. flannel が稼働していることを確認する

下記🛑より、稼働している.

vagrant@master01:~$ kubectl get pod -A
NAMESPACE              NAME                                         READY   STATUS    RESTARTS   AGE
kube-system            coredns-558bd4d5db-crmd2                     1/1     Running   0          24m
kube-system            coredns-558bd4d5db-qp6xk                     1/1     Running   0          24m
kube-system            etcd-master01                                1/1     Running   1          24m
kube-system            kube-apiserver-master01                      1/1     Running   1          24m
kube-system            kube-controller-manager-master01             1/1     Running   1          24m
kube-system          🛑kube-flannel-ds-jmxrl                        1/1   🛑Running   0          24m
kube-system            kube-proxy-xr6p9                             1/1     Running   0          24m
kube-system            kube-scheduler-master01                      1/1     Running   1          24m
kube-system            metrics-server-755675c897-p7bjx              0/1     Pending   0          24m
kubernetes-dashboard   cluster-admin-68f7c6c68f-78lgs               1/1     Running   0          24m
kubernetes-dashboard   dashboard-metrics-scraper-778b77d469-c8cps   1/1     Running   0          24m

4. クラスタ情報を確認しておく

vagrant@master01:~$ kubectl cluster-info
Kubernetes control plane is running at https://172.24.20.11:6443
CoreDNS is running at https://172.24.20.11:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://172.24.20.11:6443/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy

 

以上

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0