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 部署的更多相关文章

  1. kubernetes集群部署

    鉴于Docker如此火爆,Google推出kubernetes管理docker集群,不少人估计会进行尝试.kubernetes得到了很多大公司的支持,kubernetes集群部署工具也集成了gce,c ...

  2. Kubernetes集群部署关键知识总结

    Kubernetes集群部署需要安装的组件东西很多,过程复杂,对服务器环境要求很苛刻,最好是能连外网的环境下安装,有些组件还需要连google服务器下载,这一点一般很难满足,因此最好是能提前下载好准备 ...

  3. 基于Kubernetes集群部署skyDNS服务

    目录贴:Kubernetes学习系列 在之前几篇文章的基础,(Centos7部署Kubernetes集群.基于kubernetes集群部署DashBoard.为Kubernetes集群部署本地镜像仓库 ...

  4. Kubernetes集群部署之四Master节点部署

    Kubernetes Master节点部署三个服务:kube-apiserver.kube-controller-manager.kube-scheduler和一个命令工具kubectl. Maste ...

  5. 为Kubernetes集群部署本地镜像仓库

    目录贴:Kubernetes学习系列 经过之前两篇文章:Centos7部署Kubernetes集群.基于kubernetes集群部署DashBoard,我们基本上已经能够在k8s的集群上部署一个应用了 ...

  6. kubernetes 1.9部署实践

    目录 简要说明 环境说明 安装前的约定 配置etcd 生成相关证书 证书类型说明 cfssl配置 证书相关配置 生成ca证书 生成kubernetes证书 生成kubectl证书 生成kube-pro ...

  7. Kubernetes 集群部署(2) -- Etcd 集群

    Kubenetes 集群部署规划: 192.168.137.81  Master 192.168.137.82  Node 192.168.137.83  Node 以下在 Master 节点操作. ...

  8. Gitlab CI 集成 Kubernetes 集群部署 Spring Boot 项目

    在上一篇博客中,我们成功将 Gitlab CI 部署到了 Docker 中去,成功创建了 Gitlab CI Pipline 来执行 CI/CD 任务.那么这篇文章我们更进一步,将它集成到 K8s 集 ...

  9. Docker学习-Kubernetes - 集群部署

    Docker学习 Docker学习-VMware Workstation 本地多台虚拟机互通,主机网络互通搭建 Docker学习-Docker搭建Consul集群 Docker学习-简单的私有Dock ...

  10. kubernetes 集群部署

    kubernetes 集群部署 环境JiaoJiao_Centos7-1(152.112) 192.168.152.112JiaoJiao_Centos7-2(152.113) 192.168.152 ...

随机推荐

  1. hdu_4826_Labyrinth_2014百度之星(dp)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4826 题意:中文题,不解释 题解:dp搞,第一列只能从上往下走,所以先算出第一列的dp数组,然后开两个 ...

  2. EntityFramework日志记录

    首先在应用启动时执行:DbInterception.Add(new LogFormatter());   然后加入如下类: #region [ EF的数据库执行日志记录 ] public class ...

  3. Ansible11:变量详解【转】

    一.在Inventory中定义变量 详见<Ansible2:主机清单> 二.在Playbook中定义变量 1.通过vars关键字定义: vars: http_port: 80 server ...

  4. linux安装tomcat, jdk出现的问题

    1)卸载系统自带的jdk版本:     查看自带的jdk:     #rpm -qa|grep gcj     可能看到如下类似的信息:     libgcj-4.1.2-44.el5     jav ...

  5. jquery滚动条加载数据

    //滚动条  $(window).scroll(function () {   var scrollTop = $(this).scrollTop();   var scrollHeight = $( ...

  6. 关于安卓HTTP请求用HttpUrlConnection还是HttpClient好

    安卓和JAVA应用开发少不了要提交HTTP请求,而基本上目前有两个实现方式:HttpUrlConnection(即URL.openConnection)和HttpClient. 网上不少人都认为Htt ...

  7. queue(),dequeue()

    这两个方法,一个是往里面添加队列,一个是执行队列 也是分静态方法和实例方法, 同样,实例方法最后调用静态方法 源码主要分析一下延迟delay方法,如何起作用的,写的有点仓促,先记录一下 在这里参照了网 ...

  8. 1*Json对象声明简单,复合,对象数组

    //简单JSON对象 function btn1_click() { var json = { "id": 1001, "name": "张三&quo ...

  9. C# 截取字符串某个字符分割的最后一部分

    例如 string s1="123.456.789",想截取得到的新字符串为“789” 代码如下: string s1 = "123.456.789"; str ...

  10. 解决centos无法上传文件和打开文件夹

    使用yum搭建了ftp服务..yum的使用参考:http://blog.csdn.net/enson16855/article/details/9140623 windows使用FileZilla连接 ...