k8s-kubernetesの使用を開始する

1.ポッドkubernetesシステムアーキテクチャ:
k8s-kubernetesの使用を開始する

2.コアロジック:
k8s-kubernetesの使用を開始する

3.ネットワークモデルの基盤k8s-kubernetesの使用を開始する

4. K8sユーザー:
k8s-kubernetesの使用を開始する

5. k8s動作モード:
k8s-kubernetesの使用を開始する

6、beadm
k8s-kubernetesの使用を開始する

7.kubeadmワークフロー

k8s-kubernetesの使用を開始する

デモ環境の展開:
k8s-kubernetesの使用を開始する

k8s-kubernetesの使用を開始する

[root @ node01〜] #cat / etc / hosts

192.168.100.40 node04.magedu.com node04 node04
192.168.100.30 node03.magedu.com node03 node03
192.168.100.20 node02.magedu.com node02 node02
192.168.100.10 node01.magedu.com node01 node01

環境チェック:
[root @ node01〜]#
1。systemctlstop Firewalld systemctl disable Firewalld
2. UUID = fa47bfb8-28b6-485a-add4-3c8464933f39 swap#スワップパーティション
3を閉じる、ntpdate time1.aliyun.com

docker安装:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel .repo http://mirrors.aliyun.com/repo/epel-7.repo
wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/ linux / centos / docker-ce.repo
yum install docker -ce
-yplication:daemon.json#cat /etc/docker/daemon.json
{
"registry-mirrors":[" https://9916w1ow.mirror.aliyuncs。 com "]、
" exec-opts ":[" native.cgroupdriver = systemd "]、
" log-driver ":" json-file "、
" log-opts ":{
" max-size ":" 100m "
}、
"storage-driver": "overlay2"
}
systemctlデーモン-リロード
systemctl restart
docker systemctl start
docker systemctl enable docker

docker info#Viewドライバー

ロギングドライバー:json-file
Cgroupドライバー:systemd
k8s-kubernetesの使用を開始する

Kubernetes画像

https://developer.aliyun.com/mirror/kubernetes?spm=a2c6h.13651102.0.0.3e221b115fDyMd

cat << EOF> /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name = Kubernetes
baseurl = https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled = 1
gpgcheck = 1
repo_gpgcheck = 1
gpgkey = https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key .gpg
EOF
setenforce 0#selinux
関闭swap分区:
swapoff -a
yum install -y kubelet kubeadm kubectl
systemctl enable kubelet && systemctl start kubelet

k8s-kubernetesの使用を開始する

<<<<<<<<<<<<<<<<<<<<<<<<<
インストール:
kubeadm.x86_64 0:1.20.2-0 kubectl.x86_64 0:1.20.2 -0 kubelet.x86_64 0:1.20.2-0

インストールされている依存関係:
conntrack-tools.x86_64 0:1.4.4-7.el7 cri-tools.x86_64 0:1.13.0-0
kubernetes-cni.x86_64 0:0.8.7-0 libnetfilter_cthelper.x86_64 0:1.0.0- 11.el7
libnetfilter_cttimeout.x86_64 0:1.0.0-7.el7 libnetfilter_queue.x86_64 0:1.0.2-2.el7_2
socat.x86_64 0:1.7.3.2-2.el7
<<<<<<<<<<< <<<<<<<<<<<<

<<<<<<<
modprobe br_netfilter; echo 1> / proc / sys / net / bridge / bridge-nf-call-iptables

kubeadm init#飛行機を初期化します:

kubeadm init --image-repository Registry.aliyuncs.com/google_containers --kubernetes-version = v1.20.2 --pod-network-cidr = 10.244.0.0 / 16 --service-cidr = 10.96.0.0 / 12 --ignore -preflight-errors = Swap

<<<<<<<<<<
集群高可用:
kubeadm INIT --imageリポジトリregistry.aliyuncs.com/google_containers --kubernetesバージョン= v1.20.2 --control面エンドポイントnode01 --apiserver、宣伝-アドレス192.168.100.1--pod-network-cidr = 10.244.0.0 / 16 --service-cidr = 10.96.0.0 / 12 --ignore-preflight-errors = Swap --token-ttl 0

<<<<<<<<<<

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
ます。mkdir -p $ HOME / .kube
sudoのcpは- i /etc/kubernetes/admin.conf $ HOME / .kube / config
sudo chown $(id -u):$(id -g)$ HOME / .kube / config

または、rootユーザーの場合は、次のコマンドを実行できます。

KUBECONFIG = / etc / kubernetes /admin.confをエクスポートします

これで、ポッドネットワークをクラスターにデプロイする必要があります。https://kubernetes.io/docs/concepts/cluster-administration/addons/に
リストされているオプションの1つを使用して、「kubectl apply -f [podnetwork] .yaml」を実行します

次に、rootとしてそれぞれで以下を実行することにより、任意の数のワーカーノードに参加できます。

kubeadm join 192.168.10.110:6443 --token peuw3m.5fiyzsdokf0cfzup \
--discovery-token-ca-cert-hash sha256:82873b6ecea8107b4ab <<<<< 888888e
<ad < b791869a4aee9d6bf2dcaa9b
k8s-kubernetesの使用を開始する

###########
通常のユーザーを作成します:
useradd ilinux
echo'centos '| passwd --stdin ilinux
echo'ilinux ALL =(ALL)NOPASSWD:ALL'> /etc/sudoers.d/inlinux
cat /etc/sudoers.d/inlinux

kubectl get nodes flannel
networkプラグイン:https
//github.com/coreos/flannel

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

安装插件出现的问题:
[ilinux@jenkins-server~]$kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

サーバーraw.githubusercontent.comへの接続が拒否されました-正しいホストまたはポートを指定しましたか?
k8s-kubernetesの使用を開始する

GitHubのraw.githubusercontent.comがhttps://site.ip138.com/raw.Githubusercontent.com/で接続できない問題を解決
ます

raw.githubusercontent.comと入力して、IPアドレスを照会します

vim / etc / hostsファイル:
151.101.88.133 raw.githubusercontent.com
k8s-kubernetesの使用を開始する

验证フランネルポッド插件;
kubectl get pods -nkube-system
名前準備完了ステータス再起動年齢
coredns-7f89b7bc75-5fzrg1 / 1実行中
050m coredns-7f89b7bc75-6d4sj1 / 1実行中050mkube
-controller-manager-node03.magedu。 comの1/1は0 50メートルの実行
KUBE-フランネル-DS-48qrx 1/1 0 4m50s実行
0 50メートルを実行KUBE-プロキシvnftj 1/1

ノードノードに参加します。

kubeadm join 192.168.10.110:6443 --token peuw3m.5fiyzsdokf0cfzup \
--discovery-token-ca-cert-hash sha256:82873b6ecea8107b4ab2d9b49fc5f791869a4aee9d6bf2dcaa9b8ad788e50210

k8sクラスター検証
kubectlgetノード
k8s-kubernetesの使用を開始する

起動後にサービスが自動的に開始するかどうか:
[root @ node03〜] #systemctl is-enabled docker; systemctl is-enabled kubelet; systemctl is-enabled docker

ポッドエクササイズ:

おすすめ

転載: blog.51cto.com/13718453/2595071