kubernetes 1.7.2 安装 记录过程
系统信息
cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core)
环境信息
IP地址 |
主机名称 |
10.10.6.11 | master |
10.10.6.12 | node1 |
10.10.6.13 | node2 |
第一部分
基础环境设置(三台设备均需设置,以下master为例)
设置主机名
hostnamectl set-hostname master
禁用selinux 和firewalld
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
systemctl disable firewalld systemctl stop firewalld
设置环境变量
cat >> /etc/sysctl.d/k8s.conf <<EOF net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 EOF sysctl -p /etc/sysctl.d/k8s.conf
设置docker 、kubernetes yum 源
cat >> /etc/yum.repos.d/docker.repo <<EOF [docker-repo] name=Docker Repository baseurl=http://mirrors.aliyun.com/docker-engine/yum/repo/main/centos/7 enabled=1 gpgcheck=0 EOFcat >> /etc/yum.repos.d/kubernetes.repo <<EOF [kubernetes] name=Kubernetes baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ enabled=1 gpgcheck=0 EOF
第二部分(三台设备都需要执行)
安装docker 和kubeadm
yum install -y docker-cecat > /etc/docker/daemon.json <<EOF { "registry-mirrors": ["https://vaflkxbk.mirror.aliyuncs.com"] } EOF
启动docker ,查看docker信息 docker version
docker version Client:Version: 17.12.0-ceAPI version: 1.35Go version: go1.9.2Git commit: c97c6d6Built: Wed Dec 27 20:10:14 2017OS/Arch: linux/amd64Server:Engine:Version: 17.12.0-ceAPI version: 1.35 (minimum version 1.12)Go version: go1.9.2Git commit: c97c6d6Built: Wed Dec 27 20:12:46 2017OS/Arch: linux/amd64Experimental: false
View Code
安装kubernetes,
cat > /root/kubernetes.sh <<EOF KUBE_VERSION=1.7.2 KUBE_PAUSE_VERSION=3.0 KUBE_CNI_VERSION=0.5.1 ETCD_VERSION=3.0.17 yum install -y kubernetes-cni-${KUBE_CNI_VERSION}-0.x86_64 kubelet-${KUBE_VERSION}-0.x86_64 kubectl-${KUBE_VERSION}-0.x86_64 kubeadm-${KUBE_VERSION}-0.x86_64 EOFchmod +x /root/kubernetes.sh && sh /root/kubernetes.sh
设置Cgroup Driver: cgroupfs 类型
sed -i 's/cgroup-driver=systemd/cgroup-driver=cgroupfs/g' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
## cgroupfs 是根据docker info 中 的 Cgroup Driver: cgroupfs 来设定。
启动服务
systemctl enable docker systemctl enable kubelet systemctl start docker systemctl start kubelet
下载 images
cat images.sh
set -o errexit set -o nounset set -o pipefailKUBE_VERSION=v1.7.2 KUBE_PAUSE_VERSION=3.0 ETCD_VERSION=3.0.17 DNS_VERSION=1.14.4 FLANNEL=v0.8.0-amd64GCR_URL=gcr.io/google_containers ALIYUN_URL=registry.cn-hangzhou.aliyuncs.com/szss_k8simages=(kube-proxy-amd64:${KUBE_VERSION} kube-scheduler-amd64:${KUBE_VERSION} kube-controller-manager-amd64:${KUBE_VERSION} kube-apiserver-amd64:${KUBE_VERSION} pause-amd64:${KUBE_PAUSE_VERSION} etcd-amd64:${ETCD_VERSION} k8s-dns-sidecar-amd64:${DNS_VERSION} k8s-dns-kube-dns-amd64:${DNS_VERSION} k8s-dns-dnsmasq-nanny-amd64:${DNS_VERSION} flannel:${FLANNEL})for imageName in ${images[@]} ; dodocker pull $ALIYUN_URL/$imageNamedocker tag $ALIYUN_URL/$imageName $GCR_URL/$imageNamedocker rmi $ALIYUN_URL/$imageName done
View Code
查看下载images 确认无误
docker images REPOSITORY TAG IMAGE ID CREATED SIZE gcr.io/google_containers/kube-apiserver-amd64 v1.7.2 4935105a20b1 6 months ago 186MB gcr.io/google_containers/kube-proxy-amd64 v1.7.2 13a7af96c7e8 6 months ago 115MB gcr.io/google_containers/kube-controller-manager-amd64 v1.7.2 2790e95830f6 6 months ago 138MB gcr.io/google_containers/kube-scheduler-amd64 v1.7.2 5db1f9874ae0 6 months ago 77.2MB gcr.io/google_containers/flannel v0.8.0-amd64 9db3bab8c19e 6 months ago 50.7MB gcr.io/google_containers/k8s-dns-sidecar-amd64 1.14.4 38bac66034a6 7 months ago 41.8MB gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64 1.14.4 f7f45b9cb733 7 months ago 41.4MB gcr.io/google_containers/kubernetes-dashboard-amd64 v1.6.0 8b3d11182363 10 months ago 109MB gcr.io/google_containers/k8s-dns-kube-dns-amd64 1.14.4 f8363dbf447b 11 months ago 52.4MB gcr.io/google_containers/etcd-amd64 3.0.17 243830dae7dd 11 months ago 169MB gcr.io/google_containers/pause-amd64 3.0 99e59f495ffa 21 months ago 747kB
View Code
第三部分
在master 10.10.6.11 上执行
kubeadm init --apiserver-advertise-address=10.10.6.11 --kubernetes-version=v1.7.2 --token=863f67.19babbff7bfe8543 --pod-network-cidr=10.244.0.0/16
输出信息
[kubeadm] WARNING: kubeadm is in beta, please do not use it for production clusters. [init] Using Kubernetes version: v1.7.2 [init] Using Authorization modes: [Node RBAC] [preflight] Running pre-flight checks [preflight] WARNING: docker version is greater than the most recently validated version. Docker version: 17.12.0-ce. Max validated version: 1.12 [preflight] WARNING: hostname "master" could not be reached [preflight] WARNING: hostname "master" lookup master on 114.114.114.114:53: no such host [preflight] Starting the kubelet service [kubeadm] WARNING: starting in 1.8, tokens expire after 24 hours by default (if you require a non-expiring token use --token-ttl 0) [certificates] Generated CA certificate and key. [certificates] Generated API server certificate and key. [certificates] API Server serving cert is signed for DNS names [master kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.10.6.11] [certificates] Generated API server kubelet client certificate and key. [certificates] Generated service account token signing key and public key. [certificates] Generated front-proxy CA certificate and key. [certificates] Generated front-proxy client certificate and key. [certificates] Valid certificates and keys now exist in "/etc/kubernetes/pki" [kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/scheduler.conf" [kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/admin.conf" [kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/kubelet.conf" [kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/controller-manager.conf" [apiclient] Created API client, waiting for the control plane to become ready [apiclient] All control plane components are healthy after 31.001278 seconds [token] Using token: 863f67.19babbff7bfe8543 [apiconfig] Created RBAC rules [addons] Applied essential addon: kube-proxy [addons] Applied essential addon: kube-dnsYour Kubernetes master has initialized successfully!To start using your cluster, you need to run (as a regular user):mkdir -p $HOME/.kubesudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/configsudo chown $(id -u):$(id -g) $HOME/.kube/configYou should now deploy a pod network to the cluster. Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:http://kubernetes.io/docs/admin/addons/ You can now join any number of machines by running the following on each node as root:kubeadm join --token 863f67.19babbff7bfe8543 10.10.6.11:6443
View Code
设置环境变量,这里是把变量放到/etc/profile
export KUBECONFIG=/etc/kubernetes/admin.conf
下载 kube-flannel-rbac.yml 和
vi kube-flannel-rbac.yml
wget https://raw.githubusercontent.com/coreos/flannel/v0.8.0/Documentation/kube-flannel-rbac.ymlwget https://raw.githubusercontent.com/coreos/flannel/v0.8.0/Documentation/kube-flannel.yml
其中kube-flannel.yml 的flannel镜像 要与上面下载的flannel 一致
# Create the clusterrole and clusterrolebinding: # $ kubectl create -f kube-flannel-rbac.yml # Create the pod using the same namespace used by the flannel serviceaccount: # $ kubectl create --namespace kube-system -f kube-flannel.yml --- kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1beta1 metadata:name: flannel rules:- apiGroups:- ""resources:- podsverbs:- get- apiGroups:- ""resources:- nodesverbs:- list- watch- apiGroups:- ""resources:- nodes/statusverbs:- patch --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1beta1 metadata:name: flannel roleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: flannel subjects: - kind: ServiceAccountname: flannelnamespace: kube-system
View Code
vi kube-flannel.yml
--- apiVersion: v1 kind: ServiceAccount metadata:name: flannelnamespace: kube-system --- kind: ConfigMap apiVersion: v1 metadata:name: kube-flannel-cfgnamespace: kube-systemlabels:tier: nodeapp: flannel data:cni-conf.json: |{"name": "cbr0","type": "flannel","delegate": {"isDefaultGateway": true}}net-conf.json: |{"Network": "10.244.0.0/16","Backend": {"Type": "vxlan"}} --- apiVersion: extensions/v1beta1 kind: DaemonSet metadata:name: kube-flannel-dsnamespace: kube-systemlabels:tier: nodeapp: flannel spec:template:metadata:labels:tier: nodeapp: flannelspec:hostNetwork: truenodeSelector:beta.kubernetes.io/arch: amd64tolerations:- key: node-role.kubernetes.io/masteroperator: Existseffect: NoScheduleserviceAccountName: flannelcontainers:- name: kube-flannelimage: gcr.io/google_containers/flannel:v0.8.0-amd64command: [ "/opt/bin/flanneld", "--ip-masq", "--kube-subnet-mgr" ]securityContext:privileged: trueenv:- name: POD_NAMEvalueFrom:fieldRef:fieldPath: metadata.name- name: POD_NAMESPACEvalueFrom:fieldRef:fieldPath: metadata.namespacevolumeMounts:- name: runmountPath: /run- name: flannel-cfgmountPath: /etc/kube-flannel/- name: install-cniimage: gcr.io/google_containers/flannel:v0.8.0-amd64command: [ "/bin/sh", "-c", "set -e -x; cp -f /etc/kube-flannel/cni-conf.json /etc/cni/net.d/10-flannel.conf; while true; do sleep 3600; done" ]volumeMounts:- name: cnimountPath: /etc/cni/net.d- name: flannel-cfgmountPath: /etc/kube-flannel/volumes:- name: runhostPath:path: /run- name: cnihostPath:path: /etc/cni/net.d- name: flannel-cfgconfigMap:name: kube-flannel-cfg
View Code
执行以下命令:
kubectl --namespace kube-system apply -f kube-flannel-rbac.yml kubectl --namespace kube-system apply -f kube-flannel.yml
在两个node 节点上执行
kubeadm join --token 863f67.19babbff7bfe8543 10.10.6.11:6443 --skip-preflight-checks
输出信息
[kubeadm] WARNING: kubeadm is in beta, please do not use it for production clusters. [preflight] Skipping pre-flight checks [discovery] Trying to connect to API Server "10.10.6.11:6443" [discovery] Created cluster-info discovery client, requesting info from "https://10.10.6.11:6443" [discovery] Cluster info signature and contents are valid, will use API Server "https://10.10.6.11:6443" [discovery] Successfully established connection with API Server "10.10.6.11:6443" [bootstrap] Detected server version: v1.7.2 [bootstrap] The server supports the Certificates API (certificates.k8s.io/v1beta1) [csr] Created API client to obtain unique certificate for this node, generating keys and certificate signing request [csr] Received signed certificate from the API server, generating KubeConfig... [kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/kubelet.conf"Node join complete: * Certificate signing request sent to master and responsereceived. * Kubelet informed of new secure connection details.Run 'kubectl get nodes' on the master to see this machine join.
View Code
在master 上面查看信息
[root@master ~]# kubectl get pods --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE kube-system etcd-master 1/1 Running 0 2h kube-system kube-apiserver-master 1/1 Running 0 2h kube-system kube-controller-manager-master 1/1 Running 0 2h kube-system kube-dns-2425271678-glrxd 3/3 Running 0 2h kube-system kube-flannel-ds-7tb2x 2/2 Running 0 2h kube-system kube-flannel-ds-pvwfv 2/2 Running 0 2h kube-system kube-flannel-ds-t5b3t 2/2 Running 1 2h kube-system kube-proxy-2k10j 1/1 Running 0 2h kube-system kube-proxy-6tdhl 1/1 Running 0 2h kube-system kube-proxy-dgfrb 1/1 Running 0 2h kube-system kube-scheduler-master 1/1 Running 0 2h [root@master ~]# kubectl get pods -n kube-system -o wide NAME READY STATUS RESTARTS AGE IP NODE etcd-master 1/1 Running 0 2h 10.10.6.11 master kube-apiserver-master 1/1 Running 0 2h 10.10.6.11 master kube-controller-manager-master 1/1 Running 0 2h 10.10.6.11 master kube-dns-2425271678-glrxd 3/3 Running 0 2h 10.244.0.3 master kube-flannel-ds-7tb2x 2/2 Running 0 2h 10.10.6.13 node2 kube-flannel-ds-pvwfv 2/2 Running 0 2h 10.10.6.11 master kube-flannel-ds-t5b3t 2/2 Running 1 2h 10.10.6.12 node1 kube-proxy-2k10j 1/1 Running 0 2h 10.10.6.13 node2 kube-proxy-6tdhl 1/1 Running 0 2h 10.10.6.12 node1 kube-proxy-dgfrb 1/1 Running 0 2h 10.10.6.11 master kube-scheduler-master 1/1 Running 0 2h 10.10.6.11 master [root@master ~]#
View Code
确保都是running 的状态
转载于:https://www.cnblogs.com/sxwen/p/8422972.html
kubernetes 1.7.2 安装 记录过程相关推荐
- Kubernetes v1.10.4 安装记录
#参考文档:https://github.com/opsnull/follow-me-install-kubernetes-cluster #约定: #1.会显式的标注出命令都要再哪一台或哪几台上执行 ...
- Kubernetes Dashboard on Ubuntu 16.04安装记录
2019独角兽企业重金招聘Python工程师标准>>> Kubernetes Dashboard on Ubuntu 16.04安装记录 以下内容在Kubernetes 1.9.3 ...
- linux数据库12c安装图解,Linux + Oracle 12c RAC安装配置详细记录过程_图文并茂.pdf
Linux +Oracle12cRAC安装配置详细记录过程_图文并茂_v1.0 Version:<1.0> Linux +Oracle12cRAC安装配置详细记录过程_图文并茂_v1.0 ...
- 记录自己完美安装Archlinux过程
记录自己完美安装Archlinux过程 前言 准备 安装介质 磁盘准备 进入U盘的Linux系统 正式开始 1.联网 2.更新系统时间 3.分区与格式化 3.1 查看分区 3.2 进入选择的硬盘 3. ...
- 华为NPU卡ubuntu(无网络连接情况)驱动安装记录
华为NPU卡ubuntu驱动安装记录 前奏:文中的绝大多数情况都是因为服务器没有网络服务,如果读者的电脑有完全的网络服务可能参考意义不是很大.不过,处理的方法和排查的思路可以作为一个借鉴. root@ ...
- linux存储库rep 61082,安装informatic过程中的错误
1.Check if the DISPLAY variable is set export DISPLAY=192.168.3.201:0.0 在注销用户并切换到oracle或者infa 用户,就可以 ...
- 安装及管理程序(yum搭建本地源,了解rmp命令,查询卸载软件包,编译安装的过程)
文章目录 安装及管理程序 前言 linux命令与应用程序的关系 典型应用程序的目录结构 常见的软件包封装类型 查询RPM软件包信息 rpm概述 RPM机制封装命令格式 查询RPM软件包信息 查询未安装 ...
- datax的工具配置oracle,完全小白级DataX安装配置过程详解
apt-get install openjdk-7-jdk Linux小白,创建和删除文件夹都现问度娘学会的小白,最近被勒令研究一下DataX,当时一脸蒙X,根本木有听过吖,但是领导吩咐了就得办吖,问 ...
- mldonkey 安装详细过程
http://bbs.54cto.com/archiver/tid-891.html mldonkey 安装详细过程 1. P2P 软件 推荐使用MLdonkey( http://mldonkey.b ...
最新文章
- java 中断 继续_关于中断的线程如何继续。。在线等
- python在线读-python初级实战-----主机在线情况监控web
- Cisco BFD双向转发检测技术部署案例
- centos8安装并启动tomcat9
- Android UI开发第二十九篇——Android中五种常用的menu(菜单)
- flask web开发的相关博文学习
- repeater导出excel html,Repeater显示数据,并且导出到excel
- 编程之美 - 哪个题目最美?
- DB2完整的SQLCODE和SQLState错误信息
- Eclipse下搭建安卓开发环境(初步)
- python调用迅雷下载引擎_GitHub - cryzlasm/ThunderOpenSDK: 迅雷开放下载引擎, 收集, 使用...
- LaTex 表格的单元格划横线,分成两部分
- php 匹配中文和标点符号,php正则匹配标点符号
- 塑料填充母粒行业调研报告 - 市场现状分析与发展前景预测
- Mocha.js官方文档翻译 —— 简单、灵活、有趣
- python秒表游戏代码_python编程实战:制作秒表程序
- 强化学习1 高斯赛德尔迭代
- 公司网络机房搭建,信息化目标,网络故障处理办法
- html垂直线性渐变,再说CSS3渐变——线性渐变
- CH3NH3PbI2Cl (MAPbI2Cl) 甲胺氯基钙钛矿 1446121-07-8
热门文章
- HTML5无刷新修改URL:利用 History API 无刷新更改地址栏
- 【Java规划】DOM XML Parser分解、遍历、创XML
- jQuery将不再支持IE6/7/8
- 转帖一篇:截取密码(VC++)学习消息VC++的好处
- eclipse开发android手机定位
- Leetcode 211. 添加与搜索单词 - 数据结构设计 解题思路及C++实现
- c# excel导出png_C#与Halcon联合编程步骤
- 微信小程序swiper禁止用户手动滑动
- BugKu:cookies 欺骗
- java的知识点23——泛型Generics、Collection接口、List特点和常用方法、 ArrayList特点和底层实现