Kubernetes 1.4 部署
k8s 1.4 新版本部署
测试环境:
node-: 10.6.0.140
node-: 10.6.0.187
node-: 10.6.0.188
kubernetes 集群,包含 master 节点,与 node 节点。
hostnamectl --static set-hostname hostname 10.6.0.140 - k8s-master
10.6.0.187 - k8s-node-
10.6.0.188 - k8s-node-
配置 /etc/hosts
添加
10.6.0.140 k8s-master
10.6.0.187 k8s-node-
10.6.0.188 k8s-node-
部署:
一、安装k8s
yum install -y socat
------------------------------------------------------
cat <<EOF> /etc/yum.repos.d/k8s.repo
[kubelet]
name=kubelet
baseurl=http://files.rm-rf.ca/rpms/kubelet/
enabled=
gpgcheck=
EOF
------------------------------------------------------
yum makecache yum install -y kubelet kubeadm kubectl kubernetes-cni
由于 google 被墙, 所以使用 kubeadm init 创建 集群 的时候会出现卡住
国内已经有人将镜像上传至 docker hub 里面了
我们直接下载:
docker pull chasontang/kube-proxy-amd64:v1.4.0
docker pull chasontang/kube-discovery-amd64:1.0
docker pull chasontang/kubedns-amd64:1.7
docker pull chasontang/kube-scheduler-amd64:v1.4.0
docker pull chasontang/kube-controller-manager-amd64:v1.4.0
docker pull chasontang/kube-apiserver-amd64:v1.4.0
docker pull chasontang/etcd-amd64:2.2.
docker pull chasontang/kube-dnsmasq-amd64:1.3
docker pull chasontang/exechealthz-amd64:1.1
docker pull chasontang/pause-amd64:3.0
下载以后使用 docker tag 命令将其做别名改为 gcr.io/google_containers
docker tag chasontang/kube-proxy-amd64:v1.4.0 gcr.io/google_containers/kube-proxy-amd64:v1.4.0
docker tag chasontang/kube-discovery-amd64:1.0 gcr.io/google_containers/kube-discovery-amd64:1.0
docker tag chasontang/kubedns-amd64:1.7 gcr.io/google_containers/kubedns-amd64:1.7
docker tag chasontang/kube-scheduler-amd64:v1.4.0 gcr.io/google_containers/kube-scheduler-amd64:v1.4.0
docker tag chasontang/kube-controller-manager-amd64:v1.4.0 gcr.io/google_containers/kube-controller-manager-amd64:v1.4.0
docker tag chasontang/kube-apiserver-amd64:v1.4.0 gcr.io/google_containers/kube-apiserver-amd64:v1.4.0
docker tag chasontang/etcd-amd64:2.2. gcr.io/google_containers/etcd-amd64:2.2.
docker tag chasontang/kube-dnsmasq-amd64:1.3 gcr.io/google_containers/kube-dnsmasq-amd64:1.3
docker tag chasontang/exechealthz-amd64:1.1 gcr.io/google_containers/exechealthz-amd64:1.1
docker tag chasontang/pause-amd64:3.0 gcr.io/google_containers/pause-amd64:3.0
清除原来下载的镜像
docker rmi chasontang/kube-proxy-amd64:v1.4.0
docker rmi chasontang/kube-discovery-amd64:1.0
docker rmi chasontang/kubedns-amd64:1.7
docker rmi chasontang/kube-scheduler-amd64:v1.4.0
docker rmi chasontang/kube-controller-manager-amd64:v1.4.0
docker rmi chasontang/kube-apiserver-amd64:v1.4.0
docker rmi chasontang/etcd-amd64:2.2.
docker rmi chasontang/kube-dnsmasq-amd64:1.3
docker rmi chasontang/exechealthz-amd64:1.1
docker rmi chasontang/pause-amd64:3.0
启动 kubelet
systemctl enable kubelet
systemctl start kubelet
利用 kubeadm 创建 集群
[root@k8s-master ~]#kubeadm init --api-advertise-addresses=10.6.0.140 --use-kubernetes-version v1.4.0 <master/tokens> generated token: "eb4d40.67aac8417294a8cf"
<master/pki> created keys and certificates in "/etc/kubernetes/pki"
<util/kubeconfig> created "/etc/kubernetes/kubelet.conf"
<util/kubeconfig> created "/etc/kubernetes/admin.conf"
<master/apiclient> created API client configuration
<master/apiclient> created API client, waiting for the control plane to become ready
<master/apiclient> all control plane components are healthy after 10.304645 seconds
<master/apiclient> waiting for at least one node to register and become ready
<master/apiclient> first node has registered, but is not ready yet
<master/apiclient> first node has registered, but is not ready yet
<master/apiclient> first node has registered, but is not ready yet
<master/apiclient> first node has registered, but is not ready yet
<master/apiclient> first node has registered, but is not ready yet
<master/apiclient> first node is ready after 3.004762 seconds
<master/discovery> created essential addon: kube-discovery, waiting for it to become ready
<master/discovery> kube-discovery is ready after 4.002661 seconds
<master/addons> created essential addon: kube-proxy
<master/addons> created essential addon: kube-dns Kubernetes master initialised successfully! You can now join any number of machines by running the following on each node: kubeadm join --token 8609e3.c2822cf312e597e1 10.6.0.140
查看 kubelet 状态
systemctl status kubelet
子节点 启动 kubelet 首先必须启动 docker
systemctl enable kubelet
systemctl start kubelet
下面子节点加入集群
kubeadm join --token 8609e3.c2822cf312e597e1 10.6.0.140
查看 kubelet 状态
systemctl status kubelet
查看集群状态
[root@k8s-master ~]#kubectl get node
NAME STATUS AGE
k8s-master Ready 1d
k8s-node- Ready 1d
k8s-node- Ready 1d
此时可看到 三个节点 都已经 Ready , 但是其实 Pod 只会运行在 node 节点
如果需要所有节点,包括master 也运行 Pod 需要运行
kubectl taint nodes --all dedicated-
安装 POD 网络
这里使用官方推荐的 weave 网络
kubectl apply -f https://git.io/weave-kube
查看所有pod 状态
[root@k8s-master ~]#kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system etcd-k8s-master / Running 49m
kube-system kube-apiserver-k8s-master / Running 48m
kube-system kube-controller-manager-k8s-master / Running 48m
kube-system kube-discovery--0oq58 / Running 49m
kube-system kube-dns--ojzhw / Running 49m
kube-system kube-proxy-amd64-1hhdf / Running 49m
kube-system kube-proxy-amd64-4c2qt / Running 47m
kube-system kube-proxy-amd64-tc3kw / Running 47m
kube-system kube-scheduler-k8s-master / Running 48m
kube-system weave-net-9mrlt / Running 46m
kube-system weave-net-oyguh / Running 46m
kube-system weave-net-zc67d / Running 46m
使用 GlusterFS 作为 volume
官方详细说明:
https://github.com/kubernetes/kubernetes/tree/master/examples/volumes/glusterfs
1. 配置 GlusterFS 集群,以及设置好 GlusterFS 的 volume , node 客户端安装 glusterfs-client
2. k8s-master 创建一个 endpoints.
我这边 GlusterFS 有3个节点
vi glusterfs-endpoints.json
# 每一个 GlusterFS 节点,必须写一列. 端口随意填写(1-65535)
{
"kind": "Endpoints",
"apiVersion": "v1",
"metadata": {
"name": "glusterfs-cluster"
},
"subsets": [
{
"addresses": [
{
"ip": "10.6.0.140"
}
],
"ports": [
{
"port":
}
]
},
{
"addresses": [
{
"ip": "10.6.0.187"
}
],
"ports": [
{
"port":
}
]
},
{
"addresses": [
{
"ip": "10.6.0.188"
}
],
"ports": [
{
"port":
}
]
}
]
}
创建 endpoints
[root@k8s-master ~]#kubectl create -f glusterfs-endpoints.json
endpoints "glusterfs-cluster" created
查看 endpoints
[root@k8s-master ~]#kubectl get endpoints
NAME ENDPOINTS AGE
glusterfs-cluster 10.6.0.140:,10.6.0.187:,10.6.0.188: 37s
3. k8s-master 创建一个 service.
vi glusterfs-service.json
# 这里注意之前填写的 port
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "glusterfs-cluster"
},
"spec": {
"ports": [
{"port": }
]
}
}
创建 service
[root@k8s-master ~]#kubectl create -f glusterfs-service.json
service "glusterfs-cluster" created
查看 service
[root@k8s-master ~]#kubectl get service
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
glusterfs-cluster 100.71.255.174 <none> /TCP 14s
4. k8s-master 创建一个 Pod 来测试挂载
vi glusterfs-pod.json
# glusterfs 下 path 配置 glusterfs volume 的名称
readOnly: true (只读) and readOnly: false
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": "glusterfs"
},
"spec": {
"containers": [
{
"name": "glusterfs",
"image": "gcr.io/google_containers/pause-amd64:3.0",
"volumeMounts": [
{
"mountPath": "/mnt/glusterfs",
"name": "glusterfsvol"
}
]
}
],
"volumes": [
{
"name": "glusterfsvol",
"glusterfs": {
"endpoints": "glusterfs-cluster",
"path": "models",
"readOnly": false
}
}
]
}
}
查看 挂载的 volume
[root@k8s-node- ~]# mount | grep models
10.6.0.140:models on /var/lib/kubelet/pods/947390da-8f6a-11e6-9ade-d4ae52d1f0c9/volumes/kubernetes.io~glusterfs/glusterfsvol type fuse.glusterfs (rw,relatime,user_id=,group_id=,default_permissions,allow_other,max_read=)
编写一个 Deployment 的 yaml 文件
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas:
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort:
使用 kubectl create 进行创建
kubectl create -f nginx.yaml --record
查看 pod
[root@k8s-master ~]#kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx-deployment--459i5 / Running 9m
nginx-deployment--vxn29 / Running 9m
查看 deployment
[root@k8s-master ~]#kubectl get deploy
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
nginx-deployment 10m
Kubernetes 1.4 部署的更多相关文章
- kubernetes集群部署
鉴于Docker如此火爆,Google推出kubernetes管理docker集群,不少人估计会进行尝试.kubernetes得到了很多大公司的支持,kubernetes集群部署工具也集成了gce,c ...
- Kubernetes集群部署关键知识总结
Kubernetes集群部署需要安装的组件东西很多,过程复杂,对服务器环境要求很苛刻,最好是能连外网的环境下安装,有些组件还需要连google服务器下载,这一点一般很难满足,因此最好是能提前下载好准备 ...
- 基于Kubernetes集群部署skyDNS服务
目录贴:Kubernetes学习系列 在之前几篇文章的基础,(Centos7部署Kubernetes集群.基于kubernetes集群部署DashBoard.为Kubernetes集群部署本地镜像仓库 ...
- Kubernetes集群部署之四Master节点部署
Kubernetes Master节点部署三个服务:kube-apiserver.kube-controller-manager.kube-scheduler和一个命令工具kubectl. Maste ...
- 为Kubernetes集群部署本地镜像仓库
目录贴:Kubernetes学习系列 经过之前两篇文章:Centos7部署Kubernetes集群.基于kubernetes集群部署DashBoard,我们基本上已经能够在k8s的集群上部署一个应用了 ...
- kubernetes 1.9部署实践
目录 简要说明 环境说明 安装前的约定 配置etcd 生成相关证书 证书类型说明 cfssl配置 证书相关配置 生成ca证书 生成kubernetes证书 生成kubectl证书 生成kube-pro ...
- Kubernetes 集群部署(2) -- Etcd 集群
Kubenetes 集群部署规划: 192.168.137.81 Master 192.168.137.82 Node 192.168.137.83 Node 以下在 Master 节点操作. ...
- Gitlab CI 集成 Kubernetes 集群部署 Spring Boot 项目
在上一篇博客中,我们成功将 Gitlab CI 部署到了 Docker 中去,成功创建了 Gitlab CI Pipline 来执行 CI/CD 任务.那么这篇文章我们更进一步,将它集成到 K8s 集 ...
- Docker学习-Kubernetes - 集群部署
Docker学习 Docker学习-VMware Workstation 本地多台虚拟机互通,主机网络互通搭建 Docker学习-Docker搭建Consul集群 Docker学习-简单的私有Dock ...
- kubernetes 集群部署
kubernetes 集群部署 环境JiaoJiao_Centos7-1(152.112) 192.168.152.112JiaoJiao_Centos7-2(152.113) 192.168.152 ...
随机推荐
- hdu_5761_Rower Bo(xjb猜公式)
题目链接:hdu_5761_Rower Bo 题意: 让你求一个物理问题 题解: xjb猜公式,由题目样例可得,答案为8/7,然后我们可以xjb猜出公式为v1*a/(v1*v1-v2*v2),然后特判 ...
- Postgres数据库在Linux中的I/O优化
I/O 优化1 打开 noatime方法: 修改 /etc/fstab2 调整预读方法: 查看 sudo blockdev --getra /dev/sda 设置 sudo blockdev --se ...
- vb6学习心路
1.不能加载 'MSCOMCTL.OCX'--继续加载工程吗解决办法:新建一个VB工程,然后按CTRL + T,选中 “Microsoft Windows Common Controls 6.0” 然 ...
- DLT(Diagnostic Log and Trace)嵌入式系统程序运行记录
http://blog.csdn.net/yanlinembed/article/details/49837975 DLT的使用有属于Application范畴与Context范畴.在使用DLT时,需 ...
- js获取页面的来源页
<html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat=&quo ...
- 一篇非常适合git入门的文章
http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00137583770360579 ...
- The magic behind configure, make, make install
原文:https://robots.thoughtbot.com/the-magic-behind-configure-make-make-install#where-do-these-scripts ...
- NSArray或NSDictionary中汉字输出
1.问题: NSArray *array = [NSArray arrayWithObjects:@"我",@"在",@"鼓楼", nil] ...
- 运行第一个SparkKPI程序
1.复制一个examples中SparkPi.scala到IntelliJ IDEA编辑器,运行,出现错误: “org.apache.spark.SparkException: A master UR ...
- Ubuntu下安装使用MongoDB
安装 官网下载: https://www.mongodb.org/ 解压解包 重命名为mongodb 移动到/usr/local/目录下 创建连个软连接 ln -s /usr/local/mongo ...