K8S部署

V1.11.1
https://github.com/kubernetes/kubernetes/releases/tag/v1.11.1
环境准备:
系统:centos7.2.1511
[[email protected] ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

关闭防火墙,iptalbes,firewalld设置时间同步
systemctl stop iptalbes
systemctl disable iptalbes

systemctl stop firewalld
systemctl disable firewalld

禁用SELINUX:

setenforce 0

修改selinux
vim /etc/selinux/config文件
SELINUX=disabled

改主机名:
~]# hostnamectl set-hostname master
修改hosts
[[email protected] ~]# vim /etc/hosts
172.20.0.70 master
172.20.0.66 node1
172.20.0.67 node2



master:

[[email protected]~]# cd /etc/yum.repos.d/
下载阿里云docker-ce.repo
[[email protected] yum.repos.d]# wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

配置k8s repo
[[email protected] yum.repos.d]# vim kubernetes.repo
[kubernetes]
name=kubernetes repo
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kuberne
tes-el7-x86_64/
gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
enabled=1
[[email protected] yum.repos.d]#yum repolist

[[email protected] ~]# wget https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
[[email protected] ~]# rpm --import rpm-package-key.gpg
[[email protected] ~]# wget https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
[[email protected] ~]# rpm --import yum-key.gpg

===============================
安装docker-ce kubelet kubeadm kubectl
[[email protected] yum.repos.d]# yum install docker-ce kubelet kubeadm kubectl

配置docker服务
[[email protected] yum.repos.d]# vim /usr/lib/systemd/system/docker.service

[Service]
Environment="HTTPS_PROXY=http://www.ik8s.io:10080"
Environment="NO_PROXY=127.0.0.0/8,172.20.0.0/16"
[[email protected] yum.repos.d]# systemctl daemon-reload

[[email protected] yum.repos.d]# systemctl start docker.service
[[email protected] yum.repos.d]# docker info

验证itables桥是否为1

[[email protected] ~]# cat /proc/sys/net/bridge/bridge-nf-call-ip6tables
[[email protected] ~]# cat /proc/sys/net/bridge/bridge-nf-call-iptables

如不为1,则在/etc/sysctl.conf中添加:

net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

执行sysctl -p 时出现:
[[email protected] ~]# sysctl -p
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-ip6tables: No such file or directory
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory
解决方法:

[[email protected] ~]# modprobe br_netfilter
[[email protected] ~]# sysctl -p
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

自启动kubelet,docker
[[email protected] ~]# systemctl enable kubelet.service
[email protected] ~]# systemctl enable docker.service

启动kubelet,docker
[[email protected] ~]# systemctl start kubelet.service
[email protected] ~]# systemctl start docker.service

忽略swap报错
[[email protected] ~]# vim /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS="--fail-swap-on=false"

初始化kubeadm
[[email protected] ~]# kubeadm init --kubernetes-version=v1.11.1 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=Swap

kubeadm join 172.20.0.70:6443 --token dis2yz.m446ryn2lr298ica --discovery-token-ca-cert-hash sha256:c59f3633ecb92a31d86f64dc304abea55176555afbb3f2af9f40e5d4e013f86b

[[email protected] ~]# docker image ls

检测端口是否启动
[[email protected] ~]# ss -tnl | grep 6443

[[email protected] ~]# mkdir -p $HOME/.kube
[[email protected] ~]# cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

