欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

k8s搭建

程序员文章站 2024-02-27 23:51:27
...

title: k8s搭建
categories:

  • 运维
    tags:
  • 运维
    date: 2019-06-27 09:52:54

#查看问题

journalctl -u kubelet


设置dns namespace

sudo vim /etc/systemd/resolved.conf

[Resolve]
DNS=192.168.0.1 114.114.114.114

#重新启动
systemd-resolved

设置主机名称

sudo echo "master" > /etc/hostname
hostnamectl set-hostname master

sudo echo "node1" > /etc/hostname
hostnamectl set-hostname node1

sudo echo "node2" > /etc/hostname
hostnamectl set-hostname node2

添加添加脚本daemon.json

sudo vim  /etc/docker/daemon.json

{

  "insecure-registries": [
    "docker-registry.my:5000"
  ]
}

添加hosts配置文件

sudo cat <<EOF >>/etc/hosts

192.168.0.2 master

192.168.0.3 node1

192.168.0.4 node2

192.168.0.5 docker-registry.my

EOF

关闭交换分区

sudo vim /etc/fstab

sudo swapoff -a

禁用防火墙

ufw disable

设置路由转发

sudo cat <<EOF > /etc/sysctl.d/k8s.conf
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF


搭建镜像仓库和deb包仓库

配置mster集群


配置阿里云源(分割线下弃用,可以用为网络下载)

sudo apt-get update && apt-get install -y apt-transport-https
sudo curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -

sudo  vim /etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main


sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl

查看k8s所需要镜像

kubeadm config images list

k8s.gcr.io/kube-apiserver:v1.14.3
k8s.gcr.io/kube-controller-manager:v1.14.3
k8s.gcr.io/kube-scheduler:v1.14.3
k8s.gcr.io/kube-proxy:v1.14.3
k8s.gcr.io/pause:3.1
k8s.gcr.io/etcd:3.3.10
k8s.gcr.io/coredns:1.3.1

master 初始化

kubeadm init --kubernetes-version=v1.14.3 --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.0.2
相关标签: 运维