plantegg 发表于 2019-1-31 12:32:42

安装k8s

  1、下载etcd v3.3.9
  2、etcd > install_etcd.sh > ip配置
  删除已有member目录:rm rf /var/lib/etcd/*
  suse 12 sp3:
ETCD_LISTEN_IP=ifconfig eth0 | grep 'inet ' | awk '{print $2}' | awk -F":" '{print $2}'
  centos 7:
ETCD_LISTEN_IP=ifconfig ens192 | grep 'inet ' | awk '{print $2}'
  ./install_etcd.sh etcd01 etcd01=http://192.168.1.51:2380,etcd02=http://192.168.1.52:2380
./install_etcd.sh etcd02 etcd01=http://192.168.1.51:2380,etcd02=http://192.168.1.52:2380
  验证>> bin/etcdctl member list
localhost:/home/cxiong/Desktop/k8s_v1.10.0_install/etcd # ./bin/etcdctl member list
ab736a9ecf6d37b3: name=etcd02 peerURLs=http://192.168.1.52:2380 clientURLs=http://192.168.1.52:2379 isLeader=false
bd317460717738be: name=etcd01 peerURLs=http://192.168.1.51:2380 clientURLs=http://192.168.1.51:2379 isLeader=true
  3、下载flannel v0.10.0
  suse 12 修改网卡接口 >IFACE="eth0"
  ./install_flannel.shhttp://192.168.1.51:2379,http://192.168.1.52:2379
  验证 >ifconfig flannel.1
  localhost:/home/cxiong/Desktop/k8s_v1.10.0_install/flannel #   ifconfig flannel.1
flannel.1 Link encap:EthernetHWaddr 12:D8:E2:E8:E1:59
inet addr:172.18.89.0Bcast:0.0.0.0Mask:255.255.255.255
inet6 addr: fe80::10d8:e2ff:fee8:e159/64 Scope:Link
UP BROADCAST RUNNING MULTICASTMTU:1450Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:7 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b)TX bytes:0 (0.0 b)
  验证> etcdctl ls /cmpk8s/network/subnets
localhost:/home/cxiong/Desktop/k8s_v1.10.0_install/flannel # ../etcd/bin/etcdctl ls /cmpk8s/network/subnets
/cmpk8s/network/subnets/172.18.92.0-24
/cmpk8s/network/subnets/172.18.89.0-24
  4、安装docker 18.03
  ./install-docker.sh docker-18.03.0-ce.tgz
  验证 > ifconfig docker0
localhost:/home/cxiong/Desktop/k8s_v1.10.0_install/docker # ifconfig docker0
docker0   Link encap:EthernetHWaddr 02:42:86:5D:35:FF
inet addr:172.18.92.1Bcast:172.18.92.255Mask:255.255.255.0
UP BROADCAST MULTICASTMTU:1500Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b)TX bytes:0 (0.0 b)
  5、安装kubernetes 1.10
  master节点:
./install_k8s_master.sh 192.168.1.51 http://192.168.1.51:2379,http://192.168.1.52:2379
million节点:
./install_k8s_node.sh 192.168.1.51
  master节点验证:
验证> kubectl get cs
验证> kubectl get nodes
  6、本地仓库registry
  7、反向代理nginx
Nginx作为集群入口服务,从功能上说,一般都是充当反向代理和负载均衡的角色。在我们这里它更多是用于反向代理,因为负载均衡的事情“移交”给了K8s去实现了。
  8、pod操作
创建
kubectl create -f xxx.yaml
查询
kubectl get pod yourPodName
kubectl describe pod yourPodName
删除
kubectl delete pod yourPodName
更新
kubectl replace /path/to/yourNewYaml.yaml



页: [1]
查看完整版本: 安装k8s