[[email protected] ~]# kubectl get cs
NAME STATUS MESSAGE ERROR
scheduler Healthy ok
etcd-0 Healthy {"health": "true"}
controller-manager Healthy ok
[[email protected] ~]# kubectl get componentstatus
NAME STATUS MESSAGE ERROR
scheduler Healthy ok
controller-manager Healthy ok
etcd-0 Healthy {"health": "true"}
[[email protected] ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master NotReady master 32m v1.11.2

部署flannel网络插件
[[email protected] ~]# kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

检测flannel
[[email protected] ~]# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-78fcdf6894-4smdl 1/1 Running 58 20h
coredns-78fcdf6894-tlklk 1/1 Running 55 20h
etcd-master 1/1 Running 4 19h
kube-apiserver-master 1/1 Running 54 19h
kube-controller-manager-master 1/1 Running 9 19h
kube-flannel-ds-amd64-ds7x5 1/1 Running 2 19h
kube-proxy-tsxvp 1/1 Running 2 20h
kube-scheduler-master 1/1 Running 7 19h

[[email protected] ~]# kubectl get ns
NAME STATUS AGE
default Active 20h
kube-public Active 20h
kube-system Active 20h

master部署完毕

nodes节点
复制repo至node1,node2
[[email protected] ~]# scp /etc/hosts node1:/etc/hosts
[[email protected] ~]# scp /etc/hosts node2:/etc/hosts
[[email protected] yum.repos.d]# scp docker-ce.repo kubernetes.repo node1:/etc/yum.repos.d/
[[email protected] yum.repos.d]# scp docker-ce.repo kubernetes.repo node2:/etc/yum.repos.d/
[[email protected] ~]# scp rpm-package-key.gpg node1:/root
[[email protected] ~]# scp rpm-package-key.gpg node2:/root



node1:
[[email protected] # rpm --import rpm-package-key.gpg
[[email protected] #yum repolist
[[email protected]# yum install docker-ce kubelet kubeadm -y

复制master配置至node1

[[email protected] ~]# scp /usr/lib/systemd/system/docker.service node1:/usr/lib/systemd/system/docker.service
[[email protected] ~]# scp /etc/sysconfig/kubelet node1:/etc/sysconfig/kubelet
[[email protected] ~]# scp /etc/sysctl.conf node1:/etc/sysctl.conf
验证itables桥是否为1

[[email protected] ~]# cat /proc/sys/net/bridge/bridge-nf-call-ip6tables
[[email protected] ~]# cat /proc/sys/net/bridge/bridge-nf-call-iptables

如不为1,则在/etc/sysctl.conf中添加:

net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

执行sysctl -p 时出现:
[[email protected] ~]# sysctl -p
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-ip6tables: No such file or directory
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory
解决方法:

[[email protected] ~]# modprobe br_netfilter
[[email protected] ~]# sysctl -p
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

[[email protected] ~]# systemctl start docker kubelet
[[email protected] ~]# systemctl enable docker kubelet
[[email protected] ~]# scp /etc/sysctl.conf node2:/etc/sysctl.conf
[[email protected] ~]# kubeadm join 172.20.0.70:6443 --token dis2yz.m446ryn2lr298ica --discovery-token-ca-cert-hash sha256:c59f3633ecb92a31d86f64dc304abea55176555afbb3f2af9f40e5d4e013f86b --ignore-preflight-errors=All

[[email protected] ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready master 20h v1.11.2
node1 NotReady <none> 49s v1.11.2

[[email protected] ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
k8s.gcr.io/kube-proxy-amd64 v1.11.1 d5c25579d0ff 6 weeks ago 97.8MB
quay.io/coreos/flannel v0.10.0-amd64 f0fad859c909 7 months ago 44.6MB
k8s.gcr.io/pause 3.1 da86e6ba6ca1 8 months ago 742kB
[[email protected] ~]# kubectl get pods -n kube-system -o wide
NAME READY STATUS RESTARTS AGE IP NODE
coredns-78fcdf6894-4smdl 1/1 Running 58 20h 10.244.0.7 master
coredns-78fcdf6894-tlklk 1/1 Running 55 20h 10.244.0.6 master
etcd-master 1/1 Running 4 20h 172.18.0.67 master
kube-apiserver-master 1/1 Running 54 20h 172.18.0.67 master
kube-controller-manager-master 1/1 Running 9 20h 172.18.0.67 master
kube-flannel-ds-amd64-ds7x5 1/1 Running 2 20h 172.18.0.67 master
kube-flannel-ds-amd64-ktw9f 1/1 Running 0 4m 172.18.0.68 node1
kube-proxy-lqpms 1/1 Running 0 4m 172.18.0.68 node1
kube-proxy-tsxvp 1/1 Running 2 20h 172.18.0.67 master
kube-scheduler-master 1/1 Running 7 20h 172.18.0.67 master



node2
[[email protected] # rpm --import rpm-package-key.gpg
[[email protected]] #yum repolist
[[email protected]]# yum install docker-ce kubelet kubeadm -y
复制master配置至node2

[[email protected] ~]# scp /usr/lib/systemd/system/docker.service node1:/usr/lib/systemd/system/docker.service
[[email protected] ~]# scp /etc/sysconfig/kubelet node1:/etc/sysconfig/kubelet

验证itables桥是否为1

[[email protected] ~]# cat /proc/sys/net/bridge/bridge-nf-call-ip6tables
[[email protected] ~]# cat /proc/sys/net/bridge/bridge-nf-call-iptables

如不为1,则在/etc/sysctl.conf中添加:

net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

执行sysctl -p 时出现:
[[email protected] ~]# sysctl -p
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-ip6tables: No such file or directory
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory
解决方法:

[[email protected] ~]# modprobe br_netfilter
[[email protected] ~]# sysctl -p
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

[[email protected] ~]# systemctl start kubelet docker
[[email protected] ~]# systemctl enable kubelet docker
[[email protected] ~]# kubeadm join 172.20.0.70:6443 --token dis2yz.m446ryn2lr298ica --discovery-token-ca-cert-hash sha256:c59f3633ecb92a31d86f64dc304abea55176555afbb3f2af9f40e5d4e013f86b --ignore-preflight-errors=All

自此部署完毕master及note节点

检查master
[[email protected] ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready master 21h v1.11.2
node1 Ready <none> 46m v1.11.2
node2 NotReady <none> 28m v1.11.2

原文地址:http://blog.51cto.com/jameszhan/2174998

时间: 2024-10-30 02:54:51

K8S部署的相关文章

k8s部署wordpress记录

1.部署说明 wordpress和mysql分开部署,各部署一个svc. wordpress svc通过kube-dns组件服务访问mysql svc 配置NFS(实验环境测试用nfs方便) 配置PV,PVC存储wordpress和mysql数据 需要用到的变量: mysql MYSQL_ROOT_PASSWORD root的密码 wordpress WORDPRESS_DB_HOST 后端mysql主机 WORDPRESS_DB_PASSWORD 连接wordpress 数据的密码 WORDP

k8s部署ingress及http、https-实战篇

一.简介ingress:ingress-nginx #用于实现反代https://kubernetes.github.io/ingress-nginx/deploy/#generic-deployment kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yamlhttps://kubernetes.github.io/ingress-nginx/

k8s部署etcd集群

1.k8s部署高可用etcd集群时遇到了一些麻烦,这个是自己其中一个etcd的配置文件 例如: [Unit] Description=Etcd Server After=network.target After=network-online.target Wants=network-online.target Documentation=https://github.com/coreos [Service] User=k8s Type=notify WorkingDirectory=/var/l

centos7下的k8s+dashboard集群部署---(2)k8s部署

一.k8s部署 1.各节点安装kubectl,kubelet,kubeadm,需要通过yum安装,所以还是先配置yum源. cat /etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=0 repo_gpgcheck=0 gpgkey=

k8s部署环境

k8s部署环境 公有云环境:AWS.腾讯云.阿里云等等 私有云:OpenStack.vSphere等 Baremetal环境:物理服务器或独立虚拟机(底层没有云环境).    k8s部署方式 Minikube:Kubernetes官网提供的微型分布式环境,适合学习.初次体验,不过应该需要梯子才能用. Kubeadm:由于二进制部署方式过于复杂,所以后来出现了Kubeadm的部署方式,这种方式其实是将k8s的各组件容器化了.注意,使用容器方式部署Master节点各组件时,需要安装kubelet和d

k8s部署dns

硬件环境: 两台虚拟机, 10.10.20.203 部署docker.etcd.flannel.kube-apiserver.kube-controller-manager.kube-scheduler 10.10.20.206 部署docker.flannel.kubelet.kube-proxy 软件环境: kubernetes:1.3.3 DNS-etcd:index.tenxcloud.com/google_containers/etcd:2.2.5 kube2sky:index.ten

4.K8S部署-------- Master节点部署

部署Kubernetes API服务部署 如果没有特别指定在那台服务器执行命令.只需要按照文中的步骤执行即可 0.准备软件包 [[email protected] ~]# cd /usr/local/src/kubernetes      #kubernets解压的目录 [[email protected] kubernetes]# cp server/bin/kube-apiserver /opt/kubernetes/bin/ [[email protected] kubernetes]#

5.K8S部署-------- 部署Node节点

没有特别其他说明一切按照文档执行 1.二进制包准备 将软件包从linux-node1复制到linux-node2 linux-node3中去. [[email protected]1 ~]# cd /usr/local/src/kubernetes/server/bin/ [[email protected] bin]# cp kubelet kube-proxy /opt/kubernetes/bin/ [[email protected] bin]# scp kubelet kube-pro

centos k8s部署文档

文档会持续更新,以下是部署k8s二进制安装方法版本环境:kubernetes1.10.6Docker1.13 kubernetes?系统的各组件需要使用?TLS?证书对通信进行加密,本文档使用?CloudFlare?的 PKI 工具集cfssl?来生成 Certificate Authority (CA) 和其它证书:生成的 CA 证书和秘钥文件如下:ca-key.pemca.pemkubernetes-key.pemkubernetes.pemkube-proxy.pemkube-proxy-

streamsets k8s 部署试用

使用k8s 进行 streamsets的部署(没有使用持久化存储) k8s deploy yaml 文件 deploy.yaml apiVersion: extensions/v1beta1 kind: Deployment metadata: name: streamsets namespace: big-data labels: app: streamsets spec: replicas: 1 template: metadata: labels: app: streamsets spec