标签:语法 org server UNC move insecure node节点 资源 minikube
集群规划
准备5台2C/2g/50g虚拟机,网络10.4.7.0/24预装centos7.4。
主机名 | 分配ip | 用途 |
---|---|---|
hdss7-11.host.com | 10.4.7.11 | proxy1 |
hdss7-12.host.com | 10.4.7.12 | proxy2 |
hdss7-21.host.com | 10.4.7.21 | master1 |
hdss7-22.host.com | 10.4.7.22 | master2 |
hdss7-200.host.com | 10.4.7.200 | 运维主机 |
架构说明:
1.etcd至少3台组成一个高可用集群
2.两台proxy组成高可用代理对外提供VIP
3.两台机器共同承担master和node节点功能
4.运维主机非K8S套件,但为K8S服务
安装方式选择
1.Minikube预览使用,仅供学习
2.二进制安装(生产首选,新手推荐)
3.kubeadmin安装
相关目录
/opt 二进制服务安装路径
/opt/src 二进制包放置路径
所有机器都需要执行
~]# uname -a (内核版本最低需要3.10)
Linux alice40 3.10.0-957.21.3.el7.x86_64 #1 SMP Tue Jun 18 16:35:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
~]# systemctl stop firewalld
~]# systemctl disable firewalld
~]# setenforce 0
~]# sed -ir ‘/^SELINUX=/s/=.+/=disabled/‘ /etc/selinux/config
~]# 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
~]# yum install -y wget net-tools telnet tree nmap sysstat lrzsz dos2unix bind-utils vim less
~]# 都需要配置定时任务
~]# crontab -l
#ntp
00 * * * * /usr/sbin/ntpdate ntp6.aliyun.com
~]# yum install -y bind
注意语法(分号空格)这里的IP是内网IP
~]# vim /etc/named.conf # 确保以下配置正确
listen-on port 53 { 10.4.7.11; }; # 监听端口53 下面一行本来有ipv6地址 需要删除
directory "/var/named";
allow-query { any; }; #允许内机器都可以查
forwarders { 10.4.7.254; }; # 上级dns 虚拟机这里填的是网关地址,阿里云机器可以填223.5.5.5
recursion yes; # 采用递归方法查询IP
dnssec-enable no;
dnssec-validation no;
~]# named-checkconf # 检查配置 没有信息即为正确
~]#
增加两个zone配置,od.com为业务域,host.com.zone为主机域
~]# vim /etc/named.rfc1912.zones
zone "host.com" IN {
type master;
file "host.com.zone";
allow-update { 10.4.7.11; };
};
zone "od.com" IN {
type master;
file "od.com.zone";
allow-update { 10.4.7.11; };
};
#line6中时间需要修改 格式为xxxx xx xx01(年月日01)每次修改配置文件都需要前滚一个序列号
~]# vim /var/named/host.com.zone
$ORIGIN host.com.
$TTL 600 ; 10 minutes # 过期时间十分钟 这里的分号是注释
@ IN SOA dns.host.com. dnsadmin.host.com. (
2020010501 ; serial
10800 ; refresh (3 hours) # soa参数
900 ; retry (15 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS dns.host.com.
$TTL 60 ; 1 minute
dns A 10.4.7.11
HDSS7-11 A 10.4.7.11
HDSS7-12 A 10.4.7.12
HDSS7-21 A 10.4.7.21
HDSS7-22 A 10.4.7.22
HDSS7-200 A 10.4.7.200
~]# vim /var/named/od.com.zone
$ORIGIN od.com.
$TTL 600 ; 10 minutes
@ IN SOA dns.od.com. dnsadmin.od.com. (
2020010501 ; serial
10800 ; refresh (3 hours)
900 ; retry (15 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS dns.od.com.
$TTL 60 ; 1 minute
dns A 10.4.7.11
[root@hdss7-11 ~]# named-checkconf # 检查配置文件
[root@hdss7-11 ~]# systemctl start named ; systemctl enable named
[root@hdss7-11 ~]# dig -t A hdss7-11.host.com @10.4.7.11 +shor #检查是否可以解析到
10.4.7.11
# 5台K8S主机都需要按如下方式修改网络配置
# 修改dns并添加搜索域
[root@hdss7-11 ~]# sed -i ‘s#^DNS.*#DNS1=10.4.7.11#g‘ /etc/sysconfig/network-scripts/ifcfg-eth0
[root@hdss7-11 ~]# echo "search=host.com" >>/etc/sysconfig/network-scripts/ifcfg-eth0
[root@hdss7-11 ~]# systemctl restart network
# 检查DNS配置
[root@hdss7-11 ~]# cat /etc/resolv.conf
# Generated by NetworkManager
search host.com
nameserver 10.4.7.11
[root@hdss7-11 ~]# dig -t A hdss7-21.host.com +short
10.4.7.21
# 一定记得检查dns配置文件中是否有search信息
# windows宿主机也要改
wmnet8网卡更改DNS:10.4.7.11
# ping通才行,否则检查
ping hdss7-200.host.com
(操作在7.200这个运维机上完成)
wget https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 -O /usr/bin/cfssl
wget https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64 -O /usr/bin/cfssl-json
wget https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64 -O /usr/bin/cfssl-certinfo
chmod +x /usr/bin/cfssl*
mkdir /opt/certs
cat >/opt/certs/ca-csr.json <<EOF
{
"CN": "zqcd",
"hosts": [
],
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "CN",
"ST": "chengdu",
"L": "chengdu",
"O": "zq",
"OU": "ops"
}
],
"ca": {
"expiry": "175200h"
}
}
EOF
# 配置字段解释
CN: Common Name,浏览器使用该字段验证网站是否合法,一般写的是域名。非常重要。浏览器使用该字段验证网站是否合法
C: Country, 国家
ST: State,州,省
L: Locality,地区,城市
O: Organization Name,组织名称,公司名称
OU: Organization Unit Name,组织单位名称,公司部门
cd /opt/certs
cfssl gencert -initca ca-csr.json | cfssl-json -bare ca
[root@hdss7-200 certs]# ll
total 16
-rw-r--r-- 1 root root 989 Apr 16 20:53 cacsr
-rw-r--r-- 1 root root 324 Apr 16 20:52 ca-csr.json
-rw------- 1 root root 1679 Apr 16 20:53 ca-key.pem
-rw-r--r-- 1 root root 1330 Apr 16 20:53 ca.pem
部署主机:(21,22,200)
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
mkdir /etc/docker/
cat >/etc/docker/daemon.json <<EOF
{
"graph": "/data/docker",
"storage-driver": "overlay2",
"insecure-registries": ["registry.access.redhat.com","quay.io","harbor.zq.com"],
"registry-mirrors": ["https://q2gr04ke.mirror.aliyuncs.com"],
"bip": "172.7.21.1/24",
"exec-opts": ["native.cgroupdriver=systemd"],
"live-restore": true
}
EOF
mkdir -p /data/docker
systemctl start docker
systemctl enable docker
docker --version
当上述方法无法安装时,使用此方法(网络延迟问题,可能会出错,需要多试试)
# 国内源安装docker-ce
yum remove docker docker-common docker-selinux docker-engine
yum install -y yum-utils device-mapper-persistent-data lvm2
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
sed -i ‘s+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+‘ /etc/yum.repos.d/docker-ce.repo
yum makecache fast
yum install -y docker-ce
systemctl start docker
cat >/etc/docker/daemon.json <<EOF
{
"graph": "/data/docker",
"storage-driver": "overlay2",
"insecure-registries": ["registry.access.redhat.com","quay.io","harbor.zq.com"],
"registry-mirrors": ["https://q2gr04ke.mirror.aliyuncs.com"],
"bip": "172.7.21.1/24",
"exec-opts": ["native.cgroupdriver=systemd"],
"live-restore": true
}
EOF
注意:bip要根据宿主机ip变化
hdss7-21.host.com bip 172.7.21.1/24
hdss7-22.host.com bip 172.7.22.1/24
hdss7-200.host.com bip 172.7.200.1/24
部署主机:(200)
https://github.com/goharbor/harbor/releases/download/v1.8.5/harbor-offline-installer-v1.8.5.tgz
tar xf harbor-offline-installer-v1.8.5.tgz -C /opt/
cd /opt/
mv harbor/ harbor-v1.8.5
ln -s /opt/harbor-v1.8.5/ /opt/harbor
[root@hdss7-200 opt]# vi /opt/harbor/harbor.yml
# 以下是修改项,手动在配置文件中更改
hostname: harbor.zq.com
http:
port: 180
harbor_admin_password:Harbor12345
data_volume: /data/harbor
log:
level: info
rotate_count: 50
rotate_size:200M
location: /data/harbor/logs
[root@hdss7-200 opt]# mkdir -p /data/harbor/logs
[root@hdss7-200 opt]cd /opt/harbor/
yum install docker-compose -y
sh /opt/harbor/install.sh
docker-compose ps
docker ps -a
在7.11DNS服务上操作)
[root@hdss7-11 ~]# vi /var/named/zq.com.zone
2020032002 ; serial #每次修改DNS解析后,都要滚动此ID
harbor A 10.4.7.200
[root@hdss7-11 ~]# systemctl restart named
[root@hdss7-11 ~]# dig -t A harbor.zq.com +short
10.4.7.200
回到7.200运维机上操作)
[root@hdss7-200 harbor]# yum install nginx -y
[root@hdss7-200 harbor]# vi /etc/nginx/conf.d/harbor.zq.com.conf
server {
listen 80;
server_name harbor.zq.com;
client_max_body_size 1000m;
location / {
proxy_pass http://127.0.0.1:180;
}
}
[root@hdss7-200 harbor]# nginx -t
[root@hdss7-200 harbor]# systemctl start nginx
[root@hdss7-200 harbor]# systemctl enable nginx
浏览器输入:harbor.zq.com
用户名:admin 密码:Harbor12345
新建项目:public 访问级别:公开
pauser镜像是k8s启动pod时,预先用来创建相关资源(如名称空间)的
nginx镜像是k8s部署好以后,我们测试pod创建所用的
docker login harbor.zq.com -uadmin -pHarbor12345
docker pull kubernetes/pause
docker pull nginx:1.17.9
docker tag kubernetes/pause:latest harbor.zq.com/public/pause:latest
docker tag nginx:1.17.9 harbor.zq.com/public/nginx:v1.17.9
docker push harbor.zq.com/public/pause:latest
docker push harbor.zq.com/public/nginx:v1.17.9
创建一个nginx虚拟主机,用来提供文件访问访问,主要依赖nginx的autoindex属性
(在7.200上)
# 创建配置
cat >/etc/nginx/conf.d/k8s-yaml.zq.com.conf <<EOF
server {
listen 80;
server_name k8s-yaml.zq.com;
location / {
autoindex on;
default_type text/plain;
root /data/k8s-yaml;
}
}
EOF
# 启动nginx
mkdir -p /data/k8s-yaml/coredns
nginx -t
nginx -s reload
(在7.11的bind9域名服务器上,增加DNS记录)
vi /var/named/zq.com.zone
# 在最后添加一条解析记录
k8s-yaml A 10.4.7.200
# 同时滚动serial为
@ IN SOA dns.zq.com. dnsadmin.zq.com. (
2019061803 ; serial
重启服务并验证:
systemctl restart named
[root@hdss7-11 ~]# dig -t A k8s-yaml.zq.com +short
10.4.7.200
注意: 在每一次修改DNS解析后,都要滚动serial 的 ID(滚动:+1)
标签:语法 org server UNC move insecure node节点 资源 minikube
原文地址:https://www.cnblogs.com/wzys/p/14584446.html