第147天学习打卡(Kubernetes 部署)
Posted doudoutj
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第147天学习打卡(Kubernetes 部署)相关的知识,希望对你有一定的参考价值。
对象式编程语言:
- 以数据为中心,代码服务于数据
- 数据:对象
- 代码:方法
- class:类
- 属性,方法
K8S api: REST API(http/https)
- resource -> object
- method: GET ,PUT ,POST, DELETE, PATCH…
k8s:cluster,容器编排系统
- 核心任务:容器编排
- 容器:应用程序
- Pod Controller, Deployment
Kubernetes Network
部署要点
- 测试环境
- 可以使用单Master节点,单etcd实例;
- Node主机数量按需而定
- nfs或glusterfs等存储系统;
- 生产环境
- 高可用etcd集群,建立3、5或7个节点
- 高可用Master
- kube-apiserver无状态,可多实例
- 借助于keepalive进行vip流动实现多实例冗余;
- 或在多实例前端通过HAProxy或nginx反代,并借助keepalive对代理服务器进行冗余;
- kube-scheduler 及kube-controller-manager各自只能有一个活动实例,但可以有多个备用;
- 各自自带leader选举的功能,并且默认处于启用状态;
- kube-apiserver无状态,可多实例
- 多Node主机,数量越多,冗余能力越强;
- ceph, glusterfs, iSCSI, FC SAN及各种云存储等;
部署工具
-
常用的部署环境
- IaaS公有云环境:AWS, GCE, Azure等
- IaaS私有云或公有云环境:OpenStack和vSphere等;
- Baremetal环境:物理服务器或独立的虚拟机等;
-
常用的部署工具
- kubeadm
- kops
- kubespray
- Kontena Pharos
- …
-
其他二次封装的常用发行版
- Rancher
- Tectonic
- Openshift
- …
-
Master , Node
-
Client -> Master(API Server)
-
Registry:Docker Hub, gcr.io, quay.io
[root@iZ2vcdx512qke62ysebmttZ ~]# systemctl status chronyed
Unit chronyed.service could not be found.
[root@iZ2vcdx512qke62ysebmttZ ~]# date
Fri Jun 4 16:46:30 CST 2021
[root@iZ2vcdx512qke62ysebmttZ ~]# clear
[root@iZ2vcdx512qke62ysebmttZ ~]# systemctl stop firewalld
[root@iZ2vcdx512qke62ysebmttZ ~]# systemctl disable firewalld
[root@iZ2vcdx512qke62ysebmttZ ~]# sed -i 's/enforcing/disabled/' /etc/selinux/config
[root@iZ2vcdx512qke62ysebmttZ ~]# setenforce 0
setenforce: SELinux is disabled
[root@iZ2vcdx512qke62ysebmttZ ~]# swapoff -a
[root@iZ2vcdx512qke62ysebmttZ ~]# sed -ri 's/.*swap.*/#&/' /etc/fstab
[root@iZ2vcdx512qke62ysebmttZ ~]# hostnamectl set-hostname
Invalid number of arguments.
[root@iZ2vcdx512qke62ysebmttZ ~]# hostnamectl set-hostname master
[root@iZ2vcdx512qke62ysebmttZ ~]# cat >> /etc/hosts << EOF
> 47.109.19.74 master
> 47.109.21.242 node01
> 47.109.21.247 node02
> 47.109.23.91 node03
> EOF
[root@iZ2vcdx512qke62ysebmttZ ~]# cat > /etc/sysctl.d/k8s.conf << EOF
> net.bridge.bridge-nf-call-ip6tables = 1
> net.bridge.bridge-nf-call-iptables = 1
> EOF
[root@iZ2vcdx512qke62ysebmttZ ~]# sysctl --system
* Applying /usr/lib/sysctl.d/00-system.conf ...
* Applying /usr/lib/sysctl.d/10-default-yama-scope.conf ...
kernel.yama.ptrace_scope = 0
* Applying /usr/lib/sysctl.d/50-default.conf ...
kernel.sysrq = 16
kernel.core_uses_pid = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.promote_secondaries = 1
net.ipv4.conf.all.promote_secondaries = 1
fs.protected_hardlinks = 1
fs.protected_symlinks = 1
* Applying /etc/sysctl.d/99-sysctl.conf ...
vm.swappiness = 0
kernel.sysrq = 1
net.ipv4.neigh.default.gc_stale_time = 120
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_announce = 2
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 1024
net.ipv4.tcp_synack_retries = 2
* Applying /etc/sysctl.d/k8s.conf ...
* Applying /etc/sysctl.conf ...
vm.swappiness = 0
kernel.sysrq = 1
net.ipv4.neigh.default.gc_stale_time = 120
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_announce = 2
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 1024
net.ipv4.tcp_synack_retries = 2
[root@iZ2vcdx512qke62ysebmttZ ~]# yum install ntpdate -y
Loaded plugins: fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/7): epel/x86_64/group_gz | 96 kB 00:00:00
(2/7): base/7/x86_64/group_gz | 153 kB 00:00:00
(3/7): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(4/7): extras/7/x86_64/primary_db | 236 kB 00:00:00
(5/7): epel/x86_64/primary_db | 6.9 MB 00:00:00
(6/7): updates/7/x86_64/primary_db | 8.0 MB 00:00:00
(7/7): base/7/x86_64/primary_db | 6.1 MB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package ntpdate.x86_64 0:4.2.6p5-29.el7.centos.2 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================================
Installing:
ntpdate x86_64 4.2.6p5-29.el7.centos.2 base 87 k
Transaction Summary
====================================================================================================================================================================================
Install 1 Package
Total download size: 87 k
Installed size: 121 k
Downloading packages:
ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm | 87 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : ntpdate-4.2.6p5-29.el7.centos.2.x86_64 1/1
Verifying : ntpdate-4.2.6p5-29.el7.centos.2.x86_64 1/1
Installed:
ntpdate.x86_64 0:4.2.6p5-29.el7.centos.2
Complete!
[root@iZ2vcdx512qke62ysebmttZ ~]# ntpdate time.windows.com
4 Jun 17:02:24 ntpdate[1594]: adjust time server 52.231.114.183 offset -0.008640 sec
[root@iZ2vcdx512qke62ysebmttZ ~]# yum -y install gcc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.8.5-44.el7 will be installed
--> Processing Dependency: libgomp = 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: cpp = 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: libgcc >= 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: libmpfr.so.4()(64bit) for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: libmpc.so.3()(64bit) for package: gcc-4.8.5-44.el7.x86_64
--> Running transaction check
---> Package cpp.x86_64 0:4.8.5-44.el7 will be installed
---> Package glibc-devel.x86_64 0:2.17-324.el7_9 will be installed
--> Processing Dependency: glibc-headers = 2.17-324.el7_9 for package: glibc-devel-2.17-324.el7_9.x86_64
--> Processing Dependency: glibc = 2.17-324.el7_9 for package: glibc-devel-2.17-324.el7_9.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.17-324.el7_9.x86_64
---> Package libgcc.x86_64 0:4.8.5-39.el7 will be updated
---> Package libgcc.x86_64 0:4.8.5-44.el7 will be an update
---> Package libgomp.x86_64 0:4.8.5-39.el7 will be updated
---> Package libgomp.x86_64 0:4.8.5-44.el7 will be an update
---> Package libmpc.x86_64 0:1.0.1-3.el7 will be installed
---> Package mpfr.x86_64 0:3.1.1-4.el7 will be installed
--> Running transaction check
---> Package glibc.x86_64 0:2.17-307.el7.1 will be updated
--> Processing Dependency: glibc = 2.17-307.el7.1 for package: nscd-2.17-307.el7.1.x86_64
--> Processing Dependency: glibc = 2.17-307.el7.1 for package: glibc-common-2.17-307.el7.1.x86_64
---> Package glibc.x86_64 0:2.17-324.el7_9 will be an update
---> Package glibc-headers.x86_64 0:2.17-324.el7_9 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.17-324.el7_9.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.17-324.el7_9.x86_64
--> Running transaction check
---> Package glibc-common.x86_64 0:2.17-307.el7.1 will be updated
---> Package glibc-common.x86_64 0:2.17-324.el7_9 will be an update
---> Package kernel-headers.x86_64 0:3.10.0-1160.25.1.el7 will be installed
---> Package nscd.x86_64 0:2.17-307.el7.1 will be updated
---> Package nscd.x86_64 0:2.17-324.el7_9 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================================
Installing:
gcc x86_64 4.8.5-44.el7 base 16 M
Installing for dependencies:
cpp x86_64 4.8.5-44.el7 base 5.9 M
glibc-devel x86_64 2.17-324.el7_9 updates 1.1 M
glibc-headers x86_64 2.17-324.el7_9 updates 691 k
kernel-headers x86_64 3.10.0-1160.25.1.el7 updates 9.0 M
libmpc x86_64 1.0.1-3.el7 base 51 k
mpfr x86_64 3.1.1-4.el7 base 203 k
Updating for dependencies:
glibc x86_64 2.17-324.el7_9 updates 3.6 M
glibc-common x86_64 2.17-324.el7_9 updates 12 M
libgcc x86_64 4.8.5-44.el7 base 103 k
libgomp x86_64 4.8.5-44.el7 base 159 k
nscd x86_64 2.17-324.el7_9 updates 288 k
Transaction Summary
====================================================================================================================================================================================
Install 1 Package (+6 Dependent packages)
Upgrade ( 5 Dependent packages)
Total download size: 49 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/12): glibc-common-2.17-324.el7_9.x86_64.rpm | 12 MB 00:00:00
(2/12): gcc-4.8.5-44.el7.x86_64.rpm | 16 MB 00:00:00
(3/12): cpp-4.8.5-44.el7.x86_64.rpm | 5.9 MB 00:00:00
(4/12): glibc-2.17-324.el7_9.x86_64.rpm | 3.6 MB 00:00:00
(5/12): glibc-devel-2.17-324.el7_9.x86_64.rpm | 1.1 MB 00:00:00
(6/12): glibc-headers-2.17-324.el7_9.x86_64.rpm | 691 kB 00:00:00
(7/12): libgomp-4.8.5-44.el7.x86_64.rpm | 159 kB 00:00:00
(8/12): libmpc-1.0.1-3.el7.x86_64.rpm | 51 kB 00:00:00
(9/12): kernel-headers-3.10.0-1160.25.1.el7.x86_64.rpm | 9.0 MB 00:00:00
(10/12): libgcc-4.8.5-44.el7.x86_64.rpm | 103 kB 00:00:00
(11/12): mpfr-3.1.1-4.el7.x86_64.rpm | 203 kB 00:00:00
(12/12): nscd-2.17-324.el7_9.x86_64.rpm | 288 kB 00:00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 100 MB/s | 49 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : libgcc-4.8.5-44.el7.x86_64 1/17
Updating : glibc-common-2.17-324.el7_9.x86_64 2/17
Updating : glibc-2.17-324.el7_9.x86_64 3/17
Installing : mpfr-3.1.1-4.el7.x86_64 4/17
Installing : libmpc-1.0.1-3.el7.x86_64 5/17
Installing : cpp-4.8.5-44.el7.x86_64 6/17
Updating : libgomp-4.8.5-44.el7.x86_64 7/17
Installing : kernel-headers-3.10.0-1160.25.1.el7.x86_64 8/17
Installing : glibc-headers-2.17-324.el7_9.x86_64 9/17
Installing : glibc-devel-2.17-324.el7_9.x86_64 10/17
Installing : gcc-4.8.5-44.el7.x86_64 11/17
Updating : nscd-2.17-324.el7_9.x86_64 12/17
Cleanup : libgomp-4.8.5-39.el7.x86_64 13/17
Cleanup : nscd-2.17-307.el7.1.x86_64 14/17
Cleanup : glibc-common-2.17-307.el7.1.x86_64 15/17
Cleanup : glibc-2.17-307.el7.1.x86_64 16/17
Cleanup : libgcc-4.8.5-39.el7.x86_64 17/17
Verifying : kernel-headers-3.10.0-1160.25.1.el7.x86_64 1/17
Verifying : nscd-2.17-324.el7_9.x86_64 2/17
Verifying : glibc-2.17-324.el7_9.x86_64 3/17
Verifying : glibc-common-2.17-324.el7_9.x86_64 4/17
Verifying : mpfr-3.1.1-4.el7.x86_64 5/17
Verifying : glibc-headers-2.17-324.el7_9.x86_64 6/17
Verifying : cpp-4.8.5-44.el7.x86_64 7/17
Verifying : glibc-devel-2.17-324.el7_9.x86_64 8/17
Verifying : gcc-4.8.5-44.el7.x86_64 9/17
Verifying : libmpc-1.0.1-3.el7.x86_64 10/17
Verifying : libgcc-4.8.5-44.el7.x86_64 11/17
Verifying : libgomp-4.8.5-44.el7.x86_64 12/17
Verifying : nscd-2.17-307.el7.1.x86_64 13/17
Verifying : libgcc-4.8.5-39.el7.x86_64 14/17
Verifying : libgomp-4.8.5-39.el7.x86_64 以上是关于第147天学习打卡(Kubernetes 部署)的主要内容,如果未能解决你的问题,请参考以下文章
第156天学习打卡(Kubernetes 搭建监控平台 高可用集群部署 )
第154天学习打卡(Kubernetes 使用Helm快速部署应用, 如何自己创建Chart)
第157天学习打卡(Kubernetes k8s集群部署项目)
第148天学习打卡(Kubernetes kubeadm init 成功部署 部署网络插件 部署容器化应用)
第152天学习打卡(Kubernetes Service 部署有状态应用 部署守护进程 job corejob Secret ConfigMap )